LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 0/3] wilc1000: minor cleanups
@ 2021-08-06  8:12 Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 1/3] wilc1000: use goto labels on error path Claudiu Beznea
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Claudiu Beznea @ 2021-08-06  8:12 UTC (permalink / raw)
  To: ajay.kathat, kvalo, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Claudiu Beznea

Hi,

The series contains some cleanups for wilc1000 driver.

Thank you,
Claudiu Beznea

Claudiu Beznea (3):
  wilc1000: use goto labels on error path
  wilc1000: dipose irq on failure path
  wilc1000: use devm_clk_get_optional()

 .../net/wireless/microchip/wilc1000/sdio.c    | 29 ++++++++++---------
 drivers/net/wireless/microchip/wilc1000/spi.c | 29 ++++++++++---------
 2 files changed, 32 insertions(+), 26 deletions(-)

-- 
2.25.1


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

* [PATCH 1/3] wilc1000: use goto labels on error path
  2021-08-06  8:12 [PATCH 0/3] wilc1000: minor cleanups Claudiu Beznea
@ 2021-08-06  8:12 ` Claudiu Beznea
  2021-08-21 17:46   ` Kalle Valo
  2021-08-06  8:12 ` [PATCH 2/3] wilc1000: dipose irq on failure path Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 3/3] wilc1000: use devm_clk_get_optional() Claudiu Beznea
  2 siblings, 1 reply; 5+ messages in thread
From: Claudiu Beznea @ 2021-08-06  8:12 UTC (permalink / raw)
  To: ajay.kathat, kvalo, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Claudiu Beznea

Use goto labels on error path for probe functions. This makes code easier
to read. With this introduce also netdev_cleanup and call it where
necessary.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/sdio.c | 16 ++++++++++------
 drivers/net/wireless/microchip/wilc1000/spi.c  | 16 ++++++++++------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
index e14b9fc2c67a..d11f245542e7 100644
--- a/drivers/net/wireless/microchip/wilc1000/sdio.c
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -129,10 +129,8 @@ static int wilc_sdio_probe(struct sdio_func *func,
 
 	ret = wilc_cfg80211_init(&wilc, &func->dev, WILC_HIF_SDIO,
 				 &wilc_hif_sdio);
-	if (ret) {
-		kfree(sdio_priv);
-		return ret;
-	}
+	if (ret)
+		goto free;
 
 	if (IS_ENABLED(CONFIG_WILC1000_HW_OOB_INTR)) {
 		struct device_node *np = func->card->dev.of_node;
@@ -150,13 +148,19 @@ static int wilc_sdio_probe(struct sdio_func *func,
 
 	wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
 	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-		kfree(sdio_priv);
-		return -EPROBE_DEFER;
+		ret = -EPROBE_DEFER;
+		goto netdev_cleanup;
 	} else if (!IS_ERR(wilc->rtc_clk))
 		clk_prepare_enable(wilc->rtc_clk);
 
 	dev_info(&func->dev, "Driver Initializing success\n");
 	return 0;
+
+netdev_cleanup:
+	wilc_netdev_cleanup(wilc);
+free:
+	kfree(sdio_priv);
+	return ret;
 }
 
 static void wilc_sdio_remove(struct sdio_func *func)
diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 8e9aaf03a6fa..23d811b2b925 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -154,10 +154,8 @@ static int wilc_bus_probe(struct spi_device *spi)
 		return -ENOMEM;
 
 	ret = wilc_cfg80211_init(&wilc, &spi->dev, WILC_HIF_SPI, &wilc_hif_spi);
-	if (ret) {
-		kfree(spi_priv);
-		return ret;
-	}
+	if (ret)
+		goto free;
 
 	spi_set_drvdata(spi, wilc);
 	wilc->dev = &spi->dev;
@@ -166,12 +164,18 @@ static int wilc_bus_probe(struct spi_device *spi)
 
 	wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc");
 	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-		kfree(spi_priv);
-		return -EPROBE_DEFER;
+		ret = -EPROBE_DEFER;
+		goto netdev_cleanup;
 	} else if (!IS_ERR(wilc->rtc_clk))
 		clk_prepare_enable(wilc->rtc_clk);
 
 	return 0;
+
+netdev_cleanup:
+	wilc_netdev_cleanup(wilc);
+free:
+	kfree(spi_priv);
+	return ret;
 }
 
 static int wilc_bus_remove(struct spi_device *spi)
-- 
2.25.1


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

* [PATCH 2/3] wilc1000: dipose irq on failure path
  2021-08-06  8:12 [PATCH 0/3] wilc1000: minor cleanups Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 1/3] wilc1000: use goto labels on error path Claudiu Beznea
@ 2021-08-06  8:12 ` Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 3/3] wilc1000: use devm_clk_get_optional() Claudiu Beznea
  2 siblings, 0 replies; 5+ messages in thread
