summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/greybus/core.c14
-rw-r--r--drivers/staging/greybus/es1-ap-usb.c5
-rw-r--r--drivers/staging/greybus/gbuf.c22
-rw-r--r--drivers/staging/greybus/greybus.h21
-rw-r--r--drivers/staging/greybus/kernel_ver.h3
-rw-r--r--drivers/staging/greybus/svc_msg.h4
-rw-r--r--drivers/staging/greybus/test_sink.c4
-rw-r--r--drivers/staging/greybus/uart-gb.c2
8 files changed, 31 insertions, 44 deletions
diff --git a/drivers/staging/greybus/core.c b/drivers/staging/greybus/core.c
index 3cc54ed..f8ba49c 100644
--- a/drivers/staging/greybus/core.c
+++ b/drivers/staging/greybus/core.c
@@ -160,8 +160,6 @@ static void greybus_module_release(struct device *dev)
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);
}
@@ -298,8 +296,6 @@ static int create_cport(struct greybus_module *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;
@@ -311,15 +307,7 @@ static int create_cport(struct greybus_module *gmod,
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;
diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c
index 8df1643..410acd3 100644
--- a/drivers/staging/greybus/es1-ap-usb.c
+++ b/drivers/staging/greybus/es1-ap-usb.c
@@ -11,8 +11,10 @@
#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)
@@ -114,7 +116,8 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask)
* 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;
diff --git a/drivers/staging/greybus/gbuf.c b/drivers/staging/greybus/gbuf.c
index 94c2d6a..7b4a72a 100644
--- a/drivers/staging/greybus/gbuf.c
+++ b/drivers/staging/greybus/gbuf.c
@@ -27,7 +27,7 @@ static struct kmem_cache *gbuf_head_cache;
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)
@@ -40,7 +40,7 @@ static struct gbuf *__alloc_gbuf(struct greybus_module *gmod,
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;
@@ -64,7 +64,7 @@ static struct gbuf *__alloc_gbuf(struct greybus_module *gmod,
* 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,
@@ -73,7 +73,7 @@ struct gbuf *greybus_alloc_gbuf(struct greybus_module *gmod,
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;
@@ -146,7 +146,7 @@ static void cport_process_event(struct work_struct *work)
#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;
};
@@ -156,25 +156,25 @@ static struct gb_cport_handler cport_handler[MAX_CPORTS];
// 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;
@@ -189,7 +189,7 @@ void greybus_cport_in(struct greybus_host_device *hd, int cport_id, u8 *data,
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... */
diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h
index 1328dc9..4ca11f2 100644
--- a/drivers/staging/greybus/greybus.h
+++ b/drivers/staging/greybus/greybus.h
@@ -101,13 +101,6 @@
struct gbuf;
-struct gmod_cport {
- u16 id;
- u16 size;
- u8 speed; // valid???
- // FIXME, what else?
-};
-
struct gmod_string {
u16 length;
u8 id;
@@ -121,7 +114,7 @@ struct gbuf {
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 */
@@ -187,8 +180,8 @@ struct greybus_host_device {
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);
@@ -203,7 +196,7 @@ struct greybus_module {
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;
@@ -218,7 +211,7 @@ struct greybus_module {
#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,
@@ -298,9 +291,9 @@ int gb_gbuf_init(void);
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[];
diff --git a/drivers/staging/greybus/kernel_ver.h b/drivers/staging/greybus/kernel_ver.h
index 40cc2e8..4aa5b83 100644
--- a/drivers/staging/greybus/kernel_ver.h
+++ b/drivers/staging/greybus/kernel_ver.h
@@ -18,5 +18,8 @@
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 */
diff --git a/drivers/staging/greybus/svc_msg.h b/drivers/staging/greybus/svc_msg.h
index 4b69604..986368d 100644
--- a/drivers/staging/greybus/svc_msg.h
+++ b/drivers/staging/greybus/svc_msg.h
@@ -49,9 +49,9 @@ struct svc_function_handshake {
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 {
diff --git a/drivers/staging/greybus/test_sink.c b/drivers/staging/greybus/test_sink.c
index 8b254e3..811a237 100644
--- a/drivers/staging/greybus/test_sink.c
+++ b/drivers/staging/greybus/test_sink.c
@@ -16,9 +16,9 @@ struct test_device {
};
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);
diff --git a/drivers/staging/greybus/uart-gb.c b/drivers/staging/greybus/uart-gb.c
index 7735a04..7f9d498 100644
--- a/drivers/staging/greybus/uart-gb.c
+++ b/drivers/staging/greybus/uart-gb.c
@@ -34,7 +34,7 @@
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;
OpenPOWER on IntegriCloud