Skip to contentSkip to conversation

w1 search cleanup

PATCH New [email protected] 3 participants 6 messages Jun 2, 2005 – Jun 9, 2005 W1 dallas's 1-wire bus

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 w1 search cleanup

While writing a driver for the DS2482 (an i2c to w1 bridge), I made a few enhancements to the w1 subsystem.

1.
I added a new I/O function: triplet
A triplet reads two bits and writes a direction bit. The DS2482 implements this in hardware.
I modified w1_search() to use w1_triplet() at its core.

2.
I cleaned up the I/O functions to separate emulated vs native w1 support.
A w1 bus master must be able to do one of:
a. Set and sample the line via write_bit() and read_bit() b. Support reset_bus() and touch_bit()
Function set (a) is only needed for emulated devices (ie, a parallel port).
I hid w1_read_bit() and w1_write_bit() behind w1_touch_bit(), and changed functions to call touch_bit() instead or read/write_bit().

3.
Searching is fairly slow - it requires about 200 w1 bit cycles per device, multiplied by the number of devices on the bus.
I modified the w1_process() to NOT periodically search the bus. A sysfs entry was added to request a search. (w1_master_search). To request a search, echo anything into w1_master_search and it'll run another search.

4.
I added a default family so that a slave device will get reported even if there isn't a driver for that family.

-------------- next part --------------

drivers/w1/w1.c +131 -87
diff -Naur linux-2.6.12-rc5-mm2-clean/drivers/w1/w1.c linux-2.6.12-rc5-mm2/drivers/w1/w1.c
@@ -59,6 +59,19 @@
 static int control_needs_exit;
 static DECLARE_COMPLETION(w1_control_complete);
 
+/* stuff for the default family */
+static ssize_t w1_famdefault_read_name(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct w1_slave *sl = container_of(dev, struct w1_slave, dev);
+	return(sprintf(buf, "%s\n", sl->name));
+}
+static struct w1_family_ops w1_default_fops = {
+	.rname = &w1_famdefault_read_name,
+};
+static struct w1_family w1_default_family = {
+	.fops = &w1_default_fops,
+};
+
 static int w1_master_match(struct device *dev, struct device_driver *drv)
 {
 	return 1;
@@ -135,7 +148,7 @@
 
 static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, char *buf)
 {
-	struct w1_master *md = container_of (dev, struct w1_master, dev);
+	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	ssize_t count;
 
 	if (down_interruptible (&md->mutex))
@@ -148,6 +161,22 @@
 	return count;
 }
 
+static ssize_t w1_master_attribute_store_search(struct device * dev, 
+						struct device_attribute *attr,
+						const char * buf, size_t count)
+{
+	struct w1_master *md = container_of(dev, struct w1_master, dev);
+
+	if (down_interruptible (&md->mutex))
+		return -EBUSY;
+
+	md->search_type = W1_SEARCH;
+
+	up(&md->mutex);
+
+	return count;
+}
+
 static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, char *buf)
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
@@ -212,7 +241,6 @@
 }
 
 static ssize_t w1_master_attribute_show_slaves(struct device *dev, struct device_attribute *attr, char *buf)
