From patchwork Sun Feb 26 22:26:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 61660 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2122539wrd; Sun, 26 Feb 2023 14:28:31 -0800 (PST) X-Google-Smtp-Source: AK7set8JSasAFHViQf/QyXneZFT9tF722KCTDL9dXldcNluZxdxffTTPqVp1bje6UvGvsuZzsdA3 X-Received: by 2002:a05:6a00:1d20:b0:5e4:f141:568b with SMTP id a32-20020a056a001d2000b005e4f141568bmr8195126pfx.3.1677450510977; Sun, 26 Feb 2023 14:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677450510; cv=none; d=google.com; s=arc-20160816; b=mn6g+Y0gRWOzHIPFUZVK/Z2ku5DmsE6jQ5L8F4GORL+24PmQJys+MStZpaYXK2xoDE dfzmxSPXP0AqotPuzRGqKQAakMcQ+Qlo+R3HyS7F1c3UJA8Txlt4ySGD0UcLVLNV/h1o CGHkgjKFGgPr62zkkps0p9xHxwZqW835+6COYsrmerk9ng3q0AC/PCnsLsUh6fbBjypL /FEQnAPS4MvO4XECJbB8+cmmsCs7HFzh+ooDUoq1AutlBJpWXxDgTFWi770X6boYHMAL 4zg2InXv4CvfGvbHuGZ29jzs6wylFHMihZsiQu4MyKiU4S/uuIXYqWiXQVAHl4Xg6V6M frRA== 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; bh=ZjeW12aN7RWeW/N1hG7lRr48XB1GMIh3F3WBF44+Zn4=; b=lTluO/qeDvHjuu9pq/+F5jwqqEmwz330Ms1a6e3BObpoyfoX6AjP63u+swl0TM3LuH u6AavyxOjpYtT0mQGeEv74GUwH1uTXVW52/DlcfINCmpUpNFcs5NM+c8q1nF6iXLozC0 aM99FlnzkQ2dvXDt0XlYrYTlGqZFoLBC5WnV4W271leEmSdMJ8m1kCSE9j9O5GnspKKD uAxCcfxjoW9cMMwigAi58FEOvKfeZD0eTe9qySSlHOSVt/+wuuxHW3RcZAwScMBhBrZR i8JlLq2KGaK2OefCCazw36u7nEy8SghBOEHxWH62ZMZZSZueON9qcL3euZE9hnvKjO5r qszA== ARC-Authentication-Results: i=1; mx.google.com; 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a621a07000000b00577e14babaesi5324029pfa.4.2023.02.26.14.28.18; Sun, 26 Feb 2023 14:28:30 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229721AbjBZW1I (ORCPT + 99 others); Sun, 26 Feb 2023 17:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229549AbjBZW1H (ORCPT ); Sun, 26 Feb 2023 17:27:07 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69AC112589 for ; Sun, 26 Feb 2023 14:27:06 -0800 (PST) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pWPTx-0000vL-SG; Sun, 26 Feb 2023 23:27:01 +0100 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1pWPTx-000Ubo-0c; Sun, 26 Feb 2023 23:27:01 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pWPTw-000YPz-4i; Sun, 26 Feb 2023 23:27:00 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Wolfram Sang Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones Subject: [PATCH v2 7/9] i2c: Switch .probe() to not take an id parameter Date: Sun, 26 Feb 2023 23:26:52 +0100 Message-Id: <20230226222654.1741900-8-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230226222654.1741900-1-u.kleine-koenig@pengutronix.de> References: <20230226222654.1741900-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2954; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=CGs1waPXyH+zFPqAHQV2oj9jU9r+cYpTC2JoFW5f31U=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBj+9yilC3ENzyV5owVcV5oOynKUfMYW0YAtEKlU TkXAAfjYieJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCY/vcogAKCRDB/BR4rcrs CVZ6CACGOi8BL9+KAudAYKf3+k3pjp57A90O/bpEst7yIi23GU+DH1xQQu7zxu+3c7Ru/AyizHn oB9IfuaJP8WXIz1Jmte+i82ukcFz1oGMQTdT5ibRqUH4SpjH/0pbS/W8UCeeJRN+FWsSccJ3ApH X7HRD+Awij2JGyDDo+zrBVWXDTzg0nRIw1/kaG/HR5wj8NWprmAwsLqRBz4OE7hcUxC6igKCW/I vtn2FWOQZlWeVcfmGIf8ezNPxWUdXBbQs5TNYwEdwYR1fFvzX+jnN4yp7A/M8wn12P0unF3/EjD 5qqJ7ptN9U89PgxOF5k/TsanlVwuJYGldRTUUxfibV2JptG6 X-Developer-Key: i=u.kleine-koenig@pengutronix.de; a=openpgp; fpr=0D2511F322BFAB1C1580266BE2DCDD9132669BD6 X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758934347356504278?= X-GMAIL-MSGID: =?utf-8?q?1758934347356504278?= Commit b8a1a4cd5a98 ("i2c: Provide a temporary .probe_new() call-back type") introduced a new probe callback to convert i2c init routines to not take an i2c_device_id parameter. Now that all in-tree drivers are converted to the temporary .probe_new() callback, .probe() can be modified to match the desired prototype. Now that .probe() and .probe_new() have the same semantic, they can be defined as members of an anonymous union to save some memory and simplify the core code a bit. Signed-off-by: Uwe Kleine-König --- drivers/i2c/i2c-core-base.c | 11 ++--------- include/linux/i2c.h | 18 +++++++++++------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index cb5fa971d67e..63253e2b2c1f 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -561,15 +561,8 @@ static int i2c_device_probe(struct device *dev) goto err_detach_pm_domain; } - /* - * When there are no more users of probe(), - * rename probe_new to probe. - */ - if (driver->probe_new) - status = driver->probe_new(client); - else if (driver->probe) - status = driver->probe(client, - i2c_match_id(driver->id_table, client)); + if (driver->probe) + status = driver->probe(client); else status = -EINVAL; diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 500404d85141..5ba89663ea86 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -236,8 +236,8 @@ enum i2c_driver_flags { /** * struct i2c_driver - represent an I2C device driver * @class: What kind of i2c device we instantiate (for detect) - * @probe: Callback for device binding - soon to be deprecated - * @probe_new: New callback for device binding + * @probe: Callback for device binding + * @probe_new: Transitional callback for device binding - do not use * @remove: Callback for device unbinding * @shutdown: Callback for device shutdown * @alert: Alert callback, for example for the SMBus alert protocol @@ -272,14 +272,18 @@ enum i2c_driver_flags { struct i2c_driver { unsigned int class; + union { /* Standard driver model interfaces */ - int (*probe)(struct i2c_client *client, const struct i2c_device_id *id); + int (*probe)(struct i2c_client *client); + /* + * Legacy callback that was part of a conversion of .probe(). + * Today it has the same semantic as .probe(). Don't use for new + * code. + */ + int (*probe_new)(struct i2c_client *client); + }; void (*remove)(struct i2c_client *client); - /* New driver model interface to aid the seamless removal of the - * current probe()'s, more commonly unused than used second parameter. - */ - int (*probe_new)(struct i2c_client *client); /* driver model interfaces that don't relate to enumeration */ void (*shutdown)(struct i2c_client *client);