Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp557503rwb; Sun, 6 Nov 2022 09:53:03 -0800 (PST) X-Google-Smtp-Source: AMsMyM4fiyN88puweoKJae81rJYo4FJN5ikb70qVSEYcIo5MwJ/rsjxcpq7L403420w041rMnWEz X-Received: by 2002:a17:906:fe0a:b0:76f:e373:d84b with SMTP id wy10-20020a170906fe0a00b0076fe373d84bmr8514780ejb.297.1667757183483; Sun, 06 Nov 2022 09:53:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667757183; cv=none; d=google.com; s=arc-20160816; b=qQJJ85lL4sfi258jAvxlAEBCxteN3RvBIn4BEvvt1b8JC04rj/uxy/rFmwAYFmuV0T w9eoZwclCi1fbIsMmZNw+8dpde0H6tWcEj7g0qVj7hv3qTLbYMS8v5cV/ZjXIwX0JsM5 dVS5wQvN/qyxI0dwtwEpnAvmKP2SQVxXnFoMojRYxDbr16Dg1h5cOtHJezLVYufGgOKZ /nDDo13OtGHLfioC4YO01AxoyVfI7sfawz1C7fVp2QHbU32/0pKifUt1B1fqTVX98TEs 73fPvBm++zL90tGAGB/sl2zF/uirAVD530v3kexB4hbuxw+uLvk0wylXWX+64u0v/0kJ Wa6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=U6e7U+MZYsY/RkmvGt6wDjOX/BK1fkcdeyb1ZbR5ZEs=; b=dJ+WmVM98iQMD/BRH6wX2UZaZXmff0/Vlz2fGfjrO6B+rf1b++oUGsHzslK73GYARq 5+Rv2MmY29uNKFN9K9LF8By5FpSOIU3BfeJHxaZ6dryC9pyjPzLcE1aEro3GbuCvHlUz CC5tJF0IHQw/BKSlAA4K+Qg90m1jV9sGvRFc/qQv6/1WCV6M6kaTsCLD3naXtjlLjeFO jzE8vFDnjfe1s4bgV0PDU7f3najiBObQ5EzHAE8RXPj2s6WORnZBjrm/KAoqawi/oRkC UHQUdhpHB4H5DIQsVOufbB/tvVN91H1vzb7Zxvvx4FRgPkKvp9qfhAHq0ol2teiyfHel xGTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BaxAVJ7f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i4-20020a05640242c400b004596d6e78e3si8174281edc.144.2022.11.06.09.52.40; Sun, 06 Nov 2022 09:53:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BaxAVJ7f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbiKFRYD (ORCPT + 96 others); Sun, 6 Nov 2022 12:24:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231324AbiKFRXh (ORCPT ); Sun, 6 Nov 2022 12:23:37 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8448C30; Sun, 6 Nov 2022 09:22:56 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3706760C91; Sun, 6 Nov 2022 17:22:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E0225C433D6; Sun, 6 Nov 2022 17:22:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667755375; bh=/2kzaA+b8Jgqw1DZYFYV1wS3t52IySX4aUNpVTL5RP4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=BaxAVJ7fr1BeQFzpk9LcjnyuPYqOxRVKWoH+Lls7ChQCYnizQ6dHAVy/rjvZaz0XI pKkKBU3cYHM7iqOLGppkDio+SBHRzvTXyE7J2BtKCAdthNbLxot37xBWQzLkN/hKEf Kcr8aJnLnhmWKHClEEij2txVOaH61cRaVx0FK/jMo4VlPllkuZz7j4PuaI+52Ddp4h iZKb78GiSUDI87k5WHqJvTHP5+ZpnyaQr06UBwVLdfzAu+TpwfFqC504lCUykZ6C04 bB2do6cwwVrH0Xek7qVOQqMn2P/y+ixG0E9HfOB0V7CV+/ixEcbZtGcQHQYZiACVUQ IryyqrxzTTWxg== Date: Sun, 6 Nov 2022 17:22:49 +0000 From: Jonathan Cameron To: Angel Iglesias Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Nuno =?UTF-8?B?U8Oh?= , Andy Shevchenko , Wolfram Sang , linux-i2c@vger.kernel.org Subject: Re: [PATCH v2 1/2] i2c: core: Introduce i2c_client_get_device_id helper function Message-ID: <20221106172249.30241713@jic23-huawei> In-Reply-To: References: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.34; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 6 Nov 2022 17:42:24 +0100 Angel Iglesias wrote: > Introduces new helper function to aid in .probe_new() refactors. In order > to use existing i2c_get_device_id() on the probe callback, the device > match table needs to be accessible in that function, which would require > bigger refactors in some drivers using the deprecated .probe callback. >=20 > This issue was discussed in more detail in the IIO mailing list. >=20 > Link: https://lore.kernel.org/all/20221023132302.911644-11-u.kleine-koeni= g@pengutronix.de/ > Suggested-by: Nuno S=C3=A1 > Suggested-by: Andy Shevchenko > Suggested-by: Jonathan Cameron > Signed-off-by: Angel Iglesias > Reviewed-by: Andy Shevchenko Trivial comment inline - otherwise lgtm Reviewed-by: Jonathan Cameron Thanks, >=20 > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index b4edf10e8fd0..920676e62c22 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -2236,6 +2236,21 @@ int i2c_get_device_id(const struct i2c_client *cli= ent, > } > EXPORT_SYMBOL_GPL(i2c_get_device_id); > =20 > +/** > + * i2c_client_get_device_id - get the driver match table entry of a devi= ce > + * @client: the device to query. The device must be bound to a driver or > + * the function oopses. Maybe don't state what happens otherwise if something changes to make it instead do something else unfortunate, this comment will need updating. "The device must be bound to a driver." > + * > + * Returns a pointer to the matching entry if found, NULL otherwise. > + */ > +const struct i2c_device_id *i2c_client_get_device_id(const struct i2c_cl= ient *client) > +{ > + const struct i2c_driver *drv =3D to_i2c_driver(client->dev.driver); > + > + return i2c_match_id(drv->id_table, client); > +} > +EXPORT_SYMBOL_GPL(i2c_client_get_device_id); > + > /* ---------------------------------------------------- > * the i2c address scanning function > * Will not work for 10-bit addresses! > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index f7c49bbdb8a1..d84e0e99f084 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -189,6 +189,7 @@ s32 i2c_smbus_read_i2c_block_data_or_emulated(const s= truct i2c_client *client, > u8 *values); > int i2c_get_device_id(const struct i2c_client *client, > struct i2c_device_identity *id); > +const struct i2c_device_id *i2c_client_get_device_id(const struct i2c_cl= ient *client); > #endif /* I2C */ > =20 > /**