diff options
author | Alexander Aring <alex.aring@gmail.com> | 2014-03-15 12:29:06 +0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-18 00:10:26 +0400 |
commit | 3fa275712489d31171b612a9a83e7b9840c6364e (patch) | |
tree | 9a5dc443ca28415dc90d064540b30657fdc6d1a1 /drivers/net | |
parent | 56f023fbe8fff04a46b5486288eaa1dc8bfdd5b9 (diff) | |
download | linux-3fa275712489d31171b612a9a83e7b9840c6364e.tar.xz |
at86rf230: make reset pin optionally
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.aring@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/ieee802154/at86rf230.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c index 37442407d948..47677e3f986f 100644 --- a/drivers/net/ieee802154/at86rf230.c +++ b/drivers/net/ieee802154/at86rf230.c @@ -1059,9 +1059,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"); @@ -1069,9 +1071,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); @@ -1080,11 +1084,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); - usleep_range(120, 240); + if (gpio_is_valid(pdata->rstn)) { + udelay(1); + gpio_set_value(pdata->rstn, 0); + udelay(1); + gpio_set_value(pdata->rstn, 1); + usleep_range(120, 240); + } rc = __at86rf230_detect_device(spi, &man_id, &part, &version); if (rc < 0) @@ -1198,7 +1204,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; } @@ -1214,7 +1221,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); |