Skip to content

Commit 5581b41

Browse files
andy-shevwsakernel
authored andcommitted
i2c: i801: Refactor mux code since platform_device_unregister() is NULL aware
platform_device_unregister() is NULL-aware and thus doesn't required a duplication check in i801_del_mux(). Besides that it's also error pointer aware, and we may drop unneeded assignment in i801_add_mux() followed by conversion to PTR_ERR_OR_ZERO() for the returned value. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 926e6b2 commit 5581b41

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/i2c/busses/i2c-i801.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,7 +1433,7 @@ static int i801_add_mux(struct i801_priv *priv)
14331433
const struct i801_mux_config *mux_config;
14341434
struct i2c_mux_gpio_platform_data gpio_data;
14351435
struct gpiod_lookup_table *lookup;
1436-
int err, i;
1436+
int i;
14371437

14381438
if (!priv->mux_drvdata)
14391439
return 0;
@@ -1473,20 +1473,16 @@ static int i801_add_mux(struct i801_priv *priv)
14731473
PLATFORM_DEVID_NONE, &gpio_data,
14741474
sizeof(struct i2c_mux_gpio_platform_data));
14751475
if (IS_ERR(priv->mux_pdev)) {
1476-
err = PTR_ERR(priv->mux_pdev);
14771476
gpiod_remove_lookup_table(lookup);
1478-
priv->mux_pdev = NULL;
14791477
dev_err(dev, "Failed to register i2c-mux-gpio device\n");
1480-
return err;
14811478
}
14821479

1483-
return 0;
1480+
return PTR_ERR_OR_ZERO(priv->mux_pdev);
14841481
}
14851482

14861483
static void i801_del_mux(struct i801_priv *priv)
14871484
{
1488-
if (priv->mux_pdev)
1489-
platform_device_unregister(priv->mux_pdev);
1485+
platform_device_unregister(priv->mux_pdev);
14901486
gpiod_remove_lookup_table(priv->lookup);
14911487
}
14921488

0 commit comments

Comments
 (0)