How does commit 47ec340c not introduce a bug?
Subsystems (2)
I noticed a warning while cross-compiling all arm defconfigs.
The mmp2_defconfig gave this warning:
drivers/video/backlight/max8925_bl.c: In function 'max8925_backlight_probe':drivers/video/backlight/max8925_bl.c:177:3: warning: statement with no effect [-Wunused-value]
This appears to have been introduced by the above commit when !CONFIG_OF
Looking at this more closely, I am not sure how this was ever intended to be handled or how the errors returned in the CONFIG_OF case were intended to be handled as the return from max8925_backlight_dt_init is always ignored.
I think this needs some more attention, but do not feel like I know enough about it or have any means to test it to weigh in.
Thanks,
Robin
commit 47ec340cb8e232671e7c4a4689ff32c3bdf329da
Author: Qing Xu <[email protected]> Date: Mon Feb 4 23:40:45 2013 +0800
mfd: max8925: Support dt for backlight
Add device tree support in max8925 backlight.
drivers/video/backlight/max8925_bl.c +30 -1
@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; +#ifdef CONFIG_OF +static int max8925_backlight_dt_init (struct platform_device *pdev, +struct max8925_backlight_pdata *pdata) +{ +struct device_node *nproot = pdev->dev.parent->of_node, *np; +int dual_string; + +if (!nproot) +return -ENODEV ; + np =of_find_node_by_name (nproot,"backlight" ); +if (!np) { +dev_err (&pdev->dev,"failed to find backlight node\n" ); +return -ENODEV ; + } + +of_property_read_u32 (np,"maxim,max8925-dual-string" , &dual_string); + pdata->dual_string = dual_string; +return 0 ; +} +#else +#define max8925_backlight_dt_init (x, y) (-1) +#endif +static int max8925_backlight_probe (struct platform_device *pdev) {struct max8925_chip *chip =dev_get_drvdata (pdev->dev.parent);
@@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)platform_set_drvdata (pdev, bl); value =0 ; +if (pdev->dev.parent->of_node && !pdata) { + pdata =devm_kzalloc (&pdev->dev, +sizeof (struct max8925_backlight_pdata ), +GFP_KERNEL ); +max8925_backlight_dt_init (pdev, pdata); + } +if (pdata) {if (pdata->lxw_scl) value |= (1 <<7 );
@@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev) ret =max8925_set_bits (chip->i2c, data->reg_mode_cntl,0xfe , value);if (ret <0 ) goto out_brt; -backlight_update_status (bl);return 0 ; out_brt:
Hello,
Quoted 52 lines · Robin Holt
I noticed a warning while cross-compiling all arm defconfigs.
The
mmp2_defconfiggave this warning:
drivers/video/backlight/max8925_bl.c: In function 'max8925_backlight_probe':drivers/video/backlight/max8925_bl.c:177:3: warning: statement with no effect [-Wunused-value]This appears to have been introduced by the above commit when !CONFIG_OF
Looking at this more closely, I am not sure how this was ever intended to be handled or how the errors returned in the
CONFIG_OFcase were intended to be handled as the return frommax8925_backlight_dt_initis always ignored.I think this needs some more attention, but do not feel like I know enough about it or have any means to test it to weigh in.
Thanks,
Robincommit
47ec340cb8e232671e7c4a4689ff32c3bdf329daAuthor: Qing Xu <[email protected]> Date: Mon Feb 4 23:40:45 2013 +0800mfd: max8925: Support dt for backlight
Add device tree support in max8925 backlight.
Signed-off-by Qing Xu <[email protected]>Signed-off-by Haojian Zhuang <[email protected]>Signed-off-by Samuel Ortiz <[email protected]>drivers/video/backlight/max8925_bl.c +11
-0@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; +#ifdef CONFIG_OF +static int max8925_backlight_dt_init (struct platform_device *pdev, +struct max8925_backlight_pdata *pdata) +{ +struct device_node *nproot = pdev->dev.parent->of_node, *np; +int dual_string; + +if (!nproot) +return -ENODEV ; + np =of_find_node_by_name (nproot,"backlight" ); +if (!np) {
drivers/video/backlight/max8925_bl.c static const struct backlight_ops max8925_backlight_ops = { · line 124
Quoted 10 lines
drivers/video/backlight/max8925_bl.c +10
-0+dev_err (&pdev->dev,"failed to find backlight node\n" ); + return -ENODEV; + } + +of_property_read_u32 (np,"maxim,max8925-dual-string" , &dual_string); + pdata->dual_string = dual_string; +return 0 ; +} +#else +#define max8925_backlight_dt_init (x, y) (-1)
It's probably best to make this:
static inline max8925_backlight_dt_init(struct platform_device *pdev,
struct max8925_backlight_pdata *pdata)
{
return -ENODEV;
}Quoted 33 lines
drivers/video/backlight/max8925_bl.c +9
-1+#endif +static int max8925_backlight_probe (struct platform_device *pdev) {struct max8925_chip *chip =dev_get_drvdata (pdev->dev.parent);@@ -147,6 +170,13 @@ static int max8925_backlight_probe(struct platform_device *pdev)platform_set_drvdata (pdev, bl); value =0 ; +if (pdev->dev.parent->of_node && !pdata) { + pdata =devm_kzalloc (&pdev->dev, +sizeof (struct max8925_backlight_pdata ), +GFP_KERNEL ); +max8925_backlight_dt_init (pdev, pdata); + } +if (pdata) {if (pdata->lxw_scl) value |= (1 <<7 );@@ -158,7 +188,6 @@ static int max8925_backlight_probe(struct platform_device *pdev) ret =max8925_set_bits (chip->i2c, data->reg_mode_cntl,0xfe , value);if (ret <0 ) goto out_brt; -backlight_update_status (bl);return 0 ; out_brt:_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Quoted 67 lines · Uwe Kleine-K?nig
Hello,
Quoted 52 lines · Robin Holt
I noticed a warning while cross-compiling all arm defconfigs.
The
mmp2_defconfiggave this warning:
drivers/video/backlight/max8925_bl.c: In function 'max8925_backlight_probe':drivers/video/backlight/max8925_bl.c:177:3: warning: statement with no effect [-Wunused-value]This appears to have been introduced by the above commit when !CONFIG_OF
Looking at this more closely, I am not sure how this was ever intended to be handled or how the errors returned in the
CONFIG_OFcase were intended to be handled as the return frommax8925_backlight_dt_initis always ignored.I think this needs some more attention, but do not feel like I know enough about it or have any means to test it to weigh in.
Thanks,
Robincommit
47ec340cb8e232671e7c4a4689ff32c3bdf329daAuthor: Qing Xu <[email protected]> Date: Mon Feb 4 23:40:45 2013 +0800mfd: max8925: Support dt for backlight
Add device tree support in max8925 backlight.
Signed-off-by Qing Xu <[email protected]>Signed-off-by Haojian Zhuang <[email protected]>Signed-off-by Samuel Ortiz <[email protected]>drivers/video/backlight/max8925_bl.c +11
-0@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; +#ifdef CONFIG_OF +static int max8925_backlight_dt_init (struct platform_device *pdev, +struct max8925_backlight_pdata *pdata) +{ +struct device_node *nproot = pdev->dev.parent->of_node, *np; +int dual_string; + +if (!nproot) +return -ENODEV ; + np =of_find_node_by_name (nproot,"backlight" ); +if (!np) {drivers/video/backlight/max8925_bl.c static const struct backlight_ops max8925_backlight_ops = { · line 124
Quoted 10 lines
drivers/video/backlight/max8925_bl.c +10
-0+dev_err (&pdev->dev,"failed to find backlight node\n" ); + return -ENODEV; + } + +of_property_read_u32 (np,"maxim,max8925-dual-string" , &dual_string); + pdata->dual_string = dual_string; +return 0 ; +} +#else +#define max8925_backlight_dt_init (x, y) (-1)It's probably best to make this:
Quoted 6 lines
static inline max8925_backlight_dt_init(struct
platform_device*pdev,
structmax8925_backlight_pdata*pdata){ return -ENODEV; }
I've submitted this patch to fix this issue for a long time.
Samuel,
Should I send it again?
Regards
Haojian
Quoted 76 lines · Haojian Zhuang
Quoted 67 lines · Uwe Kleine-K?nig
Hello,
Quoted 52 lines · Robin Holt
I noticed a warning while cross-compiling all arm defconfigs.
The
mmp2_defconfiggave this warning:
drivers/video/backlight/max8925_bl.c: In function 'max8925_backlight_probe':drivers/video/backlight/max8925_bl.c:177:3: warning: statement with no effect [-Wunused-value]This appears to have been introduced by the above commit when !CONFIG_OF
Looking at this more closely, I am not sure how this was ever intended to be handled or how the errors returned in the
CONFIG_OFcase were intended to be handled as the return frommax8925_backlight_dt_initis always ignored.I think this needs some more attention, but do not feel like I know enough about it or have any means to test it to weigh in.
Thanks,
Robincommit
47ec340cb8e232671e7c4a4689ff32c3bdf329daAuthor: Qing Xu <[email protected]> Date: Mon Feb 4 23:40:45 2013 +0800mfd: max8925: Support dt for backlight
Add device tree support in max8925 backlight.
Signed-off-by Qing Xu <[email protected]>Signed-off-by Haojian Zhuang <[email protected]>Signed-off-by Samuel Ortiz <[email protected]>drivers/video/backlight/max8925_bl.c +11
-0@@ -101,6 +101,29 @@ static const struct backlight_ops max8925_backlight_ops = { .get_brightness = max8925_backlight_get_brightness, }; +#ifdef CONFIG_OF +static int max8925_backlight_dt_init (struct platform_device *pdev, +struct max8925_backlight_pdata *pdata) +{ +struct device_node *nproot = pdev->dev.parent->of_node, *np; +int dual_string; + +if (!nproot) +return -ENODEV ; + np =of_find_node_by_name (nproot,"backlight" ); +if (!np) {drivers/video/backlight/max8925_bl.c static const struct backlight_ops max8925_backlight_ops = { · line 124
Quoted 10 lines
drivers/video/backlight/max8925_bl.c +10
-0+dev_err (&pdev->dev,"failed to find backlight node\n" ); + return -ENODEV; + } + +of_property_read_u32 (np,"maxim,max8925-dual-string" , &dual_string); + pdata->dual_string = dual_string; +return 0 ; +} +#else +#define max8925_backlight_dt_init (x, y) (-1)It's probably best to make this:
Quoted 6 lines
static inline max8925_backlight_dt_init(struct
platform_device*pdev,
structmax8925_backlight_pdata*pdata){ return -ENODEV; }
Quoted 5 lines
I've submitted this patch to fix this issue for a long time.
Samuel,
Should I send it again?
It fixes nothing. The return value is not used. There is more to this bug report than the -1. You need to handle that error case. Otherwise, you could just change it into a void return.
Robin
Quoted 9 lines · Haojian Zhuang
Quoted 8 lines
It's probably best to make this:
static inline max8925_backlight_dt_init(struct
platform_device*pdev,
structmax8925_backlight_pdata*pdata){ return -ENODEV; }
Quoted 5 lines
I've submitted this patch to fix this issue for a long time.
Samuel,
Should I send it again?
To the backlight maintainers, yes. I carried 47ec340c as it was part of an MFD patchset, but now that it's upstream I shouldn't take any patches for it.
Cheers,
Samuel.
Signature · 2 lines
Intel Open Source Technology Centre http://oss.intel.com/