aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ieee802154
diff options
context:
space:
mode:
authorAlexander Aring <alex.aring@gmail.com>2014-04-24 13:09:09 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-26 12:20:33 -0400
commit0679e29b0c06979f4c2d4561eee0361548d4c80b (patch)
tree1b24f496cf6af89ef6045822fc26621fe9549453 /drivers/net/ieee802154
parent652355c5bd9430d7c382579f2bcd223bc47dd7e7 (diff)
at86rf230: use devm_gpio_request_one
This patch replace the gpio_request functions with devm_gpio_request_one functions. Then we don't need to take care about freeing gpios. Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ieee802154')
-rw-r--r--drivers/net/ieee802154/at86rf230.c53
1 files changed, 12 insertions, 41 deletions
diff --git a/drivers/net/ieee802154/at86rf230.c b/drivers/net/ieee802154/at86rf230.c
index 5856488ebd61..d52700f7e74d 100644
--- a/drivers/net/ieee802154/at86rf230.c
+++ b/drivers/net/ieee802154/at86rf230.c
@@ -1074,27 +1074,17 @@ static int at86rf230_probe(struct spi_device *spi)
1074 } 1074 }
1075 1075
1076 if (gpio_is_valid(pdata->rstn)) { 1076 if (gpio_is_valid(pdata->rstn)) {
1077 rc = gpio_request(pdata->rstn, "rstn"); 1077 rc = devm_gpio_request_one(&spi->dev, pdata->rstn,
1078 GPIOF_OUT_INIT_HIGH, "rstn");
1078 if (rc) 1079 if (rc)
1079 return rc; 1080 return rc;
1080 } 1081 }
1081 1082
1082 if (gpio_is_valid(pdata->slp_tr)) { 1083 if (gpio_is_valid(pdata->slp_tr)) {
1083 rc = gpio_request(pdata->slp_tr, "slp_tr"); 1084 rc = devm_gpio_request_one(&spi->dev, pdata->slp_tr,
1085 GPIOF_OUT_INIT_LOW, "slp_tr");
1084 if (rc) 1086 if (rc)
1085 goto err_slp_tr; 1087 return rc;
1086 }
1087
1088 if (gpio_is_valid(pdata->rstn)) {
1089 rc = gpio_direction_output(pdata->rstn, 1);
1090 if (rc)
1091 goto err_gpio_dir;
1092 }
1093
1094 if (gpio_is_valid(pdata->slp_tr)) {
1095 rc = gpio_direction_output(pdata->slp_tr, 0);
1096 if (rc)
1097 goto err_gpio_dir;
1098 } 1088 }
1099 1089
1100 /* Reset */ 1090 /* Reset */
@@ -1108,13 +1098,12 @@ static int at86rf230_probe(struct spi_device *spi)
1108 1098
1109 rc = __at86rf230_detect_device(spi, &man_id, &part, &version); 1099 rc = __at86rf230_detect_device(spi, &man_id, &part, &version);
1110 if (rc < 0) 1100 if (rc < 0)
1111 goto err_gpio_dir; 1101 return rc;
1112 1102
1113 if (man_id != 0x001f) { 1103 if (man_id != 0x001f) {
1114 dev_err(&spi->dev, "Non-Atmel dev found (MAN_ID %02x %02x)\n", 1104 dev_err(&spi->dev, "Non-Atmel dev found (MAN_ID %02x %02x)\n",
1115 man_id >> 8, man_id & 0xFF); 1105 man_id >> 8, man_id & 0xFF);
1116 rc = -EINVAL; 1106 return -EINVAL;
1117 goto err_gpio_dir;
1118 } 1107 }
1119 1108
1120 switch (part) { 1109 switch (part) {
@@ -1141,16 +1130,12 @@ static int at86rf230_probe(struct spi_device *spi)
1141 } 1130 }
1142 1131
1143 dev_info(&spi->dev, "Detected %s chip version %d\n", chip, version); 1132 dev_info(&spi->dev, "Detected %s chip version %d\n", chip, version);
1144 if (!ops) { 1133 if (!ops)
1145 rc = -ENOTSUPP; 1134 return -ENOTSUPP;
1146 goto err_gpio_dir;
1147 }
1148 1135
1149 dev = ieee802154_alloc_device(sizeof(*lp), ops); 1136 dev = ieee802154_alloc_device(sizeof(*lp), ops);
1150 if (!dev) { 1137 if (!dev)
1151 rc = -ENOMEM; 1138 return -ENOMEM;
1152 goto err_gpio_dir;
1153 }
1154 1139
1155 lp = dev->priv; 1140 lp = dev->priv;
1156 lp->dev = dev; 1141 lp->dev = dev;
@@ -1212,35 +1197,21 @@ err_hw_init:
1212 mutex_destroy(&lp->bmux); 1197 mutex_destroy(&lp->bmux);
1213 ieee802154_free_device(lp->dev); 1198 ieee802154_free_device(lp->dev);
1214 1199
1215err_gpio_dir:
1216 if (gpio_is_valid(pdata->slp_tr))
1217 gpio_free(pdata->slp_tr);
1218err_slp_tr:
1219 if (gpio_is_valid(pdata->rstn))
1220 gpio_free(pdata->rstn);
1221 return rc; 1200 return rc;
1222} 1201}
1223 1202
1224static int at86rf230_remove(struct spi_device *spi) 1203static int at86rf230_remove(struct spi_device *spi)
1225{ 1204{
1226 struct at86rf230_local *lp = spi_get_drvdata(spi); 1205 struct at86rf230_local *lp = spi_get_drvdata(spi);
1227 struct at86rf230_platform_data *pdata = spi->dev.platform_data;
1228 1206
1229 /* mask all at86rf230 irq's */ 1207 /* mask all at86rf230 irq's */
1230 at86rf230_write_subreg(lp, SR_IRQ_MASK, 0); 1208 at86rf230_write_subreg(lp, SR_IRQ_MASK, 0);
1231 ieee802154_unregister_device(lp->dev); 1209 ieee802154_unregister_device(lp->dev);
1232
1233 flush_work(&lp->irqwork); 1210 flush_work(&lp->irqwork);
1234
1235 if (gpio_is_valid(pdata->slp_tr))
1236 gpio_free(pdata->slp_tr);
1237 if (gpio_is_valid(pdata->rstn))
1238 gpio_free(pdata->rstn);
1239
1240 mutex_destroy(&lp->bmux); 1211 mutex_destroy(&lp->bmux);
1241 ieee802154_free_device(lp->dev); 1212 ieee802154_free_device(lp->dev);
1242
1243 dev_dbg(&spi->dev, "unregistered at86rf230\n"); 1213 dev_dbg(&spi->dev, "unregistered at86rf230\n");
1214
1244 return 0; 1215 return 0;
1245} 1216}
1246 1217