Commit ba993468 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: record the host device in a gbuf

The only thing we now use the gbuf->operation pointer for is
to get access to its connection's host device.

Record the host device pointer directly in the gbuf, rather
than keeping a pointer to the operation.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 6af29086
...@@ -205,7 +205,7 @@ static struct urb *next_free_urb(struct es1_ap_dev *es1, gfp_t gfp_mask) ...@@ -205,7 +205,7 @@ static struct urb *next_free_urb(struct es1_ap_dev *es1, gfp_t gfp_mask)
static int submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask) static int submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
{ {
struct greybus_host_device *hd = gbuf->operation->connection->hd; struct greybus_host_device *hd = gbuf->hd;
struct es1_ap_dev *es1 = hd_to_es1(hd); struct es1_ap_dev *es1 = hd_to_es1(hd);
struct usb_device *udev = es1->usb_dev; struct usb_device *udev = es1->usb_dev;
int retval; int retval;
...@@ -391,7 +391,7 @@ static void cport_in_callback(struct urb *urb) ...@@ -391,7 +391,7 @@ static void cport_in_callback(struct urb *urb)
static void cport_out_callback(struct urb *urb) static void cport_out_callback(struct urb *urb)
{ {
struct gbuf *gbuf = urb->context; struct gbuf *gbuf = urb->context;
struct es1_ap_dev *es1 = hd_to_es1(gbuf->operation->connection->hd); struct es1_ap_dev *es1 = hd_to_es1(gbuf->hd);
unsigned long flags; unsigned long flags;
int i; int i;
......
...@@ -34,12 +34,11 @@ static struct kmem_cache *gbuf_head_cache; ...@@ -34,12 +34,11 @@ static struct kmem_cache *gbuf_head_cache;
* that the driver can then fill up with the data to be sent out. Curse * that the driver can then fill up with the data to be sent out. Curse
* hardware designers for this issue... * hardware designers for this issue...
*/ */
struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, struct gbuf *greybus_alloc_gbuf(struct greybus_host_device *hd,
u16 dest_cport_id, u16 dest_cport_id,
unsigned int size, unsigned int size,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
struct greybus_host_device *hd = operation->connection->hd;
struct gbuf *gbuf; struct gbuf *gbuf;
int retval; int retval;
...@@ -48,7 +47,7 @@ struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, ...@@ -48,7 +47,7 @@ struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
return NULL; return NULL;
kref_init(&gbuf->kref); kref_init(&gbuf->kref);
gbuf->operation = operation; gbuf->hd = hd;
gbuf->dest_cport_id = dest_cport_id; gbuf->dest_cport_id = dest_cport_id;
gbuf->status = -EBADR; /* Initial value--means "never set" */ gbuf->status = -EBADR; /* Initial value--means "never set" */
...@@ -68,9 +67,8 @@ static DEFINE_MUTEX(gbuf_mutex); ...@@ -68,9 +67,8 @@ static DEFINE_MUTEX(gbuf_mutex);
static void free_gbuf(struct kref *kref) static void free_gbuf(struct kref *kref)
{ {
struct gbuf *gbuf = container_of(kref, struct gbuf, kref); struct gbuf *gbuf = container_of(kref, struct gbuf, kref);
struct greybus_host_device *hd = gbuf->operation->connection->hd;
hd->driver->free_gbuf_data(gbuf); gbuf->hd->driver->free_gbuf_data(gbuf);
kmem_cache_free(gbuf_head_cache, gbuf); kmem_cache_free(gbuf_head_cache, gbuf);
mutex_unlock(&gbuf_mutex); mutex_unlock(&gbuf_mutex);
...@@ -94,21 +92,17 @@ EXPORT_SYMBOL_GPL(greybus_get_gbuf); ...@@ -94,21 +92,17 @@ EXPORT_SYMBOL_GPL(greybus_get_gbuf);
int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask) int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
{ {
struct greybus_host_device *hd = gbuf->operation->connection->hd;
gbuf->status = -EINPROGRESS; gbuf->status = -EINPROGRESS;
return hd->driver->submit_gbuf(gbuf, gfp_mask); return gbuf->hd->driver->submit_gbuf(gbuf, gfp_mask);
} }
void greybus_kill_gbuf(struct gbuf *gbuf) void greybus_kill_gbuf(struct gbuf *gbuf)
{ {
struct greybus_host_device *hd = gbuf->operation->connection->hd;
if (gbuf->status != -EINPROGRESS) if (gbuf->status != -EINPROGRESS)
return; return;
hd->driver->kill_gbuf(gbuf); gbuf->hd->driver->kill_gbuf(gbuf);
} }
void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id, void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
......
...@@ -121,7 +121,7 @@ ...@@ -121,7 +121,7 @@
struct gbuf { struct gbuf {
struct kref kref; struct kref kref;
struct gb_operation *operation; struct greybus_host_device *hd;
u16 dest_cport_id; /* Destination CPort id */ u16 dest_cport_id; /* Destination CPort id */
int status; int status;
...@@ -181,7 +181,7 @@ void greybus_remove_hd(struct greybus_host_device *hd); ...@@ -181,7 +181,7 @@ void greybus_remove_hd(struct greybus_host_device *hd);
void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id, void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
u8 *data, size_t length); u8 *data, size_t length);
struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, struct gbuf *greybus_alloc_gbuf(struct greybus_host_device *hd,
u16 dest_cport_id, unsigned int size, u16 dest_cport_id, unsigned int size,
gfp_t gfp_mask); gfp_t gfp_mask);
void greybus_free_gbuf(struct gbuf *gbuf); void greybus_free_gbuf(struct gbuf *gbuf);
......
...@@ -200,6 +200,7 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation, ...@@ -200,6 +200,7 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation,
u8 type, size_t size, u8 type, size_t size,
bool data_out) bool data_out)
{ {
struct gb_connection *connection = operation->connection;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
struct gbuf *gbuf; struct gbuf *gbuf;
gfp_t gfp_flags = data_out ? GFP_KERNEL : GFP_ATOMIC; gfp_t gfp_flags = data_out ? GFP_KERNEL : GFP_ATOMIC;
...@@ -209,11 +210,12 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation, ...@@ -209,11 +210,12 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation,
return NULL; /* Message too big */ return NULL; /* Message too big */
if (data_out) if (data_out)
dest_cport_id = operation->connection->interface_cport_id; dest_cport_id = connection->interface_cport_id;
else else
dest_cport_id = CPORT_ID_BAD; dest_cport_id = CPORT_ID_BAD;
size += sizeof(*header); size += sizeof(*header);
gbuf = greybus_alloc_gbuf(operation, dest_cport_id, size, gfp_flags); gbuf = greybus_alloc_gbuf(connection->hd, dest_cport_id,
size, gfp_flags);
if (!gbuf) if (!gbuf)
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment