From e894536f5e73b741bd55dfe53e864df93532c271 Mon Sep 17 00:00:00 2001 From: Oron Peled Date: Mon, 23 May 2011 19:23:52 +0300 Subject: add to dahdi_device a "hardware_id" attribute as an alternative to "location" - The "hardware_id" does not change with device location (e.g: when a PCI card is moved from one slot to another). - Not all devices have this attribute. It is legal for it to be NULL (that is the default for all low-level drivers that do not set it explicitly). - When "hardware_id" is NULL, the sysfs attribute value is "\n" --- drivers/dahdi/dahdi-sysfs.c | 11 +++++++++++ drivers/dahdi/xpp/xbus-core.c | 2 ++ include/dahdi/kernel.h | 13 +++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/drivers/dahdi/dahdi-sysfs.c b/drivers/dahdi/dahdi-sysfs.c index 161a1d9..0523ed4 100644 --- a/drivers/dahdi/dahdi-sysfs.c +++ b/drivers/dahdi/dahdi-sysfs.c @@ -483,6 +483,16 @@ dahdi_device_location_show(struct device *dev, return sprintf(buf, "%s\n", ddev->location); } +static ssize_t +dahdi_device_hardware_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct dahdi_device *ddev = to_ddev(dev); + + return sprintf(buf, "%s\n", + (ddev->hardware_id) ? ddev->hardware_id : ""); +} + static ssize_t dahdi_device_auto_register(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) @@ -524,6 +534,7 @@ static struct device_attribute dahdi_device_attrs[] = { __ATTR(type, S_IRUGO, dahdi_device_type_show, NULL), __ATTR(span_count, S_IRUGO, dahdi_device_span_count_show, NULL), __ATTR(location, S_IRUGO, dahdi_device_location_show, NULL), + __ATTR(hardware_id, S_IRUGO, dahdi_device_hardware_id_show, NULL), __ATTR(auto_register, S_IWUSR, NULL, dahdi_device_auto_register), __ATTR(register_span, S_IWUSR, NULL, dahdi_device_register_span), __ATTR_NULL, diff --git a/drivers/dahdi/xpp/xbus-core.c b/drivers/dahdi/xpp/xbus-core.c index b414200..9c77238 100644 --- a/drivers/dahdi/xpp/xbus-core.c +++ b/drivers/dahdi/xpp/xbus-core.c @@ -852,6 +852,7 @@ static int xbus_register_dahdi_device(xbus_t *xbus) * So let's also export it via the newfangled "location" field. */ xbus->ddev->location = xbus->connector; + xbus->ddev->hardware_id = xbus->label; /* * Prepare the span list @@ -885,6 +886,7 @@ static void xbus_unregister_dahdi_device(xbus_t *xbus) kfree(xbus->ddev->devicetype); xbus->ddev->devicetype = NULL; xbus->ddev->location = NULL; + xbus->ddev->hardware_id = NULL; dahdi_free_device(xbus->ddev); xbus->ddev = NULL; } diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index d2f3dc7..2ca5acf 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -882,17 +882,22 @@ struct dahdi_span_ops { /** * dahdi_device - Represents a device that can contain one or more spans. * - * @spans: List of child spans. + * @spans: List of child spans. * @manufacturer: Device manufacturer. - * @location: The location of this device - * @devicetype: What type of device this is. - * @irqmisses: Count of "interrupt misses" for this device. + * @location: The location of this device. This should not change if + * the device is replaced (e.g: in the same PCI slot) + * @hardware_id: The hardware_id of this device (NULL for devices without + * a hardware_id). This should not change if the device is + * relocated to a different location (e.g: different PCI slot) + * @devicetype: What type of device this is. + * @irqmisses: Count of "interrupt misses" for this device. * */ struct dahdi_device { struct list_head spans; const char *manufacturer; const char *location; + const char *hardware_id; const char *devicetype; struct device dev; unsigned int irqmisses; -- cgit v1.2.3