-
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	int c = PAGE_SIZE;
@@ -243,6 +271,11 @@
 		__ATTR(w1_master_##_name, _mode,		\
 		       w1_master_attribute_show_##_name, NULL)
 
+#define W1_MASTER_ATTR_WO(_name, _mode)				\
+	struct device_attribute w1_master_attribute_##_name =	\
+		__ATTR(w1_master_##_name, _mode,		\
+		       NULL, w1_master_attribute_store_##_name)
+
 static W1_MASTER_ATTR_RO(name, S_IRUGO);
 static W1_MASTER_ATTR_RO(slaves, S_IRUGO);
 static W1_MASTER_ATTR_RO(slave_count, S_IRUGO);
@@ -251,6 +284,8 @@
 static W1_MASTER_ATTR_RO(timeout, S_IRUGO);
 static W1_MASTER_ATTR_RO(pointer, S_IRUGO);
 
+static W1_MASTER_ATTR_WO(search, S_IWUGO);
+
 static struct attribute *w1_master_default_attrs[] = {
 	&w1_master_attribute_name.attr,
 	&w1_master_attribute_slaves.attr,
@@ -259,6 +294,7 @@
 	&w1_master_attribute_attempts.attr,
 	&w1_master_attribute_timeout.attr,
 	&w1_master_attribute_pointer.attr,
+	&w1_master_attribute_search.attr,
 	NULL
 };
 
@@ -286,9 +322,9 @@
 	sl->dev.release = &w1_slave_release;
 
 	snprintf(&sl->dev.bus_id[0], sizeof(sl->dev.bus_id),
-		  "%02x-%012llx",
-		  (unsigned int) sl->reg_num.family,
-		  (unsigned long long) sl->reg_num.id);
+		 "%02x-%012llx",
+		 (unsigned int) sl->reg_num.family,
+		 (unsigned long long) sl->reg_num.id);
 	snprintf (&sl->name[0], sizeof(sl->name),
 		  "%02x-%012llx",
 		  (unsigned int) sl->reg_num.family,
@@ -300,8 +336,8 @@
 	err = device_register(&sl->dev);
 	if (err < 0) {
 		dev_err(&sl->dev,
-			 "Device registration [%s] failed. err=%d\n",
-			 sl->dev.bus_id, err);
+			"Device registration [%s] failed. err=%d\n",
+			sl->dev.bus_id, err);
 		return err;
 	}
 
@@ -314,22 +350,23 @@
 	err = device_create_file(&sl->dev, &sl->attr_name);
 	if (err < 0) {
 		dev_err(&sl->dev,
-			 "sysfs file creation for [%s] failed. err=%d\n",
-			 sl->dev.bus_id, err);
+			"sysfs file creation for [%s] failed. err=%d\n",
+			sl->dev.bus_id, err);
 		device_unregister(&sl->dev);
 		return err;
 	}
 
-	err = sysfs_create_bin_file(&sl->dev.kobj, &sl->attr_bin);
-	if (err < 0) {
-		dev_err(&sl->dev,
-			 "sysfs file creation for [%s] failed. err=%d\n",
-			 sl->dev.bus_id, err);
-		device_remove_file(&sl->dev, &sl->attr_name);
-		device_unregister(&sl->dev);
-		return err;
+	if ( sl->attr_bin.read ) {
+		err = sysfs_create_bin_file(&sl->dev.kobj, &sl->attr_bin);
+		if (err < 0) {
+			dev_err(&sl->dev,
+				"sysfs file creation for [%s] failed. err=%d\n",
+				sl->dev.bus_id, err);
+			device_remove_file(&sl->dev, &sl->attr_name);
+			device_unregister(&sl->dev);
+			return err;
+		}
 	}
-
 	list_add_tail(&sl->w1_slave_entry, &sl->master->slist);
 
 	return 0;
@@ -363,12 +400,13 @@
 	spin_lock(&w1_flock);
 	f = w1_family_registered(rn->family);
 	if (!f) {
-		spin_unlock(&w1_flock);
-		dev_info(&dev->dev, "Family %x for %02x.%012llx.%02x is not registered.\n",
+		f= &w1_default_family;
+//		spin_unlock(&w1_flock);
+		dev_info(&dev->dev, "Family %x for %02x.%012llx.%02x is not registered, using default.\n",
 			  rn->family, rn->family,
 			  (unsigned long long)rn->id, rn->crc);
-		kfree(sl);
-		return -ENODEV;
+//		kfree(sl);
+//		return -ENODEV;
 	}
 	__w1_family_get(f);
 	spin_unlock(&w1_flock);
@@ -409,7 +447,9 @@
 			flush_signals(current);
 	}
 
-	sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin);
+	if ( sl->attr_bin.read ) {
+		sysfs_remove_bin_file (&sl->dev.kobj, &sl->attr_bin);
+	}
 	device_remove_file(&sl->dev, &sl->attr_name);
 	device_unregister(&sl->dev);
 	w1_family_put(sl->family);
