public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] universal_c210: fix compiler error and compiler warning
@ 2012-12-10  6:50 Minkyu Kang
  2012-12-10  9:06 ` Wolfgang Denk
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Minkyu Kang @ 2012-12-10  6:50 UTC (permalink / raw)
  To: u-boot

This patch fix following errors

universal.c: In function 'init_pmic_lcd':
universal.c:340: warning: implicit declaration of function 'get_pmic'
universal.c:340: warning: initialization makes pointer from integer without a cast
universal.c: In function 'lcd_power_on':
universal.c:431: warning: initialization makes pointer from integer without a cast
universal.c: At top level:
universal.c:335: warning: 'init_pmic_lcd' defined but not used

Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
Cc: Donghwa Lee <dh09.lee@samsung.com>
Cc: Lukasz Majewski <l.majewski@samsung.com>
---
 board/samsung/universal_c210/universal.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
index 3d508be..4869798 100644
--- a/board/samsung/universal_c210/universal.c
+++ b/board/samsung/universal_c210/universal.c
@@ -55,6 +55,8 @@ static int get_hwrev(void)
 	return board_rev & 0xFF;
 }
 
+static void init_pmic_lcd(void);
+
 int power_init_board(void)
 {
 	int ret;
@@ -63,6 +65,8 @@ int power_init_board(void)
 	if (ret)
 		return ret;
 
+	init_pmic_lcd();
+
 	return 0;
 }
 
@@ -337,7 +341,7 @@ static void init_pmic_lcd(void)
 	unsigned char val;
 	int ret = 0;
 
-	struct pmic *p = get_pmic();
+	struct pmic *p = pmic_get("MAX8998_PMIC");
 
 	if (pmic_probe(p))
 		return;
@@ -428,7 +432,7 @@ static void reset_lcd(void)
 
 static void lcd_power_on(void)
 {
-	struct pmic *p = get_pmic();
+	struct pmic *p = pmic_get("MAX8998_PMIC");
 
 	if (pmic_probe(p))
 		return;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  6:50 [U-Boot] universal_c210: fix compiler error and compiler warning Minkyu Kang
@ 2012-12-10  9:06 ` Wolfgang Denk
  2012-12-10  9:32   ` Lukasz Majewski
  2012-12-10 10:28 ` Piotr Wilczek
  2012-12-11  4:01 ` Minkyu Kang
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Denk @ 2012-12-10  9:06 UTC (permalink / raw)
  To: u-boot

Dear Minkyu Kang,

In message <50C58623.3090308@samsung.com> you wrote:
...
> @@ -337,7 +341,7 @@ static void init_pmic_lcd(void)
>  	unsigned char val;
>  	int ret = 0;
>  
> -	struct pmic *p = get_pmic();
> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>  
>  	if (pmic_probe(p))
>  		return;
> @@ -428,7 +432,7 @@ static void reset_lcd(void)
>  
>  static void lcd_power_on(void)
>  {
> -	struct pmic *p = get_pmic();
> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>  
>  	if (pmic_probe(p))
>  		return;

This is unrelated to your patch - but what if pmic_get() returns NULL?

pmic_probe() will crashif you pass it a NULL pointer...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Digital computers are themselves more complex than most things people
build: They have very large numbers of states. This makes conceiving,
describing, and testing them hard. Software systems  have  orders-of-
magnitude more states than computers do.           - Fred Brooks, Jr.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  9:06 ` Wolfgang Denk
@ 2012-12-10  9:32   ` Lukasz Majewski
  2012-12-10  9:59     ` Minkyu Kang
  2012-12-10 10:44     ` Wolfgang Denk
  0 siblings, 2 replies; 7+ messages in thread
From: Lukasz Majewski @ 2012-12-10  9:32 UTC (permalink / raw)
  To: u-boot

Hi Wolfgang,

> Dear Minkyu Kang,
> 
> In message <50C58623.3090308@samsung.com> you wrote:
> ...
> > @@ -337,7 +341,7 @@ static void init_pmic_lcd(void)
> >  	unsigned char val;
> >  	int ret = 0;
> >  
> > -	struct pmic *p = get_pmic();
> > +	struct pmic *p = pmic_get("MAX8998_PMIC");
> >  
> >  	if (pmic_probe(p))
> >  		return;
> > @@ -428,7 +432,7 @@ static void reset_lcd(void)
> >  
> >  static void lcd_power_on(void)
> >  {
> > -	struct pmic *p = get_pmic();
> > +	struct pmic *p = pmic_get("MAX8998_PMIC");
> >  
> >  	if (pmic_probe(p))
> >  		return;
> 
> This is unrelated to your patch - but what if pmic_get() returns NULL?
> 
> pmic_probe() will crashif you pass it a NULL pointer...

The PMIC 2.0 uses malloc to allocate pmic structure.

The fix, which has been proposed would work for old pmic.

In the new one PMIC 2.0, we require to test return pointer from
pmic_get() (similar to all malloc allocations):

struct pmic *p = pmic_get("MAX8998_PMIC");
if (!p)
	return -ENODEV;


> 
> Best regards,
> 
> Wolfgang Denk
> 



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  9:32   ` Lukasz Majewski
@ 2012-12-10  9:59     ` Minkyu Kang
  2012-12-10 10:44     ` Wolfgang Denk
  1 sibling, 0 replies; 7+ messages in thread
