[libraw1394 patch] Unify {ieee1394,fw}_bandwidth_modify()

because they do the same.

We only may want a separate fw_bandwidth_modify() in the future when
firewire-core gains a special ioctl() for that.

(Not runtime-tested, but it looks good to me.)

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
This commit is contained in:
Stefan Richter 2008-12-02 12:48:23 +01:00 committed by Dan Dennedy
parent 788442d403
commit fbe1fa46c6
3 changed files with 1 additions and 56 deletions

View File

@ -541,9 +541,6 @@ int raw1394_bandwidth_modify (raw1394handle_t handle, unsigned int bandwidth,
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }
if (handle->is_fw)
return fw_bandwidth_modify(handle, bandwidth, mode);
else
return ieee1394_bandwidth_modify(handle, bandwidth, mode); return ieee1394_bandwidth_modify(handle, bandwidth, mode);
} }

View File

@ -1293,52 +1293,3 @@ fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer,
return 0; return 0;
} }
#define MAXIMUM_BANDWIDTH 4915
int
fw_bandwidth_modify (raw1394handle_t handle,
unsigned int bandwidth,
enum raw1394_modify_mode mode)
{
quadlet_t buffer, compare, swap;
nodeaddr_t addr;
int result;
if (bandwidth == 0)
return 0;
addr = CSR_REGISTER_BASE + CSR_BANDWIDTH_AVAILABLE;
/* Read current bandwidth usage from IRM. */
result = raw1394_read (handle, raw1394_get_irm_id (handle), addr,
sizeof buffer, &buffer);
if (result < 0)
return -1;
compare = ntohl (buffer);
switch (mode) {
case RAW1394_MODIFY_ALLOC:
if (compare < bandwidth)
return -1;
swap = compare - bandwidth;
break;
case RAW1394_MODIFY_FREE:
swap = compare + bandwidth;
if (swap > MAXIMUM_BANDWIDTH)
swap = MAXIMUM_BANDWIDTH;
break;
default:
return -1;
}
result = raw1394_lock(handle, raw1394_get_irm_id (handle), addr,
RAW1394_EXTCODE_COMPARE_SWAP,
htonl(swap), htonl(compare), &buffer);
if (result < 0 || ntohl(buffer) != compare)
return -1;
return 0;
}

View File

@ -211,9 +211,6 @@ int fw_update_config_rom(fw_handle_t handle, const quadlet_t *new_rom,
int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer, int fw_get_config_rom(fw_handle_t handle, quadlet_t *buffer,
size_t buffersize, size_t *rom_size, size_t buffersize, size_t *rom_size,
unsigned char *rom_version); unsigned char *rom_version);
int fw_bandwidth_modify (raw1394handle_t handle,
unsigned int bandwidth,
enum raw1394_modify_mode mode);
int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle, int fw_iso_xmit_start(raw1394handle_t handle, int start_on_cycle,
int prebuffer_packets); int prebuffer_packets);