From patchwork Fri Feb 24 12:05:58 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: 61286 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp868687wrd; Fri, 24 Feb 2023 04:10:57 -0800 (PST) X-Google-Smtp-Source: AK7set+REE9wxqcSmdiAjFxffkW3mdxjwtqCVB9W82T5jcsPBjM3HiEGl9eLhH8C6Et5rdhRz5vK X-Received: by 2002:a17:90b:1647:b0:237:461c:b31a with SMTP id il7-20020a17090b164700b00237461cb31amr8859216pjb.32.1677240657287; Fri, 24 Feb 2023 04:10:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677240657; cv=none; d=google.com; s=arc-20160816; b=iBC5FsbwAY36iYLTBD9tFv1CutBSm7rHfF7h5+Jqb7vx8Uym229jwCnTQD+Ha/4A2S kBj8mQgPLeBNXscATIQayhAiSEGHzjcrIhc2N5BhTrRF1IfNmapU6jKUJrDgyi5OeNoU ZzZYzQYih/UdpRLERdi8t/skO//oeutTptJ/KTps95lwJIPOHv5DL5PR2yOvZ4a1Ae3H +Yyh7LJ0f9N3yzpicrrkBK98qS60jx64uaV87fmdetIfCj3WUk3gkh9Z7Y2bvo1klnO2 G6pLQCshN088FCjocmQpk2gX4dKFL+bksj00r6abWRtF/XdZgoncifkvWtUzQk+DuVDk HUBw== 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=wH6ChXuJxxP6+sdtPKH3BtFJbWib+ZAxdJTV9kJtEag=; b=F6dYXTGI8Z39oRlM9NgbdsuoLS3BfElE3r0XyG5SzV2AXmKv8W/AZeaQCGKLlZWk4c s1CQTOSCcwlTkSZRApEpyZRiraIBYjmIV/iHXK1ZtpO639kA1pHJkd59Mt19B8KHwCsQ kySLM37bgXN+1R6HnwYUxerwGc9CH0Rn5Sf7OoUXQH23UV9cEjmoSUuNkS65nhOq6Di+ j7izeQ2zdEBhny+IkYuK+vqYO0C6ZFUWc31GvGYxykLKzFORhvFfdgTeWBdjrHSdf8Md jbglzvom8PiGXdScMWwEHyncNTjDWfHj+3Ak5HC8c9nvaHASYT9purhuvcN05Ct/7WWw jKOQ== 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 k3-20020a170902694300b0019c93e0dce0si9918792plt.254.2023.02.24.04.10.36; Fri, 24 Feb 2023 04:10:57 -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 S229916AbjBXMGU (ORCPT + 99 others); Fri, 24 Feb 2023 07:06:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbjBXMGS (ORCPT ); Fri, 24 Feb 2023 07:06:18 -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 5BE2865332 for ; Fri, 24 Feb 2023 04:06:17 -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 1pVWq4-0000eJ-RL; Fri, 24 Feb 2023 13:06:12 +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 1pVWq2-007B02-SE; Fri, 24 Feb 2023 13:06:12 +0100 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1pVWq2-006EZ6-R5; Fri, 24 Feb 2023 13:06:10 +0100 From: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= To: Wolfram Sang Cc: kernel@pengutronix.de, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Lee Jones Subject: [PATCH 7/9] i2c: Switch .probe() to not take an id parameter Date: Fri, 24 Feb 2023 13:05:58 +0100 Message-Id: <20230224120600.1681685-8-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230224120600.1681685-1-u.kleine-koenig@pengutronix.de> References: <20230224120600.1681685-1-u.kleine-koenig@pengutronix.de> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2393; i=u.kleine-koenig@pengutronix.de; h=from:subject; bh=+71wz5skFwCbbBFUgxFsdJ/u5S/S5H9btbK8684v6tg=; b=owEBbQGS/pANAwAKAcH8FHityuwJAcsmYgBj+KgbOSV8eecJXtOE/I8vpmKMer7YYUfbvTfuh 4KIf3VbH3CJATMEAAEKAB0WIQR+cioWkBis/z50pAvB/BR4rcrsCQUCY/ioGwAKCRDB/BR4rcrs Cd/hB/0QzSnaB2XApeqnwGVmjBbn1JKEt8p2M1ZjndmWBEcd6p9MNhUpiTNnfFu4F0hI+E/2Kz/ jdIypObLyi6RXzZFRQkCrVCMd+4v2cLcgzFDbsH3ATwLcDsuSR5qv2gJp8WOnpNlSS3RDem5sUr 0H07bF0xOdXztWWbaWhsJOX1YzNnk74lel98uHQ7RhRk62AAfO2BZ7TvaLImJQ63HvTlmEQ8Jht lomnKcSA+nFKH/PxTX9laKHiCJFS608+fUeEJVfn1xDVFpcajsrWkHlPjfCM5k2KcEjEax3uhFg pvdawi8s275N/SCAav1LQKCmOIzAyXmHG3dNpp8VXNdlzZce 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?1758714299243979689?= X-GMAIL-MSGID: =?utf-8?q?1758714299243979689?= 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 | 14 +++++++++----- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 087e480b624c..1fbe16221085 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -558,15 +558,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 d84e0e99f084..c3e022d53182 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -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);