From: Minkyu Kang @ 2012-12-10  9:59 UTC (permalink / raw)
  To: u-boot

Dear Wolfgang,

On 10/12/12 18:32, Lukasz Majewski wrote:
> Hi Wolfgang,
> 
>> Dear Minkyu Kang,
>>
>> In message <50C58623.3090308@samsung.com> you wrote:
>> ...
>>> @@ -337,7 +341,7 @@ static void init_pmic_lcd(void)
>>>  	unsigned char val;
>>>  	int ret = 0;
>>>  
>>> -	struct pmic *p = get_pmic();
>>> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>>>  
>>>  	if (pmic_probe(p))
>>>  		return;
>>> @@ -428,7 +432,7 @@ static void reset_lcd(void)
>>>  
>>>  static void lcd_power_on(void)
>>>  {
>>> -	struct pmic *p = get_pmic();
>>> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>>>  
>>>  	if (pmic_probe(p))
>>>  		return;
>>
>> This is unrelated to your patch - but what if pmic_get() returns NULL?
>>
>> pmic_probe() will crashif you pass it a NULL pointer...
> 
> The PMIC 2.0 uses malloc to allocate pmic structure.
> 
> The fix, which has been proposed would work for old pmic.
> 
> In the new one PMIC 2.0, we require to test return pointer from
> pmic_get() (similar to all malloc allocations):
> 
> struct pmic *p = pmic_get("MAX8998_PMIC");
> if (!p)
> 	return -ENODEV;
> 

I will fix it by another patch.

Thanks.
Minkyu Kang.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  6:50 [U-Boot] universal_c210: fix compiler error and compiler warning Minkyu Kang
  2012-12-10  9:06 ` Wolfgang Denk
@ 2012-12-10 10:28 ` Piotr Wilczek
  2012-12-11  4:01 ` Minkyu Kang
  2 siblings, 0 replies; 7+ messages in thread
From: Piotr Wilczek @ 2012-12-10 10:28 UTC (permalink / raw)
  To: u-boot

On 12/10/2012 07:50 AM, Minkyu Kang wrote:
> This patch fix following errors
>
> universal.c: In function 'init_pmic_lcd':
> universal.c:340: warning: implicit declaration of function 'get_pmic'
> universal.c:340: warning: initialization makes pointer from integer without a cast
> universal.c: In function 'lcd_power_on':
> universal.c:431: warning: initialization makes pointer from integer without a cast
> universal.c: At top level:
> universal.c:335: warning: 'init_pmic_lcd' defined but not used
>
> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Donghwa Lee <dh09.lee@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> ---
>   board/samsung/universal_c210/universal.c |    8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/board/samsung/universal_c210/universal.c b/board/samsung/universal_c210/universal.c
> index 3d508be..4869798 100644
> --- a/board/samsung/universal_c210/universal.c
> +++ b/board/samsung/universal_c210/universal.c
> @@ -55,6 +55,8 @@ static int get_hwrev(void)
>   	return board_rev & 0xFF;
>   }
>
> +static void init_pmic_lcd(void);
> +
>   int power_init_board(void)
>   {
>   	int ret;
> @@ -63,6 +65,8 @@ int power_init_board(void)
>   	if (ret)
>   		return ret;
>
> +	init_pmic_lcd();
> +
>   	return 0;
>   }
>
> @@ -337,7 +341,7 @@ static void init_pmic_lcd(void)
>   	unsigned char val;
>   	int ret = 0;
>
> -	struct pmic *p = get_pmic();
> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>
>   	if (pmic_probe(p))
>   		return;
> @@ -428,7 +432,7 @@ static void reset_lcd(void)
>
>   static void lcd_power_on(void)
>   {
> -	struct pmic *p = get_pmic();
> +	struct pmic *p = pmic_get("MAX8998_PMIC");
>
>   	if (pmic_probe(p))
>   		return;
>
Tested-by: Piotr Wilczek <p.wilczek@samsung.com>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  9:32   ` Lukasz Majewski
  2012-12-10  9:59     ` Minkyu Kang
@ 2012-12-10 10:44     ` Wolfgang Denk
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Denk @ 2012-12-10 10:44 UTC (permalink / raw)
  To: u-boot

Dear Lukasz Majewski,

In message <20121210103224.372c572e@amdc308.digital.local> you wrote:
> 
> > This is unrelated to your patch - but what if pmic_get() returns NULL?
> > 
> > pmic_probe() will crashif you pass it a NULL pointer...
> 
> The PMIC 2.0 uses malloc to allocate pmic structure.

...and malloc() can fail.

> The fix, which has been proposed would work for old pmic.
> 
> In the new one PMIC 2.0, we require to test return pointer from
> pmic_get() (similar to all malloc allocations):
> 
> struct pmic *p = pmic_get("MAX8998_PMIC");
> if (!p)
> 	return -ENODEV;

So this code here needs fixing.  This is what I wanted to point out.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"If you want to eat hippopatomus, you've got to pay the  freight."  -
attributed to an IBM guy, about why IBM software uses so much memory

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] universal_c210: fix compiler error and compiler warning
  2012-12-10  6:50 [U-Boot] universal_c210: fix compiler error and compiler warning Minkyu Kang
  2012-12-10  9:06 ` Wolfgang Denk
  2012-12-10 10:28 ` Piotr Wilczek
