Skip to content

Commit

Permalink
rtc: s5m: use devm_i2c_new_dummy_device()
Browse files Browse the repository at this point in the history
Use the managed variant of i2c_new_dummy_device() to shrink code and
remove the goto label. We can drop the remove callback now too.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Krzysztof Kozlowski <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
brgl authored and alexandrebelloni committed Jan 16, 2021
1 parent 1f0cbda commit 7db7ad0
Showing 1 changed file with 7 additions and 24 deletions.
31 changes: 7 additions & 24 deletions drivers/rtc/rtc-s5m.c
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
return -ENODEV;
}

info->i2c = i2c_new_dummy_device(s5m87xx->i2c->adapter, RTC_I2C_ADDR);
info->i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter,
RTC_I2C_ADDR);
if (IS_ERR(info->i2c)) {
dev_err(&pdev->dev, "Failed to allocate I2C for RTC\n");
return PTR_ERR(info->i2c);
Expand All @@ -771,7 +772,7 @@ static int s5m_rtc_probe(struct platform_device *pdev)
ret = PTR_ERR(info->regmap);
dev_err(&pdev->dev, "Failed to allocate RTC register map: %d\n",
ret);
goto err;
return ret;
}

info->dev = &pdev->dev;
Expand All @@ -781,10 +782,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
if (s5m87xx->irq_data) {
info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
if (info->irq <= 0) {
ret = -EINVAL;
dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n",
alarm_irq);
goto err;
return -EINVAL;
}
}

Expand All @@ -797,10 +797,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
info->rtc_dev = devm_rtc_device_register(&pdev->dev, "s5m-rtc",
&s5m_rtc_ops, THIS_MODULE);

if (IS_ERR(info->rtc_dev)) {
ret = PTR_ERR(info->rtc_dev);
goto err;
}
if (IS_ERR(info->rtc_dev))
return PTR_ERR(info->rtc_dev);

if (!info->irq) {
dev_info(&pdev->dev, "Alarm IRQ not available\n");
Expand All @@ -813,23 +811,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
if (ret < 0) {
dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
info->irq, ret);
goto err;
return ret;
}

return 0;

err:
i2c_unregister_device(info->i2c);

return ret;
}

static int s5m_rtc_remove(struct platform_device *pdev)
{
struct s5m_rtc_info *info = platform_get_drvdata(pdev);

i2c_unregister_device(info->i2c);

return 0;
}

Expand Down Expand Up @@ -874,7 +858,6 @@ static struct platform_driver s5m_rtc_driver = {
.pm = &s5m_rtc_pm_ops,
},
.probe = s5m_rtc_probe,
.remove = s5m_rtc_remove,
.id_table = s5m_rtc_id,
};

Expand Down

0 comments on commit 7db7ad0

Please sign in to comment.