aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDirk Brandewie <dirk.j.brandewie@intel.com>2009-08-18 11:51:52 -0400
committerInaky Perez-Gonzalez <inaky@linux.intel.com>2009-10-19 02:55:39 -0400
commita134fd6b103b78378e3beb6af94d8d8c2abdd19d (patch)
tree4a747fdeda7afce7d690c869bb6194f9a400f503 /drivers
parent81b182a7542c4282191fa0b1e8d9fcb022c03e68 (diff)
wimax/i2400m: Ensure boot mode cmd and ack buffers are alloc'd before first message
The change to the SDIO boot mode RX chain could try to use the cmd and ack buffers befor they were allocated. USB does not have the problem but both were changed for consistency's sake. Signed-off-by: Dirk Brandewie <dirk.j.brandewie@intel.com> Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wimax/i2400m/driver.c54
-rw-r--r--drivers/net/wimax/i2400m/i2400m.h2
-rw-r--r--drivers/net/wimax/i2400m/sdio.c14
-rw-r--r--drivers/net/wimax/i2400m/usb.c8
4 files changed, 64 insertions, 14 deletions
diff --git a/drivers/net/wimax/i2400m/driver.c b/drivers/net/wimax/i2400m/driver.c
index 304f0443ca4b..20d574ca9183 100644
--- a/drivers/net/wimax/i2400m/driver.c
+++ b/drivers/net/wimax/i2400m/driver.c
@@ -619,6 +619,46 @@ EXPORT_SYMBOL_GPL(i2400m_dev_reset_handle);
619 619
620 620
621/** 621/**
622 * i2400m_bm_buf_alloc - Alloc the command and ack buffers for boot mode
623 *
624 * Get the buffers needed to deal with boot mode messages. These
625 * buffers need to be allocated before the sdio recieve irq is setup.
626 */
627int i2400m_bm_buf_alloc(struct i2400m *i2400m)
628{
629 int result;
630
631 result = -ENOMEM;
632 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
633 if (i2400m->bm_cmd_buf == NULL)
634 goto error_bm_cmd_kzalloc;
635 i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
636 if (i2400m->bm_ack_buf == NULL)
637 goto error_bm_ack_buf_kzalloc;
638 return 0;
639
640error_bm_ack_buf_kzalloc:
641 kfree(i2400m->bm_cmd_buf);
642error_bm_cmd_kzalloc:
643 return result;
644}
645EXPORT_SYMBOL_GPL(i2400m_bm_buf_alloc);
646
647/**
648 * i2400m_bm_buf_free - Free boot mode command and ack buffers.
649 *
650 * Free the command and ack buffers
651 *
652 */
653void i2400m_bm_buf_free(struct i2400m *i2400m)
654{
655 kfree(i2400m->bm_ack_buf);
656 kfree(i2400m->bm_cmd_buf);
657 return;
658}
659EXPORT_SYMBOL_GPL(i2400m_bm_buf_free
660);
661/**
622 * i2400m_setup - bus-generic setup function for the i2400m device 662 * i2400m_setup - bus-generic setup function for the i2400m device
623 * 663 *
624 * @i2400m: device descriptor (bus-specific parts have been initialized) 664 * @i2400m: device descriptor (bus-specific parts have been initialized)
@@ -645,16 +685,6 @@ int i2400m_setup(struct i2400m *i2400m, enum i2400m_bri bm_flags)
645 snprintf(wimax_dev->name, sizeof(wimax_dev->name), 685 snprintf(wimax_dev->name, sizeof(wimax_dev->name),
646 "i2400m-%s:%s", dev->bus->name, dev_name(dev)); 686 "i2400m-%s:%s", dev->bus->name, dev_name(dev));
647 687
648 i2400m->bm_cmd_buf = kzalloc(I2400M_BM_CMD_BUF_SIZE, GFP_KERNEL);
649 if (i2400m->bm_cmd_buf == NULL) {
650 dev_err(dev, "cannot allocate USB command buffer\n");
651 goto error_bm_cmd_kzalloc;
652 }
653 i2400m->bm_ack_buf = kzalloc(I2400M_BM_ACK_BUF_SIZE, GFP_KERNEL);
654 if (i2400m->bm_ack_buf == NULL) {
655 dev_err(dev, "cannot allocate USB ack buffer\n");
656 goto error_bm_ack_buf_kzalloc;
657 }
658 result = i2400m_bootrom_init(i2400m, bm_flags); 688 result = i2400m_bootrom_init(i2400m, bm_flags);
659 if (result < 0) { 689 if (result < 0) {
660 dev_err(dev, "read mac addr: bootrom init " 690 dev_err(dev, "read mac addr: bootrom init "
@@ -713,10 +743,6 @@ error_dev_start:
713error_register_netdev: 743error_register_netdev:
714error_read_mac_addr: 744error_read_mac_addr:
715error_bootrom_init: 745error_bootrom_init:
716 kfree(i2400m->bm_ack_buf);
717error_bm_ack_buf_kzalloc:
718 kfree(i2400m->bm_cmd_buf);
719error_bm_cmd_kzalloc:
720 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result); 746 d_fnend(3, dev, "(i2400m %p) = %d\n", i2400m, result);
721 return result; 747 return result;
722} 748}
diff --git a/drivers/net/wimax/i2400m/i2400m.h b/drivers/net/wimax/i2400m/i2400m.h
index 60330f313f27..a6e59f1c881d 100644
--- a/drivers/net/wimax/i2400m/i2400m.h
+++ b/drivers/net/wimax/i2400m/i2400m.h
@@ -725,6 +725,8 @@ void i2400m_put(struct i2400m *i2400m)
725} 725}
726 726
727extern int i2400m_dev_reset_handle(struct i2400m *); 727extern int i2400m_dev_reset_handle(struct i2400m *);
728extern int i2400m_bm_buf_alloc(struct i2400m *i2400m);
729extern void i2400m_bm_buf_free(struct i2400m *i2400m);
728 730
729/* 731/*
730 * _setup()/_release() are called by the probe/disconnect functions of 732 * _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 c67b0264a282..a68232aa2915 100644
--- a/drivers/net/wimax/i2400m/sdio.c
+++ b/drivers/net/wimax/i2400m/sdio.c
@@ -451,6 +451,18 @@ int i2400ms_probe(struct sdio_func *func,
451 goto error_func_enable; 451 goto error_func_enable;
452 } 452 }
453 453
454 /*
455 * Before we are enabling the device interrupt register, make
456 * sure the buffer used during bootmode operation is setup so
457 * when the first D2H data interrupt comes, the memory is
458 * available for copying the D2H data.
459 */
460 result = i2400m_bm_buf_alloc(i2400m);
461 if (result < 0) {
462 dev_err(dev, "cannot allocate SDIO bootmode buffer\n");
463 goto error_bootmode_buf_setup;
464 }
465
454 result = i2400ms_rx_setup(i2400ms); 466 result = i2400ms_rx_setup(i2400ms);
455 if (result < 0) 467 if (result < 0)
456 goto error_rx_setup; 468 goto error_rx_setup;
@@ -474,6 +486,8 @@ error_debugfs_add:
474error_setup: 486error_setup:
475 i2400ms_rx_release(i2400ms); 487 i2400ms_rx_release(i2400ms);
476error_rx_setup: 488error_rx_setup:
489 i2400m_bm_buf_free(i2400m);
490error_bootmode_buf_setup:
477 sdio_claim_host(func); 491 sdio_claim_host(func);
478 sdio_disable_func(func); 492 sdio_disable_func(func);
479 sdio_release_host(func); 493 sdio_release_host(func);
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index bfa45f571341..49d7554ad707 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -419,6 +419,12 @@ int i2400mu_probe(struct usb_interface *iface,
419 usb_dev->autosuspend_disabled = 0; 419 usb_dev->autosuspend_disabled = 0;
420#endif 420#endif
421 421
422 result = i2400m_bm_buf_alloc(i2400m);
423 if (result < 0) {
424 dev_err(dev, "cannot allocate USB bootmode buffer\n");
425 goto error_bm_buf_alloc;
426 }
427
422 result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT); 428 result = i2400m_setup(i2400m, I2400M_BRI_MAC_REINIT);
423 if (result < 0) { 429 if (result < 0) {
424 dev_err(dev, "cannot setup device: %d\n", result); 430 dev_err(dev, "cannot setup device: %d\n", result);
@@ -434,6 +440,8 @@ int i2400mu_probe(struct usb_interface *iface,
434error_debugfs_add: 440error_debugfs_add:
435 i2400m_release(i2400m); 441 i2400m_release(i2400m);
436error_setup: 442error_setup:
443 i2400m_bm_buf_free(i2400m);
444error_bm_buf_alloc:
437 usb_set_intfdata(iface, NULL); 445 usb_set_intfdata(iface, NULL);
438 usb_put_dev(i2400mu->usb_dev); 446 usb_put_dev(i2400mu->usb_dev);
439 free_netdev(net_dev); 447 free_netdev(net_dev);