All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@infradead.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "Alex Hung" <alex.hung@canonical.com>,
	"Platform Driver" <platform-driver-x86@vger.kernel.org>,
	"Pali Rohár" <pali.rohar@gmail.com>
Subject: Re: [PATCH][V2] intel-hid: support 5 array button
Date: Thu, 16 Feb 2017 18:43:12 -0800	[thread overview]
Message-ID: <20170217024312.GE6814@wisp> (raw)
In-Reply-To: <CAHp75VcppJdTqXXK3aVzkOk_d4hnVFc-4ZpSiHJHGjJOBSKMTQ@mail.gmail.com>

On Thu, Feb 09, 2017 at 09:56:06PM +0200, Andy Shevchenko wrote:
> On Thu, Feb 9, 2017 at 5:09 AM, Alex Hung <alex.hung@canonical.com> wrote:
> > On Thu, Feb 9, 2017 at 10:22 AM, Darren Hart <dvhart@infradead.org> wrote:
> >> On Sat, Feb 04, 2017 at 04:58:33PM +0200, Andy Shevchenko wrote:
> >>> On Sat, Feb 4, 2017 at 3:14 AM, Darren Hart <dvhart@infradead.org> wrote:
> >>> > On Thu, Jan 26, 2017 at 03:33:01PM +0800, Alex Hung wrote:
> >>> >> New firmwares include a feature called 5 button array that supports
> >>> >> super key, volume up/down, rotation lock and power button. Especially,
> >>> >> support for this feature is required to fix power button on some recent
> >>> >> systems.
> 
> >>> >> +     ret = input_register_device(priv->array);
> >>> >> +     if (ret)
> >>> >> +             goto err_free_array_device;
> >>> >> +
> >>> >> +     return 0;
> >>> >> +
> >>> >> +err_free_array_device:
> >>> >> +     input_free_device(priv->array);
> >>> >> +     return ret;
> >>> >
> >>> > This return path is more complex than it could be, since you test for ret before
> >>> > return anyway:
> >>> >
> >>> >  out:
> >>> >  if (ret)
> >>> >          input_free_device(priv->array);
> >>> >  return ret;
> >>> >
> >>> > There is no need for a second return point that I can see. Same for the
> >>> > hid_input_setup function. We can remove 8 lines.
> >>>
> >>> Darren, if I didn't miss anything the function is purely used in
> >>> ->probe() path and thus devm_ version of input_allocate_device() would
> >>> make this error path gone.
> 
> >> These are optional input devices for the driver, so if I understand the
> >> semantics of devm_ correctly, the input device would remain allocated until such
> >> time as the driver is unloaded or if it fails to bind - which for systems with
> >> intel-hid, but no 5 button array, the unused input device would remain allocated
> >> until system shutdown.
> >>
> >> Alex, is that correct?
> >
> > Yes, the input device will be only allocated if 5 button array is
> > supported. Previous firmware that does not support 5 button array
> > won't be affected.
> 
> I guess there is a misunderstanding.
> 
> >From code I see that
> 1. input_allocate_device() is called only at ->probe() and only for
> devices that *have* 5 button HID array.
> 2. Time of live of allocated device is until device driver unbound or unloaded.

It's not critical, and I've applied v3. But, my point was that the driver will
not become unbound or unloaded just because the 5 button array input_setup fails
at some point, such as with the keymap_setup. In this case, if devm is used and
keymap_setup fails, the driver will remain loaded without 5 button array
support, and the input device will remain allocated, but unused.

The error path is definitely cleaner using devm, but it can leave an unused
input device allocated in error cases - although, perhaps such a situation is
rare enough that the advantages of devm make it the better choice.

So, I'm fine with the v3 Alex sent using devm.

-- 
Darren Hart
Intel Open Source Technology Center

  reply	other threads:[~2017-02-17  2:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-26  7:33 [PATCH][V2] intel-hid: support 5 array button Alex Hung
2017-01-27 14:16 ` Michał Kępień
2017-02-04  1:14 ` Darren Hart
2017-02-04  1:26   ` Darren Hart
2017-02-04 16:06     ` Pali Rohár
2017-02-08  7:21       ` Michał Kępień
2017-02-08  8:17         ` Pali Rohár
2017-02-08  9:05           ` Alex Hung
2017-02-08  9:07             ` Pali Rohár
2017-02-04 14:58   ` Andy Shevchenko
2017-02-09  2:22     ` Darren Hart
2017-02-09  3:09       ` Alex Hung
2017-02-09 19:56         ` Andy Shevchenko
2017-02-17  2:43           ` Darren Hart [this message]
2017-02-08  8:54   ` Alex Hung
2017-02-13 11:43     ` Michał Kępień
2017-02-13 23:23       ` Andy Shevchenko
2017-02-14  0:06         ` Alex Hung

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=20170217024312.GE6814@wisp \
    --to=dvhart@infradead.org \
    --cc=alex.hung@canonical.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=pali.rohar@gmail.com \
    --cc=platform-driver-x86@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.