On Thu, Apr 02, 2015 at 12:38:20AM +0700, Phong Tran wrote:
> The driver has to unregister from platform device when it's unloaded
> 
> Signed-off-by: Phong Tran <tranmanph...@gmail.com>
> ---
>  drivers/staging/android/ion/ion_test.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/android/ion/ion_test.c 
> b/drivers/staging/android/ion/ion_test.c
> index f36a35e..d2a236e 100644
> --- a/drivers/staging/android/ion/ion_test.c
> +++ b/drivers/staging/android/ion/ion_test.c
> @@ -278,6 +278,7 @@ static int ion_test_remove(struct platform_device *pdev)
>       return ret;
>  }
>  
> +static struct platform_device *ion_test_platform_device;

This name is too long.  You will run into the 80 character limit.

>  static struct platform_driver ion_test_platform_driver = {
>       .remove = ion_test_remove,
>       .driver = {
> @@ -287,13 +288,21 @@ static struct platform_driver ion_test_platform_driver 
> = {
>  
>  static int __init ion_test_init(void)
>  {
> -     platform_device_register_simple("ion-test", -1, NULL, 0);
> +     ion_test_platform_device = platform_device_register_simple("ion-test",
> +                                -1, NULL, 0);

This indenting is off.  It should be:

        ion_test_dev = platform_device_register_simple("ion-test",
                                                       -1, NULL, 0);

or something similar.

> +
> +     if (!ion_test_platform_device) {
> +             pr_err("failed to register ion-test platform device\n");

People add error messages without thinking about it because they think,
"Obviously, the more error messages the better."  Almost all the bad
things that can happen in platform_device_register_simple() generate
their own error message.

Also platform_driver_probe() doesn't have an error message so it's
possible to leave them out if you want.  Be bold!  Leave out the
message!  Or if you want go ahead and leave it in.  So long as you have
thought about it is what matters.

regards,
dan carpenter

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to