Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp48081rdg; Tue, 10 Oct 2023 04:03:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH81rdlhh7G3OrkdNCCREdGQ2/05rz6nuNnKFzs5M0HE73WiGHR+U0cT2Meok5I7+telfOy X-Received: by 2002:a05:6a00:1791:b0:68f:ce6a:8685 with SMTP id s17-20020a056a00179100b0068fce6a8685mr23774563pfg.14.1696935804501; Tue, 10 Oct 2023 04:03:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696935804; cv=none; d=google.com; s=arc-20160816; b=R2dNKi+KFe3m//T11hweItdMcI9LGKA92j6fA7FU8D48Gojv0fLhz6ZyF1J51W6Qdl lQJttWdczN7cewgQucSLQxgQaaEIqNlKIX53D98Jqb7yufgKfJImYXEhjGTRN1Hs5XK/ Wf2ncb53MWG34fyPCFXT7M+/nST08gt/tz5JgANYEfa24My3ZVVQwsH9fqaTEQ4Ju0Ft u6bM6YdW3KySij0mMjV05+lk8uds5XX+khA9fsw9s9ZQcCtEDdgDLOTxi76ka91MiVkD G9AgzzNrHTBWYucdPYM0hGCtoBrUpz/f9/4UdV9WVMsL86G2xOIuoT5oAzWzXlroXuez CKWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=OUvFTZGC+eH2OClmAh0E/G8BdAOqwrCjpcMCTb5200U=; fh=z00yZ2f7V1RfOG+rGk3921CNfDxg/UBBozz9LS7AlZM=; b=V4KWokmZXLf5KFO2IZDXc6Vntr1AZgKZN8rI2p+4UiZPr6vHy/NnmCLDUPetdB8EbX 29B9F8z9uDtBL5wnTHQsCUNOZLq+ygonMQoSzOKSPTGQvPkNHM3DOBbQWcUriyZ2yBCh PQBGF8i+rkVUk9QLa+BAtWpcGiQiWVRRwhkB3s7eTsiOfifIzP7ebr1p+BPNhRiwyS+c 21CrPVUs3I/Qaj7QpcKcl6YC86TkGMkrJISUPyWElWhwKMDWDa7fMY+hTVyQIpDEeJQ3 QLEo8KanVPT9CM0yQyRraoR/8P2Mt6HYpnfZMOGKQDKtP1sTl/ZM6Sxu7nLLXUo+eG1g 47vA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id c21-20020a056a000ad500b0068e3f3c6250si10061314pfl.343.2023.10.10.04.03.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 04:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8E47480D0832; Tue, 10 Oct 2023 04:03:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230180AbjJJLDC (ORCPT + 99 others); Tue, 10 Oct 2023 07:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjJJLDB (ORCPT ); Tue, 10 Oct 2023 07:03:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2025694; Tue, 10 Oct 2023 04:03:00 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 960631FB; Tue, 10 Oct 2023 04:03:40 -0700 (PDT) Received: from bogus (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C055A3F7A6; Tue, 10 Oct 2023 04:02:58 -0700 (PDT) Date: Tue, 10 Oct 2023 12:02:56 +0100 From: Sudeep Holla To: Liviu Dudau , Sebastian Reichel Cc: Rob Herring , Sudeep Holla , Lorenzo Pieralisi , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] power: reset: vexpress: Use device_get_match_data() Message-ID: <20231010110256.s34hfmtf42jxeu7g@bogus> References: <20231009172923.2457844-19-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 04:03:15 -0700 (PDT) X-Spam-Level: ** 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 > > --- > > 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 > > #include > > #include > > -#include > > #include > > +#include > > #include > > #include > > #include > > @@ -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 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/