drivers/rtc/rtc-s5m.c: allow usage on device type different than main MFD type 25/46025/2
authorKrzysztof Kozlowski <k.kozlowski@samsung.com>
Thu, 16 Apr 2015 19:49:27 +0000 (12:49 -0700)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Mon, 17 Aug 2015 07:18:12 +0000 (00:18 -0700)
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", }
};

Change-Id: I46347706ccd0f17a2e3379505c182a3185b66a24
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>
drivers/rtc/rtc-s5m.c

index f0cb0ecb3d8dc6e8e03f706c5de2216b37f9ca2c..6192dc1b9b0e938c4ea1b1c8c868ddf1c3358b64 100644 (file)
@@ -90,7 +90,7 @@ struct s5m_rtc_info {
        struct regmap *regmap;
        struct rtc_device *rtc_dev;
        int irq;
-       int device_type;
+       enum sec_device_type device_type;
        int rtc_24hr_mode;
        const struct s5m_rtc_reg_config *regs;
 };
@@ -666,7 +666,7 @@ static int s5m_rtc_probe(struct platform_device *pdev)
        if (!info)
                return -ENOMEM;
 
-       switch (pdata->device_type) {
+       switch (platform_get_device_id(pdev)->driver_data) {
        case S2MPS14X:
        case S2MPS13X:
                regmap_cfg = &s2mps14_rtc_regmap_config;
@@ -684,7 +684,9 @@ static int s5m_rtc_probe(struct platform_device *pdev)
                alarm_irq = S5M8767_IRQ_RTCA1;
                break;
        default:
-               dev_err(&pdev->dev, "Device type is not supported by RTC driver\n");
+               dev_err(&pdev->dev,
+                               "Device type %lu is not supported by RTC driver\n",
+                               platform_get_device_id(pdev)->driver_data);
                return -ENODEV;
        }
 
@@ -704,7 +706,7 @@ static int s5m_rtc_probe(struct platform_device *pdev)
 
        info->dev = &pdev->dev;
        info->s5m87xx = s5m87xx;
-       info->device_type = s5m87xx->device_type;
+       info->device_type = platform_get_device_id(pdev)->driver_data;
 
        if (s5m87xx->irq_data) {
                info->irq = regmap_irq_get_virq(s5m87xx->irq_data, alarm_irq);