aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarka Bhadram <varkabhadram@gmail.com>2014-06-11 00:34:44 -0400
committerDavid S. Miller <davem@davemloft.net>2014-06-11 18:39:19 -0400
commit0aaf43f51dc7e7f00029c90d778e895a88a90cc6 (patch)
tree7305b494d06963ec9d353c2db2ede64ed7e141e2
parentf6479449957750175a2dbd9ddf051c04a072abd6 (diff)
mrf24j40: add device managed APIs
adds the device managed APIs so that no need worry about freeing the resources. Signed-off-by: Varka Bhadram <varkab@cdac.in> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ieee802154/mrf24j40.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/drivers/net/ieee802154/mrf24j40.c b/drivers/net/ieee802154/mrf24j40.c
index 78a6552ed707..4048062011ba 100644
--- a/drivers/net/ieee802154/mrf24j40.c
+++ b/drivers/net/ieee802154/mrf24j40.c
@@ -618,12 +618,12 @@ static int mrf24j40_probe(struct spi_device *spi)
618 618
619 printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq); 619 printk(KERN_INFO "mrf24j40: probe(). IRQ: %d\n", spi->irq);
620 620
621 devrec = kzalloc(sizeof(struct mrf24j40), GFP_KERNEL); 621 devrec = devm_kzalloc(&spi->dev, sizeof(struct mrf24j40), GFP_KERNEL);
622 if (!devrec) 622 if (!devrec)
623 goto err_devrec; 623 goto err_ret;
624 devrec->buf = kzalloc(3, GFP_KERNEL); 624 devrec->buf = devm_kzalloc(&spi->dev, 3, GFP_KERNEL);
625 if (!devrec->buf) 625 if (!devrec->buf)
626 goto err_buf; 626 goto err_ret;
627 627
628 spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */ 628 spi->mode = SPI_MODE_0; /* TODO: Is this appropriate for right here? */
629 if (spi->max_speed_hz > MAX_SPI_SPEED_HZ) 629 if (spi->max_speed_hz > MAX_SPI_SPEED_HZ)
@@ -638,7 +638,7 @@ static int mrf24j40_probe(struct spi_device *spi)
638 638
639 devrec->dev = ieee802154_alloc_device(0, &mrf24j40_ops); 639 devrec->dev = ieee802154_alloc_device(0, &mrf24j40_ops);
640 if (!devrec->dev) 640 if (!devrec->dev)
641 goto err_alloc_dev; 641 goto err_ret;
642 642
643 devrec->dev->priv = devrec; 643 devrec->dev->priv = devrec;
644 devrec->dev->parent = &devrec->spi->dev; 644 devrec->dev->parent = &devrec->spi->dev;
@@ -676,12 +676,13 @@ static int mrf24j40_probe(struct spi_device *spi)
676 val &= ~0x3; /* Clear RX mode (normal) */ 676 val &= ~0x3; /* Clear RX mode (normal) */
677 write_short_reg(devrec, REG_RXMCR, val); 677 write_short_reg(devrec, REG_RXMCR, val);
678 678
679 ret = request_threaded_irq(spi->irq, 679 ret = devm_request_threaded_irq(&spi->dev,
680 NULL, 680 spi->irq,
681 mrf24j40_isr, 681 NULL,
682 IRQF_TRIGGER_LOW|IRQF_ONESHOT, 682 mrf24j40_isr,
683 dev_name(&spi->dev), 683 IRQF_TRIGGER_LOW|IRQF_ONESHOT,
684 devrec); 684 dev_name(&spi->dev),
685 devrec);
685 686
686 if (ret) { 687 if (ret) {
687 dev_err(printdev(devrec), "Unable to get IRQ"); 688 dev_err(printdev(devrec), "Unable to get IRQ");
@@ -695,11 +696,7 @@ err_read_reg:
695 ieee802154_unregister_device(devrec->dev); 696 ieee802154_unregister_device(devrec->dev);
696err_register_device: 697err_register_device:
697 ieee802154_free_device(devrec->dev); 698 ieee802154_free_device(devrec->dev);
698err_alloc_dev: 699err_ret:
699 kfree(devrec->buf);
700err_buf:
701 kfree(devrec);
702err_devrec:
703 return ret; 700 return ret;
704} 701}
705 702
@@ -709,15 +706,11 @@ static int mrf24j40_remove(struct spi_device *spi)
709 706
710 dev_dbg(printdev(devrec), "remove\n"); 707 dev_dbg(printdev(devrec), "remove\n");
711 708
712 free_irq(spi->irq, devrec);
713 ieee802154_unregister_device(devrec->dev); 709 ieee802154_unregister_device(devrec->dev);
714 ieee802154_free_device(devrec->dev); 710 ieee802154_free_device(devrec->dev);
715 /* TODO: Will ieee802154_free_device() wait until ->xmit() is 711 /* TODO: Will ieee802154_free_device() wait until ->xmit() is
716 * complete? */ 712 * complete? */
717 713
718 /* Clean up the SPI stuff. */
719 kfree(devrec->buf);
720 kfree(devrec);
721 return 0; 714 return 0;
722} 715}
723 716