From patchwork Thu Oct 26 19:54:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 158671 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp133397vqb; Thu, 26 Oct 2023 12:56:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExlK0AFnhrFPb4Lln0new2ND0JcsAe7g9lM8BGE01s8pTF8HPSnMbWgrYPhvFVm9QzZ5wc X-Received: by 2002:a25:7648:0:b0:da0:7826:8b98 with SMTP id r69-20020a257648000000b00da078268b98mr451946ybc.55.1698350216627; Thu, 26 Oct 2023 12:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698350216; cv=none; d=google.com; s=arc-20160816; b=JtjzF2nK68Br/TFZyFJFod6v6LjMNkUJirIJLNPRtkpKiL0BCE5afr/LfaOr357pQ6 xwDVu8FWoWR6uAc2Rz12hbcM5y0AEmK0EVgr+9mTAjhJ8t/4Vtlgj1SnySIn8e0CtMZ3 lRr7o4FI9LBT36YxFtZYzDN/Riu6Sc+p74qkHppy/rtqYXFNToBUWssb65A05E385NBx dapHeNIW2a5N/soNvsb5wSYVLjnvkEiCZOEdK8k5bbzkgb4GhkzeZPMJzL6yBpAMOzvv +Yg2po2WwXOzWKEDFsrbYVcZqBABFrD1qhOKqcHzdoM5v0/IALM2ivSVagTkEBWsJJTC Q4xA== 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; bh=P9SEmh3Ti6BweKuBsiI0z3j9kO6wl5de7iuUaFpsagQ=; fh=VXY2Xp/ALXAe/jIoTe2a1mM/XvNmMytw2TPHTg+Jh58=; b=ArtcAAdVRLYQ8GmdLhUJtO5wdrs4Wvre67cQL7l8hsSy7CxINlEccmgNRWBmTZLLbj r8pI0071fRgWrAWjF6toWSBhZ02+Ln3lSrQo73q3R7s7BwoZ7V4IZ5x03kXicWwg1AxE uLl54KjgvxhEoRLlWyUyYgTFDsbjTQ5uebGfMg9q5fargebJJc+kZarrIXX6ILASZPUe 4InUArlGK4KYzZ2SIaqGoRGQRV9K1vZNNdYe4vl2j5YnLebTgUBM92w1vC3Tl1XTM/AS DCIsSeyB14+OWhvf7IqFYt04gQWuTDq8RKFQCFwdZ88Voq5i/Fpj5j/brya0P9RTgS8F e+vQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id t186-20020a2546c3000000b00da0352438dbsi135864yba.590.2023.10.26.12.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 12:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 9DC5F804393A; Thu, 26 Oct 2023 12:55:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbjJZTzZ (ORCPT + 26 others); Thu, 26 Oct 2023 15:55:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbjJZTzX (ORCPT ); Thu, 26 Oct 2023 15:55:23 -0400 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A81C4B9; Thu, 26 Oct 2023 12:55:20 -0700 (PDT) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6ce291b5df9so710134a34.2; Thu, 26 Oct 2023 12:55:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698350120; x=1698954920; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=P9SEmh3Ti6BweKuBsiI0z3j9kO6wl5de7iuUaFpsagQ=; b=qID3Hdr57cb9Nur07Oa3maNzD7TzNRE4oVUrkozYxDnoQs6++5KaPlKL9IJEAxZc4l c0KVkASptzjCFGNlKkvgPB4MiIQNCN+yxDkaKr/ezK8zZlEfQgymGyt8LNW/YehLv4IG nXSfjlQmMAy0VKf6FTD6/L/MA8mB8CWHoeWbOyLZf4Vf7Jgh5+7xOExJiL3I/SduRLfG dkuO1CMJAgughUgHooAwKir9hOieqZnNyBQziR5IKNIhNrSihlPeLZb0Jq7WXh3SL7BB iQwuNOXSTJqSJainResUKCXb2JhFWZ++TFvehZoOYviKwdD3nY4SDdqxFeCIS0cRpP0P swiA== X-Gm-Message-State: AOJu0YyX3trdKa+XqUxfarLVgAiNr+fefIyIshwnm9CVlCIO1kQWF522 K9Y8cgkVbuuOaUEROm0GzQ== X-Received: by 2002:a05:6830:314c:b0:6b8:9a3a:ea12 with SMTP id c12-20020a056830314c00b006b89a3aea12mr545041ots.12.1698350119860; Thu, 26 Oct 2023 12:55:19 -0700 (PDT) Received: from herring.priv (66-90-144-107.dyn.grandenetworks.net. [66.90.144.107]) by smtp.gmail.com with ESMTPSA id d64-20020a4a5243000000b005737ca61829sm5503oob.13.2023.10.26.12.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 12:55:19 -0700 (PDT) Received: (nullmailer pid 69534 invoked by uid 1000); Thu, 26 Oct 2023 19:55:18 -0000 From: Rob Herring To: Thierry Reding , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Heiko Stuebner Cc: linux-pwm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: [PATCH v2] pwm: Use device_get_match_data() Date: Thu, 26 Oct 2023 14:54:17 -0500 Message-ID: <20231026195417.68090-2-robh@kernel.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 26 Oct 2023 12:55:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780849276536696028 X-GMAIL-MSGID: 1780849276536696028 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. As these drivers only do DT based matching, of_match_device() will never return NULL if we've gotten to probe(). Therefore, the NULL check and error returns can be dropped. Signed-off-by: Rob Herring Reviewed-by: Uwe Kleine-König --- v2: - Add to commit message about of_match_device() error checking drivers/pwm/pwm-img.c | 8 ++------ drivers/pwm/pwm-rockchip.c | 9 ++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c index 116fa060e302..0d218c0b690e 100644 --- a/drivers/pwm/pwm-img.c +++ b/drivers/pwm/pwm-img.c @@ -13,9 +13,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -260,7 +260,6 @@ static int img_pwm_probe(struct platform_device *pdev) u64 val; unsigned long clk_rate; struct img_pwm_chip *imgchip; - const struct of_device_id *of_dev_id; imgchip = devm_kzalloc(&pdev->dev, sizeof(*imgchip), GFP_KERNEL); if (!imgchip) @@ -272,10 +271,7 @@ static int img_pwm_probe(struct platform_device *pdev) if (IS_ERR(imgchip->base)) return PTR_ERR(imgchip->base); - of_dev_id = of_match_device(img_pwm_of_match, &pdev->dev); - if (!of_dev_id) - return -ENODEV; - imgchip->data = of_dev_id->data; + imgchip->data = device_get_match_data(&pdev->dev); imgchip->periph_regs = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, "img,cr-periph"); diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c index cce4381e188a..a7c647e37837 100644 --- a/drivers/pwm/pwm-rockchip.c +++ b/drivers/pwm/pwm-rockchip.c @@ -10,8 +10,8 @@ #include #include #include -#include #include +#include #include #include @@ -296,16 +296,11 @@ MODULE_DEVICE_TABLE(of, rockchip_pwm_dt_ids); static int rockchip_pwm_probe(struct platform_device *pdev) { - const struct of_device_id *id; struct rockchip_pwm_chip *pc; u32 enable_conf, ctrl; bool enabled; int ret, count; - id = of_match_device(rockchip_pwm_dt_ids, &pdev->dev); - if (!id) - return -EINVAL; - pc = devm_kzalloc(&pdev->dev, sizeof(*pc), GFP_KERNEL); if (!pc) return -ENOMEM; @@ -344,7 +339,7 @@ static int rockchip_pwm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pc); - pc->data = id->data; + pc->data = device_get_match_data(&pdev->dev); pc->chip.dev = &pdev->dev; pc->chip.ops = &rockchip_pwm_ops; pc->chip.npwm = 1;