Skip to content

Commit 19c26d9

Browse files
saschahauerbrgl
authored andcommitted
gpio: mvebu: Fix probing for chips without PWM
The PWM iomem resource is optional and its presence indicates whether the GPIO chip has a PWM or not, which is why mvebu_pwm_probe() returned successfully when the PWM resource was not present. With f51b18d the driver switched to devm_platform_ioremap_resource_byname() and its error return is propagated to the caller, so now a missing PWM resource leads to a probe error in the driver. To fix this explicitly test for the presence of the PWM resource and return successfully when it's not there. Do this check before the check for the clock is done (which GPIO chips without a PWM do not have). Also move the existing comment why the PWM resource is optional up to the actual check. Fixes: f51b18d ("gpio: mvebu: use devm_platform_ioremap_resource_byname()") Signed-off-by: Sascha Hauer <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 6409d04 commit 19c26d9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/gpio/gpio-mvebu.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,15 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
782782
"marvell,armada-370-gpio"))
783783
return 0;
784784

785+
/*
786+
* There are only two sets of PWM configuration registers for
787+
* all the GPIO lines on those SoCs which this driver reserves
788+
* for the first two GPIO chips. So if the resource is missing
789+
* we can't treat it as an error.
790+
*/
791+
if (!platform_get_resource_byname(pdev, IORESOURCE_MEM, "pwm"))
792+
return 0;
793+
785794
if (IS_ERR(mvchip->clk))
786795
return PTR_ERR(mvchip->clk);
787796

@@ -804,12 +813,6 @@ static int mvebu_pwm_probe(struct platform_device *pdev,
804813
mvchip->mvpwm = mvpwm;
805814
mvpwm->mvchip = mvchip;
806815

807-
/*
808-
* There are only two sets of PWM configuration registers for
809-
* all the GPIO lines on those SoCs which this driver reserves
810-
* for the first two GPIO chips. So if the resource is missing
811-
* we can't treat it as an error.
812-
*/
813816
mvpwm->membase = devm_platform_ioremap_resource_byname(pdev, "pwm");
814817
if (IS_ERR(mvpwm->membase))
815818
return PTR_ERR(mvpwm->membase);

0 commit comments

Comments
 (0)