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


Groups > linux.kernel > #1660031

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

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Dmitry Torokhov <dmitry.torokhov@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends
Date Wed, 07 Jun 2017 19:20:01 +0200
Message-ID <tPMMF-14L-1@gated-at.bofh.it> (permalink)
References <qpglX-5iu-7@gated-at.bofh.it> <qpjaa-70R-11@gated-at.bofh.it> <qpjDc-7r6-27@gated-at.bofh.it> <qs1A6-4xx-7@gated-at.bofh.it> <qs66K-7Gm-3@gated-at.bofh.it>
X-Original-To Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=CP8n2SEtZwcbg4AdX6fq/NYXlkaTRGUFpxz4TuS/2Fo=; b=eKphi4wTnp5midWuJ/E4Sx3SnsbIydzGCgJFbhbJkF/0B6XN3BPfCusYhtQqb+jm6f weXQLW1jThzz0SvhjjxgEOg+UXMxYc/TCirLiPIkxTjkSKzbhPSyFiqrl9J6TiCxDbFb JxroeI37eTfnfb/6kZpiUPTyb6XBoKkrbotFBHr3YAsExTEE7cUZjQGt/rRS1XVpXgZG ThJxDzM9dn4L2XjiTV6cSraEVInX/wUWUJHRAG78KAv7ny3AJ/q3uMEowTL26LNVXv9H HJR4bArcL6+9bjtKHJeHNP7bAwXrv9g3JBKr0bHtDVTDNshePbEJRD0eEyJvyJY7g6Vq UNlw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=CP8n2SEtZwcbg4AdX6fq/NYXlkaTRGUFpxz4TuS/2Fo=; b=sdaNEBbUxRA+crGluKPs9aLmp4PhTkJD9IVdQdI2YUV9J5I70HHZf6pt+vIWe98Faj z423GJDQRzDxDLGD1eJWB5sJyVj2aKHIjiXnVNbkLNsF0k1xd7MCbVxM1FgddvhZmJyB RYcO/uwubwIxjbGWDJPxIrXIbKOAjbn4Nmu1vu6nyiO11PHkifB5YxrVwXHlgJjdOOcD 5MqiE5SRjM1leZ+qrlFSDJKm+aoLAOlgtwjM1dbOSDx6N65bZvA6Dsg10q7r+0TYoSIl l4pNKnotYXve9ji0bpwHK4HTfBN0ohS3bpdnCRNDLdSZy7ZLVSS9k2HtNiZhvTmmyUnV veLg==
X-Gm-Message-State AODbwcAkaiMNFgY+kzPyq8KVgKkjjwXh1gUm7EAOWmNN6SRDgGIIFGcC qoHj0FJkUF3VGA==
X-Received by 10.98.88.196 with SMTP id m187mr17079851pfb.87.1496855531920; Wed, 07 Jun 2017 10:12:11 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.5.21 (2010-09-15)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 52
Organization linux.* mail to news gateway
X-Original-Cc htejun@gmail.com, linux-kernel@vger.kernel.org
X-Original-Date Wed, 7 Jun 2017 10:12:08 -0700
X-Original-Message-ID <20170607171208.GD13116@dtor-ws>
X-Original-References <20151030114706.GA2243@localhost> <20151030144037.GC27072@kroah.com> <20151030151311.GA20183@dtor-pixel> <20151107002407.GD28499@kroah.com> <20151107072337.GA12209@dtor-ws>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1660031

Show key headers only | View raw


On Fri, Nov 06, 2015 at 11:23:37PM -0800, Dmitry Torokhov wrote:
> On Fri, Nov 06, 2015 at 04:24:07PM -0800, Greg Kroah-Hartman wrote:
> > On Fri, Oct 30, 2015 at 08:13:11AM -0700, Dmitry Torokhov wrote:
> > > 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).
> > 
> > bound/unbound makes a bit more sense, maybe that would work, haven't
> > thought that much about it.  Given that no one in the "real world" seem
> > to notice the race condition, that means that people aren't really using
> > tools like libudev to read sysfs attributes, so maybe no one even cares
> > about the contents of them :)
> 
> Could be, or they have workarounds for this scenario.

So I have another concrete use-case for this feature: firmware updating.

Several touch controllers may come up in either normal (application) or
boot mode, depending on whether firmware/configuration is corrupted or
not when they are powered on. In boot mode we do not create input
device instance (because we do not necessarily know the characteristics
of the input device in question).

I would like to have firmware update scripts to be fired via udev. The
scripts would check the current firmware version and state of the device
and decide whether they need to update firmware or not. To do that they
need to have driver bound to the physical device (i2c or spi), and
therefore I can't rely on ADD events as those happen too early. Having
the BOUND/UNBOUND events will allow me to do this cleanly.

I will look into using this mechanism on chrome OS.

Thanks.

-- 
Dmitry

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


Thread

Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-06-07 19:20 +0200
  Re: [PATCH] sysfs: add devm_sysfs_create_group() and friends Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-06-18 02:30 +0200

csiph-web