]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
unicore32: pwm: Remove unnecessary indirection
authorThierry Reding <thierry.reding@avionic-design.de>
Thu, 30 Aug 2012 11:48:10 +0000 (13:48 +0200)
committerThierry Reding <thierry.reding@avionic-design.de>
Fri, 5 Oct 2012 18:56:40 +0000 (20:56 +0200)
Calling the actual probing function through a proxy isn't required and
makes the code needlessly complex.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
Tested-by: Qin Rui <qinrui@mprc.pku.edu.cn>
Acked-by: Guan Xuetao <gxt@mprc.pku.edu.cn>
arch/unicore32/kernel/pwm.c

index 012c54a8019ac9a71109ff9d5966133c4973b92f..7e234700d80f8e6085d1706df84a7a25e51a4c14 100644 (file)
@@ -156,8 +156,7 @@ static inline void __add_pwm(struct pwm_device *pwm)
        mutex_unlock(&pwm_lock);
 }
 
-static struct pwm_device *pwm_probe(struct platform_device *pdev,
-               unsigned int pwm_id, struct pwm_device *parent_pwm)
+static int __devinit pwm_probe(struct platform_device *pdev)
 {
        struct pwm_device *pwm;
        struct resource *r;
@@ -166,7 +165,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
        pwm = kzalloc(sizeof(struct pwm_device), GFP_KERNEL);
        if (pwm == NULL) {
                dev_err(&pdev->dev, "failed to allocate memory\n");
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;
        }
 
        pwm->clk = clk_get(NULL, "OST_CLK");
@@ -177,7 +176,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
        pwm->clk_enabled = 0;
 
        pwm->use_count = 0;
-       pwm->pwm_id = pwm_id;
+       pwm->pwm_id = pdev->id;
        pwm->pdev = pdev;
 
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -203,7 +202,7 @@ static struct pwm_device *pwm_probe(struct platform_device *pdev,
 
        __add_pwm(pwm);
        platform_set_drvdata(pdev, pwm);
-       return pwm;
+       return 0;
 
 err_release_mem:
        release_mem_region(r->start, resource_size(r));
@@ -211,17 +210,7 @@ err_free_clk:
        clk_put(pwm->clk);
 err_free:
        kfree(pwm);
-       return ERR_PTR(ret);
-}
-
-static int __devinit puv3_pwm_probe(struct platform_device *pdev)
-{
-       struct pwm_device *pwm = pwm_probe(pdev, pdev->id, NULL);
-
-       if (IS_ERR(pwm))
-               return PTR_ERR(pwm);
-
-       return 0;
+       return ret;
 }
 
 static int __devexit pwm_remove(struct platform_device *pdev)
@@ -251,7 +240,7 @@ static struct platform_driver puv3_pwm_driver = {
        .driver         = {
                .name   = "PKUnity-v3-PWM",
        },
-       .probe          = puv3_pwm_probe,
+       .probe          = pwm_probe,
        .remove         = __devexit_p(pwm_remove),
 };
 module_platform_driver(puv3_pwm_driver);