From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Axel Lin <axel.lin@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Jonathan Woithe <jwoithe@physics.adelaide.edu.au>,
Matthew Garrett <mjg@redhat.com>, Len Brown <len.brown@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Stefani Seibold <stefani@seibold.net>,
Andi Kleen <ak@linux.intel.com>,
platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH] fujitsu-laptop: remove unnecessary input_free_device calls
Date: Thu, 1 Jul 2010 23:20:00 -0700 [thread overview]
Message-ID: <20100702061958.GA3691@core.coreip.homeip.net> (raw)
In-Reply-To: <1278034977.24246.6.camel@mola>
Hi Axel,
On Fri, Jul 02, 2010 at 09:42:57AM +0800, Axel Lin wrote:
> input_free_device should only be used if input_register_device()
> was not called yet or if it failed.
> This patch removes unnecessary input_free_device calls.
>
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
> drivers/platform/x86/fujitsu-laptop.c | 21 ++++++++-------------
> 1 files changed, 8 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/platform/x86/fujitsu-laptop.c b/drivers/platform/x86/fujitsu-laptop.c
> index e325aeb..dab1a0e 100644
> --- a/drivers/platform/x86/fujitsu-laptop.c
> +++ b/drivers/platform/x86/fujitsu-laptop.c
> @@ -686,8 +686,10 @@ static int acpi_fujitsu_add(struct acpi_device *device)
> set_bit(KEY_UNKNOWN, input->keybit);
>
> error = input_register_device(input);
> - if (error)
> - goto err_free_input_dev;
> + if (error) {
> + input_free_device(input);
> + goto err_stop;
> + }
Instead of using mixed in-line and goto style cleanup I prefer doig the
following:
err_unregister_input_dev:
input_unregister_device(input);
input = NULL; <-- !!!
err_free_input_dev:
input_free_device(input);
input_free_device() happily accepts NULL pointers.
Otherwise the patch looks good.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2010-07-02 6:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 1:42 [PATCH] fujitsu-laptop: remove unnecessary input_free_device calls Axel Lin
2010-07-02 2:06 ` Jonathan Woithe
2010-07-02 6:20 ` Dmitry Torokhov [this message]
2010-07-02 7:20 ` Axel Lin
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=20100702061958.GA3691@core.coreip.homeip.net \
--to=dmitry.torokhov@gmail.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=axel.lin@gmail.com \
--cc=jwoithe@physics.adelaide.edu.au \
--cc=len.brown@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mjg@redhat.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=stefani@seibold.net \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox