mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: "Uwe Kleine-König" <ukleinek@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>
Cc: "Michael Hennerich" <michael.hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Trevor Gamblin" <tgamblin@baylibre.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	linux-pwm@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] pwm: axi-pwmgen: add support for external clock
Date: Wed, 21 May 2025 15:22:20 +0100	[thread overview]
Message-ID: <6b72e9dc9d574aa1f025c0f5d317dcec1d729ba9.camel@gmail.com> (raw)
In-Reply-To: <p3ejuwktdxcjwv43nnap5tin33ziimgxfan2xoghtaaubsxgy7@tjmwjpwy6yy5>

On Wed, 2025-05-21 at 15:54 +0200, Uwe Kleine-König wrote:
> Hello David,
> 
> On Wed, May 21, 2025 at 08:19:51AM -0500, David Lechner wrote:
> > On 5/21/25 4:22 AM, Uwe Kleine-König wrote:
> > > Can you achieve the same effect with the (IMHO slightly nicer but
> > > hand-crafted) following patch:
> > > 
> > >  	ddata = pwmchip_get_drvdata(chip);
> > >  	ddata->regmap = regmap;
> > >  
> > > -	clk = devm_clk_get_enabled(dev, NULL);
> > > -	if (IS_ERR(clk))
> > > -		return dev_err_probe(dev, PTR_ERR(clk), "failed to get
> > > clock\n");
> > > +	axi_clk = devm_clk_get_enabled(dev, "axi");
> > > +	if (IS_ERR(axi_clk))
> > > +		return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to
> > > get axi clock\n");
> > > 
> > > +	clk = devm_clk_get_enabled_optional(dev, "ext");
> > > +	if (IS_ERR(clk))
> > > +		return dev_err_probe(dev, PTR_ERR(clk), "failed to get
> > > ext clock\n");
> > > +	}
> > 
> > The trouble with this is that it would not work with existing .dtbs
> > that don't have clock-names set. I think it would need to be more like this:
> > 
> > 
> > 	axi_clk = devm_clk_get_enabled(dev, NULL);
> > 	if (IS_ERR(axi_clk))
> > 		return dev_err_probe(dev, PTR_ERR(axi_clk), "failed to get
> > axi clock\n");
> > 
> > 	clk = devm_clk_get_enabled_optional(dev, "ext");
> > 	if (IS_ERR(clk))
> > 		return dev_err_probe(dev, PTR_ERR(clk), "failed to get ext
> > clock\n");
> > 
> > 	if (!clk)
> > 		clk = axi_clk
> > 
> 
> If there are no clock-names, the parameter is ignored. (I didn't test,
> only quickly checked the code.) So passing "axi" instead of NULL should
> work and yield a more robust solution.
> 
> 

Are you sure? If there are no clock-names and you pass an id, you should get an
error back:

https://elixir.bootlin.com/linux/v6.14.7/source/drivers/clk/clk.c#L5198


I know it's not exactly the same we're discussing but of_property_match_string()
return -EINVAL if the property is not found which leads to an index < 0 and thus
of_parse_phandle_with_args() also returns an error back.

I think I'm not missing anything but it's always a possibility.

- Nuno Sá

  parent reply	other threads:[~2025-05-21 14:22 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-20 21:00 [PATCH 0/3] pwm: axi-pwmgen: add " David Lechner
2025-05-20 21:00 ` [PATCH 1/3] dt-bindings: pwm: adi,axi-pwmgen: update documentation link David Lechner
2025-05-20 21:00 ` [PATCH 2/3] dt-bindings: pwm: adi,axi-pwmgen: add external clock David Lechner
2025-05-21 10:09   ` Krzysztof Kozlowski
2025-05-21 13:14     ` David Lechner
2025-05-21 13:28       ` Krzysztof Kozlowski
2025-05-21 13:50         ` David Lechner
2025-05-20 21:00 ` [PATCH 3/3] pwm: axi-pwmgen: add support for " David Lechner
2025-05-21  9:22   ` Uwe Kleine-König
2025-05-21 13:19     ` David Lechner
2025-05-21 13:54       ` Uwe Kleine-König
2025-05-21 14:12         ` David Lechner
2025-05-21 14:32           ` Nuno Sá
2025-05-21 14:22         ` Nuno Sá [this message]
2025-05-21 15:05           ` David Lechner
2025-05-21 15:40             ` Nuno Sá
2025-05-21 10:10   ` Krzysztof Kozlowski
2025-05-21 13:23     ` David Lechner
2025-05-21 13:30       ` Krzysztof Kozlowski
2025-05-21 13:53         ` David Lechner

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=6b72e9dc9d574aa1f025c0f5d317dcec1d729ba9.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=michael.hennerich@analog.com \
    --cc=nuno.sa@analog.com \
    --cc=robh@kernel.org \
    --cc=tgamblin@baylibre.com \
    --cc=ukleinek@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®