From 048961ef90b584d00ec79c75cb7c7b28403f0c87 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 7 Mar 2007 12:12:46 -0500 Subject: [PATCH] firewire: Add rom_index attribute for unit sysfs directories. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Kristian Høgsberg Signed-off-by: Stefan Richter --- drivers/firewire/fw-device.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/firewire/fw-device.c b/drivers/firewire/fw-device.c index b24090ae9c7..4ade867db88 100644 --- a/drivers/firewire/fw-device.c +++ b/drivers/firewire/fw-device.c @@ -230,6 +230,22 @@ static struct device_attribute config_rom_attribute = { .show = show_config_rom_attribute, }; +static ssize_t +show_rom_index_attribute(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fw_device *device = fw_device(dev->parent); + struct fw_unit *unit = fw_unit(dev); + + return snprintf(buf, PAGE_SIZE, "%d\n", + unit->directory - device->config_rom); +} + +static struct device_attribute rom_index_attribute = { + .attr = { .name = "rom_index", .mode = S_IRUGO, }, + .show = show_rom_index_attribute, +}; + struct read_quadlet_callback_data { struct completion done; int rcode; @@ -393,6 +409,11 @@ static void create_units(struct fw_device *device) device_unregister(&unit->device); kfree(unit); } + + if (device_create_file(&unit->device, &rom_index_attribute) < 0) { + device_unregister(&unit->device); + kfree(unit); + } } } -- 2.20.1