diff mbox series

leds: max8997: Don't error if there is no pdata

Message ID 20220807104027.10808-1-paul@crapouillou.net
State Superseded
Headers show
Series leds: max8997: Don't error if there is no pdata | expand

Commit Message

Paul Cercueil Aug. 7, 2022, 10:40 a.m. UTC
The driver will works just fine if no platform data was supplied.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 drivers/leds/leds-max8997.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

Comments

Andy Shevchenko Aug. 8, 2022, 1:16 p.m. UTC | #1
On Sun, Aug 7, 2022 at 12:40 PM Paul Cercueil <paul@crapouillou.net> wrote:
>
> The driver will works just fine if no platform data was supplied.

s/works/work/
  ...or...
s/will//

With the above fix,
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  drivers/leds/leds-max8997.c | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c
> index c0bddb33888d..c8d7f55c9dec 100644
> --- a/drivers/leds/leds-max8997.c
> +++ b/drivers/leds/leds-max8997.c
> @@ -238,11 +238,6 @@ static int max8997_led_probe(struct platform_device *pdev)
>         char name[20];
>         int ret = 0;
>
> -       if (pdata == NULL) {
> -               dev_err(&pdev->dev, "no platform data\n");
> -               return -ENODEV;
> -       }
> -
>         led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
>         if (led == NULL)
>                 return -ENOMEM;
> @@ -258,7 +253,7 @@ static int max8997_led_probe(struct platform_device *pdev)
>         led->iodev = iodev;
>
>         /* initialize mode and brightness according to platform_data */
> -       if (pdata->led_pdata) {
> +       if (pdata && pdata->led_pdata) {
>                 u8 mode = 0, brightness = 0;
>
>                 mode = pdata->led_pdata->mode[led->id];
diff mbox series

Patch

diff --git a/drivers/leds/leds-max8997.c b/drivers/leds/leds-max8997.c
index c0bddb33888d..c8d7f55c9dec 100644
--- a/drivers/leds/leds-max8997.c
+++ b/drivers/leds/leds-max8997.c
@@ -238,11 +238,6 @@  static int max8997_led_probe(struct platform_device *pdev)
 	char name[20];
 	int ret = 0;
 
-	if (pdata == NULL) {
-		dev_err(&pdev->dev, "no platform data\n");
-		return -ENODEV;
-	}
-
 	led = devm_kzalloc(&pdev->dev, sizeof(*led), GFP_KERNEL);
 	if (led == NULL)
 		return -ENOMEM;
@@ -258,7 +253,7 @@  static int max8997_led_probe(struct platform_device *pdev)
 	led->iodev = iodev;
 
 	/* initialize mode and brightness according to platform_data */
-	if (pdata->led_pdata) {
+	if (pdata && pdata->led_pdata) {
 		u8 mode = 0, brightness = 0;
 
 		mode = pdata->led_pdata->mode[led->id];