diff mbox

physmap.c: Check return of platform_device_register()

Message ID 48CB5E9A.4010000@gmail.com
State Rejected
Headers show

Commit Message

Zev Weiss Sept. 13, 2008, 6:32 a.m. UTC
The PHYSMAP_COMPAT code had been ignoring the return value of
platform_device_register() in the physmap_init() function.

Signed-off-by: Zev Weiss <zevweiss@gmail.com>

Comments

Lennert Buytenhek Sept. 13, 2008, 10:45 a.m. UTC | #1
On Fri, Sep 12, 2008 at 11:32:58PM -0700, Zev Weiss wrote:

> The PHYSMAP_COMPAT code had been ignoring the return value of
> platform_device_register() in the physmap_init() function.
> 
> Signed-off-by: Zev Weiss <zevweiss@gmail.com>
> ---
>   drivers/mtd/maps/physmap.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
> index 42d844f..6fba0d4 100644
> --- a/drivers/mtd/maps/physmap.c
> +++ b/drivers/mtd/maps/physmap.c
> @@ -312,7 +312,7 @@ static int __init physmap_init(void)
>   	err = platform_driver_register(&physmap_flash_driver);
>   #ifdef PHYSMAP_COMPAT
>   	if (err == 0)
> -		platform_device_register(&physmap_flash);
> +		err = platform_device_register(&physmap_flash);
>   #endif

I don't think you want the registration of the physmap driver to fail
if the compat platform device fails to register.

One reason that the compat platform device can fail to register can be
that there is already a non-compat platform device for the compat flash
chip, and in that case I don't think you want to fail the driver init
(while leaving the physmap_flash_driver registered, too!).
Zev Weiss Sept. 13, 2008, 11:27 a.m. UTC | #2
Lennert Buytenhek wrote:
> On Fri, Sep 12, 2008 at 11:32:58PM -0700, Zev Weiss wrote:
> 
>> The PHYSMAP_COMPAT code had been ignoring the return value of
>> platform_device_register() in the physmap_init() function.
>>
>> Signed-off-by: Zev Weiss <zevweiss@gmail.com>
>> ---
>>   drivers/mtd/maps/physmap.c |    2 +-
>>   1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
>> index 42d844f..6fba0d4 100644
>> --- a/drivers/mtd/maps/physmap.c
>> +++ b/drivers/mtd/maps/physmap.c
>> @@ -312,7 +312,7 @@ static int __init physmap_init(void)
>>   	err = platform_driver_register(&physmap_flash_driver);
>>   #ifdef PHYSMAP_COMPAT
>>   	if (err == 0)
>> -		platform_device_register(&physmap_flash);
>> +		err = platform_device_register(&physmap_flash);
>>   #endif
> 
> I don't think you want the registration of the physmap driver to fail
> if the compat platform device fails to register.
> 
> One reason that the compat platform device can fail to register can be
> that there is already a non-compat platform device for the compat flash
> chip, and in that case I don't think you want to fail the driver init
> (while leaving the physmap_flash_driver registered, too!).
> 

Chalk another one up to ignorance on my part...sounds like a nak all 'round.
Andrew Morton Sept. 17, 2008, 6:57 p.m. UTC | #3
On Fri, 12 Sep 2008 23:32:58 -0700
Zev Weiss <zevweiss@gmail.com> wrote:

> The PHYSMAP_COMPAT code had been ignoring the return value of
> platform_device_register() in the physmap_init() function.
> 
> Signed-off-by: Zev Weiss <zevweiss@gmail.com>
> ---
>   drivers/mtd/maps/physmap.c |    2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
> index 42d844f..6fba0d4 100644
> --- a/drivers/mtd/maps/physmap.c
> +++ b/drivers/mtd/maps/physmap.c
> @@ -312,7 +312,7 @@ static int __init physmap_init(void)
>   	err = platform_driver_register(&physmap_flash_driver);
>   #ifdef PHYSMAP_COMPAT
>   	if (err == 0)
> -		platform_device_register(&physmap_flash);
> +		err = platform_device_register(&physmap_flash);
>   #endif
> 
>   	return err;

Your email client is performing space-stuffing, thus making the patches
unapplyable.

Presumably we should run platform_driver_unregister() if the
platform_device_register() failed.
Sergei Shtylyov Sept. 17, 2008, 7:43 p.m. UTC | #4
Hello.

Andrew Morton wrote:

>>The PHYSMAP_COMPAT code had been ignoring the return value of
>>platform_device_register() in the physmap_init() function.

>>Signed-off-by: Zev Weiss <zevweiss@gmail.com>
[...]
>>diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
>>index 42d844f..6fba0d4 100644
>>--- a/drivers/mtd/maps/physmap.c
>>+++ b/drivers/mtd/maps/physmap.c
>>@@ -312,7 +312,7 @@ static int __init physmap_init(void)
>>  	err = platform_driver_register(&physmap_flash_driver);
>>  #ifdef PHYSMAP_COMPAT
>>  	if (err == 0)
>>-		platform_device_register(&physmap_flash);
>>+		err = platform_device_register(&physmap_flash);
>>  #endif
>>
>>  	return err;

> Your email client is performing space-stuffing, thus making the patches
> unapplyable.

    Er... are you sure? The patch looks alright tab wise, even after quoting...

> Presumably we should run platform_driver_unregister() if the
> platform_device_register() failed.

    Why is that? There could be "normal" platform devices out there...

WBR, Sergei
Sergei Shtylyov Sept. 17, 2008, 7:46 p.m. UTC | #5
I just wrote:

>>> The PHYSMAP_COMPAT code had been ignoring the return value of
>>> platform_device_register() in the physmap_init() function.

>>> Signed-off-by: Zev Weiss <zevweiss@gmail.com>

> [...]

>>> diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
>>> index 42d844f..6fba0d4 100644
>>> --- a/drivers/mtd/maps/physmap.c
>>> +++ b/drivers/mtd/maps/physmap.c
>>> @@ -312,7 +312,7 @@ static int __init physmap_init(void)
>>>      err = platform_driver_register(&physmap_flash_driver);
>>>  #ifdef PHYSMAP_COMPAT
>>>      if (err == 0)
>>> -        platform_device_register(&physmap_flash);
>>> +        err = platform_device_register(&physmap_flash);
>>>  #endif
>>>
>>>      return err;

[...]

>> Presumably we should run platform_driver_unregister() if the
>> platform_device_register() failed.

>    Why is that? There could be "normal" platform devices out there...

   With that said, the patch is pointless (as already noted by Lennert).

WBR, Sergei
diff mbox

Patch

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 42d844f..6fba0d4 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -312,7 +312,7 @@  static int __init physmap_init(void)
  	err = platform_driver_register(&physmap_flash_driver);
  #ifdef PHYSMAP_COMPAT
  	if (err == 0)
-		platform_device_register(&physmap_flash);
+		err = platform_device_register(&physmap_flash);
  #endif

  	return err;