for (i = 0; i < gmod->num_strings; ++i)
kfree(gmod->string[i]);
- for (i = 0; i < gmod->num_cports; ++i)
- kfree(gmod->cport[i]);
kfree(gmod);
}
struct greybus_descriptor_cport *cport,
size_t desc_size)
{
- struct gmod_cport *gmod_cport;
-
if (gmod->num_cports == MAX_CPORTS_PER_MODULE) {
dev_err(gmod->dev.parent, "too many cports for this module!\n");
return -EINVAL;
return -EINVAL;
}
- gmod_cport = kzalloc(sizeof(*gmod_cport), GFP_KERNEL);
- if (!gmod_cport)
- return -ENOMEM;
-
- gmod_cport->id = le16_to_cpu(cport->id);
- gmod_cport->size = le16_to_cpu(cport->size);
- gmod_cport->speed = cport->speed;
-
- gmod->cport[gmod->num_cports] = gmod_cport;
+ gmod->cport_ids[gmod->num_cports] = le16_to_cpu(cport->id);
gmod->num_cports++;
return 0;
#include <linux/errno.h>
#include <linux/sizes.h>
#include <linux/usb.h>
+
#include "greybus.h"
#include "svc_msg.h"
+#include "kernel_ver.h"
/* Memory sizes for the buffers sent to/from the ES1 controller */
#define ES1_SVC_MSG_SIZE (sizeof(struct svc_msg) + SZ_64K)
* we will encode the cport number in the first byte of the buffer, so
* set the second byte to be the "transfer buffer"
*/
- buffer[0] = gbuf->cport->id;
+ BUG_ON(gbuf->cport_id > (u16)U8_MAX);
+ buffer[0] = gbuf->cport_id;
gbuf->transfer_buffer = &buffer[1];
gbuf->transfer_buffer_length = size;
gbuf->actual_length = size;
static struct workqueue_struct *gbuf_workqueue;
static struct gbuf *__alloc_gbuf(struct greybus_module *gmod,
- struct gmod_cport *cport,
+ u16 cport_id,
gbuf_complete_t complete,
gfp_t gfp_mask,
void *context)
kref_init(&gbuf->kref);
gbuf->gmod = gmod;
- gbuf->cport = cport;
+ gbuf->cport_id = cport_id;
INIT_WORK(&gbuf->event, cport_process_event);
gbuf->complete = complete;
gbuf->context = context;
* hardware designers for this issue...
*/
struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod,
- struct gmod_cport *cport,
+ u16 cport_id,
gbuf_complete_t complete,
unsigned int size,
gfp_t gfp_mask,
struct gbuf *gbuf;
int retval;
- gbuf = __alloc_gbuf(gmod, cport, complete, gfp_mask, context);
+ gbuf = __alloc_gbuf(gmod, cport_id, complete, gfp_mask, context);
if (!gbuf)
return NULL;
#define MAX_CPORTS 1024
struct gb_cport_handler {
gbuf_complete_t handler;
- struct gmod_cport cport;
+ u16 cport_id;
struct greybus_module *gmod;
void *context;
};
// need it, we don't have a dynamic system...
int gb_register_cport_complete(struct greybus_module *gmod,
- gbuf_complete_t handler, int cport_id,
+ gbuf_complete_t handler, u16 cport_id,
void *context)
{
if (cport_handler[cport_id].handler)
return -EINVAL;
cport_handler[cport_id].context = context;
cport_handler[cport_id].gmod = gmod;
- cport_handler[cport_id].cport.id = cport_id;
+ cport_handler[cport_id].cport_id = cport_id;
cport_handler[cport_id].handler = handler;
return 0;
}
-void gb_deregister_cport_complete(int cport_id)
+void gb_deregister_cport_complete(u16 cport_id)
{
cport_handler[cport_id].handler = NULL;
}
-void greybus_cport_in(struct greybus_host_device *hd, int cport_id, u8 *data,
- size_t length)
+void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
+ u8 *data, size_t length)
{
struct gb_cport_handler *ch;
struct gbuf *gbuf;
return;
}
- gbuf = __alloc_gbuf(ch->gmod, &ch->cport, ch->handler, GFP_ATOMIC,
+ gbuf = __alloc_gbuf(ch->gmod, ch->cport_id, ch->handler, GFP_ATOMIC,
ch->context);
if (!gbuf) {
/* Again, something bad went wrong, log it... */
struct gbuf;
-struct gmod_cport {
- u16 id;
- u16 size;
- u8 speed; // valid???
- // FIXME, what else?
-};
-
struct gmod_string {
u16 length;
u8 id;
void *hdpriv;
struct greybus_module *gmod;
- struct gmod_cport *cport;
+ u16 cport_id;
int status;
void *transfer_buffer;
u32 transfer_flags; /* flags for the transfer buffer */
struct greybus_host_device *greybus_create_hd(struct greybus_host_driver *host_driver,
struct device *parent);
void greybus_remove_hd(struct greybus_host_device *hd);
-void greybus_cport_in(struct greybus_host_device *hd, int cport_id, u8 *data,
- size_t length);
+void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
+ u8 *data, size_t length);
void greybus_gbuf_finished(struct gbuf *gbuf);
struct greybus_descriptor_module module;
int num_cports;
int num_strings;
- struct gmod_cport *cport[MAX_CPORTS_PER_MODULE];
+ u16 cport_ids[MAX_CPORTS_PER_MODULE];
struct gmod_string *string[MAX_STRINGS_PER_MODULE];
struct greybus_host_device *hd;
#define to_greybus_module(d) container_of(d, struct greybus_module, dev)
struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod,
- struct gmod_cport *cport,
+ u16 cport_id,
gbuf_complete_t complete,
unsigned int size,
gfp_t gfp_mask,
void gb_gbuf_exit(void);
int gb_register_cport_complete(struct greybus_module *gmod,
- gbuf_complete_t handler, int cport_id,
+ gbuf_complete_t handler, u16 cport_id,
void *context);
-void gb_deregister_cport_complete(int cport_id);
+void gb_deregister_cport_complete(u16 cport_id);
extern const struct attribute_group *greybus_module_groups[];
struct device_attribute dev_attr_##_name = __ATTR_RO(_name)
#endif
+#ifndef U8_MAX
+#define U8_MAX ((u8)~0U)
+#endif /* ! U8_MAX */
#endif /* __GREYBUS_KERNEL_VER_H */
struct svc_function_unipro_set_route {
__u8 source_module_id;
- __u8 source_cport_id;
+ __u8 source_cport_id; /* bottom 8 bits */
__u8 destination_module_id;
- __u8 destination_cport_id;
+ __u8 destination_cport_id; /* bottom 8 bits */
};
struct svc_function_unipro_link_up {
};
int gb_register_cport_complete(struct greybus_module *gmod,
- gbuf_complete_t handler, int cport_id,
+ gbuf_complete_t handler, u16 cport_id,
void *context);
-void gb_deregister_cport_complete(int cport_id);
+void gb_deregister_cport_complete(u16 cport_id);
struct gb_tty {
struct tty_port port;
struct greybus_module *gmod;
- int cport_id;
+ u16 cport_id;
unsigned int minor;
unsigned char clocal;
unsigned int throttled:1;