From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17F872862A1; Wed, 19 Feb 2025 10:13:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739959999; cv=none; b=decUiUzvOHP/DB4tNME6IdlpIxmFg7XiZxbpS3wa/1neOJQjeUAQiR1KbUkC4zuQH2TbVHBIQZAUF4d1eLvyjdg9HLbNyuY+rnKwktRMPd8Yoj1lPAarHioNx4BXu8tCou/5aO/DrW5qALbouTtdmseXC2URcv6HMdYF7lAuvQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739959999; c=relaxed/simple; bh=fMTgCZ4pkvP3/QIoF7iwpCmqEdcG6A1koNbMDvsj2dk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=aov2Bk8RY+eTZ4wflic/7PYWbkQDymoSSRkIEOJqvebmWRuk5R3WeHv2wi+BpxT6prqfkpFd6K1Y8hjux27ZYDdDzko4zlNkYmMMF16SzfvJCPmzL0WQOjfEPrqhKBhhq2JZbfTj34TK2DvP876ewxWKWGDQJptkN56sDm0MuJM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=LHj7SUL6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="LHj7SUL6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F40B3C4CED1; Wed, 19 Feb 2025 10:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1739959997; bh=fMTgCZ4pkvP3/QIoF7iwpCmqEdcG6A1koNbMDvsj2dk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LHj7SUL6hr9dnxeuMouAoZl+TqgPJkJnt6OxeGZBVnwjG1an8QfGZTZhAz67SUNMi V5LaRH/n8f0+cZvr3kZbgPWLsV3MQceZE5n+wYuzRWmC4ZHELcec25299VKUrxRVkD lwg+grq7xKKnKHBmMBQEKZrZR5rJUGwcEwJFWwx8= Date: Wed, 19 Feb 2025 11:13:14 +0100 From: Greg Kroah-Hartman To: Dmitry Baryshkov Cc: Jerome Brunet , Dave Ertman , Ira Weiny , "Rafael J. Wysocki" , Stephen Boyd , Arnd Bergmann , Danilo Krummrich , Conor Dooley , Daire McNamara , Philipp Zabel , Douglas Anderson , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Hans de Goede , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Bryan O'Donoghue , Vladimir Kondratiev , Gregory CLEMENT , =?iso-8859-1?Q?Th=E9o?= Lebrun , Michael Turquette , Abel Vesa , Peng Fan , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Kevin Hilman , Martin Blumenstingl , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, dri-devel@lists.freedesktop.org, platform-driver-x86@vger.kernel.org, linux-mips@vger.kernel.org, linux-clk@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org Subject: Re: [PATCH v4 1/8] driver core: auxiliary bus: add device creation helpers Message-ID: <2025021922-spongy-swirl-0746@gregkh> References: <20250218-aux-device-create-helper-v4-0-c3d7dfdea2e6@baylibre.com> <20250218-aux-device-create-helper-v4-1-c3d7dfdea2e6@baylibre.com> Precedence: bulk X-Mailing-List: linux-mips@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Feb 19, 2025 at 11:06:02AM +0200, Dmitry Baryshkov wrote: > On Tue, Feb 18, 2025 at 08:29:46PM +0100, Jerome Brunet wrote: > > Add helper functions to create a device on the auxiliary bus. > > > > This is meant for fairly simple usage of the auxiliary bus, to avoid having > > the same code repeated in the different drivers. > > > > Suggested-by: Stephen Boyd > > Cc: Arnd Bergmann > > Signed-off-by: Jerome Brunet > > --- > > drivers/base/auxiliary.c | 108 ++++++++++++++++++++++++++++++++++++++++++ > > include/linux/auxiliary_bus.h | 17 +++++++ > > 2 files changed, 125 insertions(+) > > > > diff --git a/drivers/base/auxiliary.c b/drivers/base/auxiliary.c > > index afa4df4c5a3f371b91d8dd8c4325495d32ad1291..a6d46c2759be81a0739f07528d5959c2a76eb8a8 100644 > > --- a/drivers/base/auxiliary.c > > +++ b/drivers/base/auxiliary.c > > @@ -385,6 +385,114 @@ void auxiliary_driver_unregister(struct auxiliary_driver *auxdrv) > > } > > EXPORT_SYMBOL_GPL(auxiliary_driver_unregister); > > > > +static void auxiliary_device_release(struct device *dev) > > +{ > > + struct auxiliary_device *auxdev = to_auxiliary_dev(dev); > > + > > + kfree(auxdev); > > +} > > + > > +/** > > + * auxiliary_device_create - create a device on the auxiliary bus > > + * @dev: parent device > > + * @modname: module name used to create the auxiliary driver name. > > + * @devname: auxiliary bus device name > > + * @platform_data: auxiliary bus device platform data > > + * @id: auxiliary bus device id > > + * > > + * Helper to create an auxiliary bus device. > > + * The device created matches driver 'modname.devname' on the auxiliary bus. > > + */ > > +struct auxiliary_device *auxiliary_device_create(struct device *dev, > > + const char *modname, > > + const char *devname, > > + void *platform_data, > > + int id) > > +{ > > + struct auxiliary_device *auxdev; > > + int ret; > > + > > + auxdev = kzalloc(sizeof(*auxdev), GFP_KERNEL); > > + if (!auxdev) > > + return NULL; > > + > > + auxdev->id = id; > > + auxdev->name = devname; > > + auxdev->dev.parent = dev; > > + auxdev->dev.platform_data = platform_data; > > + auxdev->dev.release = auxiliary_device_release; > > + device_set_of_node_from_dev(&auxdev->dev, dev); > > + > > + ret = auxiliary_device_init(auxdev); > > + if (ret) { > > + kfree(auxdev); > > + return NULL; > > + } > > + > > + ret = __auxiliary_device_add(auxdev, modname); > > + if (ret) { > > This loses possible error return values from __auxiliary_device_add(). Why does that really matter? > I'd suggest to return ERR_PTR(ret) here and in the > auxiliary_device_init() chunks and ERR_PTR(-ENOMEM) in case of kzalloc() > failure. Will the caller do something different based on the error value here? All we care is that this worked or not, the specific error isn't going to matter for device creation like this. thanks, greg k-h