Skip to content

Commit

Permalink
can: hi311x: hi3110_can_probe(): try to get crystal clock rate from p…
Browse files Browse the repository at this point in the history
…roperty

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.

Link: https://lore.kernel.org/all/20211206165542.69887-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Andy Shevchenko authored and Marc Kleine-Budde committed Dec 8, 2021
1 parent 369cf4e commit 3a1ae63
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions drivers/net/can/spi/hi311x.c
Original file line number Diff line number Diff line change
Expand Up @@ -830,17 +830,26 @@ static int hi3110_can_probe(struct spi_device *spi)
{
const struct of_device_id *of_id = of_match_device(hi3110_of_match,
&spi->dev);
struct device *dev = &spi->dev;
struct net_device *net;
struct hi3110_priv *priv;
struct clk *clk;
int freq, ret;
u32 freq;
int ret;

clk = devm_clk_get_optional(&spi->dev, NULL);
if (IS_ERR(clk)) {
dev_err(&spi->dev, "no CAN clock source defined\n");
return PTR_ERR(clk);
}
freq = clk_get_rate(clk);

if (clk) {
freq = clk_get_rate(clk);
} else {
ret = device_property_read_u32(dev, "clock-frequency", &freq);
if (ret)
return dev_err_probe(dev, ret, "Failed to get clock-frequency!\n");
}

/* Sanity check */
if (freq > 40000000)
Expand Down

0 comments on commit 3a1ae63

Please sign in to comment.