Skip to content

Commit 0c57c2e

Browse files
andredalexandrebelloni
authored andcommitted
rtc: s5m: convert to dev_err_probe() where appropriate
dev_err_probe() exists to simplify code and harmonise error messages, there's no reason not to use it here. Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: André Draszik <andre.draszik@linaro.org> Link: https://lore.kernel.org/r/20250304-rtc-cleanups-v2-16-d4689a71668c@linaro.org Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent e6403ae commit 0c57c2e

1 file changed

Lines changed: 21 additions & 29 deletions

File tree

drivers/rtc/rtc-s5m.c

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -626,11 +626,10 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
626626
}
627627

628628
info->rtc_24hr_mode = 1;
629-
if (ret < 0) {
630-
dev_err(info->dev, "%s: fail to write controlm reg(%d)\n",
631-
__func__, ret);
632-
return ret;
633-
}
629+
if (ret < 0)
630+
return dev_err_probe(info->dev, ret,
631+
"%s: fail to write controlm reg\n",
632+
__func__);
634633

635634
return ret;
636635
}
@@ -669,38 +668,32 @@ static int s5m_rtc_probe(struct platform_device *pdev)
669668
alarm_irq = S5M8767_IRQ_RTCA1;
670669
break;
671670
default:
672-
dev_err(&pdev->dev,
673-
"Device type %lu is not supported by RTC driver\n",
674-
platform_get_device_id(pdev)->driver_data);
675-
return -ENODEV;
671+
return dev_err_probe(&pdev->dev, -ENODEV,
672+
"Device type %lu is not supported by RTC driver\n",
673+
platform_get_device_id(pdev)->driver_data);
676674
}
677675

678676
i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter,
679677
RTC_I2C_ADDR);
680-
if (IS_ERR(i2c)) {
681-
dev_err(&pdev->dev, "Failed to allocate I2C for RTC\n");
682-
return PTR_ERR(i2c);
683-
}
678+
if (IS_ERR(i2c))
679+
return dev_err_probe(&pdev->dev, PTR_ERR(i2c),
680+
"Failed to allocate I2C for RTC\n");
684681

685682
info->regmap = devm_regmap_init_i2c(i2c, regmap_cfg);
686-
if (IS_ERR(info->regmap)) {
687-
ret = PTR_ERR(info->regmap);
688-
dev_err(&pdev->dev, "Failed to allocate RTC register map: %d\n",
689-
ret);
690-
return ret;
691-
}
683+
if (IS_ERR(info->regmap))
684+
return dev_err_probe(&pdev->dev, PTR_ERR(info->regmap),
685+
"Failed to allocate RTC register map\n");
692686

693687
info->dev = &pdev->dev;
694688
info->s5m87xx = s5m87xx;
695689
info->device_type = platform_get_device_id(pdev)->driver_data;
696690

697691
if (s5m87xx->irq_data) {
698692
info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
699-
if (info->irq <= 0) {
700-
dev_err(&pdev->dev, "Failed to get virtual IRQ %d\n",
701-
alarm_irq);
702-
return -EINVAL;
703-
}
693+
if (info->irq <= 0)
694+
return dev_err_probe(&pdev->dev, -EINVAL,
695+
"Failed to get virtual IRQ %d\n",
696+
alarm_irq);
704697
}
705698

706699
platform_set_drvdata(pdev, info);
@@ -724,11 +717,10 @@ static int s5m_rtc_probe(struct platform_device *pdev)
724717
ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL,
725718
s5m_rtc_alarm_irq, 0, "rtc-alarm0",
726719
info);
727-
if (ret < 0) {
728-
dev_err(&pdev->dev, "Failed to request alarm IRQ: %d: %d\n",
729-
info->irq, ret);
730-
return ret;
731-
}
720+
if (ret < 0)
721+
return dev_err_probe(&pdev->dev, ret,
722+
"Failed to request alarm IRQ %d\n",
723+
info->irq);
732724
device_init_wakeup(&pdev->dev, true);
733725
}
734726

0 commit comments

Comments
 (0)