pwm-core: fix compilation when OF is not selected
Subsystems (2)
PATCH 1/3 pwm-core: fix compilation when OF is not selected
else we get the following error :drivers/pwm/core.c: In function 'pwm_get':drivers/pwm/core.c:538:3: error: implicit declaration of function 'of_pwm_request' [-Werror=implicit-function-declaration]
--- drivers/pwm/core.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/pwm/core.c +2 -0
@@ -533,9 +533,11 @@ struct pwm_device *pwm_get(struct device *dev, const char *con_id)unsigned int index;unsigned int match; +#ifdef CONFIG_OF /* look up via DT first */ if (dev && dev->of_node)return of_pwm_request (dev->of_node, con_id); +#endif /* * We look up the provider in the static table typically provided by
Signature · 1 line
1.7.7.6
PATCH 2/3 pwm-imx: set chip.dev to prevent probe failure
else pwmchip_add fails
--- drivers/pwm/pwm-imx.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/pwm/pwm-imx.c +1 -0
@@ -175,6 +175,7 @@ static int __devinit imx_pwm_probe(struct platform_device *pdev) imx->chip.ops = &imx_pwm_ops; imx->chip.base =-1 ; imx->chip.npwm =1 ; + imx->chip.dev = &pdev->dev; imx->clk_enabled =0 ;
Signature · 1 line
1.7.7.6
PATCH 2/3 pwm-imx: set chip.dev to prevent probe failure
Quoted 3 lines · Eric B?nard
else
pwmchip_addfailsSigned-off-by Eric B?nard <[email protected]>
Are you okay with me folding your patch into the i.MX patch in the existing series?
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120429/43c92787/attachment.sig>
PATCH 3/3 pwm-core: fix registration of several pwm
In reply to Eric Bénard* after a pwm is allocated using alloc_pwms, ret contains the number of the pwm and is returned by pwmchip_add so the calling driver (pwm-imx in my case) fails with the following log :mxc_pwm: probe of mxc_pwm.1 failed with error 1mxc_pwm: probe of mxc_pwm.2 failed with error 2mxc_pwm: probe of mxc_pwm.3 failed with error 3
* this patch fix error handling in pwmchip_add
--- drivers/pwm/core.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/pwm/core.c +5 -2
@@ -216,8 +216,10 @@ int pwmchip_add(struct pwm_chip *chip) goto out; chip->pwms =kzalloc (chip->npwm *sizeof (*pwm),GFP_KERNEL ); -if (!chip->pwms) -return -ENOMEM ; +if (!chip->pwms) { + ret = -ENOMEM ; + goto out; + } chip->base = ret;
@@ -239,6 +241,7 @@ int pwmchip_add(struct pwm_chip *chip)if (IS_ENABLED (CONFIG_OF ))of_pwmchip_add (chip); + ret =0 ; out:mutex_unlock (&pwm_lock);return ret;
Signature · 1 line
1.7.7.6
PATCH 3/3 pwm-core: fix registration of several pwm
Quoted 19 lines · Eric B?nard
* after a pwm is allocated using
alloc_pwms, ret contains the number of the pwm and is returned bypwmchip_addso the calling driver (pwm-imx in my case) fails with the following log :mxc_pwm: probe of mxc_pwm.1 failed with error 1mxc_pwm: probe of mxc_pwm.2 failed with error 2mxc_pwm: probe of mxc_pwm.3 failed with error 3* this patch fix error handling in
pwmchip_addSigned-off-by Eric B?nard <[email protected]>--- drivers/pwm/core.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)drivers/pwm/core.c +0
-0
drivers/pwm/core.c int pwmchip_add(struct pwm_chip *chip) · line 222
Quoted 9 lines
drivers/pwm/core.c +4
-2@@ -216,8 +216,10 @@ int pwmchip_add(struct pwm_chip *chip) goto out; chip->pwms =kzalloc (chip->npwm *sizeof (*pwm),GFP_KERNEL ); -if (!chip->pwms) -return -ENOMEM ; +if (!chip->pwms) { + ret = -ENOMEM ; + goto out; + }
Good catch!
drivers/pwm/core.c int pwmchip_add(struct pwm_chip *chip) · line 247
Quoted 11 lines
drivers/pwm/core.c +1
-0chip->base = ret;@@ -239,6 +241,7 @@ int pwmchip_add(struct pwm_chip *chip)if (IS_ENABLED (CONFIG_OF ))of_pwmchip_add (chip); + ret =0 ; out:mutex_unlock (&pwm_lock);return ret;
pwmchip_add() is meant to return a negative error-code on failure, so a positive return values would still indicate success, therefore any callers should check explicitly for (ret < 0) instead of just (ret). However in this case it might be safer to make the return value explicitly 0 in case of success.
I'd like to fold this into the existing series as well, if that's okay with you.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120429/9288c84e/attachment.sig>
PATCH 1/3 pwm-core: fix compilation when OF is not selected
In reply to Eric BénardQuoted 5 lines · Eric B?nard
else we get the following error :
drivers/pwm/core.c: In function 'pwm_get':drivers/pwm/core.c:538:3: error: implicit declaration of function 'of_pwm_request' [-Werror=implicit-function-declaration]Signed-off-by Eric B?nard <[email protected]>
This is solved a little differently in the latest patches. That no longer has the of_pwm_request() function protected by #ifdef CONFIG_OF, but rather calls it in a IS_ENABLED(CONFIG_OF)-protected block so that it will still receive compile coverage in !OF configurations but at the same time will be removed by the compiler's dead code elimination.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120429/60616669/attachment.sig>
PATCH 1/3 pwm-core: fix compilation when OF is not selected
Le Sun, 29 Apr 2012 19:04:31 +0200,
Thierry Reding <[email protected]> a ?crit :
Quoted 5 lines · Eric B?nard
Quoted 4 lines
else we get the following error :
drivers/pwm/core.c: In function 'pwm_get':drivers/pwm/core.c:538:3: error: implicit declaration of function 'of_pwm_request' [-Werror=implicit-function-declaration]
Quoted 8 lines
Quoted 1 line
Signed-off-by Eric B?nard <[email protected]>This is solved a little differently in the latest patches. That no longer has the
of_pwm_request()function protected by #ifdefCONFIG_OF, but rather calls it in a IS_ENABLED(CONFIG_OF)-protected block so that it will still receive compile coverage in !OF configurations but at the same time will be removed by the compiler's dead code elimination.
OK, this was based on de8eba0b1e53ee0d2e3270c12d6482971e2beb4b in your tree dated the 27th march. I now see you updated it on friday.
Eric
PATCH 1/3 pwm-core: fix compilation when OF is not selected
In reply to Thierry RedingLe Sun, 29 Apr 2012 19:04:31 +0200,
Thierry Reding <[email protected]> a ?crit :
Quoted 5 lines · Eric B?nard
Quoted 4 lines
else we get the following error :
drivers/pwm/core.c: In function 'pwm_get':drivers/pwm/core.c:538:3: error: implicit declaration of function 'of_pwm_request' [-Werror=implicit-function-declaration]
Quoted 8 lines
Quoted 1 line
Signed-off-by Eric B?nard <[email protected]>This is solved a little differently in the latest patches. That no longer has the
of_pwm_request()function protected by #ifdefCONFIG_OF, but rather calls it in a IS_ENABLED(CONFIG_OF)-protected block so that it will still receive compile coverage in !OF configurations but at the same time will be removed by the compiler's dead code elimination.
OK this still doesn't work (using linux-2.6 at :f7b006931751f029620ad2f8310ac7a1484fbdb4 ) leads to :
CC drivers/pwm/core.o drivers/pwm/core.c: In function
'of_pwm_request': drivers/pwm/core.c:447:3: error: implicit declaration of function
'of_property_match_string' [-Werror=implicit-function-declaration] drivers/pwm/core.c:452:2: error: implicit declaration of function 'of_parse_phandle_with_args' [-Werror=implicit-function-declaration]
in include/linux/of.h the declaration of these function is inside a #ifdef CONFIG_OF / #endif so I don't see how this can compile.
Eric
PATCH 1/3 pwm-core: fix compilation when OF is not selected
Quoted 25 lines · Eric B?nard
Le Sun, 29 Apr 2012 19:04:31 +0200,
Thierry Reding <[email protected]> a ?crit :Quoted 5 lines · Eric B?nard
Quoted 4 lines
else we get the following error :
drivers/pwm/core.c: In function 'pwm_get':drivers/pwm/core.c:538:3: error: implicit declaration of function 'of_pwm_request' [-Werror=implicit-function-declaration]Quoted 8 lines
Quoted 1 line
Signed-off-by Eric B?nard <[email protected]>This is solved a little differently in the latest patches. That no longer has the
of_pwm_request()function protected by #ifdefCONFIG_OF, but rather calls it in a IS_ENABLED(CONFIG_OF)-protected block so that it will still receive compile coverage in !OF configurations but at the same time will be removed by the compiler's dead code elimination.OK this still doesn't work (using linux-2.6 at :
f7b006931751f029620ad2f8310ac7a1484fbdb4) leads to :
CCdrivers/pwm/core.odrivers/pwm/core.c: In function
'of_pwm_request':drivers/pwm/core.c:447:3: error: implicit declaration of function
'of_property_match_string' [-Werror=implicit-function-declaration]drivers/pwm/core.c:452:2: error: implicit declaration of function 'of_parse_phandle_with_args' [-Werror=implicit-function-declaration]
Quoted 2 lines
in
include/linux/of.hthe declaration of these function is inside a #ifdefCONFIG_OF/ #endif so I don't see how this can compile.
I've already posted patches to the devicetree-discuss mailing list. I hope they'll be queued soon.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120429/d0104846/attachment.sig>