From 18cdc0b34bc5fa6f5cc8feb8e15f33d8622fe5a4 Mon Sep 17 00:00:00 2001 From: Matthew Dharm Date: Tue, 20 Jan 2004 00:03:17 -0800 Subject: [PATCH] [PATCH] USB Storage: Sysfs attribute file for max_sectors After much discussion with the SCSI folks, here's a patch to export max_sectors as a sysfs attribute. Turning this down makes some people's devices more stable, but at a significant cost in performance. Now, users can adjust it without recompilation. This is YAASP (yet another Alan Stern patch). --- drivers/usb/storage/scsiglue.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 72ec698701029..10d012e386ce3 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -52,6 +52,7 @@ #include #include #include +#include /*********************************************************************** @@ -346,8 +347,34 @@ static ssize_t show_info(struct device *dev, char *buffer) static DEVICE_ATTR(info, S_IRUGO, show_info, NULL); +/* Output routine for the sysfs max_sectors file */ +static ssize_t show_max_sectors(struct device *dev, char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + + return sprintf(buf, "%u\n", sdev->request_queue->max_sectors); +} + +/* Input routine for the sysfs max_sectors file */ +static ssize_t store_max_sectors(struct device *dev, const char *buf, + size_t count) +{ + struct scsi_device *sdev = to_scsi_device(dev); + unsigned short ms; + + if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) { + blk_queue_max_sectors(sdev->request_queue, ms); + return strlen(buf); + } + return -EINVAL; +} + +static DEVICE_ATTR(max_sectors, S_IRUGO | S_IWUSR, show_max_sectors, + store_max_sectors); + static struct device_attribute *sysfs_device_attr_list[] = { &dev_attr_info, + &dev_attr_max_sectors, NULL, }; -- 2.53.0