LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Phong Tran <tranmanphong@gmail.com>
Cc: gregkh@linuxfoundation.org, arve@android.com,
	riandrews@android.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] staging: android: ion_test: unregister the platform device
Date: Thu, 2 Apr 2015 01:34:03 +0300	[thread overview]
Message-ID: <20150401223403.GG10964@mwanda> (raw)
In-Reply-To: <1427909900-22650-4-git-send-email-tranmanphong@gmail.com>

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 <tranmanphong@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


  reply	other threads:[~2015-04-01 22:33 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-01 17:38 [PATCH 0/3] Fix some issues of staging ion test driver Phong Tran
2015-04-01 17:38 ` [PATCH 1/3] staging: android: ion_test: Add the MODULE_LICENSE macro Phong Tran
2015-04-01 17:38 ` [PATCH 2/3] staging: android: ion_test: unregister the misc device Phong Tran
2015-04-01 22:22   ` Dan Carpenter
2015-04-01 17:38 ` [PATCH 3/3] staging: android: ion_test: unregister the platform device Phong Tran
2015-04-01 22:34   ` Dan Carpenter [this message]
2015-04-02 14:36   ` [PATCH V2 0/3] Fix some issues of staging ion test driver Phong Tran
2015-04-02 14:36     ` [PATCH V2 1/3] staging: android: ion_test: Add the MODULE_LICENSE macro Phong Tran
2015-04-02 14:36     ` [PATCH V2 2/3] staging: android: ion_test: unregister the misc device Phong Tran
2015-04-03 13:13       ` Greg KH
2015-04-03 14:07         ` [PATCH V3 0/2] Fix some issues of staging ion test driver Phong Tran
2015-04-03 14:07           ` [PATCH V3 1/2] staging: android: ion_test: unregister the misc device Phong Tran
2015-04-03 14:07           ` [PATCH V3 2/2] staging: android: ion_test: unregister the platform device Phong Tran
2015-04-02 14:36     ` [PATCH V2 3/3] " Phong Tran
2015-04-02 15:22     ` [PATCH V2 0/3] Fix some issues of staging ion test driver Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150401223403.GG10964@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=riandrews@android.com \
    --cc=tranmanphong@gmail.com \
    --subject='Re: [PATCH 3/3] staging: android: ion_test: unregister the platform device' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).