From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.160 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796194240; b=ll/Zhq5hdiXs2Qys57abPasUQTAzlJNaG8+odHoD8kmR7Mq8FH3HwHdr3TsHie+ifs3O zIFIIt8uEeldvn1L5Gf6lVF5tt4hQHY/e3eQTEZ2XVs3HICJSibyfaCsQ6udDye0Nn5j9 2kvIvLHYgZa/BM5FvQRzlPmk34t9nzConC8MeVF+XWO/vGBbhqfrWaD1nkkBDgEyzZR3D wUYn8Ibl2HsF+F0D4ZInCki9mZdYAQWAnRDh8NNi1B807wK8LWd90gQS/X4sRIIBD3I4D hIgGksLIBFy4XBMLAjagVMiJFmsGsF2WcCf7TW11s8+w30U5z3T5GD3cc1xpyPCMJCg== 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=pHXA3Tmo9tV1TrIcPbtJzkgDg6gtTwB0YFxhZ+vufclCBhqtO3h15ehutciZ9Q5Svm6n nPeLwyNBkz9PEFi9W+0NVl7QtjW0tgU6USWNXxKqLUpegetccbMVOeWEg1w96tJT5H8XI AiY1Sxa+2iD8A8IJhJNiAxmuKXcM7YvgrTb6qr4793Ha1Izp/sL/NPWxsCZuh76XFw/Bm P/EzEx8jBcvXJdG65d03NRXc1sCpKyFMiZ3QImLC0tqttdfWC9+Xukt5R2X6PIeKpU5Yo 45mQiydfmdLs96+SYGQT3b0zE6XWSAItNv73nTSLAH6TA23iLo8QNvu89wC6mOSOtOg== 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=iKX7vbWE; arc=none smtp.remote-ip=91.218.175.160 Received: from mta0.migadu.com (out-160.mta0.migadu.com [91.218.175.160]) (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 EAD76606A32D for ; Wed, 2 Dec 2026 06:50:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EAD76606A32D 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=iKX7vbWE X-Envelope-To: linux-omap@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=1796194237; v=1; x=1796799037; b=iKX7vbWEJX0VySt4k9mYasNLITNLHJLGDeFI8/IsLb5iHW2v2f2tfMTjSeV3pOcCjq7qPTJz G1Ab8s73TWxfPpUZUscjeRFLpvqjhBzJrszUo9I8foYSO6Ot1ciCYj2ASTjU970hRmkCFpB7SxE QQt5aohAHqV43417Lfmb4pKo= X-Envelope-To: linux-omap@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-omap@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