Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1259573

Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends

From Dmitry Torokhov <dmitry.torokhov@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends
Date 2015-10-30 16:20 +0100
Message-ID <qpjDc-7r6-27@gated-at.bofh.it> (permalink)
References <qpglX-5iu-7@gated-at.bofh.it> <qpjaa-70R-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Oct 30, 2015 at 07:40:37AM -0700, Greg Kroah-Hartman wrote:
> On Fri, Oct 30, 2015 at 04:47:06AM -0700, Dmitry Torokhov wrote:
> > Many drivers create additional driver-specific device attributes when
> > binding to the device and providing managed version of sysfs_create_group()
> > will simplify unbinding and error handling in probe path for such drivers.
> 
> But they really shouldn't, because if they do this, they have raced
> userspace and tools don't know that the files are present.
> 
> I don't want to encourage drivers to do this at all, so I don't want to
> make it easier for them to do things incorrectly.

The solution is not to forbid drivers from establishing attributes but
rather notify userspace when device is fully bound to the driver. Then
userspace that actually cares about these attributes will listen to
proper events.

We can either do KOBJ_BOUND/KOBJ_UNBOUND or reuse
KOBJ_ONLINE/KOBJ_OFFLINE. I'd prefer the former (adding new events).

> 
> Yes, I know that input does this for its devices, but I still think it
> is wrong and should be changed.  Let's not let this problem spread to
> other subsystems please.

Like HID, chargers, hwmon, wireless drivers, leds, backlights, platform
drivers and so on? Where are platform devices supposed to create their
attributes? There are more than 300 drivers that add new groups and 581
instance of device_create_file().

Let's be realistic here and see that additional attributes are not going
anywhere and adding devm interface just helps getting error handling
right.

Thanks.

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] sysfs: add devm_sysfs_create_group() and friends Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-10-30 12:50 +0100
  Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-10-30 15:50 +0100
    Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-10-30 16:20 +0100
      Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2015-11-07 03:40 +0100
        Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2015-11-07 08:30 +0100

csiph-web