@@ -483,26 +523,40 @@
 	atomic_dec(&dev->refcnt);
 }
 
-void w1_search(struct w1_master *dev)
-{
-	u64 last, rn, tmp;
-	int i, count = 0;
-	int last_family_desc, last_zero, last_device;
-	int search_bit, id_bit, comp_bit, desc_bit;
-
-	search_bit = id_bit = comp_bit = 0;
-	rn = tmp = last = 0;
-	last_device = last_zero = last_family_desc = 0;
+/**
+ * Performs a ROM Search & registers any devices found.
+ * The 1-wire search is a simple binary tree search.
+ * For each bit of the address, we read two bits and write one bit.
+ * The bit written will put to sleep all devies that don't match that bit.
+ * When the two reads differ, the direction choice is obvious.
+ * When both bits are 0, we must choose a path to take.
+ * When we can scan all 64 bits without having to choose a path, we are done.
+ * 
+ * See "Application note 187 1-wire search algorithm" at www.maxim-ic.com
+ * 
+ * @dev        The master device to search
+ * @search_cmd W1_SEARCH or W1_CONDITIONAL_SEARCH
+ * @cb         Function to call when a device is found
+ */
+void w1_search(struct w1_master *dev, u8 search_cmd, w1_slave_found_callback cb)
+{
+	u64 last_rn, rn, tmp64;
+	int i, slave_count = 0;
+	int last_zero, last_device;
+	int search_bit, desc_bit;
+	u8  triplet_ret = 0;
+
+	search_bit = 0;
+	rn = last_rn = 0;
+	last_device = 0;
+	last_zero = -1;
 
 	desc_bit = 64;
 
-	while (!(id_bit && comp_bit) && !last_device &&
-	       count++ < dev->max_slave_count) {
-		last = rn;
+	while ( !last_device && (slave_count++ < dev->max_slave_count) ) {
+		last_rn = rn;
 		rn = 0;
 
-		last_family_desc = 0;
-
 		/*
 		 * Reset bus and all 1-wire device state machines
 		 * so they can respond to our requests.
@@ -514,59 +568,39 @@
 			break;
 		}
 
-#if 1
-		w1_write_8(dev, W1_SEARCH);
+		/* Start the search */
+		w1_write_8(dev, search_cmd);
 		for (i = 0; i < 64; ++i) {
-			/*
-			 * Read 2 bits from bus.
-			 * All who don't sleep must send ID bit and COMPLEMENT ID bit.
-			 * They actually are ANDed between all senders.
-			 */
-			id_bit = w1_touch_bit(dev, 1);
-			comp_bit = w1_touch_bit(dev, 1);
-
-			if (id_bit && comp_bit)
-				break;
-
-			if (id_bit = 0 && comp_bit = 0) {
-				if (i = desc_bit)
-					search_bit = 1;
-				else if (i > desc_bit)
-					search_bit = 0;
-				else
-					search_bit = ((last >> i) & 0x1);
-
-				if (search_bit = 0) {
-					last_zero = i;
-					if (last_zero < 9)
-						last_family_desc = last_zero;
-				}
-
-			} else
-				search_bit = id_bit;
-
-			tmp = search_bit;
-			rn |= (tmp << i);
-
-			/*
-			 * Write 1 bit to bus
-			 * and make all who don't have "search_bit" in "i"'th position
-			 * in it's registration number sleep.
-			 */
-			if (dev->bus_master->touch_bit)
-				w1_touch_bit(dev, search_bit);
+			/* Determine the direction/search bit */
+			if (i = desc_bit)
+				search_bit = 1;	  /* took the 0 path last time, so take the 1 path */
+			else if (i > desc_bit)
+				search_bit = 0;	  /* take the 0 path on the next branch */
 			else
-				w1_write_bit(dev, search_bit);
+				search_bit = ((last_rn >> i) & 0x1);
 
-		}
-#endif
+			/** Read two bits and write one bit */
+			triplet_ret = w1_triplet(dev, search_bit);
 
-		if (desc_bit = last_zero)
-			last_device = 1;
+			/* quit if no device responded */
+			if ( (triplet_ret & 0x03) = 0x03 )
+				break;
 
-		desc_bit = last_zero;
+			/* If both directions were valid, and we took the 0 path... */
+			if (triplet_ret = 0)
+				last_zero = i;
+
+			/* extract the direction taken & update the device number */
+			tmp64 = (triplet_ret >> 2);
+			rn |= (tmp64 << i);
+		}
 
-		w1_slave_found(dev->bus_master->data, rn);
+		if ( (triplet_ret & 0x03) != 0x03 ) {
+			if ( (desc_bit = last_zero) || (last_zero < 0))
+				last_device = 1;
+			desc_bit = last_zero;
+			cb(dev->bus_master->data, rn);
+		}
 	}
 }
 
@@ -634,6 +668,7 @@
 {
 	struct w1_master *dev = (struct w1_master *) data;
 	struct w1_slave *sl, *sln;
+	unsigned long bit_num;
 
 	daemonize("%s", dev->name);
 	allow_signal(SIGTERM);
@@ -651,13 +686,18 @@
 		if (!dev->initialized)
 			continue;
 
+		if (dev->search_type = 0)
+			continue;
+
+		bit_num = (dev->search_type = W1_SEARCH) ? W1_SLAVE_ACTIVE : W1_SLAVE_ALARM;
+
 		if (down_interruptible(&dev->mutex))
 			continue;
 
 		list_for_each_entry(sl, &dev->slist, w1_slave_entry)
-				clear_bit(W1_SLAVE_ACTIVE, (long *)&sl->flags);
+				clear_bit(bit_num, (long *)&sl->flags);
 
-		w1_search_devices(dev, w1_slave_found);
+		w1_search_devices(dev, dev->search_type, w1_slave_found);
 
 		list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) {
 			if (!test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags) && !--sl->ttl) {
@@ -670,6 +710,9 @@
 			} else if (test_bit(W1_SLAVE_ACTIVE, (unsigned long *)&sl->flags))
 				sl->ttl = dev->slave_ttl;
 		}
