[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <333fae36f2332b705320186c2068e1236c9d1142.camel@hexdev.de>
Date: Thu, 09 May 2024 19:06:19 +0200
From: Christoph Fritz <christoph.fritz@...dev.de>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Oliver Hartkopp <socketcan@...tkopp.net>, Marc Kleine-Budde
<mkl@...gutronix.de>, Jiri Slaby <jirislaby@...nel.org>, Vincent Mailhol
<mailhol.vincent@...adoo.fr>, "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo
Abeni <pabeni@...hat.com>, Rob Herring <robh@...nel.org>, Krzysztof
Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Jiri
Kosina <jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>,
Sebastian Reichel <sre@...nel.org>, Linus Walleij
<linus.walleij@...aro.org>, Andreas Lauser
<andreas.lauser@...cedes-benz.com>, Jonathan Corbet <corbet@....net>, Pavel
Pisa <pisa@....felk.cvut.cz>, linux-can@...r.kernel.org, Netdev
<netdev@...r.kernel.org>, devicetree@...r.kernel.org,
linux-input@...r.kernel.org, linux-serial <linux-serial@...r.kernel.org>
Subject: Re: [PATCH v3 01/11] can: Add LIN bus as CAN abstraction
On Wed, 2024-05-08 at 19:48 +0100, Greg Kroah-Hartman wrote:
> On Wed, May 08, 2024 at 08:20:51PM +0200, Christoph Fritz wrote:
> > ...
> > > ...
> > > > > > +static int lin_create_sysfs_id_files(struct net_device *ndev)
> > > > > > +{
> > > > > > + struct lin_device *ldev = netdev_priv(ndev);
> > > > > > + struct kobj_attribute *attr;
> > > > > > + int ret;
> > > > > > +
> > > > > > + for (int id = 0; id < LIN_NUM_IDS; id++) {
> > > > > > + ldev->sysfs_entries[id].ldev = ldev;
> > > > > > + attr = &ldev->sysfs_entries[id].attr;
> > > > > > + attr->attr.name = kasprintf(GFP_KERNEL, "%02x", id);
> > > > > > + if (!attr->attr.name)
> > > > > > + return -ENOMEM;
> > > > > > + attr->attr.mode = 0644;
> > > > > > + attr->show = lin_identifier_show;
> > > > > > + attr->store = lin_identifier_store;
> > > > > > +
> > > > > > + sysfs_attr_init(&attr->attr);
> > > > > > + ret = sysfs_create_file(ldev->lin_ids_kobj, &attr->attr);
> > > > > > + if (ret) {
> > > > > > + kfree(attr->attr.name);
> > > > > > + return -ENOMEM;
> > > > > > + }
> > > > > > + }
> > > > > > +
> > > > > > + return 0;
> > > > > > +}
> > > > >
> > > > > Can you use .dev_groups instead ?
> > > >
> > > > I'm not sure where to attach this in this glue code here. Should I do a
> > > > class_register() and add the .dev_groups there?
> > >
> > > I guess struct class would be correct direction but I'm not sure if it's
> > > viable in this case. It would avoid the need for custom sysfs setup code
> > > if it's workable.
> >
> > I just tried to find a way, but these are 64 sysfs files and declaring
> > them all static looks a bit odd to me. I might be missing something
> > here.
> >
> > For v4 I would stick to the dynamic setup and fix the rollback.
> >
> > Any objections?
>
> Yes, you race with userspace and loose by trying to do this "by hand".
> Make this static please.
OK, static init coming up in v4
thanks
-- Christoph
Powered by blists - more mailing lists