aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firewire/fw-card.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/firewire/fw-card.c')
-rw-r--r--drivers/firewire/fw-card.c85
1 files changed, 5 insertions, 80 deletions
diff --git a/drivers/firewire/fw-card.c b/drivers/firewire/fw-card.c
index d63d0ed9e048..8b8c8c22f0fc 100644
--- a/drivers/firewire/fw-card.c
+++ b/drivers/firewire/fw-card.c
@@ -181,83 +181,9 @@ void fw_core_remove_descriptor(struct fw_descriptor *desc)
181 mutex_unlock(&card_mutex); 181 mutex_unlock(&card_mutex);
182} 182}
183 183
184#define IRM_RETRIES 2 184static int set_broadcast_channel(struct device *dev, void *data)
185
186/*
187 * The abi is set by device_for_each_child(), even though we have no use
188 * for data, nor do we have a meaningful return value.
189 */
190int fw_irm_set_broadcast_channel_register(struct device *dev, void *data)
191{ 185{
192 struct fw_device *d; 186 fw_device_set_broadcast_channel(fw_device(dev), (long)data);
193 int rcode;
194 int node_id;
195 int max_speed;
196 int retries;
197 int generation;
198 __be32 regval;
199 struct fw_card *card;
200
201 d = fw_device(dev);
202 /* FIXME: do we need locking here? */
203 generation = d->generation;
204 smp_rmb(); /* Ensure generation is at least as old as node_id */
205 node_id = d->node_id;
206 max_speed = d->max_speed;
207 retries = IRM_RETRIES;
208 card = d->card;
209tryagain_r:
210 rcode = fw_run_transaction(card, TCODE_READ_QUADLET_REQUEST,
211 node_id, generation, max_speed,
212 CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
213 &regval, 4);
214 switch (rcode) {
215 case RCODE_BUSY:
216 if (retries--)
217 goto tryagain_r;
218 fw_notify("node %x read broadcast channel busy\n",
219 node_id);
220 return 0;
221
222 default:
223 fw_notify("node %x read broadcast channel failed %x\n",
224 node_id, rcode);
225 return 0;
226
227 case RCODE_COMPLETE:
228 /*
229 * Paranoid reporting of nonstandard broadcast channel
230 * contents goes here
231 */
232 if (regval != cpu_to_be32(BROADCAST_CHANNEL_INITIAL))
233 return 0;
234 break;
235 }
236 retries = IRM_RETRIES;
237 regval = cpu_to_be32(BROADCAST_CHANNEL_INITIAL |
238 BROADCAST_CHANNEL_VALID);
239tryagain_w:
240 rcode = fw_run_transaction(card,
241 TCODE_WRITE_QUADLET_REQUEST, node_id,
242 generation, max_speed,
243 CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
244 &regval, 4);
245 switch (rcode) {
246 case RCODE_BUSY:
247 if (retries--)
248 goto tryagain_w;
249 fw_notify("node %x write broadcast channel busy\n",
250 node_id);
251 return 0;
252
253 default:
254 fw_notify("node %x write broadcast channel failed %x\n",
255 node_id, rcode);
256 return 0;
257
258 case RCODE_COMPLETE:
259 return 0;
260 }
261 return 0; 187 return 0;
262} 188}
263 189
@@ -268,9 +194,9 @@ static void allocate_broadcast_channel(struct fw_card *card, int generation)
268 fw_iso_resource_manage(card, generation, 1ULL << 31, 194 fw_iso_resource_manage(card, generation, 1ULL << 31,
269 &channel, &bandwidth, true); 195 &channel, &bandwidth, true);
270 if (channel == 31) { 196 if (channel == 31) {
271 card->is_irm = true; 197 card->broadcast_channel_allocated = true;
272 device_for_each_child(card->device, NULL, 198 device_for_each_child(card->device, (void *)(long)generation,
273 fw_irm_set_broadcast_channel_register); 199 set_broadcast_channel);
274 } 200 }
275} 201}
276 202
@@ -302,7 +228,6 @@ static void fw_card_bm_work(struct work_struct *work)
302 __be32 lock_data[2]; 228 __be32 lock_data[2];
303 229
304 spin_lock_irqsave(&card->lock, flags); 230 spin_lock_irqsave(&card->lock, flags);
305 card->is_irm = false;
306 231
307 if (card->local_node == NULL) { 232 if (card->local_node == NULL) {
308 spin_unlock_irqrestore(&card->lock, flags); 233 spin_unlock_irqrestore(&card->lock, flags);