+		
+		dev->search_type = 0;
+
 		up(&dev->mutex);
 	}
 
@@ -727,6 +770,7 @@
 		__w1_remove_master_device(dev);
 
 	control_needs_exit = 1;
+	kill_proc(control_thread, SIGTERM, 1);
 	wait_for_completion(&w1_control_complete);
 
 	driver_unregister(&w1_driver);
drivers/w1/w1.h +67 -18

119 lines not on this page · raw message

drivers/w1/w1_int.c +9 -0
diff -Naur linux-2.6.12-rc5-mm2-clean/drivers/w1/w1_int.c linux-2.6.12-rc5-mm2/drivers/w1/w1_int.c
@@ -69,6 +69,7 @@
 	dev->initialized	= 0;
 	dev->id			= id;
 	dev->slave_ttl		= slave_ttl;
+        dev->search_type        = W1_SEARCH;
 
 	atomic_set(&dev->refcnt, 2);
 
@@ -121,6 +122,14 @@
 	int retval = 0;
 	struct w1_netlink_msg msg;
 
+        /* validate minimum functionality */
+        if (!(master->touch_bit && master->reset_bus) &&
+            !(master->write_bit && master->read_bit))
+        {
+           printk(KERN_ERR "w1_add_master_device: invalid function set\n");
+           return(-EINVAL);
+        }
+
 	dev = w1_alloc_dev(w1_ids++, w1_max_slave_count, w1_max_slave_ttl, &w1_driver, &w1_device);
 	if (!dev)
 		return -ENOMEM;
