Message ID | 20231009172923.2457844-19-robh@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp2022594vqo; Mon, 9 Oct 2023 10:33:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVSU4R/jBJQEiXQsUEkWRz3S9I1QJEuPYVCFar3I176PeVJHP7NOEWfbfKKV21AhqqK1K1 X-Received: by 2002:a17:902:d489:b0:1c3:cdf5:d891 with SMTP id c9-20020a170902d48900b001c3cdf5d891mr16968874plg.46.1696872813777; Mon, 09 Oct 2023 10:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696872813; cv=none; d=google.com; s=arc-20160816; b=aZyX0xaL51dvyK2Bkr+yaFh34F6tuav0IljHxFUyLb/S+2eELMoapZ/9pXU7J8LD7P N9MQUOaOWpfaoscRg1xu7YxVuOcfdRXLhY/51ILawBDf0dltTAMVAQxE8usX+f3UndsY Kc9+th9hlCFwJFjC1xBlW6juGxqZrv05/8jAyJOq829LJmgv+KZ2mu0GlOHbzTfPtCYc ocYVbVtHJFrf29MXB1rxhnqYKrTKgzWiSMMFRPRuv6kmkSp4XInjrIhrJRz2kbF7hF5T zQMP4piQjcZwkloR1M4FrWuubLpzi9Pqld3lI9OhvhJ0Jsa0gHOLAVkV+8L8v7rwmjfX xJsw== 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=cDYKgUd3pr7vU9TGJhVRz6GZYWhqTS/2+EngU65CxhA=; fh=L8RR+qzi6WFzNId0twbuSNz6NKTVU6gtJomKKuXzkBs=; b=S5sxNvojFAXOJU0M3zHLU27LAx8dnClLlfup4h88HYlhN5cCyfPFodT9NwcLtZ6kNR W4H4O8qqho+zujZdCv5Z3KHly6AGBrKc1nwIlGdmq2p+vkfW3WuG9Mhn/KClzjSWEVTg vBgDbNXzi/lS52eQ11HowO6zmLYD83M7/Tv8z6r3UTrNXmZ/aS4CcpUP1mnUMXJ7SxCn w7ooSIYcgYAGGxeB94stvQQyXYFJB8bnPCPyZuqdwdYGRfMqJWvXQ6KlB9hPnqfOgsxu bt6zsXrFgIExK7m2k/929nIAyQ9zpUZZLo0P1YCg1rbXbe7Raomug/4fVDjlUtmbG3C6 eNfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=KIiaAQun; 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 ik11-20020a170902ab0b00b001bc836180dcsi9966522plb.520.2023.10.09.10.33.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 10:33:33 -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=KIiaAQun; 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 E5A8380D15BD; Mon, 9 Oct 2023 10:33:28 -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 S1378024AbjJIRdN (ORCPT <rfc822;ezelljr.billy@gmail.com> + 18 others); Mon, 9 Oct 2023 13:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378018AbjJIRc7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Oct 2023 13:32:59 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB2DF132; Mon, 9 Oct 2023 10:32:51 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BB0BC433C8; Mon, 9 Oct 2023 17:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696872771; bh=SVXshXiEdwU2vmo+Rd2WRtoCqJf4zLLOZYef9zCZqeM=; h=From:To:Cc:Subject:Date:From; b=KIiaAQun92uGEzEnXnpSCd6MxUz9S9l94W/P1vnDz2MTFrn61Rip6EzZC7q4cWFgb ZA0UypE1C/YicJpz4OqcALR72Yu4e4OyKLuWvVftWPy7DWEG59nJY0NpoDbo07Btch uSG7qF+InS+Yi1vPANVq286rpM+aDPYQSj0pLuo8SpSe5JtOs2oir7sT8kGlhi2qHl NEIMOWTcubNYEbsEiDlL7TkHclJJTwAT7x8WiA0VjCiuY17mK1cFODuOf2ADlQf46A 42pHJbHheRyujLP5NxwtI4IT1LJ9hhUYh/QASvPCod3fcZwbK2EVV27e+h5KJu8RHb Yh/akRVn+ZNGw== Received: (nullmailer pid 2532666 invoked by uid 1000); Mon, 09 Oct 2023 17:32:48 -0000 From: Rob Herring <robh@kernel.org> To: Sebastian Reichel <sre@kernel.org>, Liviu Dudau <liviu.dudau@arm.com>, Sudeep Holla <sudeep.holla@arm.com>, Lorenzo Pieralisi <lpieralisi@kernel.org> Cc: linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] power: reset: vexpress: Use device_get_match_data() Date: Mon, 9 Oct 2023 12:29:14 -0500 Message-ID: <20231009172923.2457844-19-robh@kernel.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> 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 10:33:28 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779300107621256701 X-GMAIL-MSGID: 1779300107621256701 |
Series |
power: reset: vexpress: Use device_get_match_data()
|
|
Commit Message
Rob Herring
Oct. 9, 2023, 5:29 p.m. UTC
Use preferred device_get_match_data() instead of of_match_device() to
get the driver match data. With this, adjust the includes to explicitly
include the correct headers.
Signed-off-by: Rob Herring <robh@kernel.org>
---
drivers/power/reset/vexpress-poweroff.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Comments
Hi Rob, On Mon, Oct 09, 2023 at 12:29:14PM -0500, Rob Herring wrote: > Use preferred device_get_match_data() instead of of_match_device() to > get the driver match data. With this, adjust the includes to explicitly > include the correct headers. > > Signed-off-by: Rob Herring <robh@kernel.org> > --- > drivers/power/reset/vexpress-poweroff.c | 11 ++++------- > 1 file changed, 4 insertions(+), 7 deletions(-) > > diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c > index 17064d7b19f6..bb22b2db5907 100644 > --- a/drivers/power/reset/vexpress-poweroff.c > +++ b/drivers/power/reset/vexpress-poweroff.c > @@ -7,8 +7,8 @@ > #include <linux/delay.h> > #include <linux/notifier.h> > #include <linux/of.h> > -#include <linux/of_device.h> > #include <linux/platform_device.h> > +#include <linux/property.h> > #include <linux/reboot.h> > #include <linux/stat.h> > #include <linux/vexpress.h> > @@ -108,20 +108,17 @@ static int _vexpress_register_restart_handler(struct device *dev) > > static int vexpress_reset_probe(struct platform_device *pdev) > { > - const struct of_device_id *match = > - of_match_device(vexpress_reset_of_match, &pdev->dev); > + enum vexpress_reset_func func; > struct regmap *regmap; > int ret = 0; > > - if (!match) > - return -EINVAL; > - > regmap = devm_regmap_init_vexpress_config(&pdev->dev); > if (IS_ERR(regmap)) > return PTR_ERR(regmap); > dev_set_drvdata(&pdev->dev, regmap); > > - switch ((uintptr_t)match->data) { > + func = (uintptr_t)device_get_match_data(&pdev->dev); > + switch (func) { > case FUNC_SHUTDOWN: > vexpress_power_off_device = &pdev->dev; > pm_power_off = vexpress_power_off; device_get_match_data() is badly un-documented but I think it can still return NULL if no match. At the moment we're checking for a match earlier and avoid calling devm_regmap_init_vexpress_config() needlessly, with your patch not so. Can you not replace each line with the equivalent code and keep the NULL check? Best regards, Liviu > -- > 2.42.0 >
On Mon, Oct 09, 2023 at 11:07:33PM +0100, Liviu Dudau wrote: > Hi Rob, > > On Mon, Oct 09, 2023 at 12:29:14PM -0500, Rob Herring wrote: > > Use preferred device_get_match_data() instead of of_match_device() to > > get the driver match data. With this, adjust the includes to explicitly > > include the correct headers. > > > > Signed-off-by: Rob Herring <robh@kernel.org> > > --- > > drivers/power/reset/vexpress-poweroff.c | 11 ++++------- > > 1 file changed, 4 insertions(+), 7 deletions(-) > > > > diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c > > index 17064d7b19f6..bb22b2db5907 100644 > > --- a/drivers/power/reset/vexpress-poweroff.c > > +++ b/drivers/power/reset/vexpress-poweroff.c > > @@ -7,8 +7,8 @@ > > #include <linux/delay.h> > > #include <linux/notifier.h> > > #include <linux/of.h> > > -#include <linux/of_device.h> > > #include <linux/platform_device.h> > > +#include <linux/property.h> > > #include <linux/reboot.h> > > #include <linux/stat.h> > > #include <linux/vexpress.h> > > @@ -108,20 +108,17 @@ static int _vexpress_register_restart_handler(struct device *dev) > > > > static int vexpress_reset_probe(struct platform_device *pdev) > > { > > - const struct of_device_id *match = > > - of_match_device(vexpress_reset_of_match, &pdev->dev); > > + enum vexpress_reset_func func; > > struct regmap *regmap; > > int ret = 0; > > > > - if (!match) > > - return -EINVAL; > > - > > regmap = devm_regmap_init_vexpress_config(&pdev->dev); > > if (IS_ERR(regmap)) > > return PTR_ERR(regmap); > > dev_set_drvdata(&pdev->dev, regmap); > > > > - switch ((uintptr_t)match->data) { > > + func = (uintptr_t)device_get_match_data(&pdev->dev); > > + switch (func) { > > case FUNC_SHUTDOWN: > > vexpress_power_off_device = &pdev->dev; > > pm_power_off = vexpress_power_off; > > device_get_match_data() is badly un-documented but I think it can still > return NULL if no match. At the moment we're checking for a match earlier > and avoid calling devm_regmap_init_vexpress_config() needlessly, with your > patch not so. Can you not replace each line with the equivalent code and > keep the NULL check? In contrast, I always questioned/wondered why we needed the NULL check for the match above as probe would have not got called if there was no match. While I agree with the less clear documentation of device_get_match_data(), I am fine with the change as such Acked-by: Sudeep Holla <sudeep.holla@arm.com> Also check similar response from Rob here[1] Sebastian, I assume you will pick this up. -- Regards, Sudeep [1] https://lore.kernel.org/all/CAL_JsqKi8PXVqHgVxqMN+mbX8U-ZGsCMUFqbxmjeFmj1xKTrjw@mail.gmail.com/
On Mon, 09 Oct 2023 12:29:14 -0500, Rob Herring wrote: > Use preferred device_get_match_data() instead of of_match_device() to > get the driver match data. With this, adjust the includes to explicitly > include the correct headers. > > Applied, thanks! [1/1] power: reset: vexpress: Use device_get_match_data() commit: 469d31745b9fb3a87424b311abb7cb530611404f Best regards,
diff --git a/drivers/power/reset/vexpress-poweroff.c b/drivers/power/reset/vexpress-poweroff.c index 17064d7b19f6..bb22b2db5907 100644 --- a/drivers/power/reset/vexpress-poweroff.c +++ b/drivers/power/reset/vexpress-poweroff.c @@ -7,8 +7,8 @@ #include <linux/delay.h> #include <linux/notifier.h> #include <linux/of.h> -#include <linux/of_device.h> #include <linux/platform_device.h> +#include <linux/property.h> #include <linux/reboot.h> #include <linux/stat.h> #include <linux/vexpress.h> @@ -108,20 +108,17 @@ static int _vexpress_register_restart_handler(struct device *dev) static int vexpress_reset_probe(struct platform_device *pdev) { - const struct of_device_id *match = - of_match_device(vexpress_reset_of_match, &pdev->dev); + enum vexpress_reset_func func; struct regmap *regmap; int ret = 0; - if (!match) - return -EINVAL; - regmap = devm_regmap_init_vexpress_config(&pdev->dev); if (IS_ERR(regmap)) return PTR_ERR(regmap); dev_set_drvdata(&pdev->dev, regmap); - switch ((uintptr_t)match->data) { + func = (uintptr_t)device_get_match_data(&pdev->dev); + switch (func) { case FUNC_SHUTDOWN: vexpress_power_off_device = &pdev->dev; pm_power_off = vexpress_power_off;