diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-07-08 04:32:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-07-08 04:32:56 -0400 |
commit | 896395c290f902576270d84291c1f7f8bfbe339d (patch) | |
tree | 650114bff3a5f808ee1d713ecc443b0eaab2e1c3 /drivers/firewire/fw-transaction.c | |
parent | af1cf204ba2fd8135933a2e4df523fb1112dc0e2 (diff) | |
parent | 1b40a895df6c7d5a80e71f65674060b03d84bbef (diff) |
Merge branch 'linus' into tmp.x86.mpparse.new
Diffstat (limited to 'drivers/firewire/fw-transaction.c')
-rw-r--r-- | drivers/firewire/fw-transaction.c | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/drivers/firewire/fw-transaction.c b/drivers/firewire/fw-transaction.c index ccf0e4cf108f..03ae8a77c479 100644 --- a/drivers/firewire/fw-transaction.c +++ b/drivers/firewire/fw-transaction.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <linux/completion.h> | 21 | #include <linux/completion.h> |
22 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
23 | #include <linux/kref.h> | ||
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/init.h> | 25 | #include <linux/init.h> |
25 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
@@ -297,37 +298,55 @@ EXPORT_SYMBOL(fw_send_request); | |||
297 | struct fw_phy_packet { | 298 | struct fw_phy_packet { |
298 | struct fw_packet packet; | 299 | struct fw_packet packet; |
299 | struct completion done; | 300 | struct completion done; |
301 | struct kref kref; | ||
300 | }; | 302 | }; |
301 | 303 | ||
302 | static void | 304 | static void phy_packet_release(struct kref *kref) |
303 | transmit_phy_packet_callback(struct fw_packet *packet, | 305 | { |
304 | struct fw_card *card, int status) | 306 | struct fw_phy_packet *p = |
307 | container_of(kref, struct fw_phy_packet, kref); | ||
308 | kfree(p); | ||
309 | } | ||
310 | |||
311 | static void transmit_phy_packet_callback(struct fw_packet *packet, | ||
312 | struct fw_card *card, int status) | ||
305 | { | 313 | { |
306 | struct fw_phy_packet *p = | 314 | struct fw_phy_packet *p = |
307 | container_of(packet, struct fw_phy_packet, packet); | 315 | container_of(packet, struct fw_phy_packet, packet); |
308 | 316 | ||
309 | complete(&p->done); | 317 | complete(&p->done); |
318 | kref_put(&p->kref, phy_packet_release); | ||
310 | } | 319 | } |
311 | 320 | ||
312 | void fw_send_phy_config(struct fw_card *card, | 321 | void fw_send_phy_config(struct fw_card *card, |
313 | int node_id, int generation, int gap_count) | 322 | int node_id, int generation, int gap_count) |
314 | { | 323 | { |
315 | struct fw_phy_packet p; | 324 | struct fw_phy_packet *p; |
325 | long timeout = DIV_ROUND_UP(HZ, 10); | ||
316 | u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | | 326 | u32 data = PHY_IDENTIFIER(PHY_PACKET_CONFIG) | |
317 | PHY_CONFIG_ROOT_ID(node_id) | | 327 | PHY_CONFIG_ROOT_ID(node_id) | |
318 | PHY_CONFIG_GAP_COUNT(gap_count); | 328 | PHY_CONFIG_GAP_COUNT(gap_count); |
319 | 329 | ||
320 | p.packet.header[0] = data; | 330 | p = kmalloc(sizeof(*p), GFP_KERNEL); |
321 | p.packet.header[1] = ~data; | 331 | if (p == NULL) |
322 | p.packet.header_length = 8; | 332 | return; |
323 | p.packet.payload_length = 0; | 333 | |
324 | p.packet.speed = SCODE_100; | 334 | p->packet.header[0] = data; |
325 | p.packet.generation = generation; | 335 | p->packet.header[1] = ~data; |
326 | p.packet.callback = transmit_phy_packet_callback; | 336 | p->packet.header_length = 8; |
327 | init_completion(&p.done); | 337 | p->packet.payload_length = 0; |
328 | 338 | p->packet.speed = SCODE_100; | |
329 | card->driver->send_request(card, &p.packet); | 339 | p->packet.generation = generation; |
330 | wait_for_completion(&p.done); | 340 | p->packet.callback = transmit_phy_packet_callback; |
341 | init_completion(&p->done); | ||
342 | kref_set(&p->kref, 2); | ||
343 | |||
344 | card->driver->send_request(card, &p->packet); | ||
345 | timeout = wait_for_completion_timeout(&p->done, timeout); | ||
346 | kref_put(&p->kref, phy_packet_release); | ||
347 | |||
348 | /* will leak p if the callback is never executed */ | ||
349 | WARN_ON(timeout == 0); | ||
331 | } | 350 | } |
332 | 351 | ||
333 | void fw_flush_transactions(struct fw_card *card) | 352 | void fw_flush_transactions(struct fw_card *card) |
@@ -572,7 +591,8 @@ allocate_request(struct fw_packet *p) | |||
572 | break; | 591 | break; |
573 | 592 | ||
574 | default: | 593 | default: |
575 | BUG(); | 594 | fw_error("ERROR - corrupt request received - %08x %08x %08x\n", |
595 | p->header[0], p->header[1], p->header[2]); | ||
576 | return NULL; | 596 | return NULL; |
577 | } | 597 | } |
578 | 598 | ||