Merge tag 'random_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[deliverable/linux.git] / drivers / pwm / pwm-mxs.c
index d9a38050a50238b1812620c770e368f3d46b2a08..e5852646f082eadee2fef58feb44f814339847ee 100644 (file)
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/slab.h>
-#include <mach/common.h>
+#include <linux/stmp_device.h>
 
 #define SET    0x4
 #define CLR    0x8
@@ -129,21 +130,26 @@ static int mxs_pwm_probe(struct platform_device *pdev)
 {
        struct device_node *np = pdev->dev.of_node;
        struct mxs_pwm_chip *mxs;
+       struct resource *res;
+       struct pinctrl *pinctrl;
        int ret;
 
        mxs = devm_kzalloc(&pdev->dev, sizeof(*mxs), GFP_KERNEL);
        if (!mxs)
                return -ENOMEM;
 
-       mxs->base = of_iomap(np, 0);
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       mxs->base = devm_request_and_ioremap(&pdev->dev, res);
        if (!mxs->base)
                return -EADDRNOTAVAIL;
 
-       mxs->clk = clk_get(&pdev->dev, NULL);
-       if (IS_ERR(mxs->clk)) {
-               ret = PTR_ERR(mxs->clk);
-               goto iounmap;
-       }
+       pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
+       if (IS_ERR(pinctrl))
+               return PTR_ERR(pinctrl);
+
+       mxs->clk = devm_clk_get(&pdev->dev, NULL);
+       if (IS_ERR(mxs->clk))
+               return PTR_ERR(mxs->clk);
 
        mxs->chip.dev = &pdev->dev;
        mxs->chip.ops = &mxs_pwm_ops;
@@ -151,38 +157,28 @@ static int mxs_pwm_probe(struct platform_device *pdev)
        ret = of_property_read_u32(np, "fsl,pwm-number", &mxs->chip.npwm);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to get pwm number: %d\n", ret);
-               goto clk_put;
+               return ret;
        }
 
        ret = pwmchip_add(&mxs->chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "failed to add pwm chip %d\n", ret);
-               goto clk_put;
+               return ret;
        }
 
        mxs->dev = &pdev->dev;
        platform_set_drvdata(pdev, mxs);
 
-       mxs_reset_block(mxs->base);
+       stmp_reset_block(mxs->base);
 
        return 0;
-
-clk_put:
-       clk_put(mxs->clk);
-iounmap:
-       iounmap(mxs->base);
-       return ret;
 }
 
 static int __devexit mxs_pwm_remove(struct platform_device *pdev)
 {
        struct mxs_pwm_chip *mxs = platform_get_drvdata(pdev);
 
-       pwmchip_remove(&mxs->chip);
-       clk_put(mxs->clk);
-       iounmap(mxs->base);
-
-       return 0;
+       return pwmchip_remove(&mxs->chip);
 }
 
 static struct of_device_id mxs_pwm_dt_ids[] = {
This page took 0.02448 seconds and 5 git commands to generate.