drivers/w1/w1_io.c +108 -11

190 lines not on this page · raw message

drivers/w1/w1_io.h +3 -4
diff -Naur linux-2.6.12-rc5-mm2-clean/drivers/w1/w1_io.h linux-2.6.12-rc5-mm2/drivers/w1/w1_io.h
@@ -26,14 +26,13 @@
 
 void w1_delay(unsigned long);
 u8 w1_touch_bit(struct w1_master *, int);
-void w1_write_bit(struct w1_master *, int);
+u8 w1_triplet(struct w1_master *dev, int bdir);
 void w1_write_8(struct w1_master *, u8);
-u8 w1_read_bit(struct w1_master *);
 u8 w1_read_8(struct w1_master *);
 int w1_reset_bus(struct w1_master *);
 u8 w1_calc_crc8(u8 *, int);
-void w1_write_block(struct w1_master *, u8 *, int);
+void w1_write_block(struct w1_master *, const u8 *, int);
 u8 w1_read_block(struct w1_master *, u8 *, int);
-void w1_search_devices(struct w1_master *dev, w1_slave_found_callback cb);
+void w1_search_devices(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb);
 
 #endif /* __W1_IO_H */
#1 lore raw

PATCH 1/1 w1 search cleanup

On Thu, 2 Jun 2005 13:09:52 -0400
<[email protected]> wrote:

Hello, Ben.

I very like your changes, although I did not tested it yet, will do it later this week.
But I have some comments about.

Quoted 9 lines

While writing a driver for the DS2482 (an i2c to w1 bridge), I made a few enhancements to the w1 subsystem.

1.
I added a new I/O function: triplet
A triplet reads two bits and writes a direction bit. The DS2482 implements this in hardware.
I modified w1_search() to use w1_triplet() at its core.

Quoted 10 lines

2.
I cleaned up the I/O functions to separate emulated vs native w1 support.
A w1 bus master must be able to do one of:
a. Set and sample the line via write_bit() and read_bit() b. Support reset_bus() and touch_bit()
Function set (a) is only needed for emulated devices (ie, a parallel port).
I hid w1_read_bit() and w1_write_bit() behind w1_touch_bit(), and changed functions to call touch_bit() instead or read/write_bit().

This changes are quite good.

Quoted 7 lines

3.
Searching is fairly slow - it requires about 200 w1 bit cycles per device, multiplied by the number of devices on the bus.
I modified the w1_process() to NOT periodically search the bus. A sysfs entry was added to request a search. (w1_master_search). To request a search, echo anything into w1_master_search and it'll run another search.

This one is very usefull, but we do want a mode, when w1 core repeatedly scans for devices - concider ibuttons which can only "exists" and be found for a couple of seconds, and it is
not always possible and sensible to have some userspace writing to the sysfs file.
I would like to have 2 search modes - writing "1" to sysfs turns default always-scan mode into write-on-request mode, and writing "2" turns it back. Or something similar...

Quoted 5 lines

4.
I added a default family so that a slave device will get reported even if there isn't a driver for that family.

Besides some whitespace and some brackets places [ugh, Greg will kill me for such patches] and my above comment I do not have objections, but I would like to test your changes first and see them presented in a splitted series of patches. I see almost 10 major changes in your patch :)

Thank you.

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#2 lore raw

PATCH 1/1 w1 search cleanup

In reply to [email protected]

Evgeniy,

Thank you for your response.

I will split this patch into a few separate patches:

1) Touch/read/write changes only

2) Triplet/w1_search() changes only

3) Search timing change with your suggested sysfs modification Should it default to continual or on-demand scan?

4) Default family change

How does that sound?

Thanks,
Ben

