leds: qcom-lpg: Use devm_pwmchip_add() simplifying driver removal
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 26 Nov 2023 09:52:32 +0000 (10:52 +0100)
committerLee Jones <lee@kernel.org>
Wed, 13 Dec 2023 11:28:44 +0000 (11:28 +0000)
With pwmchip_remove() being automatically called after switching to
devm_pwmchip_add() the remove function can be dropped completely. Yay!
With lpg_remove() gone there is no user of the platform device's drvdata
left, so platform_set_drvdata() can be dropped from .probe(), too.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Link: https://lore.kernel.org/r/20231126095230.683204-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/leds/rgb/leds-qcom-lpg.c

index 68d82a682bf67f93b50c8df96fc463fcf92437f0..f5805fd0eb218d7ac159108ebd347d8f3c3dbe19 100644 (file)
@@ -1095,7 +1095,7 @@ static int lpg_add_pwm(struct lpg *lpg)
        lpg->pwm.npwm = lpg->num_channels;
        lpg->pwm.ops = &lpg_pwm_ops;
 
-       ret = pwmchip_add(&lpg->pwm);
+       ret = devm_pwmchip_add(lpg->dev, &lpg->pwm);
        if (ret)
                dev_err(lpg->dev, "failed to add PWM chip: ret %d\n", ret);
 
@@ -1324,8 +1324,6 @@ static int lpg_probe(struct platform_device *pdev)
        if (!lpg->data)
                return -EINVAL;
 
-       platform_set_drvdata(pdev, lpg);
-
        lpg->dev = &pdev->dev;
        mutex_init(&lpg->lock);
 
@@ -1363,13 +1361,6 @@ static int lpg_probe(struct platform_device *pdev)
        return lpg_add_pwm(lpg);
 }
 
-static void lpg_remove(struct platform_device *pdev)
-{
-       struct lpg *lpg = platform_get_drvdata(pdev);
-
-       pwmchip_remove(&lpg->pwm);
-}
-
 static const struct lpg_data pm8916_pwm_data = {
        .num_channels = 1,
        .channels = (const struct lpg_channel_data[]) {
@@ -1529,7 +1520,6 @@ MODULE_DEVICE_TABLE(of, lpg_of_table);
 
 static struct platform_driver lpg_driver = {
        .probe = lpg_probe,
-       .remove_new = lpg_remove,
        .driver = {
                .name = "qcom-spmi-lpg",
                .of_match_table = lpg_of_table,