Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/rtc/rtc-s5m.c: allow usage on device type different than main MFD type

The RTC driver supports two flavors of S5M devices: S5M8767-like and
S2MPS14-like.

On S2MPS13 and S2MPS14 devices the RTC module is the same so we want to
re-use the existing support of S2MPS14. However device type was passed
from parent MFD driver in platform data structure. This way for the
S2MPS13 device the main MFD driver passed device type of 'S2MPS13X'.

Instead decouple detecting of device type between main MFD and RTC driver.
This allows adding support for other S2MPS14 variations (like S2MPS11 and
S2MPS13) easily by adding to mfd/sec-core.c:

static const struct mfd_cell s2mps13_devs[] = {
{ .name = "s2mps14-rtc", }
};

Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Krzysztof Kozlowski and committed by
Linus Torvalds
94f91922 f4ae9497

+6 -4
+6 -4
drivers/rtc/rtc-s5m.c
··· 92 92 struct regmap *regmap; 93 93 struct rtc_device *rtc_dev; 94 94 int irq; 95 - int device_type; 95 + enum sec_device_type device_type; 96 96 int rtc_24hr_mode; 97 97 const struct s5m_rtc_reg_config *regs; 98 98 }; ··· 668 668 if (!info) 669 669 return -ENOMEM; 670 670 671 - switch (pdata->device_type) { 671 + switch (platform_get_device_id(pdev)->driver_data) { 672 672 case S2MPS14X: 673 673 case S2MPS13X: 674 674 regmap_cfg = &s2mps14_rtc_regmap_config; ··· 686 686 alarm_irq = S5M8767_IRQ_RTCA1; 687 687 break; 688 688 default: 689 - dev_err(&pdev->dev, "Device type is not supported by RTC driver\n"); 689 + dev_err(&pdev->dev, 690 + "Device type %lu is not supported by RTC driver\n", 691 + platform_get_device_id(pdev)->driver_data); 690 692 return -ENODEV; 691 693 } 692 694 ··· 708 706 709 707 info->dev = &pdev->dev; 710 708 info->s5m87xx = s5m87xx; 711 - info->device_type = s5m87xx->device_type; 709 + info->device_type = platform_get_device_id(pdev)->driver_data; 712 710 713 711 if (s5m87xx->irq_data) { 714 712 info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);