diff options
author | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-09-16 21:33:26 -0400 |
---|---|---|
committer | Inaky Perez-Gonzalez <inaky@linux.intel.com> | 2009-10-19 02:56:09 -0400 |
commit | 2869da8587604e3fea5f85aeade486a08e8313bf (patch) | |
tree | e5894e5ffbc7eea4c3dc01406abfbbcfd8022467 /drivers/net/wimax/i2400m | |
parent | 0856ccf29dfbaf957e4be80dd3eb88d97810b633 (diff) |
wimax/i2400m: do bootmode buffer management in i2400m_setup/release()
After the introduction of i2400m->bus_setup/release, there is no more
race condition where the bootmode buffers are needed before
i2400m_setup() is called.
Before, the SDIO driver would setup RX before calling i2400m_setup()
and thus need those buffers; now RX setup is done in
i2400m->bus_setup(), which is called by i2400m_setup().
Thus, all the bootmode buffer management can now be done completely
inside i2400m_setup()/i2400m_release(), removing complexity from the
bus-specific drivers.
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'drivers/net/wimax/i2400m')
-rw-r--r-- | drivers/net/wimax/i2400m/driver.c | 28 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/i2400m.h | 2 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/sdio.c | 14 | ||||
-rw-r--r-- | drivers/net/wimax/i2400m/usb.c | 8 |
4 files changed, 17 insertions, 35 deletions
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c index c57020f811cd..4fcdb18261fd 100644 --- a/drivers/net/wimax/i2400m/driver.c +++ b/drivers/net/wimax/i2400m/driver.c | |||
@@ -723,12 +723,13 @@ int i2400m_dev_reset_handle(struct i2400m *i2400m, const char *reason) | |||
723 | EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); | 723 | EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle); |
724 | 724 | ||
725 | 725 | ||
726 | /** | 726 | /* |
727 | * i2400m_bm_buf_alloc - Alloc the command and ack buffers for boot mode | 727 | * Alloc the command and ack buffers for boot mode |
728 | * | 728 | * |
729 | * Get the buffers needed to deal with boot mode messages. These | 729 | * Get the buffers needed to deal with boot mode messages. These |
730 | * buffers need to be allocated before the sdio recieve irq is setup. | 730 | * buffers need to be allocated before the sdio recieve irq is setup. |
731 | */ | 731 | */ |
732 | static | ||
732 | int i2400m_bm_buf_alloc(struct i2400m *i2400m) | 733 | int i2400m_bm_buf_alloc(struct i2400m *i2400m) |
733 | { | 734 | { |
734 | int result; | 735 | int result; |
@@ -747,22 +748,19 @@ error_bm_ack_buf_kzalloc: | |||
747 | error_bm_cmd_kzalloc: | 748 | error_bm_cmd_kzalloc: |
748 | return result; | 749 | return result; |
749 | } | 750 | } |
750 | EXPORT_SYMBOL_GPL(i2400m_bm_buf_alloc); | ||
751 | 751 | ||
752 | /** | 752 | |
753 | * i2400m_bm_buf_free - Free boot mode command and ack buffers. | 753 | /* |
754 | * | 754 | * Free boot mode command and ack buffers. |
755 | * Free the command and ack buffers | ||
756 | * | ||
757 | */ | 755 | */ |
756 | static | ||
758 | void i2400m_bm_buf_free(struct i2400m *i2400m) | 757 | void i2400m_bm_buf_free(struct i2400m *i2400m) |
759 | { | 758 | { |
760 | kfree(i2400m->bm_ack_buf); | 759 | kfree(i2400m->bm_ack_buf); |
761 | kfree(i2400m->bm_cmd_buf); | 760 | kfree(i2400m->bm_cmd_buf); |
762 | return; | ||
763 | } | 761 | } |
764 | EXPORT_SYMBOL_GPL(i2400m_bm_buf_free | 762 | |
765 | ); | 763 | |
766 | /** | 764 | /** |
767 | * i2400m_setup - bus-generic setup function for the i2400m device | 765 | * i2400m_setup - bus-generic setup function for the i2400m device |
768 | * | 766 | * |
@@ -786,6 +784,12 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags) | |||
786 | snprintf(wimax_dev->name, sizeof(wimax_dev->name), | 784 | snprintf(wimax_dev->name, sizeof(wimax_dev->name), |
787 | "i2400m-%s:%s", dev->bus->name, dev_name(dev)); | 785 | "i2400m-%s:%s", dev->bus->name, dev_name(dev)); |
788 | 786 | ||
787 | result = i2400m_bm_buf_alloc(i2400m); | ||
788 | if (result < 0) { | ||
789 | dev_err(dev, "cannot allocate bootmode scratch buffers\n"); | ||
790 | goto error_bm_buf_alloc; | ||
791 | } | ||
792 | |||
789 | if (i2400m->bus_setup) { | 793 | if (i2400m->bus_setup) { |
790 | result = i2400m->bus_setup(i2400m); | 794 | result = i2400m->bus_setup(i2400m); |
791 | if (result < 0) { | 795 | if (result < 0) { |
@@ -860,6 +864,8 @@ error_bootrom_init: | |||
860 | if (i2400m->bus_release) | 864 | if (i2400m->bus_release) |
861 | i2400m->bus_release(i2400m); | 865 | i2400m->bus_release(i2400m); |
862 | error_bus_setup: | 866 | error_bus_setup: |
867 | i2400m_bm_buf_free(i2400m); | ||
868 | error_bm_buf_alloc: | ||
863 | d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result); | 869 | d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result); |
864 | return result; | 870 | return result; |
865 | } | 871 | } |
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h index 407d0972f2f6..1724955e0fe9 100644 --- a/drivers/net/wimax/i2400m/i2400m.h +++ b/drivers/net/wimax/i2400m/i2400m.h | |||
@@ -817,8 +817,6 @@ void i2400m_put(struct i2400m *i2400m) | |||
817 | } | 817 | } |
818 | 818 | ||
819 | extern int i2400m_dev_reset_handle(struct i2400m *, const char *); | 819 | extern int i2400m_dev_reset_handle(struct i2400m *, const char *); |
820 | extern int i2400m_bm_buf_alloc(struct i2400m *i2400m); | ||
821 | extern void i2400m_bm_buf_free(struct i2400m *i2400m); | ||
822 | 820 | ||
823 | /* | 821 | /* |
824 | * _setup()/_release() are called by the probe/disconnect functions of | 822 | * _setup()/_release() are called by the probe/disconnect functions of |
diff --git a/drivers/net/wimax/i2400m/sdio.c b/drivers/net/wimax/i2400m/sdio.c index 6e39665ecd89..14e66f06f235 100644 --- a/drivers/net/wimax/i2400m/sdio.c +++ b/drivers/net/wimax/i2400m/sdio.c | |||
@@ -519,18 +519,6 @@ int i2400ms_probe(struct sdio_func *func, | |||
519 | i2400m->bus_bm_mac_addr_impaired = 1; | 519 | i2400m->bus_bm_mac_addr_impaired = 1; |
520 | i2400m->bus_bm_pokes_table = &i2400ms_pokes[0]; | 520 | i2400m->bus_bm_pokes_table = &i2400ms_pokes[0]; |
521 | 521 | ||
522 | /* | ||
523 | * Before we are enabling the device interrupt register, make | ||
524 | * sure the buffer used during bootmode operation is setup so | ||
525 | * when the first D2H data interrupt comes, the memory is | ||
526 | * available for copying the D2H data. | ||
527 | */ | ||
528 | result = i2400m_bm_buf_alloc(i2400m); | ||
529 | if (result < 0) { | ||
530 | dev_err(dev, "cannot allocate SDIO bootmode buffer\n"); | ||
531 | goto error_bootmode_buf_setup; | ||
532 | } | ||
533 | |||
534 | result = i2400m_setup(i2400m, I2400M_BRI_NO_REBOOT); | 522 | result = i2400m_setup(i2400m, I2400M_BRI_NO_REBOOT); |
535 | if (result < 0) { | 523 | if (result < 0) { |
536 | dev_err(dev, "cannot setup device: %d\n", result); | 524 | dev_err(dev, "cannot setup device: %d\n", result); |
@@ -548,8 +536,6 @@ int i2400ms_probe(struct sdio_func *func, | |||
548 | error_debugfs_add: | 536 | error_debugfs_add: |
549 | i2400m_release(i2400m); | 537 | i2400m_release(i2400m); |
550 | error_setup: | 538 | error_setup: |
551 | i2400m_bm_buf_free(i2400m); | ||
552 | error_bootmode_buf_setup: | ||
553 | sdio_set_drvdata(func, NULL); | 539 | sdio_set_drvdata(func, NULL); |
554 | free_netdev(net_dev); | 540 | free_netdev(net_dev); |
555 | error_alloc_netdev: | 541 | error_alloc_netdev: |
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c index 3bf3f7288fe6..77567970fe9a 100644 --- a/drivers/net/wimax/i2400m/usb.c +++ b/drivers/net/wimax/i2400m/usb.c | |||
@@ -447,12 +447,6 @@ int i2400mu_probe(struct usb_interface *iface, | |||
447 | usb_dev->autosuspend_disabled = 0; | 447 | usb_dev->autosuspend_disabled = 0; |
448 | #endif | 448 | #endif |
449 | 449 | ||
450 | result = i2400m_bm_buf_alloc(i2400m); | ||
451 | if (result < 0) { | ||
452 | dev_err(dev, "cannot allocate USB bootmode buffer\n"); | ||
453 | goto error_bm_buf_alloc; | ||
454 | } | ||
455 | |||
456 | result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT); | 450 | result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT); |
457 | if (result < 0) { | 451 | if (result < 0) { |
458 | dev_err(dev, "cannot setup device: %d\n", result); | 452 | dev_err(dev, "cannot setup device: %d\n", result); |
@@ -468,8 +462,6 @@ int i2400mu_probe(struct usb_interface *iface, | |||
468 | error_debugfs_add: | 462 | error_debugfs_add: |
469 | i2400m_release(i2400m); | 463 | i2400m_release(i2400m); |
470 | error_setup: | 464 | error_setup: |
471 | i2400m_bm_buf_free(i2400m); | ||
472 | error_bm_buf_alloc: | ||
473 | usb_set_intfdata(iface, NULL); | 465 | usb_set_intfdata(iface, NULL); |
474 | usb_put_dev(i2400mu->usb_dev); | 466 | usb_put_dev(i2400mu->usb_dev); |
475 | free_netdev(net_dev); | 467 | free_netdev(net_dev); |