From nobody Tue Apr 7 06:23:39 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26422C433FE for ; Wed, 12 Oct 2022 17:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiJLRze (ORCPT ); Wed, 12 Oct 2022 13:55:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbiJLRz2 (ORCPT ); Wed, 12 Oct 2022 13:55:28 -0400 Received: from 5.mo583.mail-out.ovh.net (5.mo583.mail-out.ovh.net [87.98.173.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AEC16FA24 for ; Wed, 12 Oct 2022 10:55:25 -0700 (PDT) Received: from player691.ha.ovh.net (unknown [10.111.172.33]) by mo583.mail-out.ovh.net (Postfix) with ESMTP id 8D34B24DE3 for ; Wed, 12 Oct 2022 17:55:24 +0000 (UTC) Received: from sk2.org (82-65-25-201.subs.proxad.net [82.65.25.201]) (Authenticated sender: steve@sk2.org) by player691.ha.ovh.net (Postfix) with ESMTPSA id 069F92FB3C813; Wed, 12 Oct 2022 17:55:09 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-104R00506d95ab5-9e13-4dff-b839-e211efc44e30, 75377E6B882747309559AE06BD3DFEEF97A89409) smtp.auth=steve@sk2.org X-OVh-ClientIp: 82.65.25.201 From: Stephen Kitt To: Andrew Lunn , Vivien Didelot , Florian Fainelli , Vladimir Oltean , Woojung Huh , UNGLinuxDriver@microchip.com, George McCollister Cc: Stephen Kitt , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers/net/dsa: use simple i2c probe Date: Wed, 12 Oct 2022 19:55:06 +0200 Message-Id: <20221012175506.3938001-1-steve@sk2.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 18414092980370638555 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrfeejkedguddvtdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpefuthgvphhhvghnucfmihhtthcuoehsthgvvhgvsehskhdvrdhorhhgqeenucggtffrrghtthgvrhhnpeelgeetueejffejfeejvefhtddufeejgfetleegtddukeelieelvddvteduveejtdenucfkphepuddvjedrtddrtddruddpkedvrdeihedrvdehrddvtddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeoshhtvghvvgesshhkvddrohhrgheqpdhnsggprhgtphhtthhopedupdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdfovfetjfhoshhtpehmohehkeefpdhmohguvgepshhmthhpohhuth Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" All these drivers have an i2c probe function which doesn't use the "struct i2c_device_id *id" parameter, so they can trivially be converted to the "probe_new" style of probe with a single argument. This is part of an ongoing transition to single-argument i2c probe functions. Old-style probe functions involve a call to i2c_match_id: in drivers/i2c/i2c-core-base.c, /* * When there are no more users of probe(), * rename probe_new to probe. */ if (driver->probe_new) status =3D driver->probe_new(client); else if (driver->probe) status =3D driver->probe(client, i2c_match_id(driver->id_table, clie= nt)); else status =3D -EINVAL; Drivers which don't need the second parameter can be declared using probe_new instead, avoiding the call to i2c_match_id. Drivers which do can still be converted to probe_new-style, calling i2c_match_id themselves (as is done currently for of_match_id). This change was done using the following Coccinelle script, and fixed up for whitespace changes: @ rule1 @ identifier fn; identifier client, id; @@ - static int fn(struct i2c_client *client, const struct i2c_device_id *id) + static int fn(struct i2c_client *client) { ...when !=3D id } @ rule2 depends on rule1 @ identifier rule1.fn; identifier driver; @@ struct i2c_driver driver =3D { - .probe + .probe_new =3D ( fn | - &fn + fn ) , }; Signed-off-by: Stephen Kitt --- drivers/net/dsa/lan9303_i2c.c | 5 ++--- drivers/net/dsa/microchip/ksz9477_i2c.c | 5 ++--- drivers/net/dsa/xrs700x/xrs700x_i2c.c | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/lan9303_i2c.c b/drivers/net/dsa/lan9303_i2c.c index 7d746cd9ca1b..1cb41c36bd47 100644 --- a/drivers/net/dsa/lan9303_i2c.c +++ b/drivers/net/dsa/lan9303_i2c.c @@ -29,8 +29,7 @@ static const struct regmap_config lan9303_i2c_regmap_conf= ig =3D { .cache_type =3D REGCACHE_NONE, }; =20 -static int lan9303_i2c_probe(struct i2c_client *client, - const struct i2c_device_id *id) +static int lan9303_i2c_probe(struct i2c_client *client) { struct lan9303_i2c *sw_dev; int ret; @@ -106,7 +105,7 @@ static struct i2c_driver lan9303_i2c_driver =3D { .name =3D "LAN9303_I2C", .of_match_table =3D of_match_ptr(lan9303_i2c_of_match), }, - .probe =3D lan9303_i2c_probe, + .probe_new =3D lan9303_i2c_probe, .remove =3D lan9303_i2c_remove, .shutdown =3D lan9303_i2c_shutdown, .id_table =3D lan9303_i2c_id, diff --git a/drivers/net/dsa/microchip/ksz9477_i2c.c b/drivers/net/dsa/micr= ochip/ksz9477_i2c.c index 3763930dc6fc..d4f4ceb11e86 100644 --- a/drivers/net/dsa/microchip/ksz9477_i2c.c +++ b/drivers/net/dsa/microchip/ksz9477_i2c.c @@ -14,8 +14,7 @@ =20 KSZ_REGMAP_TABLE(ksz9477, not_used, 16, 0, 0); =20 -static int ksz9477_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *i2c_id) +static int ksz9477_i2c_probe(struct i2c_client *i2c) { struct regmap_config rc; struct ksz_device *dev; @@ -120,7 +119,7 @@ static struct i2c_driver ksz9477_i2c_driver =3D { .name =3D "ksz9477-switch", .of_match_table =3D of_match_ptr(ksz9477_dt_ids), }, - .probe =3D ksz9477_i2c_probe, + .probe_new =3D ksz9477_i2c_probe, .remove =3D ksz9477_i2c_remove, .shutdown =3D ksz9477_i2c_shutdown, .id_table =3D ksz9477_i2c_id, diff --git a/drivers/net/dsa/xrs700x/xrs700x_i2c.c b/drivers/net/dsa/xrs700= x/xrs700x_i2c.c index 54065cdedd35..14ff6887a225 100644 --- a/drivers/net/dsa/xrs700x/xrs700x_i2c.c +++ b/drivers/net/dsa/xrs700x/xrs700x_i2c.c @@ -76,8 +76,7 @@ static const struct regmap_config xrs700x_i2c_regmap_conf= ig =3D { .val_format_endian =3D REGMAP_ENDIAN_BIG }; =20 -static int xrs700x_i2c_probe(struct i2c_client *i2c, - const struct i2c_device_id *i2c_id) +static int xrs700x_i2c_probe(struct i2c_client *i2c) { struct xrs700x *priv; int ret; @@ -148,7 +147,7 @@ static struct i2c_driver xrs700x_i2c_driver =3D { .name =3D "xrs700x-i2c", .of_match_table =3D of_match_ptr(xrs700x_i2c_dt_ids), }, - .probe =3D xrs700x_i2c_probe, + .probe_new =3D xrs700x_i2c_probe, .remove =3D xrs700x_i2c_remove, .shutdown =3D xrs700x_i2c_shutdown, .id_table =3D xrs700x_i2c_id, base-commit: 833477fce7a14d43ae4c07f8ddc32fa5119471a2 --=20 2.30.2