From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.108 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796118376; b=dyO4VgOOG0UgLnu0rGAtWZ6P/435rTKSN8jd6pdpnnagKQWDAU1vO/zlFNoZhPb/vXCM tIWw/nTUvMMESS26BbqiRWh32kuIyoImfS2Wqtf0bUA8zOG6cAMkv2jKv/jdehk7l0GCn 20uGBYhQCvv04qne7d5Eo/Vr5fYd8CNUCu9f4V0GsepnOcjnVbD4IMlkVa2rtFKvMh0YD 4kbQFTWphX57vGneTp84ty7M/hjNz1A0r+GtuQT6KMPHhcjOkYzMDTSoG2HTb7T7S8W0+ YivFjSGF2jWm3YGDVH+szo4KVmKRRiLK14i3n3YklSB2a41AekoArzDXYDusfLsIuSg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796118376; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=19LMjn8Zgh8YD6gw5NtODr8zZxyfr6f6qPbfU3612mg=; b=CPP3KfqNPWGiq8+d0r/vTf1KCUXVzen6tKW8Jw87ogmG6iaxvS8GWiyvoIkU2PAruNyU spjQm+vTRzE5eUTEqtB+4pvrH1x3UE9Hkk5PAHJnOk45RFfmDvSSsAlNam5U5yxSAHOOA 4OT7yieJeaNSOUN5HbhIO7U2EBSzwIArdzaWulgqvkr1eAQVF2McTFVbdpEqcR/4hYInZ UU1ow5p2pP/nFw/JCos96OW9sxWWonsNxhip4IVe2ZVls5w9IzFRatI6ysFirgkxtopSw rQpbUl1ijRZj533u4bPxMul4/FLFWjkHKhn3g/Iwb9wpDhEUiNMs4IoPU7hzbOKflRQ== 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=a1zzNJsZ; arc=none smtp.remote-ip=95.215.58.108 Received: from mta1.migadu.com (out-108.mta1.migadu.com [95.215.58.108]) (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 349D6606A6BA for ; Tue, 1 Dec 2026 09:46:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 349D6606A6BA 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=a1zzNJsZ X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=eiTOdLpZ+u1sA5TxtcTuxu17HITtnZ6WVpyBl6tCtQQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796118373; v=1; x=1796723173; b=a1zzNJsZFMaNMor49OAzWol0hUAc1cuPztNOClgnslH+lwE+kFDfbgEDsLFudI3Npeco1u1Q E6ydFrNLE+azKONNeXWIlJr93KVobzP/w6s4utcLGgC++4l92AWDixRylG2nRKUXHpHiyDrVCjx KjQNqNMskTTQ6yOMRrMtE6mg= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 7079dd1b20096a9f; Tue, 01 Dec 2026 09:46:13 +0000 X-Mizu-Trace-ID: 7079dd1b20096a9f X-Migadu-Flow: FLOW_OUT From: Peng Fan Date: Tue, 01 Dec 2026 17:45:51 +0800 Subject: [PATCH 1/2] i2c: add subsys_i2c_driver() macro X-Mailing-List: linux-kernel@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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261201-add-i2c-subsys-mfd-v1-1-e7b1db408abf@nxp.com> References: <20261201-add-i2c-subsys-mfd-v1-0-e7b1db408abf@nxp.com> In-Reply-To: <20261201-add-i2c-subsys-mfd-v1-0-e7b1db408abf@nxp.com> To: 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 , Wolfram Sang Cc: 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 X-Mailer: b4 0.14.3 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 --- include/linux/i2c.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 6a847fc88d25..f26bb2e0ba0d 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -915,6 +915,29 @@ void i2c_del_driver(struct i2c_driver *driver); #define i2c_add_driver(driver) \ i2c_register_driver(THIS_MODULE, driver) +/* + * subsys_i2c_driver() - Helper macro for i2c drivers that don't do anything + * special in module init/exit but need to register 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) + +/* + * subsys_i2c_driver_probe() - Helper macro for drivers that don't do + * anything special in driver register and have no exit, but need to register + * earlier, at subsys_initcall level. This eliminates some boilerplate. Each + * driver may only use this macro once, and using it replaces subsys_initcall. + */ +#define subsys_i2c_driver_probe(__i2c_driver) \ +static int __init __i2c_driver##_init(void) \ +{ \ + return i2c_add_driver(&__i2c_driver); \ +} \ +subsys_initcall(__i2c_driver##_init) + static inline bool i2c_client_has_driver(struct i2c_client *client) { return !IS_ERR_OR_NULL(client) && client->dev.driver; -- 2.56.0