diff options
author | Alex Elder <elder@linaro.org> | 2014-10-01 21:54:11 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <greg@kroah.com> | 2014-10-02 21:17:20 -0700 |
commit | e1e9dbddfe71de1efba5bc77b3f2b374e2ba0104 (patch) | |
tree | 92832849ad53953449703be77d076d8605f6c0c2 /drivers/staging/greybus/module.h | |
parent | ecf7d579713155e7d2e2aa76227c68c4f64c5146 (diff) |
greybus: isolate greybus module code
Define new source files "module.h" and "module.c" to separate the
definitions of the Greybus module abstraction from other code.
Rename "greybus_module" to be "gb_module", for brevity. Do the same
for a few other symbols with "greybus_module" in their names. A few
(like greybus_module_id) are more visible outside this kernel module
so we'll keep their names more descriptive.
Add a definition for U8_MAX in "kernel_ver.h" (it appeared in 3.14).
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
Diffstat (limited to 'drivers/staging/greybus/module.h')
-rw-r--r-- | drivers/staging/greybus/module.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/staging/greybus/module.h b/drivers/staging/greybus/module.h new file mode 100644 index 000000000000..0d0f19f9b9fc --- /dev/null +++ b/drivers/staging/greybus/module.h @@ -0,0 +1,57 @@ +/* + * Greybus modules + * + * Copyright 2014 Google Inc. + * + * Released under the GPLv2 only. + */ + +#ifndef __MODULE_H +#define __MODULE_H + +/* Increase these values if needed */ +#define MAX_CPORTS_PER_MODULE 10 +#define MAX_STRINGS_PER_MODULE 10 + +struct gb_module { + struct device dev; + + struct list_head links; /* greybus_host_device->modules */ + u8 module_id; /* Physical location within the Endo */ + + struct greybus_descriptor_module module; + int num_cports; + int num_strings; + u16 cport_ids[MAX_CPORTS_PER_MODULE]; + struct gmod_string *string[MAX_STRINGS_PER_MODULE]; + + struct greybus_host_device *hd; + + struct gb_i2c_device *gb_i2c_dev; + struct gb_gpio_device *gb_gpio_dev; + struct gb_sdio_host *gb_sdio_host; + struct gb_tty *gb_tty; + struct gb_usb_device *gb_usb_dev; + struct gb_battery *gb_battery; +}; +#define to_gb_module(d) container_of(d, struct gb_module, dev) + +static inline void +gb_module_set_drvdata(struct gb_module *gmod, void *data) +{ + dev_set_drvdata(&gmod->dev, data); +} + +static inline void *gb_module_get_drvdata(struct gb_module *gmod) +{ + return dev_get_drvdata(&gmod->dev); +} + +const struct greybus_module_id *gb_module_match_id(struct gb_module *gmod, + const struct greybus_module_id *id); + +struct gb_module *gb_module_create(struct greybus_host_device *hd, + u8 module_id); +void gb_module_destroy(struct gb_module *module); + +#endif /* __MODULE_H */ |