aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/ohci.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:13:10 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-08 11:13:10 -0500
commitbb592cf474404e51cbf3c419fb72fda83c4b7d72 (patch)
tree05823f536d5f095857a7aff732e205d249e4b7a1 /drivers/firewire/ohci.c
parent79c9601c2e0dbbe69895d302de4d19f3a31fbd30 (diff)
parentaf0940dac37545b1e7900b19c464fb6367d3f82f (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6: ieee1394: Use hweight32 firewire: cdev: reduce stack usage by ioctl_dispatch firewire: ohci: 0 may be a valid DMA address firewire: core: WARN on wrong usage of core transaction functions firewire: core: optimize Topology Map creation firewire: core: clarify generate_config_rom usage firewire: optimize config ROM creation firewire: cdev: normalize variable names firewire: normalize style of queue_work wrappers firewire: cdev: fix memory leak in an error path
Diffstat (limited to 'drivers/firewire/ohci.c')
-rw-r--r--drivers/firewire/ohci.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c
index 94260aa76aa3..ae4556f0c0c1 100644
--- a/drivers/firewire/ohci.c
+++ b/drivers/firewire/ohci.c
@@ -205,7 +205,7 @@ struct fw_ohci {
205 dma_addr_t config_rom_bus; 205 dma_addr_t config_rom_bus;
206 __be32 *next_config_rom; 206 __be32 *next_config_rom;
207 dma_addr_t next_config_rom_bus; 207 dma_addr_t next_config_rom_bus;
208 u32 next_header; 208 __be32 next_header;
209 209
210 struct ar_context ar_request_ctx; 210 struct ar_context ar_request_ctx;
211 struct ar_context ar_response_ctx; 211 struct ar_context ar_response_ctx;
@@ -997,7 +997,8 @@ static int at_context_queue_packet(struct context *ctx,
997 packet->ack = RCODE_SEND_ERROR; 997 packet->ack = RCODE_SEND_ERROR;
998 return -1; 998 return -1;
999 } 999 }
1000 packet->payload_bus = payload_bus; 1000 packet->payload_bus = payload_bus;
1001 packet->payload_mapped = true;
1001 1002
1002 d[2].req_count = cpu_to_le16(packet->payload_length); 1003 d[2].req_count = cpu_to_le16(packet->payload_length);
1003 d[2].data_address = cpu_to_le32(payload_bus); 1004 d[2].data_address = cpu_to_le32(payload_bus);
@@ -1025,7 +1026,7 @@ static int at_context_queue_packet(struct context *ctx,
1025 */ 1026 */
1026 if (ohci->generation != packet->generation || 1027 if (ohci->generation != packet->generation ||
1027 reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) { 1028 reg_read(ohci, OHCI1394_IntEventSet) & OHCI1394_busReset) {
1028 if (packet->payload_length > 0) 1029 if (packet->payload_mapped)
1029 dma_unmap_single(ohci->card.device, payload_bus, 1030 dma_unmap_single(ohci->card.device, payload_bus,
1030 packet->payload_length, DMA_TO_DEVICE); 1031 packet->payload_length, DMA_TO_DEVICE);
1031 packet->ack = RCODE_GENERATION; 1032 packet->ack = RCODE_GENERATION;
@@ -1061,7 +1062,7 @@ static int handle_at_packet(struct context *context,
1061 /* This packet was cancelled, just continue. */ 1062 /* This packet was cancelled, just continue. */
1062 return 1; 1063 return 1;
1063 1064
1064 if (packet->payload_bus) 1065 if (packet->payload_mapped)
1065 dma_unmap_single(ohci->card.device, packet->payload_bus, 1066 dma_unmap_single(ohci->card.device, packet->payload_bus,
1066 packet->payload_length, DMA_TO_DEVICE); 1067 packet->payload_length, DMA_TO_DEVICE);
1067 1068
@@ -1357,8 +1358,9 @@ static void bus_reset_tasklet(unsigned long data)
1357 */ 1358 */
1358 reg_write(ohci, OHCI1394_BusOptions, 1359 reg_write(ohci, OHCI1394_BusOptions,
1359 be32_to_cpu(ohci->config_rom[2])); 1360 be32_to_cpu(ohci->config_rom[2]));
1360 ohci->config_rom[0] = cpu_to_be32(ohci->next_header); 1361 ohci->config_rom[0] = ohci->next_header;
1361 reg_write(ohci, OHCI1394_ConfigROMhdr, ohci->next_header); 1362 reg_write(ohci, OHCI1394_ConfigROMhdr,
1363 be32_to_cpu(ohci->next_header));
1362 } 1364 }
1363 1365
1364#ifdef CONFIG_FIREWIRE_OHCI_REMOTE_DMA 1366#ifdef CONFIG_FIREWIRE_OHCI_REMOTE_DMA
@@ -1477,7 +1479,17 @@ static int software_reset(struct fw_ohci *ohci)
1477 return -EBUSY; 1479 return -EBUSY;
1478} 1480}
1479 1481
1480static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length) 1482static void copy_config_rom(__be32 *dest, const __be32 *src, size_t length)
1483{
1484 size_t size = length * 4;
1485
1486 memcpy(dest, src, size);
1487 if (size < CONFIG_ROM_SIZE)
1488 memset(&dest[length], 0, CONFIG_ROM_SIZE - size);
1489}
1490
1491static int ohci_enable(struct fw_card *card,
1492 const __be32 *config_rom, size_t length)
1481{ 1493{
1482 struct fw_ohci *ohci = fw_ohci(card); 1494 struct fw_ohci *ohci = fw_ohci(card);
1483 struct pci_dev *dev = to_pci_dev(card->device); 1495 struct pci_dev *dev = to_pci_dev(card->device);
@@ -1579,8 +1591,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
1579 if (ohci->next_config_rom == NULL) 1591 if (ohci->next_config_rom == NULL)
1580 return -ENOMEM; 1592 return -ENOMEM;
1581 1593
1582 memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); 1594 copy_config_rom(ohci->next_config_rom, config_rom, length);
1583 fw_memcpy_to_be32(ohci->next_config_rom, config_rom, length * 4);
1584 } else { 1595 } else {
1585 /* 1596 /*
1586 * In the suspend case, config_rom is NULL, which 1597 * In the suspend case, config_rom is NULL, which
@@ -1590,7 +1601,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
1590 ohci->next_config_rom_bus = ohci->config_rom_bus; 1601 ohci->next_config_rom_bus = ohci->config_rom_bus;
1591 } 1602 }
1592 1603
1593 ohci->next_header = be32_to_cpu(ohci->next_config_rom[0]); 1604 ohci->next_header = ohci->next_config_rom[0];
1594 ohci->next_config_rom[0] = 0; 1605 ohci->next_config_rom[0] = 0;
1595 reg_write(ohci, OHCI1394_ConfigROMhdr, 0); 1606 reg_write(ohci, OHCI1394_ConfigROMhdr, 0);
1596 reg_write(ohci, OHCI1394_BusOptions, 1607 reg_write(ohci, OHCI1394_BusOptions,
@@ -1624,7 +1635,7 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
1624} 1635}
1625 1636
1626static int ohci_set_config_rom(struct fw_card *card, 1637static int ohci_set_config_rom(struct fw_card *card,
1627 u32 *config_rom, size_t length) 1638 const __be32 *config_rom, size_t length)
1628{ 1639{
1629 struct fw_ohci *ohci; 1640 struct fw_ohci *ohci;
1630 unsigned long flags; 1641 unsigned long flags;
@@ -1673,9 +1684,7 @@ static int ohci_set_config_rom(struct fw_card *card,
1673 ohci->next_config_rom = next_config_rom; 1684 ohci->next_config_rom = next_config_rom;
1674 ohci->next_config_rom_bus = next_config_rom_bus; 1685 ohci->next_config_rom_bus = next_config_rom_bus;
1675 1686
1676 memset(ohci->next_config_rom, 0, CONFIG_ROM_SIZE); 1687 copy_config_rom(ohci->next_config_rom, config_rom, length);
1677 fw_memcpy_to_be32(ohci->next_config_rom, config_rom,
1678 length * 4);
1679 1688
1680 ohci->next_header = config_rom[0]; 1689 ohci->next_header = config_rom[0];
1681 ohci->next_config_rom[0] = 0; 1690 ohci->next_config_rom[0] = 0;
@@ -1729,7 +1738,7 @@ static int ohci_cancel_packet(struct fw_card *card, struct fw_packet *packet)
1729 if (packet->ack != 0) 1738 if (packet->ack != 0)
1730 goto out; 1739 goto out;
1731 1740
1732 if (packet->payload_bus) 1741 if (packet->payload_mapped)
1733 dma_unmap_single(ohci->card.device, packet->payload_bus, 1742 dma_unmap_single(ohci->card.device, packet->payload_bus,
1734 packet->payload_length, DMA_TO_DEVICE); 1743 packet->payload_length, DMA_TO_DEVICE);
1735 1744