All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled()
@ 2023-05-28 19:58 Lars-Peter Clausen
  2023-05-28 19:58 ` [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2023-05-28 19:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Kunihiko Hayashi, linux-spi, Lars-Peter Clausen

Replace the combination of devm_clk_get_enable() plus clk_prepare_enable()
with devm_clk_get_enabled(). Slightly reduces the amount of boilerplate
code.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/spi/spi-sn-f-ospi.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c
index a2bd9dcde075..39c4df54cdb8 100644
--- a/drivers/spi/spi-sn-f-ospi.c
+++ b/drivers/spi/spi-sn-f-ospi.c
@@ -634,18 +634,12 @@ static int f_ospi_probe(struct platform_device *pdev)
 		goto err_put_ctlr;
 	}
 
-	ospi->clk = devm_clk_get(dev, NULL);
+	ospi->clk = devm_clk_get_enabled(dev, NULL);
 	if (IS_ERR(ospi->clk)) {
 		ret = PTR_ERR(ospi->clk);
 		goto err_put_ctlr;
 	}
 
-	ret = clk_prepare_enable(ospi->clk);
-	if (ret) {
-		dev_err(dev, "Failed to enable the clock\n");
-		goto err_disable_clk;
-	}
-
 	mutex_init(&ospi->mlock);
 
 	ret = f_ospi_init(ospi);
@@ -661,9 +655,6 @@ static int f_ospi_probe(struct platform_device *pdev)
 err_destroy_mutex:
 	mutex_destroy(&ospi->mlock);
 
-err_disable_clk:
-	clk_disable_unprepare(ospi->clk);
-
 err_put_ctlr:
 	spi_controller_put(ctlr);
 
@@ -674,8 +665,6 @@ static void f_ospi_remove(struct platform_device *pdev)
 {
 	struct f_ospi *ospi = platform_get_drvdata(pdev);
 
-	clk_disable_unprepare(ospi->clk);
-
 	mutex_destroy(&ospi->mlock);
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it
  2023-05-28 19:58 [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Lars-Peter Clausen
@ 2023-05-28 19:58 ` Lars-Peter Clausen
  2023-05-28 19:58 ` [PATCH 3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const Lars-Peter Clausen
  2023-05-30 17:40 ` [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2023-05-28 19:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Kunihiko Hayashi, linux-spi, Lars-Peter Clausen

Use `min_t` instead of `min` with casting the individual arguments.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/spi/spi-sn-f-ospi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c
index 39c4df54cdb8..691b6092fb3f 100644
--- a/drivers/spi/spi-sn-f-ospi.c
+++ b/drivers/spi/spi-sn-f-ospi.c
@@ -566,7 +566,7 @@ static bool f_ospi_supports_op(struct spi_mem *mem,
 
 static int f_ospi_adjust_op_size(struct spi_mem *mem, struct spi_mem_op *op)
 {
-	op->data.nbytes = min((int)op->data.nbytes, (int)(OSPI_DAT_SIZE_MAX));
+	op->data.nbytes = min_t(int, op->data.nbytes, OSPI_DAT_SIZE_MAX);
 
 	return 0;
 }
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const
  2023-05-28 19:58 [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Lars-Peter Clausen
  2023-05-28 19:58 ` [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it Lars-Peter Clausen
@ 2023-05-28 19:58 ` Lars-Peter Clausen
  2023-05-30 17:40 ` [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Lars-Peter Clausen @ 2023-05-28 19:58 UTC (permalink / raw)
  To: Mark Brown; +Cc: Kunihiko Hayashi, linux-spi, Lars-Peter Clausen

The `width_available` array is currently placed on the
`f_ospi_supports_op_width()` function's stack.

But the array is never modified. Make it `static const`. This makes the
code slightly smaller and more efficient.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/spi/spi-sn-f-ospi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-sn-f-ospi.c b/drivers/spi/spi-sn-f-ospi.c
index 691b6092fb3f..d64d3f75c726 100644
--- a/drivers/spi/spi-sn-f-ospi.c
+++ b/drivers/spi/spi-sn-f-ospi.c
@@ -526,7 +526,7 @@ static int f_ospi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
 static bool f_ospi_supports_op_width(struct spi_mem *mem,
 				     const struct spi_mem_op *op)
 {
-	u8 width_available[] = { 0, 1, 2, 4, 8 };
+	static const u8 width_available[] = { 0, 1, 2, 4, 8 };
 	u8 width_op[] = { op->cmd.buswidth, op->addr.buswidth,
 			  op->dummy.buswidth, op->data.buswidth };
 	bool is_match_found;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled()
  2023-05-28 19:58 [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Lars-Peter Clausen
  2023-05-28 19:58 ` [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it Lars-Peter Clausen
  2023-05-28 19:58 ` [PATCH 3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const Lars-Peter Clausen
@ 2023-05-30 17:40 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2023-05-30 17:40 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Kunihiko Hayashi, linux-spi

On Sun, 28 May 2023 12:58:28 -0700, Lars-Peter Clausen wrote:
> Replace the combination of devm_clk_get_enable() plus clk_prepare_enable()
> with devm_clk_get_enabled(). Slightly reduces the amount of boilerplate
> code.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled()
      commit: 5363073dfcf087393c0587e9217ef50b1d63fcce
[2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it
      commit: 282152fa9d54a84a486b93a913934c21503fb5db
[3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const
      commit: 81ea9a0710bcf74934446f63898f0186aeb2b5b8

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-05-30 17:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28 19:58 [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Lars-Peter Clausen
2023-05-28 19:58 ` [PATCH 2/3] spi: spi-sn-f-ospi: Use min_t instead of opencoding it Lars-Peter Clausen
2023-05-28 19:58 ` [PATCH 3/3] spi: spi-sn-f-ospi: Make read-only array `width_available` static const Lars-Peter Clausen
2023-05-30 17:40 ` [PATCH 1/3] spi: spi-sn-f-ospi: Use devm_clk_get_enabled() Mark Brown

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.