mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
mfd: lm3533: Use dev_groups in struct device_driver
Instead of creating and removing the device sysfs attributes directly during probe and remove of the driver, respectively, use dev_groups in struct device_driver to point to the attribute definitions and let the core take care of creating and removing them. No intentional functional impact. Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com> Reviewed-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260731113632.158440-8-clamor95@gmail.com Signed-off-by: Lee Jones <lee@kernel.org>
This commit is contained in:
parent
cdc9de135b
commit
d172f38144
|
|
@ -294,6 +294,11 @@ static struct attribute_group lm3533_attribute_group = {
|
|||
.attrs = lm3533_attributes
|
||||
};
|
||||
|
||||
static const struct attribute_group *lm3533_attribute_groups[] = {
|
||||
&lm3533_attribute_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int lm3533_device_als_init(struct lm3533 *lm3533)
|
||||
{
|
||||
struct lm3533_platform_data *pdata = dev_get_platdata(lm3533->dev);
|
||||
|
|
@ -414,16 +419,8 @@ static int lm3533_device_init(struct lm3533 *lm3533)
|
|||
lm3533_device_bl_init(lm3533);
|
||||
lm3533_device_led_init(lm3533);
|
||||
|
||||
ret = sysfs_create_group(&lm3533->dev->kobj, &lm3533_attribute_group);
|
||||
if (ret < 0) {
|
||||
dev_err(lm3533->dev, "failed to create sysfs attributes\n");
|
||||
goto err_unregister;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_unregister:
|
||||
mfd_remove_devices(lm3533->dev);
|
||||
err_disable:
|
||||
lm3533_disable(lm3533);
|
||||
|
||||
|
|
@ -434,8 +431,6 @@ static void lm3533_device_exit(struct lm3533 *lm3533)
|
|||
{
|
||||
dev_dbg(lm3533->dev, "%s\n", __func__);
|
||||
|
||||
sysfs_remove_group(&lm3533->dev->kobj, &lm3533_attribute_group);
|
||||
|
||||
mfd_remove_devices(lm3533->dev);
|
||||
lm3533_disable(lm3533);
|
||||
}
|
||||
|
|
@ -530,6 +525,7 @@ MODULE_DEVICE_TABLE(i2c, lm3533_i2c_ids);
|
|||
static struct i2c_driver lm3533_i2c_driver = {
|
||||
.driver = {
|
||||
.name = "lm3533",
|
||||
.dev_groups = lm3533_attribute_groups,
|
||||
},
|
||||
.id_table = lm3533_i2c_ids,
|
||||
.probe = lm3533_i2c_probe,
|
||||
|
|
|
|||
|
|
@ -237,6 +237,11 @@ static struct attribute_group lm3533_bl_attribute_group = {
|
|||
.attrs = lm3533_bl_attributes
|
||||
};
|
||||
|
||||
static const struct attribute_group *lm3533_bl_attribute_groups[] = {
|
||||
&lm3533_bl_attribute_group,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int lm3533_bl_setup(struct lm3533_bl *bl,
|
||||
struct lm3533_bl_platform_data *pdata)
|
||||
{
|
||||
|
|
@ -304,28 +309,17 @@ static int lm3533_bl_probe(struct platform_device *pdev)
|
|||
|
||||
platform_set_drvdata(pdev, bl);
|
||||
|
||||
ret = sysfs_create_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
|
||||
if (ret < 0) {
|
||||
dev_err(&pdev->dev, "failed to create sysfs attributes\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
backlight_update_status(bd);
|
||||
|
||||
ret = lm3533_bl_setup(bl, pdata);
|
||||
if (ret)
|
||||
goto err_sysfs_remove;
|
||||
return ret;
|
||||
|
||||
ret = lm3533_ctrlbank_enable(&bl->cb);
|
||||
if (ret)
|
||||
goto err_sysfs_remove;
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
|
||||
err_sysfs_remove:
|
||||
sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void lm3533_bl_remove(struct platform_device *pdev)
|
||||
|
|
@ -339,7 +333,6 @@ static void lm3533_bl_remove(struct platform_device *pdev)
|
|||
bd->props.brightness = 0;
|
||||
|
||||
lm3533_ctrlbank_disable(&bl->cb);
|
||||
sysfs_remove_group(&bd->dev.kobj, &lm3533_bl_attribute_group);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_SLEEP
|
||||
|
|
@ -377,6 +370,7 @@ static struct platform_driver lm3533_bl_driver = {
|
|||
.driver = {
|
||||
.name = "lm3533-backlight",
|
||||
.pm = &lm3533_bl_pm_ops,
|
||||
.dev_groups = lm3533_bl_attribute_groups,
|
||||
},
|
||||
.probe = lm3533_bl_probe,
|
||||
.remove = lm3533_bl_remove,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user