Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 151484
b: refs/heads/master
c: 0210b66
h: refs/heads/master
v: v3
  • Loading branch information
Stefan Richter committed Jun 1, 2009
1 parent 9837c61 commit f6a67e2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e5333db9285e088a98f4bad5147bfb0b4665fafb
refs/heads/master: 0210b66dd88a2a1e451901b00378a2068b6ccb35
50 changes: 50 additions & 0 deletions trunk/drivers/firewire/fw-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,56 @@ static ssize_t guid_show(struct device *dev,
return ret;
}

static int units_sprintf(char *buf, u32 *directory)
{
struct fw_csr_iterator ci;
int key, value;
int specifier_id = 0;
int version = 0;

fw_csr_iterator_init(&ci, directory);
while (fw_csr_iterator_next(&ci, &key, &value)) {
switch (key) {
case CSR_SPECIFIER_ID:
specifier_id = value;
break;
case CSR_VERSION:
version = value;
break;
}
}

return sprintf(buf, "0x%06x:0x%06x ", specifier_id, version);
}

static ssize_t units_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct fw_device *device = fw_device(dev);
struct fw_csr_iterator ci;
int key, value, i = 0;

down_read(&fw_device_rwsem);
fw_csr_iterator_init(&ci, &device->config_rom[5]);
while (fw_csr_iterator_next(&ci, &key, &value)) {
if (key != (CSR_UNIT | CSR_DIRECTORY))
continue;
i += units_sprintf(&buf[i], ci.p + value - 1);
if (i >= PAGE_SIZE - (8 + 1 + 8 + 1))
break;
}
up_read(&fw_device_rwsem);

if (i)
buf[i - 1] = '\n';

return i;
}

static struct device_attribute fw_device_attributes[] = {
__ATTR_RO(config_rom),
__ATTR_RO(guid),
__ATTR_RO(units),
__ATTR_NULL,
};

Expand Down Expand Up @@ -1000,6 +1047,9 @@ static void fw_device_refresh(struct work_struct *work)

create_units(device);

/* Userspace may want to re-read attributes. */
kobject_uevent(&device->device.kobj, KOBJ_CHANGE);

if (atomic_cmpxchg(&device->state,
FW_DEVICE_INITIALIZING,
FW_DEVICE_RUNNING) == FW_DEVICE_GONE)
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/firewire/fw-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ enum fw_device_state {
struct fw_attribute_group {
struct attribute_group *groups[2];
struct attribute_group group;
struct attribute *attrs[11];
struct attribute *attrs[12];
};

struct fw_node;
Expand Down

0 comments on commit f6a67e2

Please sign in to comment.