From: Claudiu Beznea @ 2021-08-06  8:12 UTC (permalink / raw)
  To: ajay.kathat, kvalo, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Claudiu Beznea

Dispose IRQ on failure path.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/sdio.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
index d11f245542e7..d1fd182bbbff 100644
--- a/drivers/net/wireless/microchip/wilc1000/sdio.c
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -149,14 +149,15 @@ static int wilc_sdio_probe(struct sdio_func *func,
 	wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
 	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
 		ret = -EPROBE_DEFER;
-		goto netdev_cleanup;
+		goto dispose_irq;
 	} else if (!IS_ERR(wilc->rtc_clk))
 		clk_prepare_enable(wilc->rtc_clk);
 
 	dev_info(&func->dev, "Driver Initializing success\n");
 	return 0;
 
-netdev_cleanup:
+dispose_irq:
+	irq_dispose_mapping(wilc->dev_irq_num);
 	wilc_netdev_cleanup(wilc);
 free:
 	kfree(sdio_priv);
-- 
2.25.1


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

* [PATCH 3/3] wilc1000: use devm_clk_get_optional()
  2021-08-06  8:12 [PATCH 0/3] wilc1000: minor cleanups Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 1/3] wilc1000: use goto labels on error path Claudiu Beznea
  2021-08-06  8:12 ` [PATCH 2/3] wilc1000: dipose irq on failure path Claudiu Beznea
@ 2021-08-06  8:12 ` Claudiu Beznea
  2 siblings, 0 replies; 5+ messages in thread
From: Claudiu Beznea @ 2021-08-06  8:12 UTC (permalink / raw)
  To: ajay.kathat, kvalo, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Claudiu Beznea

Use devm_clk_get_optional() for rtc clock: it simplifies a bit
the code.

Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>
---
 drivers/net/wireless/microchip/wilc1000/sdio.c | 14 ++++++--------
 drivers/net/wireless/microchip/wilc1000/spi.c  | 15 +++++++--------
 2 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/microchip/wilc1000/sdio.c b/drivers/net/wireless/microchip/wilc1000/sdio.c
index d1fd182bbbff..42e03a701ae1 100644
--- a/drivers/net/wireless/microchip/wilc1000/sdio.c
+++ b/drivers/net/wireless/microchip/wilc1000/sdio.c
@@ -146,12 +146,12 @@ static int wilc_sdio_probe(struct sdio_func *func,
 	wilc->bus_data = sdio_priv;
 	wilc->dev = &func->dev;
 
-	wilc->rtc_clk = devm_clk_get(&func->card->dev, "rtc");
-	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-		ret = -EPROBE_DEFER;
+	wilc->rtc_clk = devm_clk_get_optional(&func->card->dev, "rtc");
+	if (IS_ERR(wilc->rtc_clk)) {
+		ret = PTR_ERR(wilc->rtc_clk);
 		goto dispose_irq;
-	} else if (!IS_ERR(wilc->rtc_clk))
-		clk_prepare_enable(wilc->rtc_clk);
+	}
+	clk_prepare_enable(wilc->rtc_clk);
 
 	dev_info(&func->dev, "Driver Initializing success\n");
 	return 0;
