Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.246 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796204622; b=FC0QNydTcsrCcIejkNEmyirX7gr2hqMukxqHCSbIcmmWJxG1GX9FZcJhm7zTl3Sk/8Ul 2JFoLvv1jJegANomVfp1WDAeIk5bD8uh+KD2QvScvQEkTAogHnIWBGI+SFZSy61vhSis3 Y4hOs5PUoeS5Fkc2R+bu5a5AGfi+jnammkLGxlsr/Qd/0bLbtzl+XaZQmv6f5ku5t0oqd KqhCKR3JSe4Z5m9dlmoJ5QZA38D+LPS8tkSgoItxabW7+TXSC2nZlz3jk2vTYUQUfXOSc zgN1/eFvfGq8OYSgww5X6/MgRDuMAX2FM4yJy/J8IvGA8Via3YxKSnZ7r4asGCIVMlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796204622; 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:X-B4-Tracking: X-Change-ID:To:Cc:X-Mailer; bh=R05HnqT3r9eP7lfk1GCdHx/Z910cns06cbJnkzdGGDE=; b=4qP4/Gzwjz2Shx6/wHT4oWOdkfDfnGSPfSlmQPZlOfeURX4w3PKZMWDPxjsPmmexQB8T fib0aE26aOMRvakNU2tpGFjeQTSaVX0TbOWQS0cp/2YuQAyOTAuodX/4pWiPb+FCGq+2Z W2s8NzV+aGO70LlVSeY120+vRxV4WSIpddp58Gga0nHHDsk8ugr3bggT85SQbzBqzUH7t 0ROA+Wa9M/OXSncfegaMlXFmhBIhIjQdKkP21qZRhstYQ73mrRf2mwXExZFr5FqCnkz2K Kz0Os9a91l3jE4gjWPRLxCPkK2+XpVn9wPSz+revtXdKAiB0OUaAJVLRN1ufzDlQKCw== 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=cwjpBkEz; arc=none smtp.remote-ip=95.215.58.246 Received: from mta1.migadu.com (out-246.mta1.migadu.com [95.215.58.246]) (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 75EE8606A322 for ; Wed, 2 Dec 2026 09:43:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 75EE8606A322 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=cwjpBkEz X-Envelope-To: linux-i2c@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=DUwkSwTgErnIGUk4ZtmaHWQjrIrN85jLKsuJh7xweOo=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796204619; v=1; x=1796809419; b=cwjpBkEzB9UgbMmaztO3NBooJrX7Mw1F2N5MQs5N/pcuHfPngDXbLnrst0NWKiZp2+4ZvbaR dVr8xtnJdm+lWsdv0x5p/489bQ5UdKeUm8zwOCcPnJoaXGQcYVqss+EgCm5IAxMsDKYG/meH/rO OYEq5A+ufpwqi7uACgUZFJ3M= X-Envelope-To: linux-i2c@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 3dc17fac8ff2e81e; Wed, 02 Dec 2026 09:43:39 +0000 X-Mizu-Trace-ID: 3dc17fac8ff2e81e X-Migadu-Flow: FLOW_OUT From: Peng Fan Date: Wed, 02 Dec 2026 17:43:21 +0800 Subject: [PATCH v2] i2c: add subsys_i2c_driver() macro 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-add-i2c-subsys-mfd-v2-1-56f2cb2ac752@nxp.com> X-B4-Tracking: v=1; b=H4sIAAAAAAAC/32NOw7CMBAFrxJtzSLbghBRcQ+Uwl+yRezIC1aiy HfH5ACUM9KbtwP7TJ7h3u2QfSGmFBuoUwd20vHlkVxjUEL1UgmJ2jkkZZE/hjfGOThs3jpzDf2 gJbThkn2g9Yg+x8YT8Tvl7fgo8mf/5opEgf5mpDMXMWgTHnFdzjbNMNZav9VlAj+yAAAA X-Change-ID: 20261201-add-i2c-subsys-mfd-120cdb5f68a1 To: Andi Shyti , Wolfram Sang , Lee Jones Cc: linux-i2c@vger.kernel.org, mfd@lists.linux.dev, Peng Fan X-Mailer: b4 0.14.3 From: Peng Fan 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 --- Changes in v2: - Drop subsys_i2c_driver_probe. - I drop the mfd patch in this version, and shrink the To/Cc list. will repost mfd after this patch land in upstream. And I will also convert other subsystem drivers to use this new helper later. - Link to v1: https://lore.kernel.org/r/20261201-add-i2c-subsys-mfd-v1-0-e7b1db408abf@nxp.com --- 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); --- base-commit: e5aad2bdbbee783611d32599f89cea3f12f9593d change-id: 20261201-add-i2c-subsys-mfd-120cdb5f68a1 Best regards, -- Peng Fan