mtd: fix Orion NAND driver compilation with ARM OABI
[safe/jmp/linux-2.6] / drivers / w1 / w1.c
index f3be299..ad5897d 100644 (file)
@@ -81,10 +81,10 @@ static void w1_slave_release(struct device *dev)
 {
        struct w1_slave *sl = dev_to_w1_slave(dev);
 
-       printk("%s: Releasing %s.\n", __func__, sl->name);
+       dev_dbg(dev, "%s: Releasing %s.\n", __func__, sl->name);
 
        while (atomic_read(&sl->refcnt)) {
-               printk("Waiting for %s to become free: refcnt=%d.\n",
+               dev_dbg(dev, "Waiting for %s to become free: refcnt=%d.\n",
                                sl->name, atomic_read(&sl->refcnt));
                if (msleep_interruptible(1000))
                        flush_signals(current);
@@ -103,35 +103,20 @@ static ssize_t w1_slave_read_name(struct device *dev, struct device_attribute *a
        return sprintf(buf, "%s\n", sl->name);
 }
 
-static ssize_t w1_slave_read_id(struct kobject *kobj,
-                               struct bin_attribute *bin_attr,
-                               char *buf, loff_t off, size_t count)
+static ssize_t w1_slave_read_id(struct device *dev,
+       struct device_attribute *attr, char *buf)
 {
-       struct w1_slave *sl = kobj_to_w1_slave(kobj);
-
-       if (off > 8) {
-               count = 0;
-       } else {
-               if (off + count > 8)
-                       count = 8 - off;
-
-               memcpy(buf, (u8 *)&sl->reg_num, count);
-       }
+       struct w1_slave *sl = dev_to_w1_slave(dev);
+       ssize_t count = sizeof(sl->reg_num);
 
+       memcpy(buf, (u8 *)&sl->reg_num, count);
        return count;
 }
 
 static struct device_attribute w1_slave_attr_name =
        __ATTR(name, S_IRUGO, w1_slave_read_name, NULL);
-
-static struct bin_attribute w1_slave_attr_bin_id = {
-      .attr = {
-              .name = "id",
-              .mode = S_IRUGO,
-      },
-      .size = 8,
-      .read = w1_slave_read_id,
-};
+static struct device_attribute w1_slave_attr_id =
+       __ATTR(id, S_IRUGO, w1_slave_read_id, NULL);
 
 /* Default family */
 
@@ -212,7 +197,7 @@ struct device_driver w1_master_driver = {
 struct device w1_master_device = {
        .parent = NULL,
        .bus = &w1_bus_type,
-       .bus_id = "w1 bus master",
+       .init_name = "w1 bus master",
        .driver = &w1_master_driver,
        .release = &w1_master_release
 };
@@ -226,7 +211,7 @@ static struct device_driver w1_slave_driver = {
 struct device w1_slave_device = {
        .parent = NULL,
        .bus = &w1_bus_type,
-       .bus_id = "w1 bus slave",
+       .init_name = "w1 bus slave",
        .driver = &w1_slave_driver,
        .release = &w1_slave_release
 };
@@ -588,7 +573,7 @@ static int w1_uevent(struct device *dev, struct kobj_uevent_env *env)
        }
 
        dev_dbg(dev, "Hotplug event for %s %s, bus_id=%s.\n",
-                       event_owner, name, dev->bus_id);
+                       event_owner, name, dev_name(dev));
 
        if (dev->driver != &w1_slave_driver || !sl)
                return 0;
@@ -620,8 +605,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
        sl->dev.bus = &w1_bus_type;
        sl->dev.release = &w1_slave_release;
 
-       snprintf(&sl->dev.bus_id[0], sizeof(sl->dev.bus_id),
-                "%02x-%012llx",
+       dev_set_name(&sl->dev, "%02x-%012llx",
                 (unsigned int) sl->reg_num.family,
                 (unsigned long long) sl->reg_num.id);
        snprintf(&sl->name[0], sizeof(sl->name),
@@ -630,13 +614,13 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
                 (unsigned long long) sl->reg_num.id);
 
        dev_dbg(&sl->dev, "%s: registering %s as %p.\n", __func__,
-               &sl->dev.bus_id[0], sl);
+               dev_name(&sl->dev), sl);
 
        err = device_register(&sl->dev);
        if (err < 0) {
                dev_err(&sl->dev,
                        "Device registration [%s] failed. err=%d\n",
-                       sl->dev.bus_id, err);
+                       dev_name(&sl->dev), err);
                return err;
        }
 
@@ -645,16 +629,16 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
        if (err < 0) {
                dev_err(&sl->dev,
                        "sysfs file creation for [%s] failed. err=%d\n",
-                       sl->dev.bus_id, err);
+                       dev_name(&sl->dev), err);
                goto out_unreg;
        }
 
        /* Create "id" entry */
-       err = sysfs_create_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
+       err = device_create_file(&sl->dev, &w1_slave_attr_id);
        if (err < 0) {
                dev_err(&sl->dev,
                        "sysfs file creation for [%s] failed. err=%d\n",
-                       sl->dev.bus_id, err);
+                       dev_name(&sl->dev), err);
                goto out_rem1;
        }
 
