summaryrefslogtreecommitdiffstats
path: root/include/linux/mfd/core.h
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2011-02-17 19:07:34 -0800
committerSamuel Ortiz <sameo@linux.intel.com>2011-03-23 10:41:58 +0100
commit1e29af62f2b285bd18685da93c3ce8c33ca2d1db (patch)
tree662545398e04cfb5b10fa4b13810d47ddd003c98 /include/linux/mfd/core.h
parentdcb50e83bb86d66d3554ba9c365488669c84d037 (diff)
downloadlinux-stable-1e29af62f2b285bd18685da93c3ce8c33ca2d1db.tar.gz
linux-stable-1e29af62f2b285bd18685da93c3ce8c33ca2d1db.tar.bz2
linux-stable-1e29af62f2b285bd18685da93c3ce8c33ca2d1db.zip
mfd: Add refcounting support to mfd_cells
This provides convenience functions for sharing of cells across multiple mfd clients. Mfd drivers can provide enable/disable hooks to actually tweak the hardware, and clients can call mfd_shared_cell_{en,dis}able without having to worry about whether or not another client happens to have enabled or disabled the cell/hardware. Note that this is purely optional; drivers can continue to use the mfd_cell's enable/disable hooks for their own purposes, if desired. Signed-off-by: Andres Salomon <dilinger@queued.net> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'include/linux/mfd/core.h')
-rw-r--r--include/linux/mfd/core.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/include/linux/mfd/core.h b/include/linux/mfd/core.h
index 71cd1f983cce..22a2f5ebd9db 100644
--- a/include/linux/mfd/core.h
+++ b/include/linux/mfd/core.h
@@ -25,8 +25,11 @@ struct mfd_cell {
const char *name;
int id;
+ /* refcounting for multiple drivers to use a single cell */
+ atomic_t *usage_count;
int (*enable)(struct platform_device *dev);
int (*disable)(struct platform_device *dev);
+
int (*suspend)(struct platform_device *dev);
int (*resume)(struct platform_device *dev);
@@ -51,6 +54,15 @@ struct mfd_cell {
};
/*
+ * Convenience functions for clients using shared cells. Refcounting
+ * happens automatically, with the cell's enable/disable callbacks
+ * being called only when a device is first being enabled or no other
+ * clients are making use of it.
+ */
+extern int mfd_shared_cell_enable(struct platform_device *pdev);
+extern int mfd_shared_cell_disable(struct platform_device *pdev);
+
+/*
* Given a platform device that's been created by mfd_add_devices(), fetch
* the mfd_cell that created it.
*/
@@ -69,7 +81,7 @@ static inline void *mfd_get_data(struct platform_device *pdev)
}
extern int mfd_add_devices(struct device *parent, int id,
- const struct mfd_cell *cells, int n_devs,
+ struct mfd_cell *cells, int n_devs,
struct resource *mem_base,
int irq_base);