Le 09/12/2024 à 12:26, Dzmitry Sankouski a écrit :
Add driver for Maxim 77705 switch-mode charger (part of max77705 MFD driver) providing power supply class information to userspace. The driver is configured through DTS (battery and system related settings). Signed-off-by: Dzmitry Sankouski <dsankouski@xxxxxxxxx>
...
+static void max77705_chgin_isr_work(struct work_struct *work) +{ + struct max77705_charger_data *charger = + container_of(work, struct max77705_charger_data, chgin_work);
Missing new line.
+ power_supply_changed(charger->psy_chg); +}
...
+static int max77705_charger_probe(struct platform_device *pdev) +{ + struct power_supply_config pscfg = {}; + struct i2c_client *i2c_chg; + struct max77693_dev *max77705; + struct max77705_charger_data *chg; + struct device *dev, *parent; + struct regmap_irq_chip_data *irq_data; + int ret; + + dev = &pdev->dev; + parent = dev->parent; + max77705 = dev_get_drvdata(parent); + + chg = devm_kzalloc(dev, sizeof(*chg), GFP_KERNEL); + if (!chg) + return -ENOMEM; + + platform_set_drvdata(pdev, chg); + + i2c_chg = devm_i2c_new_dummy_device(dev, max77705->i2c->adapter, I2C_ADDR_CHG); + if (IS_ERR(i2c_chg)) + return PTR_ERR(i2c_chg); + + chg->regmap = devm_regmap_init_i2c(i2c_chg, &max77705_chg_regmap_config); + if (IS_ERR(chg->regmap)) + return PTR_ERR(chg->regmap); + + chg->dev = dev; + + ret = regmap_update_bits(chg->regmap, + MAX77705_CHG_REG_INT_MASK, + MAX77705_CHGIN_IM, 0); + if (ret) + return ret; + + pscfg.of_node = dev->of_node; + pscfg.drv_data = chg; + + chg->psy_chg = devm_power_supply_register(dev, &max77705_charger_psy_desc, &pscfg); + if (IS_ERR(chg->psy_chg)) + return PTR_ERR(chg->psy_chg); + + max77705_charger_irq_chip.irq_drv_data = chg; + ret = devm_regmap_add_irq_chip(chg->dev, chg->regmap, max77705->irq, + IRQF_ONESHOT | IRQF_SHARED, 0, + &max77705_charger_irq_chip, + &irq_data); + if (ret) + return dev_err_probe(dev, ret, "failed to add irq chip\n"); + + chg->wqueue = create_singlethread_workqueue(dev_name(dev)); + if (IS_ERR(chg->wqueue)) + return dev_err_probe(dev, PTR_ERR(chg->wqueue), "failed to create workqueue\n"); + + INIT_WORK(&chg->chgin_work, max77705_chgin_isr_work); + + max77705_charger_initialize(chg); + + ret = devm_add_action_or_reset(dev, max77705_charger_disable, chg);
*Based on naming only*, it is strange to add an action to disable something that seems to be enabled a few lines below.
Should this be after a successfulmax77705_charger_enable()?
+ if (ret) + return ret; + + return max77705_charger_enable(chg); +}
... CJ