Commit f036e056 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

greybus: gbuf: implement submission logic

parent 29f000f4
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ static int alloc_gbuf(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask)
	u8 *buffer;

	if (size > ES1_GBUF_MSG_SIZE) {
		pr_err("guf was asked to be bigger than %d!\n",
		pr_err("guf was asked to be bigger than %ld!\n",
		       ES1_GBUF_MSG_SIZE);
	}

@@ -189,7 +189,7 @@ static struct urb *next_free_urb(struct es1_ap_dev *es1, gfp_t gfp_mask)
	return urb;
}

static int send_gbuf(struct gbuf *gbuf, struct greybus_host_device *hd,
static int submit_gbuf(struct gbuf *gbuf, struct greybus_host_device *hd,
		       gfp_t gfp_mask)
{
	struct es1_ap_dev *es1 = hd_to_es1(hd);
@@ -220,7 +220,7 @@ static struct greybus_host_driver es1_driver = {
	.alloc_gbuf	= alloc_gbuf,
	.free_gbuf	= free_gbuf,
	.send_svc_msg	= send_svc_msg,
	.send_gbuf = send_gbuf,
	.submit_gbuf	= submit_gbuf,
};

/* Callback for when we get a SVC message */
+17 −10
Original line number Diff line number Diff line
@@ -112,10 +112,9 @@ struct gbuf *greybus_get_gbuf(struct gbuf *gbuf)
}
EXPORT_SYMBOL_GPL(greybus_get_gbuf);

int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t mem_flags)
int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t gfp_mask)
{
	// FIXME - implement
	return -ENOMEM;
	return gbuf->gdev->hd->driver->submit_gbuf(gbuf, gbuf->gdev->hd, gfp_mask);
}

int greybus_kill_gbuf(struct gbuf *gbuf)
@@ -124,13 +123,6 @@ int greybus_kill_gbuf(struct gbuf *gbuf)
	return -ENOMEM;
}

/* Can be called in interrupt context, do the work and get out of here */
void greybus_gbuf_finished(struct gbuf *gbuf)
{
	// FIXME - implement
}
EXPORT_SYMBOL_GPL(greybus_gbuf_finished);

#define MAX_CPORTS	1024
struct gb_cport_handler {
	gbuf_complete_t handler;
@@ -236,6 +228,21 @@ void greybus_cport_in_data(struct greybus_host_device *hd, int cport, u8 *data,
}
EXPORT_SYMBOL_GPL(greybus_cport_in_data);

/* Can be called in interrupt context, do the work and get out of here */
void greybus_gbuf_finished(struct gbuf *gbuf)
{
	struct cport_msg *cm;

	/* Again with the slow allocate... */
	cm = kmalloc(sizeof(*cm), GFP_ATOMIC);
	cm->gbuf = gbuf;
	INIT_WORK(&cm->event, cport_process_event);
	queue_work(cport_workqueue, &cm->event);

	// FIXME - implement
}
EXPORT_SYMBOL_GPL(greybus_gbuf_finished);

int gb_gbuf_init(void)
{
	cport_workqueue = alloc_workqueue("greybus_gbuf", 0, 1);
+4 −3
Original line number Diff line number Diff line
@@ -107,8 +107,9 @@ struct greybus_host_driver {

	int (*alloc_gbuf)(struct gbuf *gbuf, unsigned int size, gfp_t gfp_mask);
	void (*free_gbuf)(struct gbuf *gbuf);
	int (*send_svc_msg)(struct svc_msg *svc_msg, struct greybus_host_device *hd);
	int (*send_gbuf)(struct gbuf *gbuf, struct greybus_host_device *hd,
	int (*send_svc_msg)(struct svc_msg *svc_msg,
			    struct greybus_host_device *hd);
	int (*submit_gbuf)(struct gbuf *gbuf, struct greybus_host_device *hd,
			   gfp_t gfp_mask);
};