Message ID | 20250228-rtc-cleanups-v1-2-b44cec078481@linaro.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | a few rtc driver cleanups | expand |
On 28/02/2025 15:07, André Draszik wrote: > When this driver was converted to using the devres managed i2c device > in commit 7db7ad0817fe ("rtc: s5m: use devm_i2c_new_dummy_device()"), > struct s5m_rtc_info::i2c became essentially unused. > > We can drop it from the structure and just use a local temporary > variable, reducing runtime memory consumption by a few bytes. > > Signed-off-by: André Draszik <andre.draszik@linaro.org> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Best regards, Krzysztof
Hi André, kernel test robot noticed the following build warnings: [auto build test WARNING on 0226d0ce98a477937ed295fb7df4cc30b46fc304] url: https://github.com/intel-lab-lkp/linux/commits/Andr-Draszik/rtc-max77686-drop-needless-struct-max77686_rtc_info-rtc-member/20250228-221320 base: 0226d0ce98a477937ed295fb7df4cc30b46fc304 patch link: https://lore.kernel.org/r/20250228-rtc-cleanups-v1-2-b44cec078481%40linaro.org patch subject: [PATCH 02/18] rtc: s5m: drop needless struct s5m_rtc_info::i2c member config: arm-randconfig-004-20250301 (https://download.01.org/0day-ci/archive/20250302/202503020150.LkqTktVQ-lkp@intel.com/config) compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 14170b16028c087ca154878f5ed93d3089a965c6) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250302/202503020150.LkqTktVQ-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202503020150.LkqTktVQ-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/rtc/rtc-s5m.c:11: In file included from include/linux/i2c.h:19: In file included from include/linux/regulator/consumer.h:35: In file included from include/linux/suspend.h:5: In file included from include/linux/swap.h:9: In file included from include/linux/memcontrol.h:21: In file included from include/linux/mm.h:2287: include/linux/vmstat.h:507:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion] 507 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_" | ~~~~~~~~~~~ ^ ~~~ >> drivers/rtc/rtc-s5m.c:678:46: warning: variable 'i2c' is uninitialized when used here [-Wuninitialized] 678 | i2c = devm_i2c_new_dummy_device(&pdev->dev, i2c->adapter, | ^~~ drivers/rtc/rtc-s5m.c:642:24: note: initialize the variable 'i2c' to silence this warning 642 | struct i2c_client *i2c; | ^ | = NULL 2 warnings generated. vim +/i2c +678 drivers/rtc/rtc-s5m.c 637 638 static int s5m_rtc_probe(struct platform_device *pdev) 639 { 640 struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent); 641 struct s5m_rtc_info *info; 642 struct i2c_client *i2c; 643 const struct regmap_config *regmap_cfg; 644 int ret, alarm_irq; 645 646 info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); 647 if (!info) 648 return -ENOMEM; 649 650 switch (platform_get_device_id(pdev)->driver_data) { 651 case S2MPS15X: 652 regmap_cfg = &s2mps14_rtc_regmap_config; 653 info->regs = &s2mps15_rtc_regs; 654 alarm_irq = S2MPS14_IRQ_RTCA0; 655 break; 656 case S2MPS14X: 657 regmap_cfg = &s2mps14_rtc_regmap_config; 658 info->regs = &s2mps14_rtc_regs; 659 alarm_irq = S2MPS14_IRQ_RTCA0; 660 break; 661 case S2MPS13X: 662 regmap_cfg = &s2mps14_rtc_regmap_config; 663 info->regs = &s2mps13_rtc_regs; 664 alarm_irq = S2MPS14_IRQ_RTCA0; 665 break; 666 case S5M8767X: 667 regmap_cfg = &s5m_rtc_regmap_config; 668 info->regs = &s5m_rtc_regs; 669 alarm_irq = S5M8767_IRQ_RTCA1; 670 break; 671 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; 676 } 677 > 678 i2c = devm_i2c_new_dummy_device(&pdev->dev, i2c->adapter, 679 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 } 684 685 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 } 692 693 info->dev = &pdev->dev; 694 info->s5m87xx = s5m87xx; 695 info->device_type = platform_get_device_id(pdev)->driver_data; 696 697 if (s5m87xx->irq_data) { 698 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 } 704 } 705 706 platform_set_drvdata(pdev, info); 707 708 ret = s5m8767_rtc_init_reg(info); 709 if (ret) 710 return ret; 711 712 info->rtc_dev = devm_rtc_allocate_device(&pdev->dev); 713 if (IS_ERR(info->rtc_dev)) 714 return PTR_ERR(info->rtc_dev); 715 716 info->rtc_dev->ops = &s5m_rtc_ops; 717 718 info->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; 719 info->rtc_dev->range_max = RTC_TIMESTAMP_END_2099; 720 721 if (!info->irq) { 722 clear_bit(RTC_FEATURE_ALARM, info->rtc_dev->features); 723 } else { 724 ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, 725 s5m_rtc_alarm_irq, 0, "rtc-alarm0", 726 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 } 732 device_init_wakeup(&pdev->dev, true); 733 } 734 735 return devm_rtc_register_device(info->rtc_dev); 736 } 737
diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index 36acca5b2639e272dd9baed06ea5582f635702b0..77dd61c30681b8f0a2f23063ad5f7eb52f5b7158 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c @@ -146,7 +146,6 @@ static const struct s5m_rtc_reg_config s2mps15_rtc_regs = { struct s5m_rtc_info { struct device *dev; - struct i2c_client *i2c; struct sec_pmic_dev *s5m87xx; struct regmap *regmap; struct rtc_device *rtc_dev; @@ -640,6 +639,7 @@ static int s5m_rtc_probe(struct platform_device *pdev) { struct sec_pmic_dev *s5m87xx = dev_get_drvdata(pdev->dev.parent); struct s5m_rtc_info *info; + struct i2c_client *i2c; const struct regmap_config *regmap_cfg; int ret, alarm_irq; @@ -675,14 +675,14 @@ static int s5m_rtc_probe(struct platform_device *pdev) return -ENODEV; } - info->i2c = devm_i2c_new_dummy_device(&pdev->dev, s5m87xx->i2c->adapter, - RTC_I2C_ADDR); - if (IS_ERR(info->i2c)) { + i2c = devm_i2c_new_dummy_device(&pdev->dev, i2c->adapter, + RTC_I2C_ADDR); + if (IS_ERR(i2c)) { dev_err(&pdev->dev, "Failed to allocate I2C for RTC\n"); - return PTR_ERR(info->i2c); + return PTR_ERR(i2c); } - info->regmap = devm_regmap_init_i2c(info->i2c, regmap_cfg); + info->regmap = devm_regmap_init_i2c(i2c, regmap_cfg); if (IS_ERR(info->regmap)) { ret = PTR_ERR(info->regmap); dev_err(&pdev->dev, "Failed to allocate RTC register map: %d\n",
When this driver was converted to using the devres managed i2c device in commit 7db7ad0817fe ("rtc: s5m: use devm_i2c_new_dummy_device()"), struct s5m_rtc_info::i2c became essentially unused. We can drop it from the structure and just use a local temporary variable, reducing runtime memory consumption by a few bytes. Signed-off-by: André Draszik <andre.draszik@linaro.org> --- drivers/rtc/rtc-s5m.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)