On 08/05/2023 15:10, Zeynep Arslanbenzer wrote: > MFD driver for MAX77643/54/58/59 to enable its sub > devices. > > The MAX77643 is a multi-function devices. It includes > regulator. > > The MAX77654 is a multi-function devices. It includes > regulator and charger. > > The MAX77658 is a multi-function devices. It includes > regulator, charger and battery. > > The MAX77659 is a multi-function devices. It includes > regulator and charger. > > Signed-off-by: Nurettin Bolucu <Nurettin.Bolucu@xxxxxxxxxx> > Signed-off-by: Zeynep Arslanbenzer <Zeynep.Arslanbenzer@xxxxxxxxxx> > --- > drivers/mfd/Kconfig | 13 ++ > drivers/mfd/Makefile | 1 + > drivers/mfd/max77658.c | 426 +++++++++++++++++++++++++++++++++++ > include/linux/mfd/max77658.h | 80 +++++++ > 4 files changed, 520 insertions(+) > create mode 100644 drivers/mfd/max77658.c > create mode 100644 include/linux/mfd/max77658.h > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 8b93856de432..aa1630a6d33a 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -821,6 +821,19 @@ config MFD_MAX77650 > the following functionalities of the device: GPIO, regulator, > charger, LED, onkey. > ... glbl1_chip, &max77658->irqc_glbl1); > +} > + > +static int max77658_i2c_probe(struct i2c_client *client, > + const struct i2c_device_id *id) > +{ > + struct device *dev = &client->dev; > + struct max77658_dev *max77658; > + const struct mfd_cell *cells; > + struct i2c_client *fuel; > + int ret, n_devs; > + > + max77658 = devm_kzalloc(dev, sizeof(*max77658), GFP_KERNEL); > + if (!max77658) > + return -ENOMEM; > + > + i2c_set_clientdata(client, max77658); > + max77658->irq = client->irq; > + > + max77658->id = (enum max77658_ids)device_get_match_data(dev); Double space -> One space. > + if (!max77658->id) > + max77658->id = (enum max77658_ids)id->driver_data; > + > + if (!max77658->id) > + return -EINVAL; > + > + max77658->regmap = devm_regmap_init_i2c(client, > + &max77658_regmap_config); > + if (IS_ERR(max77658->regmap)) > + return dev_err_probe(dev, PTR_ERR(max77658->regmap), > + "Failed to initialize regmap\n"); > + > + fuel = i2c_new_dummy_device(client->adapter, I2C_ADDR_FUEL_GAUGE); > + if (IS_ERR(fuel)) > + return dev_err_probe(dev, PTR_ERR(fuel), > + "Failed to create I2C device[0x%Xh]\n", > + I2C_ADDR_FUEL_GAUGE); Where do you free "fuel" instance? > + > + i2c_set_clientdata(fuel, max77658); > + > + max77658->regmap_fg = devm_regmap_init_i2c(fuel, > + &max77658_regmap_config_fg); > + if (IS_ERR(max77658->regmap_fg)) > + return dev_err_probe(dev, > + PTR_ERR(max77658->regmap_fg), > + "Failed to initialize I2C device[0x%Xh]\n", > + I2C_ADDR_FUEL_GAUGE); > + > + ret = max77658_pmic_irq_init(dev); > + if (ret < 0) > + return dev_err_probe(dev, ret, "Failed to initialize IRQ\n"); > + > + switch (max77658->id) { > + case ID_MAX77643: > + cells = max77643_devs; > + n_devs = ARRAY_SIZE(max77643_devs); > + break; > + case ID_MAX77654: > + cells = max77654_devs; > + n_devs = ARRAY_SIZE(max77654_devs); > + break; > + case ID_MAX77658: > + cells = max77658_devs; > + n_devs = ARRAY_SIZE(max77658_devs); > + break; > + case ID_MAX77659: > + cells = max77659_devs; > + n_devs = ARRAY_SIZE(max77659_devs); > + break; > + default: > + return -EINVAL; > + } > + > + ret = devm_mfd_add_devices(dev, -1, cells, n_devs, NULL, 0, NULL); > + if (ret) > + return dev_err_probe(dev, ret, "Failed to add sub-devices\n"); > + > + return device_init_wakeup(dev, true); > +} Best regards, Krzysztof