Message ID | 20250403-s2mpg10-v3-25-b542b3505e68@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Samsung S2MPG10 PMIC MFD-based drivers | expand |
On 03/04/2025 10:59, André Draszik wrote: > platform_get_device_id() is called mulitple times during probe. This > makes the code harder to read than necessary. > > Just get the ID once, which also trims the lengths of the lines > involved. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> > --- > drivers/rtc/rtc-s5m.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c > index db5c9b641277213aa1371776c63e2eda3f223465..53c76b0e4253a9ba225c3c723d35d9182d071607 100644 > --- a/drivers/rtc/rtc-s5m.c > +++ b/drivers/rtc/rtc-s5m.c > @@ -637,6 +637,8 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) > static int s5m_rtc_probe(struct platform_device *pdev) > { > struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent); > + const struct platform_device_id * const id = > + platform_get_device_id(pdev); If doing this, why not storing here driver data, so the enum type? Best regards, Krzysztof
diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index db5c9b641277213aa1371776c63e2eda3f223465..53c76b0e4253a9ba225c3c723d35d9182d071607 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -637,6 +637,8 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) static int s5m_rtc_probe(struct platform_device *pdev) { struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent); + const struct platform_device_id * const id = + platform_get_device_id(pdev); struct s5m_rtc_info *info; struct i2c_client *i2c; const struct regmap_config *regmap_cfg; @@ -646,7 +648,7 @@ static int s5m_rtc_probe(struct platform_device *pdev) if (!info) return -ENOMEM; - switch (platform_get_device_id(pdev)->driver_data) { + switch (id->driver_data) { case S2MPS15X: regmap_cfg = &s2mps14_rtc_regmap_config; info->regs = &s2mps15_rtc_regs; @@ -670,7 +672,7 @@ static int s5m_rtc_probe(struct platform_device *pdev) default: return dev_err_probe(&pdev->dev, -ENODEV, "Device type %lu is not supported by RTC driver\n", - platform_get_device_id(pdev)->driver_data); + id->driver_data); } i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter, @@ -686,7 +688,7 @@ static int s5m_rtc_probe(struct platform_device *pdev) info->dev = &pdev->dev; info->s5m87xx = s5m87xx; - info->device_type = platform_get_device_id(pdev)->driver_data; + info->device_type = id->driver_data; if (s5m87xx->irq_data) { info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);
platform_get_device_id() is called mulitple times during probe. This makes the code harder to read than necessary. Just get the ID once, which also trims the lengths of the lines involved. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/rtc/rtc-s5m.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)