mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthias Brugger <mbrugger@suse.com>
To: "Rafał Miłecki" <zajec5@gmail.com>
Cc: "Richard Purdie" <rpurdie@rpsys.net>,
	"Jacek Anaszewski" <j.anaszewski@samsung.com>,
	"Felipe Balbi" <balbi@kernel.org>,
	"Peter Chen" <hzpeterchen@gmail.com>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"Jonathan Corbet" <corbet@lwn.net>,
	"Ezequiel Garcia" <ezequiel@vanguardiasur.com.ar>,
	"Boris Brezillon" <boris.brezillon@free-electrons.com>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Stephan Linz" <linz@li-pro.net>,
	"open list:DOCUMENTATION" <linux-doc@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	"open list:LED SUBSYSTEM" <linux-leds@vger.kernel.org>
Subject: Re: [PATCH V3] leds: trigger: Introduce an USB port trigger
Date: Wed, 24 Aug 2016 13:27:50 +0200	[thread overview]
Message-ID: <6beb372b-cc66-0d7b-0111-19a1217f7833@suse.com> (raw)
In-Reply-To: <CACna6rxz1xV7K__3w+8LM2QO47CC634K4t1iQXPjLADNi-8ObA@mail.gmail.com>



On 24/08/16 13:02, Rafał Miłecki wrote:
> On 24 August 2016 at 12:49, Matthias Brugger <mbrugger@suse.com> wrote:
>> On 24/08/16 00:03, Rafał Miłecki wrote:

[...]

>>> +static int usbport_trig_notify(struct notifier_block *nb, unsigned long
>>> action,
>>> +                              void *data)
>>> +{
>>> +       struct usbport_trig_data *usbport_data =
>>> +               container_of(nb, struct usbport_trig_data, nb);
>>> +       struct led_classdev *led_cdev = usbport_data->led_cdev;
>>> +
>>> +       switch (action) {
>>> +       case USB_DEVICE_ADD:
>>> +               if (usbport_trig_usb_dev_observed(usbport_data, data)) {
>>
>>
>> Maybe we should switch this and fist see if the usbport is observed before
>> evaluating the action. Also cast data to "struct usb_device *" to make that
>> clear.
>
> I'm aware there is one duplicated line of code, I did to first
> evaluate very quick test (checking unsigned long value), then iterate
> over ports & keep only 1 switch block. I could move
> usbport_trig_usb_dev_observed call up, but it would be executed for
> other actions as well (currently just USB_BUS_ADD and USB_BUS_REMOVE).
>

Ok. I'm a USB noop but from my understanding the notifier is only called 
when a device or a hub gets added/removed. So this shouldn't happen that 
much. Therefor it has no impact if we check if the usb device is in the 
observer list for all actions.

>
>>> +                       if (usbport_data->count++ == 0)
>>
>>
>> I'm a bit puzzled. I think:
>> if (++usbport_data->count > 0)
>> makes this more consistent with the remove case.
>
> Your condition would be always true (as we don't use negative
> numbers). The point is to enable LED only if it was disabled before.
> So I need to increase counter unconditionally but enable LED only if
> initial value (before increasing it) was 0.
>

Got it. My personal opinion is, that adding one line for 
incrementing/decrementing the counter would help to make this 
crystal-clear to everyone (at least to me :)

Cheers,
Matthias

>
>>> +module_init(usbport_trig_init);
>>> +module_exit(usbport_trig_exit);
>>> +
>>> +MODULE_AUTHOR("Rafał Miłecki <rafal@milecki@pl>");
>>
>>
>> Nit: rafal@milecki.pl
>
> Oops, thanks!
>

  reply	other threads:[~2016-08-24 11:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 22:03 Rafał Miłecki
2016-08-24  9:21 ` Greg KH
2016-08-24  9:26   ` Rafał Miłecki
2016-08-24 21:04     ` Greg KH
2016-08-24  9:22 ` Greg KH
2016-08-24  9:29   ` Rafał Miłecki
2016-08-24 21:04     ` Greg KH
2016-08-25  5:14       ` Rafał Miłecki
2016-08-25 12:53         ` Greg KH
2016-08-25 18:39           ` Bjørn Mork
2016-08-25 20:55             ` Greg KH
2016-08-24 10:49 ` Matthias Brugger
2016-08-24 11:02   ` Rafał Miłecki
2016-08-24 11:27     ` Matthias Brugger [this message]
2016-08-24 17:52 ` [PATCH RFC V3.5] " Rafał Miłecki
2016-08-24 18:48   ` Bjørn Mork
2016-08-24 20:42     ` Rafał Miłecki
2016-08-25  8:03   ` Jacek Anaszewski
2016-08-25  8:27     ` Matthias Brugger
2016-08-25  8:29     ` Rafał Miłecki
2016-08-25  9:04       ` Jacek Anaszewski
2016-08-25 14:30         ` Alan Stern
2016-08-25 18:48           ` Jacek Anaszewski
2016-08-25 19:35             ` Alan Stern
2016-08-25 20:08               ` Alan Stern
2016-08-26 15:58             ` Rafał Miłecki
2016-08-29  7:41               ` Jacek Anaszewski
2016-08-29  8:05                 ` Pavel Machek
2016-08-29  8:21                   ` Rafał Miłecki
2016-08-29  8:41                     ` Pavel Machek
2016-08-29  9:01                       ` Rafał Miłecki
2016-08-26 19:50             ` Pavel Machek
2016-08-29  8:29               ` Jacek Anaszewski
2016-08-26 19:48         ` Pavel Machek
2016-08-25  8:32     ` Rafał Miłecki

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=6beb372b-cc66-0d7b-0111-19a1217f7833@suse.com \
    --to=mbrugger@suse.com \
    --cc=balbi@kernel.org \
    --cc=boris.brezillon@free-electrons.com \
    --cc=corbet@lwn.net \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=geert@linux-m68k.org \
    --cc=hzpeterchen@gmail.com \
    --cc=j.anaszewski@samsung.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linz@li-pro.net \
    --cc=rafal@milecki.pl \
    --cc=rpurdie@rpsys.net \
    --cc=zajec5@gmail.com \
    /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

all inboxes | Powered by JetHome®