From: Arun Muthusamy <arun.muthusamy@gaisler.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
mailhol@kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-can@vger.kernel.org,
Daniel Hellstrom <daniel@gaisler.com>
Subject: Re: [PATCH v3 04/15] can: grcan: Add clock handling
Date: Tue, 27 Jan 2026 14:27:38 +0100 [thread overview]
Message-ID: <c63eb30b-5856-4fc5-84e1-78e07125f0e7@gaisler.com> (raw)
In-Reply-To: <20260123-astonishing-swine-from-mars-0f9b52-mkl@pengutronix.de>
On 1/23/26 14:44, Marc Kleine-Budde wrote:
> On 22.01.2026 13:10:27, Arun Muthusamy wrote:
>> From: Daniel Hellstrom <daniel@gaisler.com>
>>
>> Add clock handling and add error messages for missing 'freq' DT property.
>>
>> Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
>> Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
>> ---
>> drivers/net/can/grcan.c | 19 ++++++++++++++++---
>> 1 file changed, 16 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
>> index 3b1b09943436..538a9b4f82ab 100644
>> --- a/drivers/net/can/grcan.c
>> +++ b/drivers/net/can/grcan.c
>> @@ -34,7 +34,7 @@
>> #include <linux/spinlock.h>
>> #include <linux/of.h>
>> #include <linux/of_irq.h>
>> -
>> +#include <linux/clk.h>
>> #include <linux/dma-mapping.h>
>>
>> #define DRV_NAME "grcan"
>> @@ -1644,6 +1644,7 @@ static int grcan_probe(struct platform_device *ofdev)
>> {
>> struct device_node *np = ofdev->dev.of_node;
>> struct device_node *sysid_parent;
>> + struct clk *clk;
>> u32 sysid, ambafreq;
>> int irq, err;
>> void __iomem *base;
>> @@ -1663,8 +1664,20 @@ static int grcan_probe(struct platform_device *ofdev)
>>
>> err = of_property_read_u32(np, "freq", &ambafreq);
>> if (err) {
>> - dev_err(&ofdev->dev, "unable to fetch \"freq\" property\n");
>> - goto exit_error;
>> + clk = devm_clk_get(&ofdev->dev, NULL);
>> + if (IS_ERR(clk)) {
>> + dev_err_probe(&ofdev->dev, PTR_ERR(clk),
>> + "Failed both to get \"freq\" property and clock for fallback\n");
>> + err = PTR_ERR(clk);
>> + goto exit_error;
>> + }
> I think devm_clk_get() either returns an error pointer or a valid clock
> pointer.
>
>> + if (clk) {
>> + ambafreq = clk_get_rate(clk);
>> + if (!ambafreq) {
>> + dev_err(&ofdev->dev, "Invalid or Uninitialized clock\n");
>> + return -EINVAL;
>> + }
>> + }
>> }
>>
>> base = devm_platform_ioremap_resource(ofdev, 0);
>>
you are correct, since devm_clk_get() returns either a valid clock pointer or an error pointer, "if (clk)" check is indeed redundant.
next prev parent reply other threads:[~2026-01-27 13:27 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 12:10 [PATCH v3 00/15] can: grcan: Enhance driver with CANFD Support and Improvemens Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 01/15] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Arun Muthusamy
2026-01-22 12:44 ` Krzysztof Kozlowski
2026-01-22 12:10 ` [PATCH v3 02/15] net: can: Convert gaisler,grcan to DT schema Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 03/15] MAINTAINERS: Add maintainers for GRCAN CAN network driver Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 04/15] can: grcan: Add clock handling Arun Muthusamy
2026-01-23 13:44 ` Marc Kleine-Budde
2026-01-27 13:27 ` Arun Muthusamy [this message]
2026-01-22 12:10 ` [PATCH v3 05/15] can: grcan: Replace bit timing macros with literal values Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 06/15] can: grcan: Simplify timing configuration Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 07/15] can: grcan: add FD capability detection and nominal bit-timing Arun Muthusamy
2026-01-23 13:52 ` Marc Kleine-Budde
2026-01-22 12:10 ` [PATCH v3 08/15] can: grcan: optimize DMA by 32-bit accesses Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 09/15] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 10/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers Arun Muthusamy
2026-01-23 14:00 ` Marc Kleine-Budde
2026-01-28 8:35 ` Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 11/15] can: grcan: Reserve space between cap and next register to align with address layout Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 12/15] can: grcan: Advertise CANFD capability Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 13/15] can: grcan: Add CANFD TX support alongside legacy CAN Arun Muthusamy
2026-01-23 14:25 ` Marc Kleine-Budde
2026-01-27 14:06 ` Arun Muthusamy
2026-01-27 14:12 ` Marc Kleine-Budde
2026-01-27 14:17 ` Arun Muthusamy
2026-01-27 14:18 ` Marc Kleine-Budde
2026-01-22 12:10 ` [PATCH v3 14/15] can: grcan: Add CANFD RX " Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 15/15] can: grcan: Update echo skb handling to match variable length CANFD frame Arun Muthusamy
2026-01-23 14:12 ` Marc Kleine-Budde
2026-01-23 14:17 ` Marc Kleine-Budde
2026-01-28 8:14 ` Arun Muthusamy
2026-01-23 14:30 ` [PATCH v3 00/15] can: grcan: Enhance driver with CANFD Support and Improvemens Marc Kleine-Budde
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=c63eb30b-5856-4fc5-84e1-78e07125f0e7@gaisler.com \
--to=arun.muthusamy@gaisler.com \
--cc=conor+dt@kernel.org \
--cc=daniel@gaisler.com \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®