diff options
author | YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> | 2013-03-07 20:42:26 -0500 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2013-03-13 11:11:10 -0400 |
commit | 9d39c90abc6766f875d2855a1a73c43b6ffa09c0 (patch) | |
tree | 16b6372ea074cc53d33e2b7f92ea6f9837c9f71f /drivers/firewire | |
parent | 5104a03d7d0ef4b0222155f2fa6902bf727b1005 (diff) |
firewire net: Introduce fwnet_fifo_{start, stop}() helpers.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/net.c | 51 |
1 files changed, 35 insertions, 16 deletions
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index a7a0e8277147..96f6ee5bffd4 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c | |||
@@ -1116,6 +1116,36 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask) | |||
1116 | return 0; | 1116 | return 0; |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | static void fwnet_fifo_stop(struct fwnet_device *dev) | ||
1120 | { | ||
1121 | if (dev->local_fifo == FWNET_NO_FIFO_ADDR) | ||
1122 | return; | ||
1123 | |||
1124 | fw_core_remove_address_handler(&dev->handler); | ||
1125 | dev->local_fifo = FWNET_NO_FIFO_ADDR; | ||
1126 | } | ||
1127 | |||
1128 | static int fwnet_fifo_start(struct fwnet_device *dev) | ||
1129 | { | ||
1130 | int retval; | ||
1131 | |||
1132 | if (dev->local_fifo != FWNET_NO_FIFO_ADDR) | ||
1133 | return 0; | ||
1134 | |||
1135 | dev->handler.length = 4096; | ||
1136 | dev->handler.address_callback = fwnet_receive_packet; | ||
1137 | dev->handler.callback_data = dev; | ||
1138 | |||
1139 | retval = fw_core_add_address_handler(&dev->handler, | ||
1140 | &fw_high_memory_region); | ||
1141 | if (retval < 0) | ||
1142 | return retval; | ||
1143 | |||
1144 | dev->local_fifo = dev->handler.offset; | ||
1145 | |||
1146 | return 0; | ||
1147 | } | ||
1148 | |||
1119 | static int fwnet_broadcast_start(struct fwnet_device *dev) | 1149 | static int fwnet_broadcast_start(struct fwnet_device *dev) |
1120 | { | 1150 | { |
1121 | struct fw_iso_context *context; | 1151 | struct fw_iso_context *context; |
@@ -1126,18 +1156,9 @@ static int fwnet_broadcast_start(struct fwnet_device *dev) | |||
1126 | unsigned long offset; | 1156 | unsigned long offset; |
1127 | unsigned u; | 1157 | unsigned u; |
1128 | 1158 | ||
1129 | if (dev->local_fifo == FWNET_NO_FIFO_ADDR) { | 1159 | retval = fwnet_fifo_start(dev); |
1130 | dev->handler.length = 4096; | 1160 | if (retval < 0) |
1131 | dev->handler.address_callback = fwnet_receive_packet; | 1161 | goto failed_initial; |
1132 | dev->handler.callback_data = dev; | ||
1133 | |||
1134 | retval = fw_core_add_address_handler(&dev->handler, | ||
1135 | &fw_high_memory_region); | ||
1136 | if (retval < 0) | ||
1137 | goto failed_initial; | ||
1138 | |||
1139 | dev->local_fifo = dev->handler.offset; | ||
1140 | } | ||
1141 | 1162 | ||
1142 | max_receive = 1U << (dev->card->max_receive + 1); | 1163 | max_receive = 1U << (dev->card->max_receive + 1); |
1143 | num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; | 1164 | num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; |
@@ -1219,8 +1240,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev) | |||
1219 | fw_iso_context_destroy(context); | 1240 | fw_iso_context_destroy(context); |
1220 | dev->broadcast_rcv_context = NULL; | 1241 | dev->broadcast_rcv_context = NULL; |
1221 | failed_context_create: | 1242 | failed_context_create: |
1222 | fw_core_remove_address_handler(&dev->handler); | 1243 | fwnet_fifo_stop(dev); |
1223 | dev->local_fifo = FWNET_NO_FIFO_ADDR; | ||
1224 | failed_initial: | 1244 | failed_initial: |
1225 | 1245 | ||
1226 | return retval; | 1246 | return retval; |
@@ -1600,8 +1620,7 @@ static int fwnet_remove(struct device *_dev) | |||
1600 | if (list_empty(&dev->peer_list)) { | 1620 | if (list_empty(&dev->peer_list)) { |
1601 | unregister_netdev(net); | 1621 | unregister_netdev(net); |
1602 | 1622 | ||
1603 | if (dev->local_fifo != FWNET_NO_FIFO_ADDR) | 1623 | fwnet_fifo_stop(dev); |
1604 | fw_core_remove_address_handler(&dev->handler); | ||
1605 | if (dev->broadcast_rcv_context) { | 1624 | if (dev->broadcast_rcv_context) { |
1606 | fw_iso_context_stop(dev->broadcast_rcv_context); | 1625 | fw_iso_context_stop(dev->broadcast_rcv_context); |
1607 | fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, | 1626 | fw_iso_buffer_destroy(&dev->broadcast_rcv_buffer, |