*/
static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask)
{
- struct es1_ap_dev *es1 = hd_to_es1(gbuf->gmod->hd);
+ struct es1_ap_dev *es1 = hd_to_es1(gbuf->connection->hd);
u8 *buffer;
if (size > ES1_GBUF_MSG_SIZE) {
* we will encode the cport number in the first byte of the buffer, so
* set the second byte to be the "transfer buffer"
*/
- if (gbuf->cport_id > (u16)U8_MAX) {
- pr_err("gbuf->cport_id is '%d' and is out of range!\n",
- gbuf->cport_id);
+ if (gbuf->connection->interface_cport_id > (u16)U8_MAX) {
+ pr_err("gbuf->interface_cport_id (%hd) is out of range!\n",
+ gbuf->connection->interface_cport_id);
kfree(buffer);
return -EINVAL;
}
- buffer[0] = gbuf->cport_id;
+ buffer[0] = gbuf->connection->interface_cport_id;
gbuf->transfer_buffer = &buffer[1];
gbuf->transfer_buffer_length = size;
/* Workqueue to handle Greybus buffer completions. */
static struct workqueue_struct *gbuf_workqueue;
-static struct gbuf *__alloc_gbuf(struct gb_module *gmod,
- u16 cport_id,
+static struct gbuf *__alloc_gbuf(struct gb_connection *connection,
gbuf_complete_t complete,
gfp_t gfp_mask,
void *context)
return NULL;
kref_init(&gbuf->kref);
- gbuf->gmod = gmod;
- gbuf->cport_id = cport_id;
+ gbuf->connection = connection;
INIT_WORK(&gbuf->event, cport_process_event);
gbuf->complete = complete;
gbuf->context = context;
* that the driver can then fill up with the data to be sent out. Curse
* hardware designers for this issue...
*/
-struct gbuf *greybus_alloc_gbuf(struct gb_module *gmod,
- u16 cport_id,
+struct gbuf *greybus_alloc_gbuf(struct gb_connection *connection,
gbuf_complete_t complete,
unsigned int size,
gfp_t gfp_mask,
struct gbuf *gbuf;
int retval;
- gbuf = __alloc_gbuf(gmod, cport_id, complete, gfp_mask, context);
+ gbuf = __alloc_gbuf(connection, complete, gfp_mask, context);
if (!gbuf)
return NULL;
gbuf->direction = GBUF_DIRECTION_OUT;
/* Host controller specific allocation for the actual buffer */
- retval = gmod->hd->driver->alloc_gbuf_data(gbuf, size, gfp_mask);
+ retval = connection->hd->driver->alloc_gbuf_data(gbuf, size, gfp_mask);
if (retval) {
greybus_free_gbuf(gbuf);
return NULL;
/* If the direction is "out" then the host controller frees the data */
if (gbuf->direction == GBUF_DIRECTION_OUT) {
- gbuf->gmod->hd->driver->free_gbuf_data(gbuf);
+ gbuf->connection->hd->driver->free_gbuf_data(gbuf);
} else {
/* we "own" this in data, so free it ourselves */
kfree(gbuf->transfer_buffer);
int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
{
- return gbuf->gmod->hd->driver->submit_gbuf(gbuf, gbuf->gmod->hd, gfp_mask);
+ struct greybus_host_device *hd = gbuf->connection->hd;
+
+ return hd->driver->submit_gbuf(gbuf, hd, gfp_mask);
}
int greybus_kill_gbuf(struct gbuf *gbuf)
return;
}
- gbuf = __alloc_gbuf(ch->gmod, ch->cport_id, ch->handler, GFP_ATOMIC,
- ch->context);
+ gbuf = __alloc_gbuf(connection, ch->handler, GFP_ATOMIC, ch->context);
if (!gbuf) {
/* Again, something bad went wrong, log it... */
pr_err("can't allocate gbuf???\n");
struct kref kref;
void *hdpriv;
- struct gb_module *gmod;
- u16 cport_id;
+ struct gb_connection *connection;
int status;
void *transfer_buffer;
u32 transfer_flags; /* flags for the transfer buffer */
u8 *data, size_t length);
void greybus_gbuf_finished(struct gbuf *gbuf);
-struct gbuf *greybus_alloc_gbuf(struct gb_module *gmod, u16 cport_id,
+struct gbuf *greybus_alloc_gbuf(struct gb_connection *connection,
gbuf_complete_t complete, unsigned int size,
gfp_t gfp_mask, void *context);
void greybus_free_gbuf(struct gbuf *gbuf);