]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
pwm: make the PWM_POLARITY flag in DTB optional
authorLothar Waßmann <LW@KARO-electronics.de>
Thu, 12 Jun 2014 11:37:52 +0000 (13:37 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Fri, 4 Jul 2014 10:36:04 +0000 (12:36 +0200)
Change the pwm chip driver registration, so that a chip driver that
supports polarity inversion can still be used with DTBs that don't
provide the 'PWM_POLARITY' flag.

This is done to provide polarity inversion support for the pwm-imx
driver without having to modify all existing DTS files.

drivers/pwm/core.c
drivers/pwm/pwm-atmel-tcb.c
drivers/pwm/pwm-atmel.c
drivers/pwm/pwm-pxa.c
drivers/pwm/pwm-renesas-tpu.c
drivers/pwm/pwm-samsung.c
drivers/pwm/pwm-tiecap.c
drivers/pwm/pwm-tiehrpwm.c
drivers/pwm/pwm-vt8500.c
include/linux/pwm.h

index 7af00437bb19e727292d1f129eec45e3042e2a40..ab0fc5ab0e3b9e5e2c5f2fb1f4c9f737346ade53 100644 (file)
@@ -136,7 +136,7 @@ of_pwm_xlate_with_flags(struct pwm_chip *pc, const struct of_phandle_args *args)
 {
        struct pwm_device *pwm;
 
-       if (pc->of_pwm_n_cells < 3)
+       if (args->args_count != 3)
                return ERR_PTR(-EINVAL);
 
        if (args->args[0] >= pc->npwm)
@@ -162,12 +162,15 @@ of_pwm_simple_xlate(struct pwm_chip *pc, const struct of_phandle_args *args)
 {
        struct pwm_device *pwm;
 
-       if (pc->of_pwm_n_cells < 2)
+       if (args->args_count < 2)
                return ERR_PTR(-EINVAL);
 
        if (args->args[0] >= pc->npwm)
                return ERR_PTR(-EINVAL);
 
+       if (args->args_count > 2)
+               return of_pwm_xlate_with_flags(pc, args);
+
        pwm = pwm_request_from_chip(pc, args->args[0], NULL);
        if (IS_ERR(pwm))
                return pwm;
@@ -182,10 +185,8 @@ static void of_pwmchip_add(struct pwm_chip *chip)
        if (!chip->dev || !chip->dev->of_node)
                return;
 
-       if (!chip->of_xlate) {
+       if (!chip->of_xlate)
                chip->of_xlate = of_pwm_simple_xlate;
-               chip->of_pwm_n_cells = 2;
-       }
 
        of_node_get(chip->dev->of_node);
 }
@@ -536,13 +537,6 @@ struct pwm_device *of_pwm_get(struct device_node *np, const char *con_id)
                goto put;
        }
 
-       if (args.args_count != pc->of_pwm_n_cells) {
-               pr_debug("%s: wrong #pwm-cells for %s\n", np->full_name,
-                        args.np->full_name);
-               pwm = ERR_PTR(-EINVAL);
-               goto put;
-       }
-
        pwm = pc->of_xlate(pc, &args);
        if (IS_ERR(pwm))
                goto put;
index f3dcd02390f1b5da7d9cf43d3b053d3e6840bc0f..55fabf85a67d1cdd82a10043f076ddbb15ee0212 100644 (file)
@@ -395,7 +395,6 @@ static int atmel_tcb_pwm_probe(struct platform_device *pdev)
        tcbpwm->chip.dev = &pdev->dev;
        tcbpwm->chip.ops = &atmel_tcb_pwm_ops;
        tcbpwm->chip.of_xlate = of_pwm_xlate_with_flags;
-       tcbpwm->chip.of_pwm_n_cells = 3;
        tcbpwm->chip.base = -1;
        tcbpwm->chip.npwm = NPWM;
        tcbpwm->tc = tc;
index 6e700a541ca32ded0d5881842214a53d87ffe0f6..ae7c9464bcf5a45d8738fe7212eff64cf536a991 100644 (file)
@@ -350,10 +350,8 @@ static int atmel_pwm_probe(struct platform_device *pdev)
        atmel_pwm->chip.dev = &pdev->dev;
        atmel_pwm->chip.ops = &atmel_pwm_ops;
 
-       if (pdev->dev.of_node) {
+       if (pdev->dev.of_node)
                atmel_pwm->chip.of_xlate = of_pwm_xlate_with_flags;
-               atmel_pwm->chip.of_pwm_n_cells = 3;
-       }
 
        atmel_pwm->chip.base = -1;
        atmel_pwm->chip.npwm = 4;
index 0b312ec420b6920b34cf3cb236a0f20c16c3f502..56560529aa879f7ac6e4a98301352ff599f3aa18 100644 (file)
@@ -191,10 +191,9 @@ static int pwm_probe(struct platform_device *pdev)
        pwm->chip.base = -1;
        pwm->chip.npwm = (id->driver_data & HAS_SECONDARY_PWM) ? 2 : 1;
 
-       if (IS_ENABLED(CONFIG_OF)) {
+       if (IS_ENABLED(CONFIG_OF))
                pwm->chip.of_xlate = pxa_pwm_of_xlate;
-               pwm->chip.of_pwm_n_cells = 1;
-       }
+
 
        r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        pwm->mmio_base = devm_ioremap_resource(&pdev->dev, r);
index 3b71b42e89d505cf5120f87d173f7e78f05e6550..5271da347dd3546373cdd350fb92fb7937dae358 100644 (file)
@@ -419,7 +419,6 @@ static int tpu_probe(struct platform_device *pdev)
        tpu->chip.dev = &pdev->dev;
        tpu->chip.ops = &tpu_pwm_ops;
        tpu->chip.of_xlate = of_pwm_xlate_with_flags;
-       tpu->chip.of_pwm_n_cells = 3;
        tpu->chip.base = -1;
        tpu->chip.npwm = TPU_CHANNEL_MAX;
 
index ba6b650cf8dc166cf529e067b3b4844691e0cfd1..317d7d1ca7605df23cf635fd9a99094cfd98b4c0 100644 (file)
@@ -484,7 +484,6 @@ static int pwm_samsung_probe(struct platform_device *pdev)
                        return ret;
 
                chip->chip.of_xlate = of_pwm_xlate_with_flags;
-               chip->chip.of_pwm_n_cells = 3;
        } else {
                if (!pdev->dev.platform_data) {
                        dev_err(&pdev->dev, "no platform data specified\n");
index 74efbe7f20c3ab084939421dcafa40b108baee95..a8e828242fb5aa7119f435a0ae76ef1d11c4dc84 100644 (file)
@@ -227,7 +227,6 @@ static int ecap_pwm_probe(struct platform_device *pdev)
        pc->chip.dev = &pdev->dev;
        pc->chip.ops = &ecap_pwm_ops;
        pc->chip.of_xlate = of_pwm_xlate_with_flags;
-       pc->chip.of_pwm_n_cells = 3;
        pc->chip.base = -1;
        pc->chip.npwm = 1;
 
index cb75133085a8b9b0adaa71a3374645520a0023c6..12a8ae4cb96798db3d7c927aa31052dd2d8960d9 100644 (file)
@@ -458,7 +458,6 @@ static int ehrpwm_pwm_probe(struct platform_device *pdev)
        pc->chip.dev = &pdev->dev;
        pc->chip.ops = &ehrpwm_pwm_ops;
        pc->chip.of_xlate = of_pwm_xlate_with_flags;
-       pc->chip.of_pwm_n_cells = 3;
        pc->chip.base = -1;
        pc->chip.npwm = NUM_PWM_CHANNEL;
 
index 652e6b5b859b92d6cdd2585506e9e24a7528f35b..e04a3c0f34f8e7278b45e1e0f04611e50a3bade2 100644 (file)
@@ -217,7 +217,6 @@ static int vt8500_pwm_probe(struct platform_device *pdev)
        chip->chip.dev = &pdev->dev;
        chip->chip.ops = &vt8500_pwm_ops;
        chip->chip.of_xlate = of_pwm_xlate_with_flags;
-       chip->chip.of_pwm_n_cells = 3;
        chip->chip.base = -1;
        chip->chip.npwm = VT8500_NR_PWMS;
 
index e90628cac8fae57e8a88ecd9f93d2a2f1342b9d5..4cf156926ac0275c83e171e4d38df03e16b6447a 100644 (file)
@@ -174,7 +174,6 @@ struct pwm_chip {
 
        struct pwm_device *     (*of_xlate)(struct pwm_chip *pc,
                                            const struct of_phandle_args *args);
-       unsigned int            of_pwm_n_cells;
        bool                    can_sleep;
 };