From patchwork Wed Nov 22 18:01:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 13465315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EA82EC61D97 for ; Wed, 22 Nov 2023 18:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=e6KJoEMYBj+gnGu8K2PQnt7fIIliPMZGx1eP3CJbfgc=; b=i+uLNvEV8vJFJH mUlpCDDroBzPbi2xDixOoDD85aSy4ivLinsTH1eC4KKA/2Kf87wS3NBDFDYI+1naALc26OhIoZI1s Orvi5AaOE9EZEBerje94fagwUXDCsiKdVe4A/wjTNfcU+xZnSvAZ0T6V0iDrBcbyb0mq50gebKrKT 0DxeeEIyNt4wTd9NqULOEcrfrniXxyXsEAKZsLNeIBRZ34kd0H2cSjtNgH43W/9TeF6S7sR3cg3XV bRB2HPv1fYL4tSdzo9nXpLMUxL61aveDH+XclejLMbCTZ8z5juZCh2nOQAo5pji2l/MeNiw5K9fgn 7EhwF71iDaF5d2aYP2vQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r5rXy-002koN-0n; Wed, 22 Nov 2023 18:01:58 +0000 Received: from mail-il1-f173.google.com ([209.85.166.173]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r5rXv-002kmh-1Q for linux-arm-kernel@lists.infradead.org; Wed, 22 Nov 2023 18:01:57 +0000 Received: by mail-il1-f173.google.com with SMTP id e9e14a558f8ab-35b144ba935so99525ab.1 for ; Wed, 22 Nov 2023 10:01:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700676112; x=1701280912; 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=If8d0YtZJS0mQrEYNoRxWpqFNsU6KzCVMh6IszFfggc=; b=eHyJG+teg6AOyyJardhdj3plnv0ewjRWrYoxp8Iy4wlz7B7uwfJrkmRTMiuvtWIJPz BnS8wD6GVZ2klbl1WoJHz7tf+1KUcfTbaGMxZ2SE/zBg4Th5VvijuMpH9UCDJIetuG5B Ep2cNlbVMYck3XEJFlY/TL9MZgCgYOitraYhmgjpv9kmeSh74cr6kC9udWirl90J0VsP bMI4UyT63elHEJgcYBF+ZCiz7ACxwpBCfrAsY8J+uUVTob79I2dbqoiHjuCThFlI+jSe OcWMIN8EH0j7Evsc07P63UmtrJJtc7FoV23O8k3c3XYshcGs3BfL/U66oT47r/kC+EXf m2Cg== X-Gm-Message-State: AOJu0YzNmOZmhvBKHBRNdz5TGWzBdOAcwupKOwNB0HTtYheMn1uPlKBr KAwqpqMxzXkIKTG7g7ACDw== X-Google-Smtp-Source: AGHT+IF1dkbNJetLgO0LDH6ZmMlsbwQjH0FPKo8tVU1ObnCUsCKI/ybOACitXlO0Xw/jZM71V94chA== X-Received: by 2002:a05:6e02:20c7:b0:35a:d0b3:427a with SMTP id 7-20020a056e0220c700b0035ad0b3427amr3956494ilq.1.1700676112384; Wed, 22 Nov 2023 10:01:52 -0800 (PST) Received: from herring.priv ([64.188.179.252]) by smtp.gmail.com with ESMTPSA id v19-20020a056638359300b004665c29605fsm1766820jal.139.2023.11.22.10.01.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 10:01:51 -0800 (PST) Received: (nullmailer pid 1433277 invoked by uid 1000); Wed, 22 Nov 2023 18:01:49 -0000 From: Rob Herring To: Wolfgang Grandegger , Marc Kleine-Budde , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Appana Durga Kedareswara rao , Naga Sureshkumar Relli , Michal Simek Cc: Simon Horman , linux-can@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] net: can: Use device_get_match_data() Date: Wed, 22 Nov 2023 11:01:39 -0700 Message-ID: <20231122180140.1432025-1-robh@kernel.org> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231122_100155_479518_6C2607A6 X-CRM114-Status: GOOD ( 18.88 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. Error checking for matching and match data was not necessary as matching is always successful if we're already in probe and the match tables always have data pointers. Signed-off-by: Rob Herring Reviewed-by: Simon Horman --- v2: - Drop calling "platform_get_device_id(pdev)->driver_data" in c_can and flexcan as device_get_match_data() already did that. The logic was also wrong and would have resulted in returning -ENODEV. - Drop initializing devtype in xilinx_can --- drivers/net/can/c_can/c_can_platform.c | 13 ++----------- drivers/net/can/flexcan/flexcan-core.c | 12 ++---------- drivers/net/can/mscan/mpc5xxx_can.c | 8 ++++---- drivers/net/can/xilinx_can.c | 9 +++------ 4 files changed, 11 insertions(+), 31 deletions(-) diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index f44ba2600415..e2ec69aa46e5 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c @@ -30,9 +30,9 @@ #include #include #include +#include #include #include -#include #include #include @@ -259,22 +259,13 @@ static int c_can_plat_probe(struct platform_device *pdev) void __iomem *addr; struct net_device *dev; struct c_can_priv *priv; - const struct of_device_id *match; struct resource *mem; int irq; struct clk *clk; const struct c_can_driver_data *drvdata; struct device_node *np = pdev->dev.of_node; - match = of_match_device(c_can_of_table, &pdev->dev); - if (match) { - drvdata = match->data; - } else if (pdev->id_entry->driver_data) { - drvdata = (struct c_can_driver_data *) - platform_get_device_id(pdev)->driver_data; - } else { - return -ENODEV; - } + drvdata = device_get_match_data(&pdev->dev); /* get the appropriate clk */ clk = devm_clk_get(&pdev->dev, NULL); diff --git a/drivers/net/can/flexcan/flexcan-core.c b/drivers/net/can/flexcan/flexcan-core.c index d15f85a40c1e..8ea7f2795551 100644 --- a/drivers/net/can/flexcan/flexcan-core.c +++ b/drivers/net/can/flexcan/flexcan-core.c @@ -23,11 +23,11 @@ #include #include #include -#include #include #include #include #include +#include #include #include @@ -2034,7 +2034,6 @@ MODULE_DEVICE_TABLE(platform, flexcan_id_table); static int flexcan_probe(struct platform_device *pdev) { - const struct of_device_id *of_id; const struct flexcan_devtype_data *devtype_data; struct net_device *dev; struct flexcan_priv *priv; @@ -2090,14 +2089,7 @@ static int flexcan_probe(struct platform_device *pdev) if (IS_ERR(regs)) return PTR_ERR(regs); - of_id = of_match_device(flexcan_of_match, &pdev->dev); - if (of_id) - devtype_data = of_id->data; - else if (platform_get_device_id(pdev)->driver_data) - devtype_data = (struct flexcan_devtype_data *) - platform_get_device_id(pdev)->driver_data; - else - return -ENODEV; + devtype_data = device_get_match_data(&pdev->dev); if ((devtype_data->quirks & FLEXCAN_QUIRK_SUPPORT_FD) && !((devtype_data->quirks & diff --git a/drivers/net/can/mscan/mpc5xxx_can.c b/drivers/net/can/mscan/mpc5xxx_can.c index 4837df6efa92..5b3d69c3b6b6 100644 --- a/drivers/net/can/mscan/mpc5xxx_can.c +++ b/drivers/net/can/mscan/mpc5xxx_can.c @@ -12,8 +12,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -290,7 +292,7 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev) int irq, mscan_clksrc = 0; int err = -ENOMEM; - data = of_device_get_match_data(&ofdev->dev); + data = device_get_match_data(&ofdev->dev); if (!data) return -EINVAL; @@ -351,13 +353,11 @@ static int mpc5xxx_can_probe(struct platform_device *ofdev) static void mpc5xxx_can_remove(struct platform_device *ofdev) { - const struct of_device_id *match; const struct mpc5xxx_can_data *data; struct net_device *dev = platform_get_drvdata(ofdev); struct mscan_priv *priv = netdev_priv(dev); - match = of_match_device(mpc5xxx_can_table, &ofdev->dev); - data = match ? match->data : NULL; + data = device_get_match_data(&ofdev->dev); unregister_mscandev(dev); if (data && data->put_clock) diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c index abe58f103043..3722eaa84234 100644 --- a/drivers/net/can/xilinx_can.c +++ b/drivers/net/can/xilinx_can.c @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -1726,8 +1726,7 @@ static int xcan_probe(struct platform_device *pdev) struct net_device *ndev; struct xcan_priv *priv; struct phy *transceiver; - const struct of_device_id *of_id; - const struct xcan_devtype_data *devtype = &xcan_axi_data; + const struct xcan_devtype_data *devtype; void __iomem *addr; int ret; int rx_max, tx_max; @@ -1741,9 +1740,7 @@ static int xcan_probe(struct platform_device *pdev) goto err; } - of_id = of_match_device(xcan_of_match, &pdev->dev); - if (of_id && of_id->data) - devtype = of_id->data; + devtype = device_get_match_data(&pdev->dev); hw_tx_max_property = devtype->flags & XCAN_FLAG_TX_MAILBOXES ? "tx-mailbox-count" : "tx-fifo-depth";