@@ -168,9 +168,7 @@ static void wilc_sdio_remove(struct sdio_func *func)
 {
 	struct wilc *wilc = sdio_get_drvdata(func);
 
-	if (!IS_ERR(wilc->rtc_clk))
-		clk_disable_unprepare(wilc->rtc_clk);
-
+	clk_disable_unprepare(wilc->rtc_clk);
 	wilc_netdev_cleanup(wilc);
 }
 
diff --git a/drivers/net/wireless/microchip/wilc1000/spi.c b/drivers/net/wireless/microchip/wilc1000/spi.c
index 23d811b2b925..8b180c29d682 100644
--- a/drivers/net/wireless/microchip/wilc1000/spi.c
+++ b/drivers/net/wireless/microchip/wilc1000/spi.c
@@ -162,12 +162,12 @@ static int wilc_bus_probe(struct spi_device *spi)
 	wilc->bus_data = spi_priv;
 	wilc->dev_irq_num = spi->irq;
 
-	wilc->rtc_clk = devm_clk_get(&spi->dev, "rtc");
-	if (PTR_ERR_OR_ZERO(wilc->rtc_clk) == -EPROBE_DEFER) {
-		ret = -EPROBE_DEFER;
+	wilc->rtc_clk = devm_clk_get_optional(&spi->dev, "rtc");
+	if (IS_ERR(wilc->rtc_clk)) {
+		ret = PTR_ERR(wilc->rtc_clk);
 		goto netdev_cleanup;
-	} else if (!IS_ERR(wilc->rtc_clk))
-		clk_prepare_enable(wilc->rtc_clk);
+	}
+	clk_prepare_enable(wilc->rtc_clk);
 
 	return 0;
 
@@ -182,10 +182,9 @@ static int wilc_bus_remove(struct spi_device *spi)
 {
 	struct wilc *wilc = spi_get_drvdata(spi);
 
-	if (!IS_ERR(wilc->rtc_clk))
-		clk_disable_unprepare(wilc->rtc_clk);
-
+	clk_disable_unprepare(wilc->rtc_clk);
 	wilc_netdev_cleanup(wilc);
+
 	return 0;
 }
 
-- 
2.25.1


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

* Re: [PATCH 1/3] wilc1000: use goto labels on error path
  2021-08-06  8:12 ` [PATCH 1/3] wilc1000: use goto labels on error path Claudiu Beznea
@ 2021-08-21 17:46   ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2021-08-21 17:46 UTC (permalink / raw)
  To: Claudiu Beznea
  Cc: ajay.kathat, davem, kuba, linux-wireless, netdev, linux-kernel,
	Claudiu Beznea

Claudiu Beznea <claudiu.beznea@microchip.com> wrote:

> Use goto labels on error path for probe functions. This makes code easier
> to read. With this introduce also netdev_cleanup and call it where
> necessary.
> 
> Signed-off-by: Claudiu Beznea <claudiu.beznea@microchip.com>

3 patches applied to wireless-drivers-next.git, thanks.

dc8b338f3bcd wilc1000: use goto labels on error path
f36a0ee599c9 wilc1000: dispose irq on failure path
1d89fd1a39d1 wilc1000: use devm_clk_get_optional()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20210806081229.721731-2-claudiu.beznea@microchip.com/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


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

end of thread, other threads:[~2021-08-21 17:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06  8:12 [PATCH 0/3] wilc1000: minor cleanups Claudiu Beznea
2021-08-06  8:12 ` [PATCH 1/3] wilc1000: use goto labels on error path Claudiu Beznea
2021-08-21 17:46   ` Kalle Valo
2021-08-06  8:12 ` [PATCH 2/3] wilc1000: dipose irq on failure path Claudiu Beznea
2021-08-06  8:12 ` [PATCH 3/3] wilc1000: use devm_clk_get_optional() Claudiu Beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).