From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.158 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796194240; b=14aggNgZHCJREq7ST/ZBpJr+rz8LIXtf6UZxcavu7teMrzMtf/cq+ob2wbR+fFLQwXjb b7DtbXxKx2nrurY19zSwcVS1XoftoxmNBXRGlt8zKGaGxYKMLQV984iw9fj8B6eHwxylb cn55h0Ta4INKsOwKYywYtGh4Tor7zSOEf0WWB1jv9py1OXF/xISqmjO7w7F/VgGKWQeAX LCpo7PrrFEh6IxrLeQ0kHsJs05OqpC5N2k3hlfVfYrsKBrhbJMIeI7/dkcJXeXyoGOazr C2rXXPJRYQa8OKkOSzhglpBK/mCgXienN5q0y3+6PuoNqseQMZGcv9RDllpTZ/BB+xA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796194240; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=uZlkUIMP0YEZEAD/BZBO1MJpZuT9Fk0NN93rf8pFTpo=; b=4Zi93ihY8e9q+lyWPE8iholtjgUeBW4Ned6GaFy2/3/5qTB7t6CAjsOeSL6TOED+a6Xi 4JJsQM9I5br+oGL6VZtj490v257U3NXTHZAsP/OL+DpdSAEGzQ/atpnUsbBrdt8DPhHYZ DSUpJF1WDUJfMFj+Lm9nP4vyeOYTh1XsBPVpXsBY4NoGIE+wGmNf6cVYkdQuSwsu7dqTg J8cswoTp5si2waKS65aNyguYIuwV7DRHK1aQudqgMr1To5rKosSLFTbaM6TbfeWmScC7r TsWQiPh61S6gSXysAsowZrYd8eqLMMTRcwghI58oTVbsoi+0/8tAaDL8uF8oWvgVg+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=QndhTOBo; arc=none smtp.remote-ip=91.218.175.158 Received: from mta0.migadu.com (out-158.mta0.migadu.com [91.218.175.158]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C265606A31A for ; Wed, 2 Dec 2026 06:50:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5C265606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=QndhTOBo X-Envelope-To: linux-i2c@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=hjRCaCcoteQl7+PU6NsoDPDP5rF5jC/wGviAOOChbl0=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796194236; v=1; x=1796799036; b=QndhTOBoaTWEhB+2gBPx+l9zfnXQwVy2HCAKyvwr2cDtHPaslMd1IR9TPkR4LuyTU0SL08N0 K7sF9FAevUxDgeXjBHTeqWoS0kJ+gPJ1AUPdUhZHNwIEsjVpHKW85vULDg3jVnxXapqKdArwRRc kWDoI3c6IwiCn5YZRH5b33M0= X-Envelope-To: linux-i2c@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 579a00c75dab3a81; Wed, 02 Dec 2026 06:50:31 +0000 X-Mizu-Trace-ID: 579a00c75dab3a81 X-Migadu-Flow: FLOW_OUT Date: Wed, 2 Dec 2026 14:50:18 +0800 From: Peng Fan To: Wolfram Sang Cc: Andi Shyti , Lee Jones , Support Opensource , Charles Keepax , Richard Fitzgerald , Chanwoo Choi , Krzysztof Kozlowski , Aaro Koskinen , Andreas Kemnade , Kevin Hilman , Roger Quadros , Tony Lindgren , Matti Vaittinen , linux-i2c@vger.kernel.org, mfd@lists.linux.dev, patches@opensource.cirrus.com, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Peng Fan Subject: Re: [PATCH 1/2] i2c: add subsys_i2c_driver() macro Message-ID: References: <20261201-add-i2c-subsys-mfd-v1-0-e7b1db408abf@nxp.com> <20261201-add-i2c-subsys-mfd-v1-1-e7b1db408abf@nxp.com> X-Mailing-List: linux-i2c@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Wolfram, On Tue, Dec 01, 2026 at 11:50:27PM +0100, Wolfram Sang wrote: >On Tue, Dec 01, 2026 at 05:45:51PM +0800, Peng Fan wrote: >> From: Peng Fan >> >> Add subsys_i2c_driver() and subsys_i2c_driver_probe() macros so that >> I2C drivers registered at the subsys_initcall() level can avoid the >> open-coded init/exit boilerplate. >> >> subsys_i2c_driver() replaces subsys_initcall() plus module_exit() for >> drivers that need an unregister path. subsys_i2c_driver_probe() replaces >> subsys_initcall() for drivers without an exit callback. >> >> Signed-off-by: Peng Fan > >Acked-by: Wolfram Sang > >Applied to my for-andi branch, thanks! Thanks for applying. Sashiko reported minor issue: https://sashiko.dev/#/message/sashiko-outbox-243018%40kernel.org I am thinking to use below simplied version, do you expect a V2 or the applied version is fine for you? Thanks Peng ------------------------------------------------------ Subject: [PATCH V2] i2c: add subsys_i2c_driver() macro Add subsys_i2c_driver() so that I2C drivers registered at the subsys_initcall() level can avoid the open-coded init/exit boilerplate. It replaces subsys_initcall() plus module_exit() and is a parallel of module_i2c_driver() with the init call promoted to subsys_initcall() when built in. Signed-off-by: Peng Fan --- include/linux/i2c.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 6a847fc88d25..c583fd1ab691 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -1020,6 +1020,19 @@ int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr); #define builtin_i2c_driver(__i2c_driver) \ builtin_driver(__i2c_driver, i2c_add_driver) +/** + * subsys_i2c_driver() - Helper macro for registering an I2C driver + * @__i2c_driver: i2c_driver struct + * + * Helper macro for I2C drivers which do not do anything special in their + * init/exit and need to be registered earlier, at subsys_initcall() level, + * when built in. This eliminates a lot of boilerplate. Each driver may only + * use this macro once, and calling it replaces subsys_initcall() and + * module_exit(). + */ +#define subsys_i2c_driver(__i2c_driver) \ + subsys_driver(__i2c_driver, i2c_add_driver, i2c_del_driver) + /* must call put_device() when done with returned i2c_client device */ struct i2c_client *i2c_find_device_by_fwnode(struct fwnode_handle *fwnode); -- 2.56.0