diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-07 18:42:27 -0400 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2009-10-14 17:10:48 -0400 |
commit | fe242579e9f33150868f1bb79c7e262ad7953f17 (patch) | |
tree | 6b6ca473ed6e506372f0c0e7d97faac02bc1f88c | |
parent | 8e85973efc87dfae8508f1a3440fd44612897458 (diff) |
firewire: core: clarify generate_config_rom usage
Move the static config ROM buffer into the scope of the two callers of
generate_config_rom(). That way the ROM length can be passed over as
return value rather than through a pointer argument.
It also becomes more obvious that accesses to the config ROM buffer have
to be serialized and how this is accomplished. And firewire-core.ko
shrinks a bit as well.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
-rw-r--r-- | drivers/firewire/core-card.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c index f73e3bdfc84c..f58130789990 100644 --- a/drivers/firewire/core-card.c +++ b/drivers/firewire/core-card.c | |||
@@ -69,6 +69,8 @@ static LIST_HEAD(card_list); | |||
69 | static LIST_HEAD(descriptor_list); | 69 | static LIST_HEAD(descriptor_list); |
70 | static int descriptor_count; | 70 | static int descriptor_count; |
71 | 71 | ||
72 | static __be32 tmp_config_rom[256]; | ||
73 | |||
72 | #define BIB_CRC(v) ((v) << 0) | 74 | #define BIB_CRC(v) ((v) << 0) |
73 | #define BIB_CRC_LENGTH(v) ((v) << 16) | 75 | #define BIB_CRC_LENGTH(v) ((v) << 16) |
74 | #define BIB_INFO_LENGTH(v) ((v) << 24) | 76 | #define BIB_INFO_LENGTH(v) ((v) << 24) |
@@ -84,10 +86,9 @@ static int descriptor_count; | |||
84 | #define BIB_CMC ((1) << 30) | 86 | #define BIB_CMC ((1) << 30) |
85 | #define BIB_IMC ((1) << 31) | 87 | #define BIB_IMC ((1) << 31) |
86 | 88 | ||
87 | static __be32 *generate_config_rom(struct fw_card *card, size_t *rom_length) | 89 | static size_t generate_config_rom(struct fw_card *card, __be32 *config_rom) |
88 | { | 90 | { |
89 | struct fw_descriptor *desc; | 91 | struct fw_descriptor *desc; |
90 | static __be32 config_rom[256]; | ||
91 | int i, j, k, length; | 92 | int i, j, k, length; |
92 | 93 | ||
93 | /* | 94 | /* |
@@ -142,20 +143,17 @@ static __be32 *generate_config_rom(struct fw_card *card, size_t *rom_length) | |||
142 | for (i = 0; i < j; i += length + 1) | 143 | for (i = 0; i < j; i += length + 1) |
143 | length = __compute_block_crc(config_rom + i); | 144 | length = __compute_block_crc(config_rom + i); |
144 | 145 | ||
145 | *rom_length = j; | 146 | return j; |
146 | |||
147 | return config_rom; | ||
148 | } | 147 | } |
149 | 148 | ||
150 | static void update_config_roms(void) | 149 | static void update_config_roms(void) |
151 | { | 150 | { |
152 | struct fw_card *card; | 151 | struct fw_card *card; |
153 | __be32 *config_rom; | ||
154 | size_t length; | 152 | size_t length; |
155 | 153 | ||
156 | list_for_each_entry (card, &card_list, link) { | 154 | list_for_each_entry (card, &card_list, link) { |
157 | config_rom = generate_config_rom(card, &length); | 155 | length = generate_config_rom(card, tmp_config_rom); |
158 | card->driver->set_config_rom(card, config_rom, length); | 156 | card->driver->set_config_rom(card, tmp_config_rom, length); |
159 | } | 157 | } |
160 | } | 158 | } |
161 | 159 | ||
@@ -443,7 +441,6 @@ EXPORT_SYMBOL(fw_card_initialize); | |||
443 | int fw_card_add(struct fw_card *card, | 441 | int fw_card_add(struct fw_card *card, |
444 | u32 max_receive, u32 link_speed, u64 guid) | 442 | u32 max_receive, u32 link_speed, u64 guid) |
445 | { | 443 | { |
446 | __be32 *config_rom; | ||
447 | size_t length; | 444 | size_t length; |
448 | int ret; | 445 | int ret; |
449 | 446 | ||
@@ -453,8 +450,8 @@ int fw_card_add(struct fw_card *card, | |||
453 | 450 | ||
454 | mutex_lock(&card_mutex); | 451 | mutex_lock(&card_mutex); |
455 | 452 | ||
456 | config_rom = generate_config_rom(card, &length); | 453 | length = generate_config_rom(card, tmp_config_rom); |
457 | ret = card->driver->enable(card, config_rom, length); | 454 | ret = card->driver->enable(card, tmp_config_rom, length); |
458 | if (ret == 0) | 455 | if (ret == 0) |
459 | list_add_tail(&card->link, &card_list); | 456 | list_add_tail(&card->link, &card_list); |
460 | 457 | ||