Message ID | a844cc7c85898b40abbdcb1f068338619c6010eb.1668361368.git.ang.iglesiasg@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1775801wru; Sun, 13 Nov 2022 09:55:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf6NZ5JqK7S5dKy7tb9sqSmv2Tg15HITityuGg6g/iwrNkg8DzLQ7PV07mTQZ0tt4IrOcrq4 X-Received: by 2002:a17:903:22d2:b0:172:9db6:3c5 with SMTP id y18-20020a17090322d200b001729db603c5mr10739918plg.110.1668362133284; Sun, 13 Nov 2022 09:55:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668362133; cv=none; d=google.com; s=arc-20160816; b=HvCHAMWItfLr/iK8or9NvISpULxB35gD/lfcyW6nY91bfXYi0W0HSozLgL+WQgPaH4 G1OAB/yparOKI/iAoQwjbLBeop9wJ7CxCif0toROR+W8GDvFqGYj/zQIC2nZE/ruxhEz 1yd/etQ0TnfxSstFTrAkNDIGGjikEWUErO8Y4O1Ux+E5nFCgqVO+tMprpjO+K2Ew13sO zlbxe6fpGjB4sk20Po0a2bCDLR7I8G3Oxv3DmQI+KDTqa2NozRtofigaR0p7KtJNZ2uv uJqxpNHKU+8ZFcZ21oOURpNMOfvCfTjqg/rIYCH/ZgyBmEtkAokI5jH/Aa/kGpefcz9t bvDA== 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:date:subject:cc:to:from :dkim-signature; bh=2l0dzmwTO65CA0gPY3ng3ObRUSns6fVOx71jf/hSipk=; b=FLz+GPI+SK6BmQHVs/fIxtOS7lOcV+U4wGpp3NwRLZlwmeOrqFcndFh381zT3PbdfA a75H5o/yR1W7iGqftxaoM1N1nnD0sQ8oaEE9C/fNEnRNEJ5R960daJ12IOElWRvbyPrx 2OhwHSsNJg95A/vCNk0KjvyCmTdFkuxRYSL7Qm+vtcne829UwdGzHqzceBoBHjWWaCms yn8fY5NYrMWqD/GBv8iTF4KKpcC8s30YmBWsSZZCdhNhb4C4MOMk7+CeCu8bMW6E/D05 GTv+sCqeqNXbrq1uZ2n37bvgRVophgv6Bdv4zaKNnYqBI3aPj5NmH2TzQ9puK9PzNAA7 bYGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BIz809Ut; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a17090a5d8d00b0020267707b1csi12121471pji.59.2022.11.13.09.55.19; Sun, 13 Nov 2022 09:55:33 -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=@gmail.com header.s=20210112 header.b=BIz809Ut; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235321AbiKMRrB (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Sun, 13 Nov 2022 12:47:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbiKMRrA (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 13 Nov 2022 12:47:00 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72433E0E8; Sun, 13 Nov 2022 09:46:59 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id v1so13474057wrt.11; Sun, 13 Nov 2022 09:46:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2l0dzmwTO65CA0gPY3ng3ObRUSns6fVOx71jf/hSipk=; b=BIz809Utr/lOU6vpdJp3qPaelQRmkxk3jnrnqatFrYCd+WECF7jwa9baShSLjzLNUc 2NTXzcDe3k/HjBo/qWr9yKncoZPWc5nGdkalR1voOliKF7QRpDy3Oq6hoJ0ZdxsaEhCx 4jldVCS8dHlrxRg4iMVIr8dnedT4+tAAEAiIsFs4Q8kBVkH0Izob9jmebSdlhE6pb+Y+ ZwSe1ef5cmm6AgGJRJj9zMGKyQr0ZWGPu/qdNFR04CkLEp3EJBDmO5Kl3XxZQCneVnbp XCXhBphT0oT+NT4cSasN1kQ34bKaZCMTsqcGnmWLGtKXYWS0fapvF5o6hN1wEsb/q2wS APKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2l0dzmwTO65CA0gPY3ng3ObRUSns6fVOx71jf/hSipk=; b=NzX6q3upBAAfZrZJKQT/uApRBeyNxEuRAl6r7yEgXvIMR0mpOEW0mI+PVqmHYV14su nEMtOQDgrXH4Thsvc4z9V+wKnmjd7360lLgttG2XzpKfcA18VqdEpUcjnB/gYxstk2CP 9vcF5xkCa2XaKrROIAwsd9s8Vm2d6WTBbZZhRehQFqHLj7YXbrBM0Vk5l6MA/zxisnBp 3FBS/61lizOjvFa58ORTYufgvFq8vSDnZ9GFG5ArsD1+eVM6dfFW8bpWJCg37S2Erdbo sO/TPbKh93ShFAaRB3CjOc1xY7o7rkTf0VVQInzeWTxvWQC26c0Vs+mJ6Qw7ly0RhSiD nUaw== X-Gm-Message-State: ANoB5pmZS1pzT0hCs8XivPMUgMFH0wXqFRY/x8yYranaZUhDspF4Bm6H Yul/BArrR8hwrwVbh15TJEP7pmjVsS0= X-Received: by 2002:a5d:4522:0:b0:236:5f1c:bedf with SMTP id j2-20020a5d4522000000b002365f1cbedfmr5842595wra.367.1668361617804; Sun, 13 Nov 2022 09:46:57 -0800 (PST) Received: from localhost.localdomain (188.red-83-35-57.dynamicip.rima-tde.net. [83.35.57.188]) by smtp.gmail.com with ESMTPSA id x10-20020adff64a000000b00236883f2f5csm7458463wrp.94.2022.11.13.09.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 09:46:57 -0800 (PST) From: Angel Iglesias <ang.iglesiasg@gmail.com> To: linux-iio@vger.kernel.org Cc: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, linux-kernel@vger.kernel.org, Angel Iglesias <ang.iglesiasg@gmail.com>, =?utf-8?q?Nuno_S=C3=A1?= <noname.nuno@gmail.com>, Andy Shevchenko <andriy.shevchenko@linux.intel.com>, Jonathan Cameron <jic23@kernel.org>, Wolfram Sang <wsa@kernel.org>, linux-i2c@vger.kernel.org Subject: [PATCH v3 1/2] i2c: core: Introduce i2c_client_get_device_id helper function Date: Sun, 13 Nov 2022 18:46:30 +0100 Message-Id: <a844cc7c85898b40abbdcb1f068338619c6010eb.1668361368.git.ang.iglesiasg@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <cover.1668361368.git.ang.iglesiasg@gmail.com> References: <cover.1668361368.git.ang.iglesiasg@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749404492497269760?= X-GMAIL-MSGID: =?utf-8?q?1749404492497269760?= |
Series |
i2c: core: Introduce i2c_client_get_device_id helper
|
|
Commit Message
Angel Iglesias
Nov. 13, 2022, 5:46 p.m. UTC
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. This issue was discussed in more detail in the IIO mailing list. Link: https://lore.kernel.org/all/20221023132302.911644-11-u.kleine-koenig@pengutronix.de/ Suggested-by: Nuno Sá <noname.nuno@gmail.com> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Comments
On Sun, Nov 13, 2022 at 06:46:30PM +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. > > This issue was discussed in more detail in the IIO mailing list. > > Link: https://lore.kernel.org/all/20221023132302.911644-11-u.kleine-koenig@pengutronix.de/ > Suggested-by: Nuno Sá <noname.nuno@gmail.com> > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Suggested-by: Jonathan Cameron <jic23@kernel.org> > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Immutable branch here: git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/client_device_id_helper-immutable I merged this branch also into i2c/for-mergewindow. Thank you, everyone!
On Sun, 13 Nov 2022 18:46:30 +0100 Angel Iglesias <ang.iglesiasg@gmail.com> 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. > > This issue was discussed in more detail in the IIO mailing list. > > Link: https://lore.kernel.org/all/20221023132302.911644-11-u.kleine-koenig@pengutronix.de/ > Suggested-by: Nuno Sá <noname.nuno@gmail.com> > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Suggested-by: Jonathan Cameron <jic23@kernel.org> > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index b4edf10e8fd0..9aa7b9d9a485 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -2236,6 +2236,20 @@ int i2c_get_device_id(const struct i2c_client *client, > } > EXPORT_SYMBOL_GPL(i2c_get_device_id); > > +/** > + * i2c_client_get_device_id - get the driver match table entry of a device > + * @client: the device to query. 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_client *client) > +{ > + const struct i2c_driver *drv = 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 struct 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_client *client); > #endif /* I2C */ > > /**
On Mon, 14 Nov 2022 20:53:20 +0100 Wolfram Sang <wsa@kernel.org> wrote: > On Sun, Nov 13, 2022 at 06:46:30PM +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. > > > > This issue was discussed in more detail in the IIO mailing list. > > > > Link: https://lore.kernel.org/all/20221023132302.911644-11-u.kleine-koenig@pengutronix.de/ > > Suggested-by: Nuno Sá <noname.nuno@gmail.com> > > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Suggested-by: Jonathan Cameron <jic23@kernel.org> > > Signed-off-by: Angel Iglesias <ang.iglesiasg@gmail.com> > > Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Immutable branch here: > > git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/client_device_id_helper-immutable > > I merged this branch also into i2c/for-mergewindow. > > Thank you, everyone! > Excellent. Merged that into iio.git/togreg and applied patch 2. Thanks, Jonathan
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index b4edf10e8fd0..9aa7b9d9a485 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -2236,6 +2236,20 @@ int i2c_get_device_id(const struct i2c_client *client, } EXPORT_SYMBOL_GPL(i2c_get_device_id); +/** + * i2c_client_get_device_id - get the driver match table entry of a device + * @client: the device to query. 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_client *client) +{ + const struct i2c_driver *drv = 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 struct 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_client *client); #endif /* I2C */ /**