From d5d1903dcd158e220275a64f9f4df6cd06addb82 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 11 Aug 2014 19:03:20 +0800 Subject: [PATCH] greybus: add framework for 'struct gbuf' This is the equlivant of sk_buf or urbs for Greybus. --- drivers/staging/greybus/Makefile | 2 +- drivers/staging/greybus/gbuf.c | 42 +++++++++++++++++++++++++ drivers/staging/greybus/greybus.h | 51 ++++++++++++++++++++++++++++++- 3 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 drivers/staging/greybus/gbuf.c diff --git a/drivers/staging/greybus/Makefile b/drivers/staging/greybus/Makefile index 753436d94f1f..cc9c3a7d17b8 100644 --- a/drivers/staging/greybus/Makefile +++ b/drivers/staging/greybus/Makefile @@ -1,4 +1,4 @@ -greybus-y := core.o +greybus-y := core.o gbuf.o obj-m += greybus.o obj-m += i2c-gb.o diff --git a/drivers/staging/greybus/gbuf.c b/drivers/staging/greybus/gbuf.c new file mode 100644 index 000000000000..de31da8165de --- /dev/null +++ b/drivers/staging/greybus/gbuf.c @@ -0,0 +1,42 @@ +/* + * Greybus gbuf handling + * + * Copyright 2014 Google Inc. + * + * Released under the GPLv2 only. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include +#include +#include + +#include "greybus.h" + + +struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev, + struct cport *cport, + gfp_t mem_flags) +{ + return NULL; +} + +void greybus_free_gbuf(struct gbuf *gbuf) +{ +} + +int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t mem_flags) +{ + return -ENOMEM; +} + +int greybus_kill_gbuf(struct gbuf *gbuf) +{ + return -ENOMEM; +} + + + diff --git a/drivers/staging/greybus/greybus.h b/drivers/staging/greybus/greybus.h index 28b3148fb1da..51b9f5b69979 100644 --- a/drivers/staging/greybus/greybus.h +++ b/drivers/staging/greybus/greybus.h @@ -29,19 +29,68 @@ .match_flags = GREYBUS_DEVICE_ID_MATCH_SERIAL, \ .lSerial = (serial), - struct greybus_descriptor { __u16 wVendor; __u16 wProduct; __u64 lSerialNumber; }; + +struct gbuf; + +struct cport { + u16 number; + // FIXME, what else? +}; + +typedef void (*gbuf_complete_t)(struct gbuf *gbuf); + +struct gbuf { + struct kref kref; + void *hcpriv; + + struct list_head anchor_list; + struct gbuf_anchor *anchor; // FIXME do we need? + + struct greybus_device *gdev; + struct cport *cport; + int status; + void *transfer_buffer; + u32 transfer_flags; /* flags for the transfer buffer */ + u32 transfer_buffer_length; + u32 actual_length; + + struct scatterlist *sg; // FIXME do we need? + int num_sgs; + + void *context; + gbuf_complete_t complete; +}; + +/* + * gbuf->transfer_flags + */ +#define GBUF_FREE_BUFFER BIT(0) /* Free the transfer buffer with the gbuf */ + + struct greybus_device { struct device dev; struct greybus_descriptor descriptor; + int num_cport; + struct cport cport[0]; }; #define to_greybus_device(d) container_of(d, struct greybus_device, dev) + +struct gbuf *greybus_alloc_gbuf(struct greybus_device *gdev, + struct cport *cport, + gfp_t mem_flags); +void greybus_free_gbuf(struct gbuf *gbuf); + +int greybus_submit_gbuf(struct gbuf *gbuf, gfp_t mem_flags); +int greybus_kill_gbuf(struct gbuf *gbuf); + + struct greybus_driver { const char *name; -- 2.20.1