From patchwork Mon Oct 9 21:13:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 150337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2125010vqo; Mon, 9 Oct 2023 14:15:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE88GzxzcaRROW0MXe2tplvsCq5PM4Vvxx6z+CElT2ad0B9zxgkYocg6yIMl5MJ/pfQR2Hm X-Received: by 2002:a05:6a20:734a:b0:15d:641b:57b6 with SMTP id v10-20020a056a20734a00b0015d641b57b6mr16551459pzc.5.1696886151111; Mon, 09 Oct 2023 14:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696886151; cv=none; d=google.com; s=arc-20160816; b=z0J+hchdZ2bZquc0YrQaI0M7rrfMZq8OuOYkn3PMx1y81aKPuR4iUSszGSiG0qEoo8 KEkow5VP3jlTLsCQ0Rw2ZPqernm2zFnxUKjF0JfTyfVh0R4hNPQ9+apCM4M0fBlNYmh5 jJTDoXjkghOiZlOjZZBGwlNdNEVY+tyWNuPRrCz5BU/oCC0fZUAck/gFqeVQHvl7/2mY ve1GC9MF/qBABJDv/AUcu4kGmvBwkAzmtKdgzwarubmShOIlsYGYY5iEuadGotR9UaBH 0i5nwY7/FRBGbQ1UGo6ikRMkeKG5M0ctgbQghrDC5tLKK1NTnDLaEqzgCo7GjS+ognjd TuHQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=rp4asLkwGRPLkOyqnoVQPynyhlSBf1G6TTRiIz+Q35E=; fh=c6mXZUhBVY4UQmDjqyCLZbdjm2PbHVV23TcjabtEYDI=; b=pT1xFAUYC3d7JKQM54rzAycUNPUDbPrGFTknm5BNEtnhIWgTs+Ut6wqSwejdXQtw4F CgPzO2LwaTmpHNcXi1N3wB5CA1hmK/e7w5RwY1Lyt1tXPBun0lHSDLi7feDxs+KApw2I LqLLH72znzoUrWsE5U6gESEGGQqkI1zMy6ozpO/v3VnK0xF7ECgse/Acv4bp9FsCyg3G uUrap7XSZCVbatD7leiYhPbabWQFaCv4HBpOVbHsXhOQ2jIdc3lw2uaSRPhWLNEuetMP xaSy+PqyJFPLof5gheahOUNyLFEro6aH5U7Qe4Fo+c3XO8w3yZdPvHcWsEdX7LyeQFxJ XUuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JHKpR1bc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id f5-20020a170902684500b001bef085a37dsi10118451pln.86.2023.10.09.14.15.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 14:15:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JHKpR1bc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5105F808725F; Mon, 9 Oct 2023 14:15:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378662AbjJIVOU (ORCPT + 19 others); Mon, 9 Oct 2023 17:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378657AbjJIVOQ (ORCPT ); Mon, 9 Oct 2023 17:14:16 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3185892 for ; Mon, 9 Oct 2023 14:14:15 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CA74C433BA; Mon, 9 Oct 2023 21:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696886054; bh=vXdS6prYg0vTMoJ0Kq07ybf3uIB5ClVyk/8JPboxWbw=; h=From:To:Cc:Subject:Date:From; b=JHKpR1bc8VPvT+UEgmag2buUjSi/GHDsQsHvcjdx79u5ZWj3+XSCMk6P4TVBPbFiB n7AbBWbC563JG5bET7La2D+8sDsf/mLr2kCt5wp7+MxFrcTeqt1eYdN2UOt9QC4SmH 9iZ3pEQl/hxU2VxWiCI4jQaoHYFByCQDwpZbqUTUEoAOqvi3ZEI+/0ySoQqZHQ8pkh RcIJv+0RFFUebPjuZM+d8rvSG1UhxX1yyub3h6oJeOy0i5sfdtifSOzDVs6jQFEIMX pg8HBK2mQlTMcUaKUAhTc5L2gTab4eCcU4SgwvHXZI2lKJuKqej4Zv3bVMlgEqaQ7C COuH3DShT8mBw== Received: (nullmailer pid 3245430 invoked by uid 1000); Mon, 09 Oct 2023 21:14:08 -0000 From: Rob Herring To: Charles Keepax , Richard Fitzgerald , Lee Jones , Chanwoo Choi , Krzysztof Kozlowski Cc: patches@opensource.cirrus.com, linux-kernel@vger.kernel.org Subject: [PATCH] mfd: Use i2c_get_match_data() Date: Mon, 9 Oct 2023 16:13:34 -0500 Message-ID: <20231009211356.3242037-4-robh@kernel.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 14:15:20 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779314092639666633 X-GMAIL-MSGID: 1779314092639666633 Use preferred i2c_get_match_data() instead of of_match_device() and i2c driver_data to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring --- drivers/mfd/lochnagar-i2c.c | 9 ++------- drivers/mfd/lp87565.c | 9 +++------ drivers/mfd/max14577.c | 14 +++----------- drivers/mfd/rn5t618.c | 11 ++--------- drivers/mfd/wm831x-i2c.c | 16 ++++------------ drivers/mfd/wm8994-core.c | 11 +---------- 6 files changed, 15 insertions(+), 55 deletions(-) diff --git a/drivers/mfd/lochnagar-i2c.c b/drivers/mfd/lochnagar-i2c.c index 59092f839d65..0b76fcccd0bd 100644 --- a/drivers/mfd/lochnagar-i2c.c +++ b/drivers/mfd/lochnagar-i2c.c @@ -15,8 +15,8 @@ #include #include #include +#include #include -#include #include #include @@ -270,7 +270,6 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c) { struct device *dev = &i2c->dev; const struct lochnagar_config *config = NULL; - const struct of_device_id *of_id; struct lochnagar *lochnagar; struct gpio_desc *reset, *present; unsigned int val; @@ -282,11 +281,7 @@ static int lochnagar_i2c_probe(struct i2c_client *i2c) if (!lochnagar) return -ENOMEM; - of_id = of_match_device(lochnagar_of_match, dev); - if (!of_id) - return -EINVAL; - - config = of_id->data; + config = i2c_get_match_data(i2c); lochnagar->dev = dev; mutex_init(&lochnagar->analogue_config_lock); diff --git a/drivers/mfd/lp87565.c b/drivers/mfd/lp87565.c index 1b7f8349911d..08c62ddfb4f5 100644 --- a/drivers/mfd/lp87565.c +++ b/drivers/mfd/lp87565.c @@ -6,10 +6,11 @@ */ #include +#include #include #include +#include #include -#include #include #include @@ -46,7 +47,6 @@ MODULE_DEVICE_TABLE(of, of_lp87565_match_table); static int lp87565_probe(struct i2c_client *client) { struct lp87565 *lp87565; - const struct of_device_id *of_id; int ret; unsigned int otpid; @@ -89,10 +89,7 @@ static int lp87565_probe(struct i2c_client *client) } lp87565->rev = otpid & LP87565_OTP_REV_OTP_ID; - - of_id = of_match_device(of_lp87565_match_table, &client->dev); - if (of_id) - lp87565->dev_type = (uintptr_t)of_id->data; + lp87565->dev_type = (uintptr_t)i2c_get_match_data(client); i2c_set_clientdata(client, lp87565); diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c index 1f4f5002595c..8f7472c76009 100644 --- a/drivers/mfd/max14577.c +++ b/drivers/mfd/max14577.c @@ -9,9 +9,10 @@ // This driver is based on max8997.c #include +#include +#include #include #include -#include #include #include #include @@ -357,7 +358,6 @@ static void max77836_remove(struct max14577 *max14577) static int max14577_i2c_probe(struct i2c_client *i2c) { - const struct i2c_device_id *id = i2c_client_get_device_id(i2c); struct max14577 *max14577; struct max14577_platform_data *pdata = dev_get_platdata(&i2c->dev); struct device_node *np = i2c->dev.of_node; @@ -397,15 +397,7 @@ static int max14577_i2c_probe(struct i2c_client *i2c) return ret; } - if (np) { - const struct of_device_id *of_id; - - of_id = of_match_device(max14577_dt_match, &i2c->dev); - if (of_id) - max14577->dev_type = (uintptr_t)of_id->data; - } else { - max14577->dev_type = id->driver_data; - } + max14577->dev_type = (enum maxim_device_type)i2c_get_match_data(i2c); max14577_print_dev_type(max14577); diff --git a/drivers/mfd/rn5t618.c b/drivers/mfd/rn5t618.c index 0fe616b2db8e..7336e6d8a001 100644 --- a/drivers/mfd/rn5t618.c +++ b/drivers/mfd/rn5t618.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include @@ -179,22 +179,15 @@ MODULE_DEVICE_TABLE(of, rn5t618_of_match); static int rn5t618_i2c_probe(struct i2c_client *i2c) { - const struct of_device_id *of_id; struct rn5t618 *priv; int ret; - of_id = of_match_device(rn5t618_of_match, &i2c->dev); - if (!of_id) { - dev_err(&i2c->dev, "Failed to find matching DT ID\n"); - return -EINVAL; - } - priv = devm_kzalloc(&i2c->dev, sizeof(*priv), GFP_KERNEL); if (!priv) return -ENOMEM; i2c_set_clientdata(i2c, priv); - priv->variant = (long)of_id->data; + priv->variant = (long)i2c_get_match_data(i2c); priv->irq = i2c->irq; priv->dev = &i2c->dev; diff --git a/drivers/mfd/wm831x-i2c.c b/drivers/mfd/wm831x-i2c.c index 694ddbbf0372..9bee007f9c99 100644 --- a/drivers/mfd/wm831x-i2c.c +++ b/drivers/mfd/wm831x-i2c.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include @@ -23,22 +22,15 @@ static int wm831x_i2c_probe(struct i2c_client *i2c) { - const struct i2c_device_id *id = i2c_client_get_device_id(i2c); struct wm831x_pdata *pdata = dev_get_platdata(&i2c->dev); - const struct of_device_id *of_id; struct wm831x *wm831x; enum wm831x_parent type; int ret; - if (i2c->dev.of_node) { - of_id = of_match_device(wm831x_of_match, &i2c->dev); - if (!of_id) { - dev_err(&i2c->dev, "Failed to match device\n"); - return -ENODEV; - } - type = (uintptr_t)of_id->data; - } else { - type = (enum wm831x_parent)id->driver_data; + type = (uintptr_t)i2c_get_match_data(i2c); + if (!type) { + dev_err(&i2c->dev, "Failed to match device\n"); + return -ENODEV; } wm831x = devm_kzalloc(&i2c->dev, sizeof(struct wm831x), GFP_KERNEL); diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index aba7af688175..d5ac066f9db4 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -612,8 +611,6 @@ MODULE_DEVICE_TABLE(of, wm8994_of_match); static int wm8994_i2c_probe(struct i2c_client *i2c) { - const struct i2c_device_id *id = i2c_client_get_device_id(i2c); - const struct of_device_id *of_id; struct wm8994 *wm8994; int ret; @@ -625,13 +622,7 @@ static int wm8994_i2c_probe(struct i2c_client *i2c) wm8994->dev = &i2c->dev; wm8994->irq = i2c->irq; - if (i2c->dev.of_node) { - of_id = of_match_device(wm8994_of_match, &i2c->dev); - if (of_id) - wm8994->type = (uintptr_t)of_id->data; - } else { - wm8994->type = id->driver_data; - } + wm8994->type = (enum wm8994_type)i2c_get_match_data(i2c); wm8994->regmap = devm_regmap_init_i2c(i2c, &wm8994_base_regmap_config); if (IS_ERR(wm8994->regmap)) {