From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752335AbbDAWWH (ORCPT ); Wed, 1 Apr 2015 18:22:07 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:35326 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751735AbbDAWWG (ORCPT ); Wed, 1 Apr 2015 18:22:06 -0400 Date: Thu, 2 Apr 2015 01:22:28 +0300 From: Dan Carpenter To: Phong Tran Cc: gregkh@linuxfoundation.org, arve@android.com, riandrews@android.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] staging: android: ion_test: unregister the misc device Message-ID: <20150401222228.GF10964@mwanda> References: <1427909900-22650-1-git-send-email-tranmanphong@gmail.com> <1427909900-22650-3-git-send-email-tranmanphong@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427909900-22650-3-git-send-email-tranmanphong@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: aserv0021.oracle.com [141.146.126.233] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 02, 2015 at 12:38:19AM +0700, Phong Tran wrote: > Add the remove() method for deregister from misc device > when it's unloaded. > > Signed-off-by: Phong Tran > --- > drivers/staging/android/ion/ion_test.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c > index 3bc461c..f36a35e 100644 > --- a/drivers/staging/android/ion/ion_test.c > +++ b/drivers/staging/android/ion/ion_test.c > @@ -261,7 +261,25 @@ static int __init ion_test_probe(struct platform_device *pdev) > return 0; > } > > +static int ion_test_remove(struct platform_device *pdev) > +{ > + int ret = 0; Don't initialize variables if you don't need to. Just remove the ret variable completely. > + struct ion_test_device *testdev; > + > + testdev = platform_get_drvdata(pdev); > + > + if (!testdev) { Remove the blank line between the function and the check. They are part of the same thing/paragraph. > + pr_err("failed to get pdev data.\n"); Just leave this error statement out. It will never get printed. It's just a waste of RAM. If it were printed the -ENODATA error is unique to this path so it's all the debug out put we need. > + return -ENODATA; > + } > + > + ret = misc_deregister(&testdev->misc); > + > + return ret; return misc_deregister(&testdev->misc); regards, dan carpenter