- struct fw_device *d;
- int rcode;
- int node_id;
- int max_speed;
- int retries;
- int generation;
- __be32 regval;
- struct fw_card *card;
-
- d = fw_device(dev);
- /* FIXME: do we need locking here? */
- generation = d->generation;
- smp_rmb(); /* Ensure generation is at least as old as node_id */
- node_id = d->node_id;
- max_speed = d->max_speed;
- retries = IRM_RETRIES;
- card = d->card;
-tryagain_r:
- rcode = fw_run_transaction(card, TCODE_READ_QUADLET_REQUEST,
- node_id, generation, max_speed,
- CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
- ®val, 4);
- switch (rcode) {
- case RCODE_BUSY:
- if (retries--)
- goto tryagain_r;
- fw_notify("node %x read broadcast channel busy\n",
- node_id);
- return 0;
-
- default:
- fw_notify("node %x read broadcast channel failed %x\n",
- node_id, rcode);
- return 0;
-
- case RCODE_COMPLETE:
- /*
- * Paranoid reporting of nonstandard broadcast channel
- * contents goes here
- */
- if (regval != cpu_to_be32(BROADCAST_CHANNEL_INITIAL))
- return 0;
- break;
- }
- retries = IRM_RETRIES;
- regval = cpu_to_be32(BROADCAST_CHANNEL_INITIAL |
- BROADCAST_CHANNEL_VALID);
-tryagain_w:
- rcode = fw_run_transaction(card,
- TCODE_WRITE_QUADLET_REQUEST, node_id,
- generation, max_speed,
- CSR_REGISTER_BASE + CSR_BROADCAST_CHANNEL,
- ®val, 4);
- switch (rcode) {
- case RCODE_BUSY:
- if (retries--)
- goto tryagain_w;
- fw_notify("node %x write broadcast channel busy\n",
- node_id);
- return 0;
-
- default:
- fw_notify("node %x write broadcast channel failed %x\n",
- node_id, rcode);
- return 0;
-
- case RCODE_COMPLETE:
- return 0;
- }