-----Original Message-----
From: Evgeniy Polyakov [mailto:[email protected]]
Sent: Thursday, June 02, 2005 3:03 PM
To: Gardner, Ben
Cc: [email protected]
Subject: Re: [lm-sensors] [PATCH 2.6.12-rc5-mm2] w1 search cleanup

On Thu, 2 Jun 2005 13:09:52 -0400
<[email protected]> wrote:

Hello, Ben.

I very like your changes, although I did not tested it yet, will do it later this week.
But I have some comments about.

Quoted 9 lines

While writing a driver for the DS2482 (an i2c to w1 bridge), I made a few enhancements to the w1 subsystem.

1.
I added a new I/O function: triplet
A triplet reads two bits and writes a direction bit. The DS2482 implements this in hardware.
I modified w1_search() to use w1_triplet() at its core.

Quoted 10 lines

2.
I cleaned up the I/O functions to separate emulated vs native w1 support.
A w1 bus master must be able to do one of:
a. Set and sample the line via write_bit() and read_bit() b. Support reset_bus() and touch_bit()
Function set (a) is only needed for emulated devices (ie, a parallel port).
I hid w1_read_bit() and w1_write_bit() behind w1_touch_bit(), and changed functions to call touch_bit() instead or read/write_bit().

This changes are quite good.

Quoted 7 lines

3.
Searching is fairly slow - it requires about 200 w1 bit cycles per device, multiplied by the number of devices on the bus.
I modified the w1_process() to NOT periodically search the bus. A sysfs entry was added to request a search. (w1_master_search). To request a search, echo anything into w1_master_search and it'll run another search.

This one is very usefull, but we do want a mode, when w1 core repeatedly scans for devices - concider ibuttons which can only "exists" and be found for a couple of seconds, and it is
not always possible and sensible to have some userspace writing to the sysfs
file.
I would like to have 2 search modes - writing "1" to sysfs turns default always-scan mode into write-on-request mode, and writing "2" turns it back.
Or something similar...

Quoted 5 lines

4.
I added a default family so that a slave device will get reported even if there isn't a driver for that family.

Besides some whitespace and some brackets places [ugh, Greg will kill me

for such patches] and my above comment I do not have objections, but I would like to test your changes first and see them presented in a splitted series of patches. I see almost 10 major changes in your patch :)

Thank you.

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#3 lore raw

PATCH 1/1 w1 search cleanup

In reply to [email protected]
Quoted 8 lines · On Thu, 2 Jun 2005 17:45:34 -0400 <[email protected]> wrote:

Evgeniy,

Thank you for your response.

I will split this patch into a few separate patches:

1) Touch/read/write changes only

Quoted 8 lines

2) Triplet/w1_search() changes only

3) Search timing change with your suggested sysfs modification Should it default to continual or on-demand scan?

4) Default family change

How does that sound?

It sounds very good.
I think defult should be continual scan for systems without "extended" userspace.

Please post them so I will test it tomorrow and push upstrem.

And could you please create some documentation about new features in Documentation/w1.

Thank you.

Quoted 73 lines

Thanks,
Ben

-----Original Message-----
From: Evgeniy Polyakov [mailto:[email protected]]
Sent: Thursday, June 02, 2005 3:03 PM
To: Gardner, Ben
Cc: [email protected]
Subject: Re: [lm-sensors] [PATCH 2.6.12-rc5-mm2] w1 search cleanup

On Thu, 2 Jun 2005 13:09:52 -0400
<[email protected]> wrote:

Hello, Ben.

I very like your changes, although I did not tested it yet, will do it later this week.
But I have some comments about.

Quoted 9 lines

While writing a driver for the DS2482 (an i2c to w1 bridge), I made a few enhancements to the w1 subsystem.

1.
I added a new I/O function: triplet
A triplet reads two bits and writes a direction bit. The DS2482 implements this in hardware.
I modified w1_search() to use w1_triplet() at its core.

