All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org
Subject: Re: [PATCH v3 1/2] can: mcp251xfd: mcp251xfd_probe(): try to get crystal clock rate from property
Date: Mon, 31 May 2021 13:09:41 +0300	[thread overview]
Message-ID: <YLS15VESjAVZ2w6G@smile.fi.intel.com> (raw)
In-Reply-To: <20210531084444.1785397-1-mkl@pengutronix.de>

On Mon, May 31, 2021 at 10:44:43AM +0200, Marc Kleine-Budde wrote:
> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> In some configurations, mainly ACPI-based, the clock frequency of the
> device is supplied by very well established 'clock-frequency'
> property. Hence, try to get it from the property at last if no other
> providers are available.

Oops, I have answered to v2 before looking for new version from you,

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

> v3: - only read clock-frequency property if no clk is found
>     - add error handling to device_property_read_u32()
> v2: new patch    
> 
>  drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> index 47c3f408a799..c8f8bdfc1bfb 100644
> --- a/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> +++ b/drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
> @@ -2883,11 +2883,19 @@ static int mcp251xfd_probe(struct spi_device *spi)
>  		return dev_err_probe(&spi->dev, PTR_ERR(reg_xceiver),
>  				     "Failed to get Transceiver regulator!\n");
>  
> -	clk = devm_clk_get(&spi->dev, NULL);
> +	clk = devm_clk_get_optional(&spi->dev, NULL);
>  	if (IS_ERR(clk))
>  		return dev_err_probe(&spi->dev, PTR_ERR(clk),
>  				     "Failed to get Oscillator (clock)!\n");
> -	freq = clk_get_rate(clk);

> +	if (clk) {

This check basically only for property case, clk_get_rate() has it.
That's why I have different flow, but this one also will work, thanks!

> +		freq = clk_get_rate(clk);
> +	} else {
> +		err = device_property_read_u32(&spi->dev, "clock-frequency",
> +					       &freq);
> +		if (err)
> +			return dev_err_probe(&spi->dev, err,
> +					     "Failed to get clock-frequency!\n");
> +	}
>  
>  	/* Sanity check */
>  	if (freq < MCP251XFD_SYSCLOCK_HZ_MIN ||
> -- 
> 2.30.2
> 
> 

-- 
With Best Regards,
Andy Shevchenko



  parent reply	other threads:[~2021-05-31 10:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-31  8:44 Marc Kleine-Budde
2021-05-31  8:44 ` [PATCH v3 2/2] can: mcp251xfd: Fix header block to clarify independence from OF Marc Kleine-Budde
2021-05-31 10:09 ` Andy Shevchenko [this message]
2021-07-06 10:10   ` [PATCH v3 1/2] can: mcp251xfd: mcp251xfd_probe(): try to get crystal clock rate from property Andy Shevchenko
2021-07-06 10:14     ` Marc Kleine-Budde
2021-07-22 18:52       ` Andy Shevchenko

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=YLS15VESjAVZ2w6G@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --subject='Re: [PATCH v3 1/2] can: mcp251xfd: mcp251xfd_probe(): try to get crystal clock rate from property' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.