Skip to content

Commit 002cc0e

Browse files
andredalexandrebelloni
authored andcommitted
rtc: s5m: cache device type during probe
platform_get_device_id() is called mulitple times during probe to retrieve the device type. This makes the code harder to read than necessary. Just get the type once, which also trims the lengths of the lines involved. Signed-off-by: André Draszik <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Belloni <[email protected]>
1 parent 19272b3 commit 002cc0e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/rtc/rtc-s5m.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,8 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info)
637637
static int s5m_rtc_probe(struct platform_device *pdev)
638638
{
639639
struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent);
640+
enum sec_device_type device_type =
641+
platform_get_device_id(pdev)->driver_data;
640642
struct s5m_rtc_info *info;
641643
struct i2c_client *i2c;
642644
const struct regmap_config *regmap_cfg;
@@ -646,7 +648,7 @@ static int s5m_rtc_probe(struct platform_device *pdev)
646648
if (!info)
647649
return -ENOMEM;
648650

649-
switch (platform_get_device_id(pdev)->driver_data) {
651+
switch (device_type) {
650652
case S2MPS15X:
651653
regmap_cfg = &s2mps14_rtc_regmap_config;
652654
info->regs = &s2mps15_rtc_regs;
@@ -669,8 +671,8 @@ static int s5m_rtc_probe(struct platform_device *pdev)
669671
break;
670672
default:
671673
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);
674+
"Device type %d is not supported by RTC driver\n",
675+
device_type);
674676
}
675677

676678
i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter,
@@ -686,7 +688,7 @@ static int s5m_rtc_probe(struct platform_device *pdev)
686688

687689
info->dev = &pdev->dev;
688690
info->s5m87xx = s5m87xx;
689-
info->device_type = platform_get_device_id(pdev)->driver_data;
691+
info->device_type = device_type;
690692

691693
if (s5m87xx->irq_data) {
692694
info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);

0 commit comments

Comments
 (0)