Get rid of the attr_changed_internally(), and always create queue_type and
queue_depth as read/write, and then writes fail if not supported.
Signed-off-by: Patrick Mansfield <[EMAIL PROTECTED]>
--- linux-2.6.11/drivers/scsi/scsi_sysfs.c 2005-03-02 02:59:50.000000000
-0800
+++ sattrs-linux-2.6.11/drivers/scsi/scsi_sysfs.c 2005-03-02
09:27:15.000000000 -0800
@@ -312,7 +312,6 @@
* Create the actual show/store functions and data structures.
*/
sdev_rd_attr (device_blocked, "%d\n");
-sdev_rd_attr (queue_depth, "%d\n");
sdev_rd_attr (type, "%d\n");
sdev_rd_attr (scsi_level, "%d\n");
sdev_rd_attr (vendor, "%.8s\n");
@@ -392,41 +391,9 @@
static DEVICE_ATTR(state, S_IRUGO | S_IWUSR, show_state_field,
store_state_field);
-static ssize_t
-show_queue_type_field(struct device *dev, char *buf)
-{
- struct scsi_device *sdev = to_scsi_device(dev);
- const char *name = "none";
-
- if (sdev->ordered_tags)
- name = "ordered";
- else if (sdev->simple_tags)
- name = "simple";
-
- return snprintf(buf, 20, "%s\n", name);
-}
-
-static DEVICE_ATTR(queue_type, S_IRUGO, show_queue_type_field, NULL);
-
-
-/* Default template for device attributes. May NOT be modified */
-static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
- &dev_attr_device_blocked,
- &dev_attr_queue_depth,
- &dev_attr_queue_type,
- &dev_attr_type,
- &dev_attr_scsi_level,
- &dev_attr_vendor,
- &dev_attr_model,
- &dev_attr_rev,
- &dev_attr_rescan,
- &dev_attr_delete,
- &dev_attr_state,
- &dev_attr_timeout,
- NULL
-};
+sdev_show_function (queue_depth, "%d\n");
-static ssize_t sdev_store_queue_depth_rw(struct device *dev, const char *buf,
+static ssize_t sdev_store_queue_depth(struct device *dev, const char *buf,
size_t count)
{
int depth, retval;
@@ -448,11 +415,25 @@
return count;
}
-static struct device_attribute sdev_attr_queue_depth_rw =
+static struct device_attribute dev_attr_queue_depth =
__ATTR(queue_depth, S_IRUGO | S_IWUSR, sdev_show_queue_depth,
- sdev_store_queue_depth_rw);
+ sdev_store_queue_depth);
-static ssize_t sdev_store_queue_type_rw(struct device *dev, const char *buf,
+static ssize_t
+show_queue_type_field(struct device *dev, char *buf)
+{
+ struct scsi_device *sdev = to_scsi_device(dev);
+ const char *name = "none";
+
+ if (sdev->ordered_tags)
+ name = "ordered";
+ else if (sdev->simple_tags)
+ name = "simple";
+
+ return snprintf(buf, 20, "%s\n", name);
+}
+
+static ssize_t sdev_store_queue_type(struct device *dev, const char *buf,
size_t count)
{
struct scsi_device *sdev = to_scsi_device(dev);
@@ -480,23 +461,26 @@
return count;
}
-static struct device_attribute sdev_attr_queue_type_rw =
+static struct device_attribute dev_attr_queue_type =
__ATTR(queue_type, S_IRUGO | S_IWUSR, show_queue_type_field,
- sdev_store_queue_type_rw);
-
-static struct device_attribute *attr_changed_internally(
- struct Scsi_Host *shost,
- struct device_attribute * attr)
-{
- if (!strcmp("queue_depth", attr->attr.name)
- && shost->hostt->change_queue_depth)
- return &sdev_attr_queue_depth_rw;
- else if (!strcmp("queue_type", attr->attr.name)
- && shost->hostt->change_queue_type)
- return &sdev_attr_queue_type_rw;
- return attr;
-}
+ sdev_store_queue_type);
+/* Default template for device attributes. May NOT be modified */
+static struct device_attribute *scsi_sysfs_sdev_attrs[] = {
+ &dev_attr_device_blocked,
+ &dev_attr_queue_depth,
+ &dev_attr_queue_type,
+ &dev_attr_type,
+ &dev_attr_scsi_level,
+ &dev_attr_vendor,
+ &dev_attr_model,
+ &dev_attr_rev,
+ &dev_attr_rescan,
+ &dev_attr_delete,
+ &dev_attr_state,
+ &dev_attr_timeout,
+ NULL
+};
static struct device_attribute *attr_overridden(
struct device_attribute **attrs,
@@ -602,10 +586,8 @@
for (i = 0; scsi_sysfs_sdev_attrs[i]; i++) {
if (!attr_overridden(sdev->host->hostt->sdev_attrs,
scsi_sysfs_sdev_attrs[i])) {
- struct device_attribute * attr =
- attr_changed_internally(sdev->host,
-
scsi_sysfs_sdev_attrs[i]);
- error = device_create_file(&sdev->sdev_gendev, attr);
+ error = device_create_file(&sdev->sdev_gendev,
+ scsi_sysfs_sdev_attrs[i]);
if (error) {
scsi_remove_device(sdev);
goto out;
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html