Re: [PATCH 5/6] gpio: pca953x: Make platform teardown callback return void

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 28, 2022 at 4:04 PM Uwe Kleine-König
<u.kleine-koenig@xxxxxxxxxxxxxx> wrote:
>
> All platforms that provide a teardown callback return 0. New users are
> supposed to not make use of platform support, so there is no
> functionality lost.
>
> This patch is a preparation for making i2c remove callbacks return void.
>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> Forwarded: id:20220502170555.51183-1-u.kleine-koenig@xxxxxxxxxxxxxx

What is this tag for? Has it been documented?

(Linus recently was ranting against homegrown custom (read:
non-documented) tags)

For now the code looks good,
Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>

However, I prefer to see dropping those callbacks altogether (find the
way how to use GPIO descriptors / GPIO table / etc instead of ugly
custom callbacks).

> ---
>  arch/arm/mach-davinci/board-da850-evm.c | 12 ++++--------
>  drivers/gpio/gpio-pca953x.c             | 11 +++--------
>  include/linux/platform_data/pca953x.h   |  2 +-
>  3 files changed, 8 insertions(+), 17 deletions(-)
>
> diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c
> index efc26b472ef8..09253e70d0dc 100644
> --- a/arch/arm/mach-davinci/board-da850-evm.c
> +++ b/arch/arm/mach-davinci/board-da850-evm.c
> @@ -518,8 +518,8 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,
>         return ret;
>  }
>
> -static int da850_evm_ui_expander_teardown(struct i2c_client *client,
> -                                       unsigned gpio, unsigned ngpio, void *c)
> +static void da850_evm_ui_expander_teardown(struct i2c_client *client,
> +                                          unsigned gpio, unsigned ngpio, void *c)
>  {
>         platform_device_unregister(&da850_evm_ui_keys_device);
>
> @@ -531,8 +531,6 @@ static int da850_evm_ui_expander_teardown(struct i2c_client *client,
>         gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C);
>         gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B);
>         gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A);
> -
> -       return 0;
>  }
>
>  /* assign the baseboard expander's GPIOs after the UI board's */
> @@ -699,13 +697,11 @@ static int da850_evm_bb_expander_setup(struct i2c_client *client,
>         return ret;
>  }
>
> -static int da850_evm_bb_expander_teardown(struct i2c_client *client,
> -                                       unsigned gpio, unsigned ngpio, void *c)
> +static void da850_evm_bb_expander_teardown(struct i2c_client *client,
> +                                          unsigned gpio, unsigned ngpio, void *c)
>  {
>         platform_device_unregister(&da850_evm_bb_leds_device);
>         platform_device_unregister(&da850_evm_bb_keys_device);
> -
> -       return 0;
>  }
>
>  static struct pca953x_platform_data da850_evm_ui_expander_info = {
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index 08bc52c3cdcb..3eedeac9ec8d 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -1099,20 +1099,15 @@ static int pca953x_remove(struct i2c_client *client)
>  {
>         struct pca953x_platform_data *pdata = dev_get_platdata(&client->dev);
>         struct pca953x_chip *chip = i2c_get_clientdata(client);
> -       int ret;
>
>         if (pdata && pdata->teardown) {
> -               ret = pdata->teardown(client, chip->gpio_chip.base,
> -                                     chip->gpio_chip.ngpio, pdata->context);
> -               if (ret < 0)
> -                       dev_err(&client->dev, "teardown failed, %d\n", ret);
> -       } else {
> -               ret = 0;
> +               pdata->teardown(client, chip->gpio_chip.base,
> +                               chip->gpio_chip.ngpio, pdata->context);
>         }
>
>         regulator_disable(chip->regulator);
>
> -       return ret;
> +       return 0;
>  }
>
>  #ifdef CONFIG_PM_SLEEP
> diff --git a/include/linux/platform_data/pca953x.h b/include/linux/platform_data/pca953x.h
> index 4eb53e023997..96c1a14ab365 100644
> --- a/include/linux/platform_data/pca953x.h
> +++ b/include/linux/platform_data/pca953x.h
> @@ -22,7 +22,7 @@ struct pca953x_platform_data {
>         int             (*setup)(struct i2c_client *client,
>                                 unsigned gpio, unsigned ngpio,
>                                 void *context);
> -       int             (*teardown)(struct i2c_client *client,
> +       void            (*teardown)(struct i2c_client *client,
>                                 unsigned gpio, unsigned ngpio,
>                                 void *context);
>         const char      *const *names;
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux