diff mbox series

[2/2] platform/mellanox: mlxreg-hotplug: convert to use i2c_new_client_device()

Message ID 20200326210952.12857-3-wsa+renesas@sang-engineering.com
State Accepted
Headers show
Series platform: convert to use new I2C API | expand

Commit Message

Wolfram Sang March 26, 2020, 9:09 p.m. UTC
Move away from the deprecated API and return the shiny new ERRPTR where
useful.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/platform/mellanox/mlxreg-hotplug.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Andy Shevchenko March 27, 2020, 7:38 a.m. UTC | #1
On Thu, Mar 26, 2020 at 11:10 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> Move away from the deprecated API and return the shiny new ERRPTR where
> useful.
>

Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
>  drivers/platform/mellanox/mlxreg-hotplug.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
> index 77be37a1fbcf..ed48917af162 100644
> --- a/drivers/platform/mellanox/mlxreg-hotplug.c
> +++ b/drivers/platform/mellanox/mlxreg-hotplug.c
> @@ -101,6 +101,7 @@ static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
>                                         struct mlxreg_core_data *data)
>  {
>         struct mlxreg_core_hotplug_platform_data *pdata;
> +       struct i2c_client *client;
>
>         /* Notify user by sending hwmon uevent. */
>         kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE);
> @@ -121,18 +122,20 @@ static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
>                 return -EFAULT;
>         }
>
> -       data->hpdev.client = i2c_new_device(data->hpdev.adapter,
> -                                           data->hpdev.brdinfo);
> -       if (!data->hpdev.client) {
> +       client = i2c_new_client_device(data->hpdev.adapter,
> +                                      data->hpdev.brdinfo);
> +       if (IS_ERR(client)) {
>                 dev_err(priv->dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
>                         data->hpdev.brdinfo->type, data->hpdev.nr +
>                         pdata->shift_nr, data->hpdev.brdinfo->addr);
>
>                 i2c_put_adapter(data->hpdev.adapter);
>                 data->hpdev.adapter = NULL;
> -               return -EFAULT;
> +               return PTR_ERR(client);
>         }
>
> +       data->hpdev.client = client;
> +
>         return 0;
>  }
>
> --
> 2.20.1
>
Wolfram Sang April 25, 2020, 8:54 p.m. UTC | #2
On Fri, Mar 27, 2020 at 09:38:21AM +0200, Andy Shevchenko wrote:
> On Thu, Mar 26, 2020 at 11:10 PM Wolfram Sang
> <wsa+renesas@sang-engineering.com> wrote:
> >
> > Move away from the deprecated API and return the shiny new ERRPTR where
> > useful.
> >
> 
> Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Thanks, Andy! Is there a platform-x86-tree where this can go in? Or
shall I take it via the I2C tree? Same question for the similar patch
for x86/platform/intel-mid?
Andy Shevchenko April 26, 2020, 8:34 a.m. UTC | #3
On Sat, Apr 25, 2020 at 11:54 PM Wolfram Sang <wsa@the-dreams.de> wrote:
>
> On Fri, Mar 27, 2020 at 09:38:21AM +0200, Andy Shevchenko wrote:
> > On Thu, Mar 26, 2020 at 11:10 PM Wolfram Sang
> > <wsa+renesas@sang-engineering.com> wrote:
> > >
> > > Move away from the deprecated API and return the shiny new ERRPTR where
> > > useful.
> > >
> >
> > Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>
> Thanks, Andy! Is there a platform-x86-tree where this can go in? Or
> shall I take it via the I2C tree?

platform/mellanox usually goes via other trees, so, feel free to carry on.

> Same question for the similar patch
> for x86/platform/intel-mid?

TIP maintainers usually take this. If I didn't tag it, feel free to add my Rb.
Wolfram Sang April 26, 2020, 8:57 a.m. UTC | #4
> > Thanks, Andy! Is there a platform-x86-tree where this can go in? Or
> > shall I take it via the I2C tree?
> 
> platform/mellanox usually goes via other trees, so, feel free to carry on.

Then, I will pick it.

> > Same question for the similar patch
> > for x86/platform/intel-mid?
> 
> TIP maintainers usually take this. If I didn't tag it, feel free to add my Rb.

You tagged it. Thanks for the heads up, I will wait some more here.
diff mbox series

Patch

diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 77be37a1fbcf..ed48917af162 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -101,6 +101,7 @@  static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
 					struct mlxreg_core_data *data)
 {
 	struct mlxreg_core_hotplug_platform_data *pdata;
+	struct i2c_client *client;
 
 	/* Notify user by sending hwmon uevent. */
 	kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE);
@@ -121,18 +122,20 @@  static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
 		return -EFAULT;
 	}
 
-	data->hpdev.client = i2c_new_device(data->hpdev.adapter,
-					    data->hpdev.brdinfo);
-	if (!data->hpdev.client) {
+	client = i2c_new_client_device(data->hpdev.adapter,
+				       data->hpdev.brdinfo);
+	if (IS_ERR(client)) {
 		dev_err(priv->dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
 			data->hpdev.brdinfo->type, data->hpdev.nr +
 			pdata->shift_nr, data->hpdev.brdinfo->addr);
 
 		i2c_put_adapter(data->hpdev.adapter);
 		data->hpdev.adapter = NULL;
-		return -EFAULT;
+		return PTR_ERR(client);
 	}
 
+	data->hpdev.client = client;
+
 	return 0;
 }