misc: sram: Improve and simplify clk handling
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thu, 2 Mar 2023 09:12:51 +0000 (10:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Mar 2023 16:31:53 +0000 (17:31 +0100)
commit9263271a61fcb07b8a30379e785391415d10aa72
treead5a651e499ccb62dd58c73e086a162589a74c9a
parent7ef1a2c1c9dffa177ecc3ea50b7f5ee63a621137
misc: sram: Improve and simplify clk handling

The current code tries to get an associated clk, ignores any errors in the
process and if there is a clock enables it unconditionally for the whole
lifetime of the sram device.

Instead use an "optional" variant of devm_clk_get() which handles the case
where no clk is needed for the sram device and do proper error handling
for the remaining error cases. Also use an "enabled" variant of
devm_clk_get() to simplify. With that .probe() is the only function using
struct sram_dev::clk, so it can be replaced by a local variable.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
Link: https://lore.kernel.org/r/20230302091251.1852454-1-u.kleine-koenig@pengutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/sram.c
drivers/misc/sram.h