netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ieee802154: at86rf230: drop support for platform data
@ 2023-02-01  5:34 Dmitry Torokhov
  2023-02-01  5:34 ` [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API Dmitry Torokhov
  2023-02-01 20:55 ` [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Stefan Schmidt
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2023-02-01  5:34 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt
  Cc: Arnd Bergmann, Miquel Raynal, Andy Shevchenko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel,
	linux-wpan, netdev

There are no users of platform data in the mainline tree, and new
boards should use either ACPI or device tree, so let's stop supporting
it. This will help with converting the driver to gpiod API.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 42 ++++++++----------------------
 include/linux/spi/at86rf230.h      | 20 --------------
 2 files changed, 11 insertions(+), 51 deletions(-)
 delete mode 100644 include/linux/spi/at86rf230.h

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 15f283b26721..d6b6b355348b 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -17,8 +17,8 @@
 #include <linux/irq.h>
 #include <linux/gpio.h>
 #include <linux/delay.h>
+#include <linux/property.h>
 #include <linux/spi/spi.h>
-#include <linux/spi/at86rf230.h>
 #include <linux/regmap.h>
 #include <linux/skbuff.h>
 #include <linux/of_gpio.h>
@@ -1415,32 +1415,6 @@ static int at86rf230_hw_init(struct at86rf230_local *lp, u8 xtal_trim)
 	return at86rf230_write_subreg(lp, SR_SLOTTED_OPERATION, 0);
 }
 
-static int
-at86rf230_get_pdata(struct spi_device *spi, int *rstn, int *slp_tr,
-		    u8 *xtal_trim)
-{
-	struct at86rf230_platform_data *pdata = spi->dev.platform_data;
-	int ret;
-
-	if (!IS_ENABLED(CONFIG_OF) || !spi->dev.of_node) {
-		if (!pdata)
-			return -ENOENT;
-
-		*rstn = pdata->rstn;
-		*slp_tr = pdata->slp_tr;
-		*xtal_trim = pdata->xtal_trim;
-		return 0;
-	}
-
-	*rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
-	*slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
-	ret = of_property_read_u8(spi->dev.of_node, "xtal-trim", xtal_trim);
-	if (ret < 0 && ret != -EINVAL)
-		return ret;
-
-	return 0;
-}
-
 static int
 at86rf230_detect_device(struct at86rf230_local *lp)
 {
@@ -1548,19 +1522,24 @@ static int at86rf230_probe(struct spi_device *spi)
 	struct at86rf230_local *lp;
 	unsigned int status;
 	int rc, irq_type, rstn, slp_tr;
-	u8 xtal_trim = 0;
+	u8 xtal_trim;
 
 	if (!spi->irq) {
 		dev_err(&spi->dev, "no IRQ specified\n");
 		return -EINVAL;
 	}
 
-	rc = at86rf230_get_pdata(spi, &rstn, &slp_tr, &xtal_trim);
+	rc = device_property_read_u8(&spi->dev, "xtal-trim", &xtal_trim);
 	if (rc < 0) {
-		dev_err(&spi->dev, "failed to parse platform_data: %d\n", rc);
-		return rc;
+		if (rc != -EINVAL) {
+			dev_err(&spi->dev,
+				"failed to parse xtal-trim: %d\n", rc);
+			return rc;
+		}
+		xtal_trim = 0;
 	}
 
+	rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
 	if (gpio_is_valid(rstn)) {
 		rc = devm_gpio_request_one(&spi->dev, rstn,
 					   GPIOF_OUT_INIT_HIGH, "rstn");
@@ -1568,6 +1547,7 @@ static int at86rf230_probe(struct spi_device *spi)
 			return rc;
 	}
 
+	slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
 	if (gpio_is_valid(slp_tr)) {
 		rc = devm_gpio_request_one(&spi->dev, slp_tr,
 					   GPIOF_OUT_INIT_LOW, "slp_tr");
diff --git a/include/linux/spi/at86rf230.h b/include/linux/spi/at86rf230.h
deleted file mode 100644
index d278576ab692..000000000000
--- a/include/linux/spi/at86rf230.h
+++ /dev/null
@@ -1,20 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * AT86RF230/RF231 driver
- *
- * Copyright (C) 2009-2012 Siemens AG
- *
- * Written by:
- * Dmitry Eremin-Solenikov <dmitry.baryshkov@siemens.com>
- */
-#ifndef AT86RF230_H
-#define AT86RF230_H
-
-struct at86rf230_platform_data {
-	int rstn;
-	int slp_tr;
-	int dig2;
-	u8 xtal_trim;
-};
-
-#endif
-- 
2.39.1.456.gfc5497dd1b-goog


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

* [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API
  2023-02-01  5:34 [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Dmitry Torokhov
@ 2023-02-01  5:34 ` Dmitry Torokhov
  2023-02-01 20:55   ` Stefan Schmidt
  2023-02-01 20:55 ` [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Stefan Schmidt
  1 sibling, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2023-02-01  5:34 UTC (permalink / raw)
  To: Alexander Aring, Stefan Schmidt
  Cc: Arnd Bergmann, Miquel Raynal, Andy Shevchenko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel,
	linux-wpan, netdev

Switch the driver from legacy gpio API that is deprecated to the newer
gpiod API that respects line polarities described in ACPI/DT.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 52 +++++++++++++++---------------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index d6b6b355348b..62b984f84d9f 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -82,7 +82,7 @@ struct at86rf230_local {
 	struct ieee802154_hw *hw;
 	struct at86rf2xx_chip_data *data;
 	struct regmap *regmap;
-	int slp_tr;
+	struct gpio_desc *slp_tr;
 	bool sleep;
 
 	struct completion state_complete;
@@ -107,8 +107,8 @@ at86rf230_async_state_change(struct at86rf230_local *lp,
 static inline void
 at86rf230_sleep(struct at86rf230_local *lp)
 {
-	if (gpio_is_valid(lp->slp_tr)) {
-		gpio_set_value(lp->slp_tr, 1);
+	if (lp->slp_tr) {
+		gpiod_set_value(lp->slp_tr, 1);
 		usleep_range(lp->data->t_off_to_sleep,
 			     lp->data->t_off_to_sleep + 10);
 		lp->sleep = true;
@@ -118,8 +118,8 @@ at86rf230_sleep(struct at86rf230_local *lp)
 static inline void
 at86rf230_awake(struct at86rf230_local *lp)
 {
-	if (gpio_is_valid(lp->slp_tr)) {
-		gpio_set_value(lp->slp_tr, 0);
+	if (lp->slp_tr) {
+		gpiod_set_value(lp->slp_tr, 0);
 		usleep_range(lp->data->t_sleep_to_off,
 			     lp->data->t_sleep_to_off + 100);
 		lp->sleep = false;
@@ -204,9 +204,9 @@ at86rf230_write_subreg(struct at86rf230_local *lp,
 static inline void
 at86rf230_slp_tr_rising_edge(struct at86rf230_local *lp)
 {
-	gpio_set_value(lp->slp_tr, 1);
+	gpiod_set_value(lp->slp_tr, 1);
 	udelay(1);
-	gpio_set_value(lp->slp_tr, 0);
+	gpiod_set_value(lp->slp_tr, 0);
 }
 
 static bool
@@ -819,7 +819,7 @@ at86rf230_write_frame_complete(void *context)
 
 	ctx->trx.len = 2;
 
-	if (gpio_is_valid(lp->slp_tr))
+	if (lp->slp_tr)
 		at86rf230_slp_tr_rising_edge(lp);
 	else
 		at86rf230_async_write_reg(lp, RG_TRX_STATE, STATE_BUSY_TX, ctx,
@@ -1520,8 +1520,10 @@ static int at86rf230_probe(struct spi_device *spi)
 {
 	struct ieee802154_hw *hw;
 	struct at86rf230_local *lp;
+	struct gpio_desc *slp_tr;
+	struct gpio_desc *rstn;
 	unsigned int status;
-	int rc, irq_type, rstn, slp_tr;
+	int rc, irq_type;
 	u8 xtal_trim;
 
 	if (!spi->irq) {
@@ -1539,28 +1541,26 @@ static int at86rf230_probe(struct spi_device *spi)
 		xtal_trim = 0;
 	}
 
-	rstn = of_get_named_gpio(spi->dev.of_node, "reset-gpio", 0);
-	if (gpio_is_valid(rstn)) {
-		rc = devm_gpio_request_one(&spi->dev, rstn,
-					   GPIOF_OUT_INIT_HIGH, "rstn");
-		if (rc)
-			return rc;
-	}
+	rstn = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_LOW);
+	rc = PTR_ERR_OR_ZERO(rstn);
+	if (rc)
+		return rc;
 
-	slp_tr = of_get_named_gpio(spi->dev.of_node, "sleep-gpio", 0);
-	if (gpio_is_valid(slp_tr)) {
-		rc = devm_gpio_request_one(&spi->dev, slp_tr,
-					   GPIOF_OUT_INIT_LOW, "slp_tr");
-		if (rc)
-			return rc;
-	}
+	gpiod_set_consumer_name(rstn, "rstn");
+
+	slp_tr = devm_gpiod_get_optional(&spi->dev, "sleep", GPIOD_OUT_LOW);
+	rc = PTR_ERR_OR_ZERO(slp_tr);
+	if (rc)
+		return rc;
+
+	gpiod_set_consumer_name(slp_tr, "slp_tr");
 
 	/* Reset */
-	if (gpio_is_valid(rstn)) {
+	if (rstn) {
 		udelay(1);
-		gpio_set_value_cansleep(rstn, 0);
+		gpiod_set_value_cansleep(rstn, 1);
 		udelay(1);
-		gpio_set_value_cansleep(rstn, 1);
+		gpiod_set_value_cansleep(rstn, 0);
 		usleep_range(120, 240);
 	}
 
-- 
2.39.1.456.gfc5497dd1b-goog


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

* Re: [PATCH 1/2] ieee802154: at86rf230: drop support for platform data
  2023-02-01  5:34 [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Dmitry Torokhov
  2023-02-01  5:34 ` [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API Dmitry Torokhov
@ 2023-02-01 20:55 ` Stefan Schmidt
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2023-02-01 20:55 UTC (permalink / raw)
  To: Dmitry Torokhov, Alexander Aring
  Cc: Arnd Bergmann, Miquel Raynal, Andy Shevchenko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel,
	linux-wpan, netdev

Hello.

On 01.02.23 06:34, Dmitry Torokhov wrote:
> There are no users of platform data in the mainline tree, and new
> boards should use either ACPI or device tree, so let's stop supporting
> it. This will help with converting the driver to gpiod API.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>   drivers/net/ieee802154/at86rf230.c | 42 ++++++++----------------------
>   include/linux/spi/at86rf230.h      | 20 --------------
>   2 files changed, 11 insertions(+), 51 deletions(-)
>   delete mode 100644 include/linux/spi/at86rf230.h

This patch has been applied to the wpan-next tree and will be
part of the next pull request to net-next. Thanks!

regards
Stefan Schmidt

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

* Re: [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API
  2023-02-01  5:34 ` [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API Dmitry Torokhov
@ 2023-02-01 20:55   ` Stefan Schmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2023-02-01 20:55 UTC (permalink / raw)
  To: Dmitry Torokhov, Alexander Aring
  Cc: Arnd Bergmann, Miquel Raynal, Andy Shevchenko, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, linux-kernel,
	linux-wpan, netdev

Hello.

On 01.02.23 06:34, Dmitry Torokhov wrote:
> Switch the driver from legacy gpio API that is deprecated to the newer
> gpiod API that respects line polarities described in ACPI/DT.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>   drivers/net/ieee802154/at86rf230.c | 52 +++++++++++++++---------------
>   1 file changed, 26 insertions(+), 26 deletions(-)

This patch has been applied to the wpan-next tree and will be
part of the next pull request to net-next. Thanks!

regards
Stefan Schmidt

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

end of thread, other threads:[~2023-02-01 20:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-01  5:34 [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Dmitry Torokhov
2023-02-01  5:34 ` [PATCH 2/2] ieee802154: at86rf230: switch to using gpiod API Dmitry Torokhov
2023-02-01 20:55   ` Stefan Schmidt
2023-02-01 20:55 ` [PATCH 1/2] ieee802154: at86rf230: drop support for platform data Stefan Schmidt

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).