@@ -663,7 +647,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
            ((err = sl->family->fops->add_slave(sl)) < 0)) {
                dev_err(&sl->dev,
                        "sysfs file creation for [%s] failed. err=%d\n",
-                       sl->dev.bus_id, err);
+                       dev_name(&sl->dev), err);
                goto out_rem2;
        }
 
@@ -672,7 +656,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl)
        return 0;
 
 out_rem2:
-       sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
+       device_remove_file(&sl->dev, &w1_slave_attr_id);
 out_rem1:
        device_remove_file(&sl->dev, &w1_slave_attr_name);
 out_unreg:
@@ -754,7 +738,7 @@ void w1_slave_detach(struct w1_slave *sl)
        msg.type = W1_SLAVE_REMOVE;
        w1_netlink_send(sl->master, &msg);
 
-       sysfs_remove_bin_file(&sl->dev.kobj, &w1_slave_attr_bin_id);
+       device_remove_file(&sl->dev, &w1_slave_attr_id);
        device_remove_file(&sl->dev, &w1_slave_attr_name);
        device_unregister(&sl->dev);
 
@@ -845,9 +829,7 @@ void w1_reconnect_slaves(struct w1_family *f, int attach)
 
 static void w1_slave_found(struct w1_master *dev, u64 rn)
 {
-       int slave_count;
        struct w1_slave *sl;
-       struct list_head *ent;
        struct w1_reg_num *tmp;
        u64 rn_le = cpu_to_le64(rn);
 
@@ -855,24 +837,12 @@ static void w1_slave_found(struct w1_master *dev, u64 rn)
 
        tmp = (struct w1_reg_num *) &rn;
 
-       slave_count = 0;
-       list_for_each(ent, &dev->slist) {
-
-               sl = list_entry(ent, struct w1_slave, w1_slave_entry);
-
-               if (sl->reg_num.family == tmp->family &&
-                   sl->reg_num.id == tmp->id &&
-                   sl->reg_num.crc == tmp->crc) {
-                       set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
-                       break;
-               }
-
-               slave_count++;
-       }
-
-       if (slave_count == dev->slave_count &&
-               rn && ((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn_le, 7)) {
-               w1_attach_slave_device(dev, tmp);
+       sl = w1_slave_search_device(dev, tmp);
+       if (sl) {
+               set_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
+       } else {
+               if (rn && tmp->crc == w1_calc_crc8((u8 *)&rn_le, 7))
+                       w1_attach_slave_device(dev, tmp);
        }
 
        atomic_dec(&dev->refcnt);
@@ -949,7 +919,7 @@ void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb
                        rn |= (tmp64 << i);
 
                        if (kthread_should_stop()) {
-                               printk(KERN_INFO "Abort w1_search (exiting)\n");
+                               dev_dbg(&dev->dev, "Abort w1_search\n");
                                return;
                        }
                }
@@ -1016,7 +986,7 @@ int w1_process(void *data)
        return 0;
 }
 
-static int w1_init(void)
+static int __init w1_init(void)
 {
        int retval;
 
@@ -1064,7 +1034,7 @@ err_out_exit_init:
        return retval;
 }
 
-static void w1_fini(void)
+static void __exit w1_fini(void)
 {
        struct w1_master *dev;