From: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
To: Wolfgang Grandegger <wg@grandegger.com>,
Marc Kleine-Budde <mkl@pengutronix.de>
Cc: Fabrizio Castro <fabrizio.castro@bp.renesas.com>,
Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>,
"David S. Miller" <davem@davemloft.net>,
linux-can@vger.kernel.org, netdev@vger.kernel.org,
Simon Horman <horms@verge.net.au>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Chris Paterson <Chris.Paterson2@renesas.com>,
Biju Das <biju.das@bp.renesas.com>,
linux-renesas-soc@vger.kernel.org
Subject: [PATCH 1/3][can-next] can: rcar_can: Fix erroneous registration
Date: Thu, 23 Aug 2018 14:07:31 +0100 [thread overview]
Message-ID: <1535029653-7418-2-git-send-email-fabrizio.castro@bp.renesas.com> (raw)
In-Reply-To: <1535029653-7418-1-git-send-email-fabrizio.castro@bp.renesas.com>
Assigning 2 to "renesas,can-clock-select" tricks the driver into
registering the CAN interface, even though we don't want that.
This patch fixes this problem and also allows for architectures
missing some of the clocks (e.g. RZ/G2) to behave as expected.
Fixes: 862e2b6af9413b43 ("can: rcar_can: support all input clocks")
Signed-off-by: Fabrizio Castro <fabrizio.castro@bp.renesas.com>
Signed-off-by: Chris Paterson <Chris.Paterson2@renesas.com>
---
This patch applies on linux-can-next-for-4.19-20180727
drivers/net/can/rcar/rcar_can.c | 43 +++++++++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c
index 11662f4..fbd9284 100644
--- a/drivers/net/can/rcar/rcar_can.c
+++ b/drivers/net/can/rcar/rcar_can.c
@@ -21,9 +21,13 @@
#include <linux/clk.h>
#include <linux/can/platform/rcar_can.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#define RCAR_CAN_DRV_NAME "rcar_can"
+#define RCAR_SUPPORTED_CLOCKS (BIT(CLKR_CLKP1) | BIT(CLKR_CLKP2) | \
+ BIT(CLKR_CLKEXT))
+
/* Mailbox configuration:
* mailbox 60 - 63 - Rx FIFO mailboxes
* mailbox 56 - 59 - Tx FIFO mailboxes
@@ -745,10 +749,12 @@ static int rcar_can_probe(struct platform_device *pdev)
u32 clock_select = CLKR_CLKP1;
int err = -ENODEV;
int irq;
+ uintptr_t allowed_clks = RCAR_SUPPORTED_CLOCKS;
if (pdev->dev.of_node) {
of_property_read_u32(pdev->dev.of_node,
"renesas,can-clock-select", &clock_select);
+ allowed_clks = (uintptr_t)of_device_get_match_data(&pdev->dev);
} else {
pdata = dev_get_platdata(&pdev->dev);
if (!pdata) {
@@ -789,7 +795,7 @@ static int rcar_can_probe(struct platform_device *pdev)
goto fail_clk;
}
- if (clock_select >= ARRAY_SIZE(clock_names)) {
+ if (!(BIT(clock_select) & allowed_clks)) {
err = -EINVAL;
dev_err(&pdev->dev, "invalid CAN clock selected\n");
goto fail_clk;
@@ -899,13 +905,34 @@ static int __maybe_unused rcar_can_resume(struct device *dev)
static SIMPLE_DEV_PM_OPS(rcar_can_pm_ops, rcar_can_suspend, rcar_can_resume);
static const struct of_device_id rcar_can_of_table[] __maybe_unused = {
- { .compatible = "renesas,can-r8a7778" },
- { .compatible = "renesas,can-r8a7779" },
- { .compatible = "renesas,can-r8a7790" },
- { .compatible = "renesas,can-r8a7791" },
- { .compatible = "renesas,rcar-gen1-can" },
- { .compatible = "renesas,rcar-gen2-can" },
- { .compatible = "renesas,rcar-gen3-can" },
+ {
+ .compatible = "renesas,can-r8a7778",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,can-r8a7779",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,can-r8a7790",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,can-r8a7791",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,rcar-gen1-can",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,rcar-gen2-can",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
+ {
+ .compatible = "renesas,rcar-gen3-can",
+ .data = (void *)RCAR_SUPPORTED_CLOCKS,
+ },
{ }
};
MODULE_DEVICE_TABLE(of, rcar_can_of_table);
--
2.7.4
next prev parent reply other threads:[~2018-08-23 13:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-23 13:07 [PATCH 0/3] Add CAN support to rcar_can driver Fabrizio Castro
2018-08-23 13:07 ` Fabrizio Castro [this message]
2018-08-24 9:15 ` [PATCH 1/3][can-next] can: rcar_can: Fix erroneous registration Simon Horman
2018-08-27 12:28 ` Geert Uytterhoeven
2018-09-10 9:45 ` Fabrizio Castro
2018-08-23 13:07 ` [PATCH 2/3][can-next] can: rcar_can: Add RZ/G2 support Fabrizio Castro
2018-08-24 9:16 ` Simon Horman
2018-08-24 9:22 ` Fabrizio Castro
2018-08-27 12:30 ` Geert Uytterhoeven
2018-09-10 9:45 ` Fabrizio Castro
2018-08-23 13:07 ` [PATCH 3/3] dt-bindings: can: rcar_can: Add r8a774a1 support Fabrizio Castro
2018-08-24 9:17 ` Simon Horman
2018-08-24 9:22 ` Fabrizio Castro
2018-08-27 12:40 ` Geert Uytterhoeven
2018-09-10 9:54 ` Fabrizio Castro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1535029653-7418-2-git-send-email-fabrizio.castro@bp.renesas.com \
--to=fabrizio.castro@bp.renesas.com \
--cc=Chris.Paterson2@renesas.com \
--cc=biju.das@bp.renesas.com \
--cc=davem@davemloft.net \
--cc=geert+renesas@glider.be \
--cc=horms@verge.net.au \
--cc=linux-can@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).