mfd: mc13xxx: Allow to set callback for mc13xxx
Some boards have to initialize the PMIC before other devices can be initialized. This requires three levels of initcalls: one level in which the PMIC is probed, one in which the board can call mc13xxx_get() and the third one to initialize the PMIC dependent devices. Allow to register a callback which is called once the PMIC is initialized. This way mc13xxx_get() is no longer necessary and the number of required initcalls levels is reduced to two. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
85c29d2860
commit
214f0d9264
|
@ -60,6 +60,21 @@ int mc13xxx_revision(struct mc13xxx *mc13xxx)
|
|||
}
|
||||
EXPORT_SYMBOL(mc13xxx_revision);
|
||||
|
||||
static void(*mc13xxx_init_callback)(struct mc13xxx *mc13xxx);
|
||||
|
||||
int mc13xxx_register_init_callback(void(*callback)(struct mc13xxx *mc13xxx))
|
||||
{
|
||||
if (mc13xxx_init_callback)
|
||||
return -EBUSY;
|
||||
|
||||
mc13xxx_init_callback = callback;
|
||||
|
||||
if (mc_dev)
|
||||
mc13xxx_init_callback(mc_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI
|
||||
static int spi_rw(struct spi_device *spi, void * buf, size_t len)
|
||||
{
|
||||
|
@ -350,6 +365,9 @@ static int __init mc13xxx_probe(struct device_d *dev)
|
|||
mc_dev->revision = rev;
|
||||
devfs_create(&mc_dev->cdev);
|
||||
|
||||
if (mc13xxx_init_callback)
|
||||
mc13xxx_init_callback(mc_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -171,6 +171,7 @@ extern int mc13xxx_revision(struct mc13xxx *mc13xxx);
|
|||
extern int mc13xxx_reg_read(struct mc13xxx *mc13xxx, u8 reg, u32 *val);
|
||||
extern int mc13xxx_reg_write(struct mc13xxx *mc13xxx, u8 reg, u32 val);
|
||||
extern int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u32 val);
|
||||
int mc13xxx_register_init_callback(void(*callback)(struct mc13xxx *mc13xxx));
|
||||
#else
|
||||
static inline struct mc13xxx *mc13xxx_get(void)
|
||||
{
|
||||
|
@ -196,6 +197,11 @@ static inline int mc13xxx_set_bits(struct mc13xxx *mc13xxx, u8 reg, u32 mask, u3
|
|||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static inline int mc13xxx_register_init_callback(void(*callback)(struct mc13xxx *mc13xxx))
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __MFD_MC13XXX_H */
|
||||
|
|
Loading…
Reference in New Issue