Quoted 10 lines

2.
I cleaned up the I/O functions to separate emulated vs native w1 support.
A w1 bus master must be able to do one of:
a. Set and sample the line via write_bit() and read_bit() b. Support reset_bus() and touch_bit()
Function set (a) is only needed for emulated devices (ie, a parallel port).
I hid w1_read_bit() and w1_write_bit() behind w1_touch_bit(), and changed functions to call touch_bit() instead or read/write_bit().

This changes are quite good.

Quoted 7 lines

3.
Searching is fairly slow - it requires about 200 w1 bit cycles per device, multiplied by the number of devices on the bus.
I modified the w1_process() to NOT periodically search the bus. A sysfs entry was added to request a search. (w1_master_search). To request a search, echo anything into w1_master_search and it'll run another search.

This one is very usefull, but we do want a mode, when w1 core repeatedly scans for devices - concider ibuttons which can only "exists" and be found for a couple of seconds, and it is
not always possible and sensible to have some userspace writing to the sysfs
file.
I would like to have 2 search modes - writing "1" to sysfs turns default always-scan mode into write-on-request mode, and writing "2" turns it back.
Or something similar...

Quoted 5 lines

4.
I added a default family so that a slave device will get reported even if there isn't a driver for that family.

Besides some whitespace and some brackets places [ugh, Greg will kill me

for such patches] and my above comment I do not have objections, but I would like to test your changes first and see them presented in a splitted series of patches. I see almost 10 major changes in your patch :)

Quoted 7 lines

Thank you.

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#4 lore raw

PATCH 1/1 w1 search cleanup

In reply to [email protected]
Quoted 28 lines · On Thu, 2 Jun 2005 13:09:52 -0400 <[email protected]> wrote:

While writing a driver for the DS2482 (an i2c to w1 bridge), I made a few enhancements to the w1 subsystem.

1.
I added a new I/O function: triplet
A triplet reads two bits and writes a direction bit. The DS2482 implements this in hardware.
I modified w1_search() to use w1_triplet() at its core.

2.
I cleaned up the I/O functions to separate emulated vs native w1 support.
A w1 bus master must be able to do one of:
a. Set and sample the line via write_bit() and read_bit() b. Support reset_bus() and touch_bit()
Function set (a) is only needed for emulated devices (ie, a parallel port).
I hid w1_read_bit() and w1_write_bit() behind w1_touch_bit(), and changed functions to call touch_bit() instead or read/write_bit().

3.
Searching is fairly slow - it requires about 200 w1 bit cycles per device, multiplied by the number of devices on the bus.
I modified the w1_process() to NOT periodically search the bus. A sysfs entry was added to request a search. (w1_master_search). To request a search, echo anything into w1_master_search and it'll run another search.

Quoted 5 lines

4.
I added a default family so that a slave device will get reported even if there isn't a driver for that family.

I've tested your patches and all looks ok. But patches 3 and 4 were applied with several hunks.

Greg, did you applied my previous 4 cleanups for w1?
Current patches are made against pure rc5-mm2 patches
and thus can fuzz and even fail with your tree with previous w1 cleanups. Can your try to apply this 5 patches [inlined in the next e-mails] and one I will send in a next e-mail with reconnect feature and confirm that it can not be applied or not.

Thanks.

Evgeniy Polyakov

Only failure makes us experts. -- Theo de Raadt

#5 lore raw

PATCH 1/1 w1 search cleanup

In reply to [email protected]
Quoted 1 line · Evgeniy Polyakov

Greg, did you applied my previous 4 cleanups for w1?

Yes I have, they are in the -mm tree as well.

Quoted 2 lines

Current patches are made against pure rc5-mm2 patches
and thus can fuzz and even fail with your tree with previous w1 cleanups.

Well, as -mm has your patches, these should apply. I'll see how well they go and let you know.

thanks,

greg k-h