aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/pcmcia')
-rw-r--r--drivers/char/pcmcia/ipwireless/hardware.c50
1 files changed, 18 insertions, 32 deletions
diff --git a/drivers/char/pcmcia/ipwireless/hardware.c b/drivers/char/pcmcia/ipwireless/hardware.c
index 929101ecbae2..6a3e666af019 100644
--- a/drivers/char/pcmcia/ipwireless/hardware.c
+++ b/drivers/char/pcmcia/ipwireless/hardware.c
@@ -389,7 +389,7 @@ static void dump_data_bytes(const char *type, const unsigned char *data,
389static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data, 389static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data,
390 unsigned length) 390 unsigned length)
391{ 391{
392 int i; 392 unsigned i;
393 unsigned long flags; 393 unsigned long flags;
394 394
395 start_timing(); 395 start_timing();
@@ -414,7 +414,7 @@ static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data,
414 unsigned short d = data[i]; 414 unsigned short d = data[i];
415 __le16 raw_data; 415 __le16 raw_data;
416 416
417 if (likely(i + 1 < length)) 417 if (i + 1 < length)
418 d |= data[i + 1] << 8; 418 d |= data[i + 1] << 8;
419 raw_data = cpu_to_le16(d); 419 raw_data = cpu_to_le16(d);
420 outw(raw_data, hw->base_port + IODWR); 420 outw(raw_data, hw->base_port + IODWR);
@@ -428,7 +428,7 @@ static int do_send_fragment(struct ipw_hardware *hw, const unsigned char *data,
428 unsigned short d = data[i]; 428 unsigned short d = data[i];
429 __le16 raw_data; 429 __le16 raw_data;
430 430
431 if ((i + 1 < length)) 431 if (i + 1 < length)
432 d |= data[i + 1] << 8; 432 d |= data[i + 1] << 8;
433 raw_data = cpu_to_le16(d); 433 raw_data = cpu_to_le16(d);
434 outw(raw_data, hw->base_port + IODMADPR); 434 outw(raw_data, hw->base_port + IODMADPR);
@@ -549,12 +549,7 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
549 if (!packet) { 549 if (!packet) {
550 unsigned long flags; 550 unsigned long flags;
551 551
552 /*
553 * If this is the first fragment, then we will need to fetch a
554 * packet to put it in.
555 */
556 spin_lock_irqsave(&hw->spinlock, flags); 552 spin_lock_irqsave(&hw->spinlock, flags);
557 /* If we have one in our pool, then pull it out. */
558 if (!list_empty(&hw->rx_pool)) { 553 if (!list_empty(&hw->rx_pool)) {
559 packet = list_first_entry(&hw->rx_pool, 554 packet = list_first_entry(&hw->rx_pool,
560 struct ipw_rx_packet, queue); 555 struct ipw_rx_packet, queue);
@@ -562,15 +557,14 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
562 hw->rx_pool_size--; 557 hw->rx_pool_size--;
563 spin_unlock_irqrestore(&hw->spinlock, flags); 558 spin_unlock_irqrestore(&hw->spinlock, flags);
564 } else { 559 } else {
565 /* Otherwise allocate a new one. */
566 static int min_capacity = 256; 560 static int min_capacity = 256;
567 int new_capacity; 561 int new_capacity;
568 562
569 spin_unlock_irqrestore(&hw->spinlock, flags); 563 spin_unlock_irqrestore(&hw->spinlock, flags);
570 new_capacity = 564 new_capacity =
571 minimum_free_space > min_capacity 565 (minimum_free_space > min_capacity
572 ? minimum_free_space 566 ? minimum_free_space
573 : min_capacity; 567 : min_capacity);
574 packet = kmalloc(sizeof(struct ipw_rx_packet) 568 packet = kmalloc(sizeof(struct ipw_rx_packet)
575 + new_capacity, GFP_ATOMIC); 569 + new_capacity, GFP_ATOMIC);
576 if (!packet) 570 if (!packet)
@@ -580,10 +574,6 @@ static struct ipw_rx_packet *pool_allocate(struct ipw_hardware *hw,
580 packet->length = 0; 574 packet->length = 0;
581 } 575 }
582 576
583 /*
584 * If this packet does not have sufficient capacity for the data we
585 * want to add, then make it bigger.
586 */
587 if (packet->length + minimum_free_space > packet->capacity) { 577 if (packet->length + minimum_free_space > packet->capacity) {
588 struct ipw_rx_packet *old_packet = packet; 578 struct ipw_rx_packet *old_packet = packet;
589 579
@@ -686,7 +676,7 @@ static void queue_received_packet(struct ipw_hardware *hw,
686 list_add_tail(&packet->queue, &hw->rx_queue); 676 list_add_tail(&packet->queue, &hw->rx_queue);
687 /* Block reception of incoming packets if queue is full. */ 677 /* Block reception of incoming packets if queue is full. */
688 hw->blocking_rx = 678 hw->blocking_rx =
689 hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE; 679 (hw->rx_bytes_queued >= IPWIRELESS_RX_QUEUE_SIZE);
690 680
691 spin_unlock_irqrestore(&hw->spinlock, flags); 681 spin_unlock_irqrestore(&hw->spinlock, flags);
692 schedule_work(&hw->work_rx); 682 schedule_work(&hw->work_rx);
@@ -850,7 +840,7 @@ static void acknowledge_data_read(struct ipw_hardware *hw)
850static void do_receive_packet(struct ipw_hardware *hw) 840static void do_receive_packet(struct ipw_hardware *hw)
851{ 841{
852 unsigned len; 842 unsigned len;
853 unsigned int i; 843 unsigned i;
854 unsigned char pkt[LL_MTU_MAX]; 844 unsigned char pkt[LL_MTU_MAX];
855 845
856 start_timing(); 846 start_timing();
@@ -916,8 +906,7 @@ static int get_current_packet_priority(struct ipw_hardware *hw)
916 * until setup is complete. 906 * until setup is complete.
917 */ 907 */
918 return (hw->to_setup || hw->initializing 908 return (hw->to_setup || hw->initializing
919 ? PRIO_SETUP + 1 : 909 ? PRIO_SETUP + 1 : NL_NUM_OF_PRIORITIES);
920 NL_NUM_OF_PRIORITIES);
921} 910}
922 911
923/* 912/*
@@ -1128,9 +1117,8 @@ static irqreturn_t ipwireless_handle_v2_v3_interrupt(int irq,
1128 } else { 1117 } else {
1129 return IRQ_NONE; 1118 return IRQ_NONE;
1130 } 1119 }
1131 } else { 1120 } else
1132 return IRQ_NONE; 1121 return IRQ_NONE;
1133 }
1134 } 1122 }
1135 1123
1136 /* 1124 /*
@@ -1297,15 +1285,14 @@ int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx,
1297{ 1285{
1298 struct ipw_tx_packet *packet; 1286 struct ipw_tx_packet *packet;
1299 1287
1300 packet = alloc_data_packet(length, 1288 packet = alloc_data_packet(length, (channel_idx + 1),
1301 (unsigned char) (channel_idx + 1), 1289 TL_PROTOCOLID_COM_DATA);
1302 TL_PROTOCOLID_COM_DATA);
1303 if (!packet) 1290 if (!packet)
1304 return -ENOMEM; 1291 return -ENOMEM;
1305 packet->packet_callback = callback; 1292 packet->packet_callback = callback;
1306 packet->callback_data = callback_data; 1293 packet->callback_data = callback_data;
1307 memcpy((unsigned char *) packet + 1294 memcpy((unsigned char *) packet + sizeof(struct ipw_tx_packet), data,
1308 sizeof(struct ipw_tx_packet), data, length); 1295 length);
1309 1296
1310 send_packet(hw, PRIO_DATA, packet); 1297 send_packet(hw, PRIO_DATA, packet);
1311 return 0; 1298 return 0;
@@ -1321,12 +1308,11 @@ static int set_control_line(struct ipw_hardware *hw, int prio,
1321 protocolid = TL_PROTOCOLID_SETUP; 1308 protocolid = TL_PROTOCOLID_SETUP;
1322 1309
1323 packet = alloc_ctrl_packet(sizeof(struct ipw_control_packet), 1310 packet = alloc_ctrl_packet(sizeof(struct ipw_control_packet),
1324 (unsigned char) (channel_idx + 1), 1311 (channel_idx + 1), protocolid, line);
1325 protocolid, line);
1326 if (!packet) 1312 if (!packet)
1327 return -ENOMEM; 1313 return -ENOMEM;
1328 packet->header.length = sizeof(struct ipw_control_packet_body); 1314 packet->header.length = sizeof(struct ipw_control_packet_body);
1329 packet->body.value = (unsigned char) (state == 0 ? 0 : 1); 1315 packet->body.value = (state == 0 ? 0 : 1);
1330 send_packet(hw, prio, &packet->header); 1316 send_packet(hw, prio, &packet->header);
1331 return 0; 1317 return 0;
1332} 1318}
@@ -1651,8 +1637,8 @@ void ipwireless_init_hardware_v1(struct ipw_hardware *hw,
1651 enable_irq(hw->irq); 1637 enable_irq(hw->irq);
1652 } 1638 }
1653 hw->base_port = base_port; 1639 hw->base_port = base_port;
1654 hw->hw_version = is_v2_card ? HW_VERSION_2 : HW_VERSION_1; 1640 hw->hw_version = (is_v2_card ? HW_VERSION_2 : HW_VERSION_1);
1655 hw->ll_mtu = hw->hw_version == HW_VERSION_1 ? LL_MTU_V1 : LL_MTU_V2; 1641 hw->ll_mtu = (hw->hw_version == HW_VERSION_1 ? LL_MTU_V1 : LL_MTU_V2);
1656 hw->memregs_CCR = (struct MEMCCR __iomem *) 1642 hw->memregs_CCR = (struct MEMCCR __iomem *)
1657 ((unsigned short __iomem *) attr_memory + 0x200); 1643 ((unsigned short __iomem *) attr_memory + 0x200);
1658 hw->memory_info_regs = (struct MEMINFREG __iomem *) common_memory; 1644 hw->memory_info_regs = (struct MEMINFREG __iomem *) common_memory;