diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2022-07-24 21:00:01 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2022-08-08 16:22:06 +0200 |
commit | 8a2e1d28af89818d5c24bd89f5366aa0bf7ff784 (patch) | |
tree | 6b47b1295202dfa25010c1ef23454343ab05b514 /drivers/mfd | |
parent | 1da26bfb9da2d0d0054169b15d90e9a2c85ae902 (diff) | |
download | barebox-8a2e1d28af89818d5c24bd89f5366aa0bf7ff784.tar.gz barebox-8a2e1d28af89818d5c24bd89f5366aa0bf7ff784.tar.xz |
mfd: implement mfd_add_devices
This makes it easier to port Linux drivers like PMICs, where a device
tree probed MFD node exists and the driver matching against it then
registers a number of MFD cell devices, which don't have their own
DT compatibles.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20220724190006.2160802-1-a.fatoum@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/Makefile | 2 | ||||
-rw-r--r-- | drivers/mfd/core.c | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 50f54cfcf2..2b988bdc9a 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -1,4 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-y += core.o + obj-$(CONFIG_MFD_ACT8846) += act8846.o obj-$(CONFIG_MFD_DA9053) += da9053.o obj-$(CONFIG_MFD_DA9063) += da9063.o diff --git a/drivers/mfd/core.c b/drivers/mfd/core.c new file mode 100644 index 0000000000..495427ae9c --- /dev/null +++ b/drivers/mfd/core.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#include <linux/mfd/core.h> +#include <driver.h> + +int mfd_add_devices(struct device_d *parent, const struct mfd_cell *cells, int n_devs) +{ + struct device_d *dev; + int ret, i; + + for (i = 0; i < n_devs; i++) { + dev = device_alloc(cells[i].name, DEVICE_ID_DYNAMIC); + dev->parent = parent; + + ret = device_add_data(dev, &cells[i], sizeof(cells[i])); + if (ret) + return ret; + + ret = platform_device_register(dev); + if (ret) + return ret; + } + + return 0; +} |