ChangeSet 1.2065.3.13, 2005/03/12 08:24:09-08:00, [EMAIL PROTECTED]

        [PATCH] pcmcia: rsrc_nonstatic: sysfs input
        
        Add a sysfs input method for the non-static socket resource database. It
        works by writing
        "+ 0x%[l]x - 0x%[l]x"
        or simply
        "0x%[l]x - 0x%[l]x"
        for adding resources, and by
        "- 0x%[l]x - 0x%[l]x"
        for removing resources to
        /sys/class/pcmcia_socket/pcmcia_socket%n/available_resources_{io_mem}
        
        Signed-off-by: Dominik Brodowski <[EMAIL PROTECTED]>
        Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
        Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>



 rsrc_nonstatic.c |   68 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 66 insertions(+), 2 deletions(-)


diff -Nru a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c
--- a/drivers/pcmcia/rsrc_nonstatic.c   2005-03-12 21:27:14 -08:00
+++ b/drivers/pcmcia/rsrc_nonstatic.c   2005-03-12 21:27:14 -08:00
@@ -844,7 +844,39 @@
        up(&rsrc_sem);
        return (ret);
 }
-static CLASS_DEVICE_ATTR(available_resources_io, 0400, show_io_db, NULL);
+
+static ssize_t store_io_db(struct class_device *class_dev, const char *buf, 
size_t count)
+{
+       struct pcmcia_socket *s = class_get_devdata(class_dev);
+       unsigned long start_addr, end_addr;
+       unsigned int add = 1;
+       adjust_t adj;
+       ssize_t ret = 0;
+
+       ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
+       if (ret != 2) {
+               ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
+               add = 0;
+               if (ret != 2) {
+                       ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, 
&end_addr);
+                       add = 1;
+                       if (ret != 2)
+                               return -EINVAL;
+               }
+       }
+       if (end_addr <= start_addr)
+               return -EINVAL;
+
+       adj.Action = add ? ADD_MANAGED_RESOURCE : REMOVE_MANAGED_RESOURCE;
+       adj.Resource = RES_IO_RANGE;
+       adj.resource.io.BasePort = start_addr;
+       adj.resource.io.NumPorts = end_addr - start_addr + 1;
+
+       ret = adjust_io(s, &adj);
+
+       return ret ? ret : count;
+}
+static CLASS_DEVICE_ATTR(available_resources_io, 0600, show_io_db, 
store_io_db);
 
 static ssize_t show_mem_db(struct class_device *class_dev, char *buf)
 {
@@ -868,7 +900,39 @@
        up(&rsrc_sem);
        return (ret);
 }
-static CLASS_DEVICE_ATTR(available_resources_mem, 0400, show_mem_db, NULL);
+
+static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, 
size_t count)
+{
+       struct pcmcia_socket *s = class_get_devdata(class_dev);
+       unsigned long start_addr, end_addr;
+       unsigned int add = 1;
+       adjust_t adj;
+       ssize_t ret = 0;
+
+       ret = sscanf (buf, "+ 0x%lx - 0x%lx", &start_addr, &end_addr);
+       if (ret != 2) {
+               ret = sscanf (buf, "- 0x%lx - 0x%lx", &start_addr, &end_addr);
+               add = 0;
+               if (ret != 2) {
+                       ret = sscanf (buf, "0x%lx - 0x%lx", &start_addr, 
&end_addr);
+                       add = 1;
+                       if (ret != 2)
+                               return -EINVAL;
+               }
+       }
+       if (end_addr <= start_addr)
+               return -EINVAL;
+
+       adj.Action = add ? ADD_MANAGED_RESOURCE : REMOVE_MANAGED_RESOURCE;
+       adj.Resource = RES_MEMORY_RANGE;
+       adj.resource.memory.Base = start_addr;
+       adj.resource.memory.Size = end_addr - start_addr + 1;
+
+       ret = adjust_memory(s, &adj);
+
+       return ret ? ret : count;
+}
+static CLASS_DEVICE_ATTR(available_resources_mem, 0600, show_mem_db, 
store_mem_db);
 
 static struct class_device_attribute *pccard_rsrc_attributes[] = {
        &class_device_attr_available_resources_io,
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to