[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2025020710-tree-greedless-65bd@gregkh>
Date: Fri, 7 Feb 2025 10:16:06 +0100
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Zijun Hu <quic_zijuhu@...cinc.com>
Cc: linux-kernel@...r.kernel.org, "Rafael J. Wysocki" <rafael@...nel.org>,
Danilo Krummrich <dakr@...nel.org>, Lyude Paul <lyude@...hat.com>,
Alexander Lobakin <aleksander.lobakin@...el.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Liam Girdwood <lgirdwood@...il.com>, Lukas Wunner <lukas@...ner.de>,
Mark Brown <broonie@...nel.org>,
MaĆra Canal <mairacanal@...eup.net>,
Robin Murphy <robin.murphy@....com>,
Simona Vetter <simona.vetter@...ll.ch>, linux-usb@...r.kernel.org,
rust-for-linux@...r.kernel.org
Subject: Re: [PATCH v3 1/8] driver core: add a faux bus for use when a simple
device/bus is needed
On Fri, Feb 07, 2025 at 10:54:38AM +0800, Zijun Hu wrote:
> On 2/7/2025 1:38 AM, Greg Kroah-Hartman wrote:
> > +#include "base.h"
> > +
> > +#define MAX_FAUX_NAME_SIZE 256 /* Max size of a faux_device name */
>
> Remove this macro?
>
> > ++ */
>
> <snip>
>
> > +struct faux_device *faux_device_create_with_groups(const char *name,
> > + const struct faux_device_ops *faux_ops,
> > + const struct attribute_group **groups)
> > +{
> > + struct device *dev;
> > + struct faux_object *faux_obj;
> > + struct faux_device *faux_dev;
> > + int name_size;
>
> Remove @name_size?
>
> > + int ret;
> > +
> > + name_size = strlen(name);
> > + if (name_size > MAX_FAUX_NAME_SIZE)
> > + return NULL;
> > +
>
> Remove above block related to @name_size
>
> > + faux_obj = kzalloc(sizeof(*faux_obj) + name_size + 1, GFP_KERNEL);
>
> faux_obj = kzalloc(sizeof(*faux_obj), GFP_KERNEL);
Yes to all above, I forgot to rip that out when I dropped the name
logic, good catch.
> > ++int __init faux_bus_init(void)
> > +{
> > + int ret;
> > +
> > + ret = device_register(&faux_bus_root);
> > + if (ret) {
> > + put_device(&faux_bus_root);
> > + return ret;
> > + }
> > +
> > + ret = bus_register(&faux_bus_type);
> > + if (ret)
> > + goto error_bus;
> > +
> > + ret = driver_register(&faux_driver);
> > + if (ret)
> > + goto error_driver;
> > +
> > + return ret;
>
> return 0;
Nah, this is a common pattern, it's fine as-is.
thanks,
greg k-h
Powered by blists - more mailing lists