Commit 0aaf43f5 authored by Varka Bhadram's avatar Varka Bhadram Committed by David S. Miller

mrf24j40: add device managed APIs

adds the device managed APIs so that no need worry about
freeing the resources.
Signed-off-by: default avatarVarka Bhadram <varkab@cdac.in>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f6479449
...@@ -618,12 +618,12 @@ static int mrf24j40_probe(struct spi_device *spi) ...@@ -618,12 +618,12 @@ static int mrf24j40_probe(struct spi_device *spi)
printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq); printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
devrec = kzalloc(sizeof(struct mrf24j40), GFP_KERNEL); devrec = devm_kzalloc(&spi->dev, sizeof(struct mrf24j40), GFP_KERNEL);
if (!devrec) if (!devrec)
goto err_devrec; goto err_ret;
devrec->buf = kzalloc(3, GFP_KERNEL); devrec->buf = devm_kzalloc(&spi->dev, 3, GFP_KERNEL);
if (!devrec->buf) if (!devrec->buf)
goto err_buf; goto err_ret;
spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */ spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */
if (spi->max_speed_hz > MAX_SPI_SPEED_HZ) if (spi->max_speed_hz > MAX_SPI_SPEED_HZ)
...@@ -638,7 +638,7 @@ static int mrf24j40_probe(struct spi_device *spi) ...@@ -638,7 +638,7 @@ static int mrf24j40_probe(struct spi_device *spi)
devrec->dev = ieee802154_alloc_device(0, &mrf24j40_ops); devrec->dev = ieee802154_alloc_device(0, &mrf24j40_ops);
if (!devrec->dev) if (!devrec->dev)
goto err_alloc_dev; goto err_ret;
devrec->dev->priv = devrec; devrec->dev->priv = devrec;
devrec->dev->parent = &devrec->spi->dev; devrec->dev->parent = &devrec->spi->dev;
...@@ -676,12 +676,13 @@ static int mrf24j40_probe(struct spi_device *spi) ...@@ -676,12 +676,13 @@ static int mrf24j40_probe(struct spi_device *spi)
val &= ~0x3; /* Clear RX mode (normal) */ val &= ~0x3; /* Clear RX mode (normal) */
write_short_reg(devrec, REG_RXMCR, val); write_short_reg(devrec, REG_RXMCR, val);
ret = request_threaded_irq(spi->irq, ret = devm_request_threaded_irq(&spi->dev,
NULL, spi->irq,
mrf24j40_isr, NULL,
IRQF_TRIGGER_LOW|IRQF_ONESHOT, mrf24j40_isr,
dev_name(&spi->dev), IRQF_TRIGGER_LOW|IRQF_ONESHOT,
devrec); dev_name(&spi->dev),
devrec);
if (ret) { if (ret) {
dev_err(printdev(devrec), "Unable to get IRQ"); dev_err(printdev(devrec), "Unable to get IRQ");
...@@ -695,11 +696,7 @@ static int mrf24j40_probe(struct spi_device *spi) ...@@ -695,11 +696,7 @@ static int mrf24j40_probe(struct spi_device *spi)
ieee802154_unregister_device(devrec->dev); ieee802154_unregister_device(devrec->dev);
err_register_device: err_register_device:
ieee802154_free_device(devrec->dev); ieee802154_free_device(devrec->dev);
err_alloc_dev: err_ret:
kfree(devrec->buf);
err_buf:
kfree(devrec);
err_devrec:
return ret; return ret;
} }
...@@ -709,15 +706,11 @@ static int mrf24j40_remove(struct spi_device *spi) ...@@ -709,15 +706,11 @@ static int mrf24j40_remove(struct spi_device *spi)
dev_dbg(printdev(devrec), "remove\n"); dev_dbg(printdev(devrec), "remove\n");
free_irq(spi->irq, devrec);
ieee802154_unregister_device(devrec->dev); ieee802154_unregister_device(devrec->dev);
ieee802154_free_device(devrec->dev); ieee802154_free_device(devrec->dev);
/* TODO: Will ieee802154_free_device() wait until ->xmit() is /* TODO: Will ieee802154_free_device() wait until ->xmit() is
* complete? */ * complete? */
/* Clean up the SPI stuff. */
kfree(devrec->buf);
kfree(devrec);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment