Skip to contentSkip to conversation

W1 patches for 2.6.11

PATCH New Greg KH 1 participant 8 messages Mar 4, 2005 – Mar 5, 2005 W1 dallas's 1-wire bus

lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 W1 patches for 2.6.11

Hi,

Here are some W1 driver patches against the latest 2.6.11 tree. These have all been in the past few -mm releases.

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/w1-2.6

thanks,

greg k-h

 drivers/w1/dscore.c    |   27 ++++++++++++++-------------
 drivers/w1/dscore.h    |    3 ---
 drivers/w1/matrox_w1.c |    2 +-
 drivers/w1/w1.c        |   41 +++++++++++++++--------------------------
 drivers/w1/w1.h        |    1 -
 drivers/w1/w1_family.c |    4 ++--
 drivers/w1/w1_int.c    |    4 ----
 drivers/w1/w1_therm.c  |   12 ++++++------
 8 files changed, 38 insertions(+), 56 deletions(-)

-----

Christophe Lucas:
o drivers/w1/*: convert to pci_register_driver

Evgeniy Polyakov:
o w1: get rid of the potential problems with atomic operations
o w1: replace obsoleted *sleep_on*
o w1: Core cleanup 1/2
o w1: dscore cleanups. 2/2

Greg Kroah-Hartman:
o w1: fix some compiler warnings generated by the last "static" patch

Nishanth Aravamudan:
o w1/w1_therm: replace schedule_timeout() with msleep_interruptible()

author
#1 lore raw

PATCH 1/1 w1/w1_therm: replace schedule_timeout() with msleep_interruptible()

ChangeSet 1.2080, 2005/03/02 16:58:20-08:00, [email protected]

[PATCH] w1/w1_therm: replace schedule_timeout() with msleep_interruptible()

Description: Use msleep_interruptible() instead of schedule_timeout() to guarantee the task delays as expected. Changed tm to an int, as it now is in terms of msecs, not jiffies.

 drivers/w1/w1_therm.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/w1/w1_therm.c +4 -6
diff -Nru a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
@@ -26,6 +26,7 @@
 #include <linux/moduleparam.h>
 #include <linux/device.h>
 #include <linux/types.h>
+#include <linux/delay.h>
 
 #include "w1.h"
 #include "w1_io.h"
@@ -128,7 +129,7 @@
 		if (!w1_reset_bus (dev)) {
 			int count = 0;
 			u8 match[9] = {W1_MATCH_ROM, };
-			unsigned long tm;
+			unsigned int tm = 750;
 
 			memcpy(&match[1], (u64 *) & sl->reg_num, 8);
 			
@@ -136,11 +137,8 @@
 
 			w1_write_8(dev, W1_CONVERT_TEMP);
 
-			tm = jiffies + msecs_to_jiffies(750);
-			while(time_before(jiffies, tm)) {
-				set_current_state(TASK_INTERRUPTIBLE);
-				schedule_timeout(tm-jiffies);
-
+			while (tm) {
+				tm = msleep_interruptible(tm);
 				if (signal_pending(current))
 					flush_signals(current);
 			}
author
#2 lore raw

PATCH 1/1 w1: dscore cleanups. 2/2

ChangeSet 1.2081, 2005/03/02 16:58:36-08:00, [email protected]

[PATCH] w1: dscore cleanups. 2/2

Trivial cleanups, mostly static/non static, removed unneded exports.

 drivers/w1/dscore.c |   24 ++++++++++++++----------
 1 files changed, 14 insertions(+), 10 deletions(-)
drivers/w1/dscore.c +14 -10
diff -Nru a/drivers/w1/dscore.c b/drivers/w1/dscore.c
@@ -148,7 +148,7 @@
 	return count;
 }
 
-int ds_recv_status(struct ds_device *dev, struct ds_status *st)
+static int ds_recv_status(struct ds_device *dev, struct ds_status *st)
 {
 	unsigned char buf[64];
 	int count, err = 0, i;
@@ -206,7 +206,7 @@
 	return err;
 }
 
-int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
+static int ds_recv_data(struct ds_device *dev, unsigned char *buf, int size)
 {
 	int count, err;
 	struct ds_status st;
@@ -234,7 +234,7 @@
 	return count;
 }
 
-int ds_send_data(struct ds_device *dev, unsigned char *buf, int len)
+static int ds_send_data(struct ds_device *dev, unsigned char *buf, int len)
 {
 	int count, err;
 	
@@ -774,15 +774,19 @@
 EXPORT_SYMBOL(ds_write_byte);
 EXPORT_SYMBOL(ds_write_bit);
 EXPORT_SYMBOL(ds_write_block);
+EXPORT_SYMBOL(ds_reset);
+EXPORT_SYMBOL(ds_get_device);
+EXPORT_SYMBOL(ds_put_device);
+
+/*
+ * This functions can be used for EEPROM programming, 
+ * when driver will be included into mainline this will 
+ * require uncommenting.
+ */
+#if 0
 EXPORT_SYMBOL(ds_start_pulse);
 EXPORT_SYMBOL(ds_set_speed);
-EXPORT_SYMBOL(ds_reset);
 EXPORT_SYMBOL(ds_detect);
 EXPORT_SYMBOL(ds_stop_pulse);
-EXPORT_SYMBOL(ds_send_data);
-EXPORT_SYMBOL(ds_recv_data);
-EXPORT_SYMBOL(ds_recv_status);
 EXPORT_SYMBOL(ds_search);
-EXPORT_SYMBOL(ds_get_device);
-EXPORT_SYMBOL(ds_put_device);
-
+#endif
author
#3 lore raw

PATCH 1/1 w1: Core cleanup 1/2

ChangeSet 1.2082, 2005/03/02 16:58:52-08:00, [email protected]

[PATCH] w1: Core cleanup 1/2

Trivial cleanups, mostly static/non static, removed unneded exports. It fuzzes a bit, sorry, patch is quite old.

 drivers/w1/w1.c        |   23 ++++++++++-------------
 drivers/w1/w1_family.c |    2 --
 drivers/w1/w1_int.c    |    3 ---
 3 files changed, 10 insertions(+), 18 deletions(-)
drivers/w1/w1.c +10 -13
diff -Nru a/drivers/w1/w1.c b/drivers/w1/w1.c
@@ -19,8 +19,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
-#include <asm/atomic.h>
-
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -33,6 +31,8 @@
 #include <linux/slab.h>
 #include <linux/sched.h>
 
+#include <asm/atomic.h>
+
 #include "w1.h"
 #include "w1_io.h"
 #include "w1_log.h"
@@ -100,7 +100,7 @@
 	return sprintf(buf, "No family registered.\n");
 }
 
-struct bus_type w1_bus_type = {
+static struct bus_type w1_bus_type = {
 	.name = "w1",
 	.match = w1_master_match,
 };
@@ -138,7 +138,7 @@
 	.show = &w1_default_read_name,
 };
 
-ssize_t w1_master_attribute_show_name(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_name(struct device *dev, char *buf)
 {
 	struct w1_master *md = container_of (dev, struct w1_master, dev);
 	ssize_t count;
@@ -153,7 +153,7 @@
 	return count;
 }
 
-ssize_t w1_master_attribute_show_pointer(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_pointer(struct device *dev, char *buf)
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	ssize_t count;
@@ -167,14 +167,14 @@
 	return count;
 }
 
-ssize_t w1_master_attribute_show_timeout(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_timeout(struct device *dev, char *buf)
 {
 	ssize_t count;
 	count = sprintf(buf, "%d\n", w1_timeout);
 	return count;
 }
 
-ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, char *buf)
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	ssize_t count;
@@ -188,7 +188,7 @@
 	return count;
 }
 
-ssize_t w1_master_attribute_show_attempts(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_attempts(struct device *dev, char *buf)
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	ssize_t count;
@@ -202,7 +202,7 @@
 	return count;
 }
 
-ssize_t w1_master_attribute_show_slave_count(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_slave_count(struct device *dev, char *buf)
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
 	ssize_t count;
@@ -216,7 +216,7 @@
 	return count;
 }
 
-ssize_t w1_master_attribute_show_slaves(struct device *dev, char *buf)
+static ssize_t w1_master_attribute_show_slaves(struct device *dev, char *buf)
 
 {
 	struct w1_master *md = container_of(dev, struct w1_master, dev);
@@ -839,6 +839,3 @@
 
 module_init(w1_init);
 module_exit(w1_fini);
-
-EXPORT_SYMBOL(w1_create_master_attributes);
-EXPORT_SYMBOL(w1_destroy_master_attributes);
drivers/w1/w1_family.c +0 -2
diff -Nru a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
@@ -143,8 +143,6 @@
 
 EXPORT_SYMBOL(w1_family_get);
 EXPORT_SYMBOL(w1_family_put);
-EXPORT_SYMBOL(__w1_family_get);
-EXPORT_SYMBOL(__w1_family_put);
 EXPORT_SYMBOL(w1_family_registered);
 EXPORT_SYMBOL(w1_unregister_family);
 EXPORT_SYMBOL(w1_register_family);
drivers/w1/w1_int.c +0 -3
diff -Nru a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
@@ -217,8 +217,5 @@
 	__w1_remove_master_device(dev);
 }
 
-EXPORT_SYMBOL(w1_alloc_dev);
-EXPORT_SYMBOL(w1_free_dev);
 EXPORT_SYMBOL(w1_add_master_device);
 EXPORT_SYMBOL(w1_remove_master_device);
-EXPORT_SYMBOL(__w1_remove_master_device);
author
#4 lore raw

PATCH 1/1 w1: fix some compiler warnings generated by the last "static" patch.

ChangeSet 1.2083, 2005/03/02 16:59:08-08:00, [email protected]

[PATCH] w1: fix some compiler warnings generated by the last "static" patch.

 drivers/w1/dscore.c |    3 ---
 drivers/w1/dscore.h |    3 ---
 2 files changed, 6 deletions(-)
drivers/w1/dscore.c +0 -3
diff -Nru a/drivers/w1/dscore.c b/drivers/w1/dscore.c
@@ -45,9 +45,6 @@
 int ds_reset(struct ds_device *, struct ds_status *);
 int ds_detect(struct ds_device *, struct ds_status *);
 int ds_stop_pulse(struct ds_device *, int);
-int ds_send_data(struct ds_device *, unsigned char *, int);
-int ds_recv_data(struct ds_device *, unsigned char *, int);
-int ds_recv_status(struct ds_device *, struct ds_status *);
 struct ds_device * ds_get_device(void);
 void ds_put_device(struct ds_device *);
 
drivers/w1/dscore.h +0 -3
diff -Nru a/drivers/w1/dscore.h b/drivers/w1/dscore.h
@@ -161,9 +161,6 @@
 int ds_reset(struct ds_device *, struct ds_status *);
 int ds_detect(struct ds_device *, struct ds_status *);
 int ds_stop_pulse(struct ds_device *, int);
-int ds_send_data(struct ds_device *, unsigned char *, int);
-int ds_recv_data(struct ds_device *, unsigned char *, int);
-int ds_recv_status(struct ds_device *, struct ds_status *);
 struct ds_device * ds_get_device(void);
 void ds_put_device(struct ds_device *);
 int ds_write_block(struct ds_device *, u8 *, int);
author
#5 lore raw

PATCH 1/1 w1: replace obsoleted *sleep_on*

ChangeSet 1.2084, 2005/03/02 16:59:25-08:00, [email protected]

[PATCH] w1: replace obsoleted *sleep_on*

Remove obsoleded *sleep_on*.

Since they are used only to wait for a given flags and awakening only happens on signals, we can just replace them with msleep_interruptible.

 drivers/w1/w1.c     |   18 +++++-------------
 drivers/w1/w1.h     |    1 -
 drivers/w1/w1_int.c |    1 -
 3 files changed, 5 insertions(+), 15 deletions(-)
drivers/w1/w1.c +5 -13
diff -Nru a/drivers/w1/w1.c b/drivers/w1/w1.c
@@ -58,7 +58,6 @@
 static pid_t control_thread;
 static int control_needs_exit;
 static DECLARE_COMPLETION(w1_control_complete);
-static DECLARE_WAIT_QUEUE_HEAD(w1_control_wait);
 
 static int w1_master_match(struct device *dev, struct device_driver *drv)
 {
@@ -649,7 +648,7 @@
 	struct w1_slave *sl;
 	struct w1_master *dev;
 	struct list_head *ent, *ment, *n, *mn;
-	int err, have_to_wait = 0, timeout;
+	int err, have_to_wait = 0;
 
 	daemonize("w1_control");
 	allow_signal(SIGTERM);
@@ -657,11 +656,8 @@
 	while (!control_needs_exit || have_to_wait) {
 		have_to_wait = 0;
 
-		timeout = w1_timeout*HZ;
-		do {
-			timeout = interruptible_sleep_on_timeout(&w1_control_wait, timeout);
-			try_to_freeze(PF_FREEZE);
-		} while (!signal_pending(current) && (timeout > 0));
+		try_to_freeze(PF_FREEZE);
+		msleep_interruptible(w1_timeout * 1000);
 
 		if (signal_pending(current))
 			flush_signals(current);
@@ -721,7 +717,6 @@
 int w1_process(void *data)
 {
 	struct w1_master *dev = (struct w1_master *) data;
-	unsigned long timeout;
 	struct list_head *ent, *n;
 	struct w1_slave *sl;
 
@@ -729,11 +724,8 @@
 	allow_signal(SIGTERM);
 
 	while (!dev->need_exit) {
-		timeout = w1_timeout*HZ;
-		do {
-			timeout = interruptible_sleep_on_timeout(&dev->kwait, timeout);
-			try_to_freeze(PF_FREEZE);
-		} while (!signal_pending(current) && (timeout > 0));
+		try_to_freeze(PF_FREEZE);
+		msleep_interruptible(w1_timeout * 1000);
 
 		if (signal_pending(current))
 			flush_signals(current);
drivers/w1/w1.h +0 -1
diff -Nru a/drivers/w1/w1.h b/drivers/w1/w1.h
@@ -115,7 +115,6 @@
 
 	int			need_exit;
 	pid_t			kpid;
-	wait_queue_head_t 	kwait;
 	struct semaphore 	mutex;
 
 	struct device_driver	*driver;
drivers/w1/w1_int.c +0 -1
diff -Nru a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c
@@ -74,7 +74,6 @@
 	INIT_LIST_HEAD(&dev->slist);
 	init_MUTEX(&dev->mutex);
 
-	init_waitqueue_head(&dev->kwait);
 	init_completion(&dev->dev_released);
 	init_completion(&dev->dev_exited);
 
author
#6 lore raw

PATCH 1/1 w1: get rid of the potential problems with atomic operations.

ChangeSet 1.2085, 2005/03/02 16:59:41-08:00, [email protected]

[PATCH] w1: get rid of the potential problems with atomic operations.

Get rid of the potential problems with atomic operations.

According to upcoming atomic_ops.txt by David Miller and Anton Blanchard some archs may reoder atomic operations with nonatomic, since the former are always visible but the latter are not, this can lead to unpredicted behaviour.

 drivers/w1/w1_family.c |    2 ++
 drivers/w1/w1_therm.c  |    2 ++
 2 files changed, 4 insertions(+)
drivers/w1/w1_family.c +2 -0
diff -Nru a/drivers/w1/w1_family.c b/drivers/w1/w1_family.c
@@ -138,7 +138,9 @@
 
 void __w1_family_get(struct w1_family *f)
 {
+	smp_mb__before_atomic_inc();
 	atomic_inc(&f->refcnt);
+	smp_mb__after_atomic_inc();
 }
 
 EXPORT_SYMBOL(w1_family_get);
drivers/w1/w1_therm.c +2 -0
diff -Nru a/drivers/w1/w1_therm.c b/drivers/w1/w1_therm.c
@@ -104,6 +104,7 @@
 	int i, max_trying = 10;
 
 	atomic_inc(&sl->refcnt);
+	smp_mb__after_atomic_inc();
 	if (down_interruptible(&sl->master->mutex)) {
 		count = 0;
 		goto out_dec;
@@ -179,6 +180,7 @@
 out:
 	up(&dev->mutex);
 out_dec:
+	smp_mb__before_atomic_inc();
 	atomic_dec(&sl->refcnt);
 
 	return count;
author
#7 lore raw

PATCH 1/1 drivers/w1/*: convert to pci_register_driver

ChangeSet 1.2086, 2005/03/02 16:59:57-08:00, [email protected]

[PATCH] drivers/w1/*: convert to pci_register_driver

convert from pci_module_init to pci_register_driver (from:http://kerneljanitors.org/TODO).

 drivers/w1/matrox_w1.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/w1/matrox_w1.c +1 -1
diff -Nru a/drivers/w1/matrox_w1.c b/drivers/w1/matrox_w1.c
@@ -235,7 +235,7 @@
 
 static int __init matrox_w1_init(void)
 {
-	return pci_module_init(&matrox_w1_pci_driver);
+	return pci_register_driver(&matrox_w1_pci_driver);
 }
 
 static void __exit matrox_w1_fini(void)