Re: [PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-10 Thread Mark Brown
On Thu, Jan 10, 2013 at 10:33:06AM +0800, Axel Lin wrote:
> This driver use id as array index, thus add bounder checking for id.

Applied, thanks.


signature.asc
Description: Digital signature


Re: [PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-10 Thread Mark Brown
On Thu, Jan 10, 2013 at 10:33:06AM +0800, Axel Lin wrote:
 This driver use id as array index, thus add bounder checking for id.

Applied, thanks.


signature.asc
Description: Digital signature


Re: [PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-09 Thread Fengguang Wu

Thanks for the fix! It works!

Tested-by: Fengguang Wu  

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-09 Thread Axel Lin
This driver use id as array index, thus add bounder checking for id.

This patch fixes below build warning:
drivers/regulator/lp8788-buck.c: In function 'lp8788_buck_probe':
drivers/regulator/lp8788-buck.c:490:8: warning: array subscript is above array 
bounds [-Warray-bounds]
drivers/regulator/lp8788-buck.c:489:63: warning: array subscript is above array 
bounds [-Warray-bounds]

Reported-by: Fengguang Wu 
Signed-off-by: Axel Lin 
---
Hi Fengguang,
My toolchain does not show the warning you mentioned,
can you test if this patch indeed silence the build warning?

Thanks,
Axel
 drivers/regulator/lp8788-buck.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c
index 1161949..ef845c7 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -474,7 +474,7 @@ static int lp8788_init_dvs(struct platform_device *pdev,
u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C };
 
/* no dvs for buck3, 4 */
-   if (id == BUCK3 || id == BUCK4)
+   if (id > BUCK2)
return 0;
 
/* no dvs platform data, then dvs will be selected by I2C registers */
@@ -505,6 +505,9 @@ static int lp8788_buck_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
int ret;
 
+   if (id >= LP8788_NUM_BUCKS)
+   return -EINVAL;
+
buck = devm_kzalloc(>dev, sizeof(struct lp8788_buck), GFP_KERNEL);
if (!buck)
return -ENOMEM;
-- 
1.7.9.5



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-09 Thread Axel Lin
This driver use id as array index, thus add bounder checking for id.

This patch fixes below build warning:
drivers/regulator/lp8788-buck.c: In function 'lp8788_buck_probe':
drivers/regulator/lp8788-buck.c:490:8: warning: array subscript is above array 
bounds [-Warray-bounds]
drivers/regulator/lp8788-buck.c:489:63: warning: array subscript is above array 
bounds [-Warray-bounds]

Reported-by: Fengguang Wu fengguang...@intel.com
Signed-off-by: Axel Lin axel@ingics.com
---
Hi Fengguang,
My toolchain does not show the warning you mentioned,
can you test if this patch indeed silence the build warning?

Thanks,
Axel
 drivers/regulator/lp8788-buck.c |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c
index 1161949..ef845c7 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -474,7 +474,7 @@ static int lp8788_init_dvs(struct platform_device *pdev,
u8 default_dvs_mode[] = { LP8788_BUCK1_DVS_I2C, LP8788_BUCK2_DVS_I2C };
 
/* no dvs for buck3, 4 */
-   if (id == BUCK3 || id == BUCK4)
+   if (id  BUCK2)
return 0;
 
/* no dvs platform data, then dvs will be selected by I2C registers */
@@ -505,6 +505,9 @@ static int lp8788_buck_probe(struct platform_device *pdev)
struct regulator_dev *rdev;
int ret;
 
+   if (id = LP8788_NUM_BUCKS)
+   return -EINVAL;
+
buck = devm_kzalloc(pdev-dev, sizeof(struct lp8788_buck), GFP_KERNEL);
if (!buck)
return -ENOMEM;
-- 
1.7.9.5



--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RFT] regulator: lp8788-buck: Silence build warning

2013-01-09 Thread Fengguang Wu

Thanks for the fix! It works!

Tested-by: Fengguang Wu fengguang...@intel.com 

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/