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>
This commit is contained in:
committed by
Samuel Ortiz
parent
dcb50e83bb
commit
1e29af62f2
@ -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);
|
||||
|
||||
@ -50,6 +53,15 @@ struct mfd_cell {
|
||||
bool pm_runtime_no_callbacks;
|
||||
};
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
|
Reference in New Issue
Block a user