diff options
| author | Andres Salomon <dilinger@queued.net> | 2011-02-17 22:07:34 -0500 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2011-03-23 05:41:58 -0400 |
| commit | 1e29af62f2b285bd18685da93c3ce8c33ca2d1db (patch) | |
| tree | 662545398e04cfb5b10fa4b13810d47ddd003c98 /include/linux/mfd | |
| parent | dcb50e83bb86d66d3554ba9c365488669c84d037 (diff) | |
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')
| -rw-r--r-- | include/linux/mfd/core.h | 14 |
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 { | |||
| 25 | const char *name; | 25 | const char *name; |
| 26 | int id; | 26 | int id; |
| 27 | 27 | ||
| 28 | /* refcounting for multiple drivers to use a single cell */ | ||
| 29 | atomic_t *usage_count; | ||
| 28 | int (*enable)(struct platform_device *dev); | 30 | int (*enable)(struct platform_device *dev); |
| 29 | int (*disable)(struct platform_device *dev); | 31 | int (*disable)(struct platform_device *dev); |
| 32 | |||
| 30 | int (*suspend)(struct platform_device *dev); | 33 | int (*suspend)(struct platform_device *dev); |
| 31 | int (*resume)(struct platform_device *dev); | 34 | int (*resume)(struct platform_device *dev); |
| 32 | 35 | ||
| @@ -51,6 +54,15 @@ struct mfd_cell { | |||
| 51 | }; | 54 | }; |
| 52 | 55 | ||
| 53 | /* | 56 | /* |
| 57 | * Convenience functions for clients using shared cells. Refcounting | ||
| 58 | * happens automatically, with the cell's enable/disable callbacks | ||
| 59 | * being called only when a device is first being enabled or no other | ||
| 60 | * clients are making use of it. | ||
| 61 | */ | ||
| 62 | extern int mfd_shared_cell_enable(struct platform_device *pdev); | ||
| 63 | extern int mfd_shared_cell_disable(struct platform_device *pdev); | ||
| 64 | |||
| 65 | /* | ||
| 54 | * Given a platform device that's been created by mfd_add_devices(), fetch | 66 | * Given a platform device that's been created by mfd_add_devices(), fetch |
| 55 | * the mfd_cell that created it. | 67 | * the mfd_cell that created it. |
| 56 | */ | 68 | */ |
| @@ -69,7 +81,7 @@ static inline void *mfd_get_data(struct platform_device *pdev) | |||
| 69 | } | 81 | } |
| 70 | 82 | ||
| 71 | extern int mfd_add_devices(struct device *parent, int id, | 83 | extern int mfd_add_devices(struct device *parent, int id, |
| 72 | const struct mfd_cell *cells, int n_devs, | 84 | struct mfd_cell *cells, int n_devs, |
| 73 | struct resource *mem_base, | 85 | struct resource *mem_base, |
| 74 | int irq_base); | 86 | int irq_base); |
| 75 | 87 | ||