@ 2012-12-11  4:01 ` Minkyu Kang
  2 siblings, 0 replies; 7+ messages in thread
From: Minkyu Kang @ 2012-12-11  4:01 UTC (permalink / raw)
  To: u-boot

On 10/12/12 15:50, Minkyu Kang wrote:
> This patch fix following errors
> 
> universal.c: In function 'init_pmic_lcd':
> universal.c:340: warning: implicit declaration of function 'get_pmic'
> universal.c:340: warning: initialization makes pointer from integer without a cast
> universal.c: In function 'lcd_power_on':
> universal.c:431: warning: initialization makes pointer from integer without a cast
> universal.c: At top level:
> universal.c:335: warning: 'init_pmic_lcd' defined but not used
> 
> Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
> Cc: Donghwa Lee <dh09.lee@samsung.com>
> Cc: Lukasz Majewski <l.majewski@samsung.com>
> ---
>  board/samsung/universal_c210/universal.c |    8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 

applied to u-boot-samsung/resolve

Thanks.
Minkyu Kang.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-11  4:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10  6:50 [U-Boot] universal_c210: fix compiler error and compiler warning Minkyu Kang
2012-12-10  9:06 ` Wolfgang Denk
2012-12-10  9:32   ` Lukasz Majewski
2012-12-10  9:59     ` Minkyu Kang
2012-12-10 10:44     ` Wolfgang Denk
2012-12-10 10:28 ` Piotr Wilczek
2012-12-11  4:01 ` Minkyu Kang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox