This patch make the reset pin optionally. Some devices like the atben
from qi-hardware don't have a reset pin externally. The usually way is
to turn power off/on for the atben device to initiate a device reset.

Signed-off-by: Alexander Aring <alex.ar...@gmail.com>
---
 drivers/net/ieee802154/at86rf230.c | 34 +++++++++++++++++++++-------------
 1 file changed, 21 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ieee802154/at86rf230.c 
b/drivers/net/ieee802154/at86rf230.c
index bc9bad7..f37460a 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1057,9 +1057,11 @@ static int at86rf230_probe(struct spi_device *spi)
                return -EINVAL;
        }
 
-       rc = gpio_request(pdata->rstn, "rstn");
-       if (rc)
-               return rc;
+       if (gpio_is_valid(pdata->rstn)) {
+               rc = gpio_request(pdata->rstn, "rstn");
+               if (rc)
+                       return rc;
+       }
 
        if (gpio_is_valid(pdata->slp_tr)) {
                rc = gpio_request(pdata->slp_tr, "slp_tr");
@@ -1067,9 +1069,11 @@ static int at86rf230_probe(struct spi_device *spi)
                        goto err_slp_tr;
        }
 
-       rc = gpio_direction_output(pdata->rstn, 1);
-       if (rc)
-               goto err_gpio_dir;
+       if (gpio_is_valid(pdata->rstn)) {
+               rc = gpio_direction_output(pdata->rstn, 1);
+               if (rc)
+                       goto err_gpio_dir;
+       }
 
        if (gpio_is_valid(pdata->slp_tr)) {
                rc = gpio_direction_output(pdata->slp_tr, 0);
@@ -1078,11 +1082,13 @@ static int at86rf230_probe(struct spi_device *spi)
        }
 
        /* Reset */
-       udelay(1);
-       gpio_set_value(pdata->rstn, 0);
-       udelay(1);
-       gpio_set_value(pdata->rstn, 1);
-       udelay(1);
+       if (gpio_is_valid(pdata->rstn)) {
+               udelay(1);
+               gpio_set_value(pdata->rstn, 0);
+               udelay(1);
+               gpio_set_value(pdata->rstn, 1);
+               udelay(1);
+       }
 
        rc = __at86rf230_detect_device(spi, &man_id, &part, &version);
        if (rc < 0)
@@ -1192,7 +1198,8 @@ err_gpio_dir:
        if (gpio_is_valid(pdata->slp_tr))
                gpio_free(pdata->slp_tr);
 err_slp_tr:
-       gpio_free(pdata->rstn);
+       if (gpio_is_valid(pdata->rstn))
+               gpio_free(pdata->rstn);
        return rc;
 }
 
@@ -1208,7 +1215,8 @@ static int at86rf230_remove(struct spi_device *spi)
 
        if (gpio_is_valid(pdata->slp_tr))
                gpio_free(pdata->slp_tr);
-       gpio_free(pdata->rstn);
+       if (gpio_is_valid(pdata->rstn))
+               gpio_free(pdata->rstn);
 
        mutex_destroy(&lp->bmux);
        ieee802154_free_device(lp->dev);
-- 
1.9.0


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Linux-zigbee-devel mailing list
Linux-zigbee-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-zigbee-devel

Reply via email to