]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
can: grcan: grcan_probe(): fix broken system id check for errata workaround needs
authorAndreas Larsson <andreas@gaisler.com>
Fri, 29 Apr 2022 08:46:55 +0000 (10:46 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:23:13 +0000 (14:23 +0200)
BugLink: https://bugs.launchpad.net/bugs/1978240
commit 1e93ed26acf03fe6c97c6d573a10178596aadd43 upstream.

The systemid property was checked for in the wrong place of the device
tree and compared to the wrong value.

Fixes: 6cec9b07fe6a ("can: grcan: Add device driver for GRCAN and GRHCAN cores")
Link: https://lore.kernel.org/all/20220429084656.29788-3-andreas@gaisler.com
Cc: stable@vger.kernel.org
Signed-off-by: Andreas Larsson <andreas@gaisler.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/can/grcan.c

index 867e179ac304a7a83f8a748f0765a4a027d8f79b..ff6685f1683e94e6b7218b5247d83fbf630e0c24 100644 (file)
@@ -241,7 +241,7 @@ struct grcan_device_config {
                .rxsize         = GRCAN_DEFAULT_BUFFER_SIZE,    \
                }
 
-#define GRCAN_TXBUG_SAFE_GRLIB_VERSION 0x4100
+#define GRCAN_TXBUG_SAFE_GRLIB_VERSION 4100
 #define GRLIB_VERSION_MASK             0xffff
 
 /* GRCAN private data structure */
@@ -1656,6 +1656,7 @@ exit_free_candev:
 static int grcan_probe(struct platform_device *ofdev)
 {
        struct device_node *np = ofdev->dev.of_node;
+       struct device_node *sysid_parent;
        u32 sysid, ambafreq;
        int irq, err;
        void __iomem *base;
@@ -1664,10 +1665,15 @@ static int grcan_probe(struct platform_device *ofdev)
        /* Compare GRLIB version number with the first that does not
         * have the tx bug (see start_xmit)
         */
-       err = of_property_read_u32(np, "systemid", &sysid);
-       if (!err && ((sysid & GRLIB_VERSION_MASK)
-                    >= GRCAN_TXBUG_SAFE_GRLIB_VERSION))
-               txbug = false;
+       sysid_parent = of_find_node_by_path("/ambapp0");
+       if (sysid_parent) {
+               of_node_get(sysid_parent);
+               err = of_property_read_u32(sysid_parent, "systemid", &sysid);
+               if (!err && ((sysid & GRLIB_VERSION_MASK) >=
+                            GRCAN_TXBUG_SAFE_GRLIB_VERSION))
+                       txbug = false;
+               of_node_put(sysid_parent);
+       }
 
        err = of_property_read_u32(np, "freq", &ambafreq);
        if (err) {