V4L/DVB (8819): gspca: Initialize the ov519 at open time and source cleanup.
[safe/jmp/linux-2.6] / drivers / zorro / zorro-sysfs.c
index dad03fc..5290552 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/zorro.h>
 #include <linux/stat.h>
+#include <linux/string.h>
 
 #include "zorro.h"
 
@@ -21,7 +22,7 @@
 /* show configuration fields */
 #define zorro_config_attr(name, field, format_string)                  \
 static ssize_t                                                         \
-show_##name(struct device *dev, char *buf)                             \
+show_##name(struct device *dev, struct device_attribute *attr, char *buf)                              \
 {                                                                      \
        struct zorro_dev *z;                                            \
                                                                        \
@@ -36,29 +37,25 @@ zorro_config_attr(serial, rom.er_SerialNumber, "0x%08x\n");
 zorro_config_attr(slotaddr, slotaddr, "0x%04x\n");
 zorro_config_attr(slotsize, slotsize, "0x%04x\n");
 
-static ssize_t zorro_show_resource(struct device *dev, char *buf)
+static ssize_t zorro_show_resource(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct zorro_dev *z = to_zorro_dev(dev);
 
        return sprintf(buf, "0x%08lx 0x%08lx 0x%08lx\n",
-                      zorro_resource_start(z), zorro_resource_end(z),
+                      (unsigned long)zorro_resource_start(z),
+                      (unsigned long)zorro_resource_end(z),
                       zorro_resource_flags(z));
 }
 
 static DEVICE_ATTR(resource, S_IRUGO, zorro_show_resource, NULL);
 
-static ssize_t zorro_read_config(struct kobject *kobj, char *buf, loff_t off,
-                                size_t count)
+static ssize_t zorro_read_config(struct kobject *kobj,
+                                struct bin_attribute *bin_attr,
+                                char *buf, loff_t off, size_t count)
 {
        struct zorro_dev *z = to_zorro_dev(container_of(kobj, struct device,
                                           kobj));
        struct ConfigDev cd;
-       unsigned int size = sizeof(cd);
-
-       if (off > size)
-               return 0;
-       if (off+count > size)
-               count = size-off;
 
        /* Construct a ConfigDev */
        memset(&cd, 0, sizeof(cd));
@@ -68,15 +65,13 @@ static ssize_t zorro_read_config(struct kobject *kobj, char *buf, loff_t off,
        cd.cd_BoardAddr = (void *)zorro_resource_start(z);
        cd.cd_BoardSize = zorro_resource_len(z);
 
-       memcpy(buf, (void *)&cd+off, count);
-       return count;
+       return memory_read_from_buffer(buf, count, &off, &cd, sizeof(cd));
 }
 
 static struct bin_attribute zorro_config_attr = {
        .attr = {
                .name = "config",
-               .mode = S_IRUGO | S_IWUSR,
-               .owner = THIS_MODULE
+               .mode = S_IRUGO,
        },
        .size = sizeof(struct ConfigDev),
        .read = zorro_read_config,