linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / w1 / w1_smem.c
index a54e425..e3209d0 100644 (file)
@@ -1,8 +1,8 @@
 /*
- *     w1_smem.c
+ *     w1_smem.c
  *
  * Copyright (c) 2004 Evgeniy Polyakov <johnpol@2ka.mipt.ru>
- * 
+ *
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the smems of the GNU General Public License as published by
@@ -36,82 +36,35 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Evgeniy Polyakov <johnpol@2ka.mipt.ru>");
 MODULE_DESCRIPTION("Driver for 1-wire Dallas network protocol, 64bit memory family.");
 
-static ssize_t w1_smem_read_name(struct device *, char *);
-static ssize_t w1_smem_read_val(struct device *, char *);
-static ssize_t w1_smem_read_bin(struct kobject *, char *, loff_t, size_t);
+static struct w1_family w1_smem_family_01 = {
+       .fid = W1_FAMILY_SMEM_01,
+};
 
-static struct w1_family_ops w1_smem_fops = {
-       .rname = &w1_smem_read_name,
-       .rbin = &w1_smem_read_bin,
-       .rval = &w1_smem_read_val,
-       .rvalname = "id",
+static struct w1_family w1_smem_family_81 = {
+       .fid = W1_FAMILY_SMEM_81,
 };
 
-static ssize_t w1_smem_read_name(struct device *dev, char *buf)
+static int __init w1_smem_init(void)
 {
-       struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
+       int err;
 
-       return sprintf(buf, "%s\n", sl->name);
-}
-
-static ssize_t w1_smem_read_val(struct device *dev, char *buf)
-{
-       struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
-       int i;
-       ssize_t count = 0;
+       err = w1_register_family(&w1_smem_family_01);
+       if (err)
+               return err;
        
-       for (i = 0; i < 8; ++i)
-               count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
-       count += sprintf(buf + count, "\n");
-
-       return count;
-}
-
-static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, size_t count)
-{
-       struct w1_slave *sl = container_of(container_of(kobj, struct device, kobj),
-                                               struct w1_slave, dev);
-       int i;
-
-       atomic_inc(&sl->refcnt);
-       if (down_interruptible(&sl->master->mutex)) {
-               count = 0;
-               goto out_dec;
+       err = w1_register_family(&w1_smem_family_81);
+       if (err) {
+               w1_unregister_family(&w1_smem_family_01);
+               return err;
        }
 
-       if (off > W1_SLAVE_DATA_SIZE) {
-               count = 0;
-               goto out;
-       }
-       if (off + count > W1_SLAVE_DATA_SIZE) {
-               count = 0;
-               goto out;
-       }
-       for (i = 0; i < 8; ++i)
-               count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]);
-       count += sprintf(buf + count, "\n");
-       
-out:
-       up(&sl->master->mutex);
-out_dec:
-       atomic_dec(&sl->refcnt);
-
-       return count;
-}
-
-static struct w1_family w1_smem_family = {
-       .fid = W1_FAMILY_SMEM,
-       .fops = &w1_smem_fops,
-};
-
-static int __init w1_smem_init(void)
-{
-       return w1_register_family(&w1_smem_family);
+       return 0;
 }
 
 static void __exit w1_smem_fini(void)
 {
-       w1_unregister_family(&w1_smem_family);
+       w1_unregister_family(&w1_smem_family_01);
+       w1_unregister_family(&w1_smem_family_81);
 }
 
 module_init(w1_smem_init);