pwm: lpss: Move resource mapping to the glue drivers
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 27 Sep 2022 16:24:17 +0000 (19:24 +0300)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 28 Sep 2022 14:10:35 +0000 (16:10 +0200)
Move resource mapping to the glue drivers which helps
to transform pwm_lpss_probe() to pure library function
that may be used by others without need of specific
resource management.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-lpss-pci.c
drivers/pwm/pwm-lpss-platform.c
drivers/pwm/pwm-lpss.c
drivers/pwm/pwm-lpss.h

index 9f2c666b95ecde14412b683c2c80a0c05de1939e..f3367e844e61cf5caf2cacbcd2594838d143f3ee 100644 (file)
@@ -25,8 +25,12 @@ static int pwm_lpss_probe_pci(struct pci_dev *pdev,
        if (err < 0)
                return err;
 
+       err = pcim_iomap_regions(pdev, BIT(0), pci_name(pdev));
+       if (err)
+               return err;
+
        info = (struct pwm_lpss_boardinfo *)id->driver_data;
-       lpwm = pwm_lpss_probe(&pdev->dev, &pdev->resource[0], info);
+       lpwm = pwm_lpss_probe(&pdev->dev, pcim_iomap_table(pdev)[0], info);
        if (IS_ERR(lpwm))
                return PTR_ERR(lpwm);
 
index 65154c0abab1b35796de91aeb3293074b83c3bf1..7bbbb7a9b5785cfabaaaf202e984180a8b9ecbe8 100644 (file)
@@ -21,16 +21,19 @@ static int pwm_lpss_probe_platform(struct platform_device *pdev)
        const struct pwm_lpss_boardinfo *info;
        const struct acpi_device_id *id;
        struct pwm_lpss_chip *lpwm;
-       struct resource *r;
+       void __iomem *base;
 
        id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
        if (!id)
                return -ENODEV;
 
        info = (const struct pwm_lpss_boardinfo *)id->driver_data;
-       r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 
-       lpwm = pwm_lpss_probe(&pdev->dev, r, info);
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
+
+       lpwm = pwm_lpss_probe(&pdev->dev, base, info);
        if (IS_ERR(lpwm))
                return PTR_ERR(lpwm);
 
index 74a296cb1af014c9a5a031900d17aba4f3c9c81b..a20915459809b18c8e82f1c0508b430d36c5891d 100644 (file)
@@ -243,7 +243,7 @@ static const struct pwm_ops pwm_lpss_ops = {
        .owner = THIS_MODULE,
 };
 
-struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
+struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
                                     const struct pwm_lpss_boardinfo *info)
 {
        struct pwm_lpss_chip *lpwm;
@@ -258,10 +258,7 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
        if (!lpwm)
                return ERR_PTR(-ENOMEM);
 
-       lpwm->regs = devm_ioremap_resource(dev, r);
-       if (IS_ERR(lpwm->regs))
-               return ERR_CAST(lpwm->regs);
-
+       lpwm->regs = base;
        lpwm->info = info;
 
        c = lpwm->info->clk_rate;
index 9ea5b145a353f5909913e679ba06b1353b614114..c344921b2cabcabe2de4d279b047a8dfb1aef9a3 100644 (file)
@@ -38,7 +38,7 @@ extern const struct pwm_lpss_boardinfo pwm_lpss_bsw_info;
 extern const struct pwm_lpss_boardinfo pwm_lpss_bxt_info;
 extern const struct pwm_lpss_boardinfo pwm_lpss_tng_info;
 
-struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
+struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, void __iomem *base,
                                     const struct pwm_lpss_boardinfo *info);
 
 #endif /* __PWM_LPSS_H */