From 8523ff45672a5c9209ab7459142e37e7cd393e6c Mon Sep 17 00:00:00 2001 From: "johnpol@2ka.mipt.ru" Date: Mon, 18 Apr 2005 21:16:57 -0700 Subject: [PATCH] w1: real fix for big endian machines. Real fix for big endian machines - crc must be calculated using little endian byte order. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman --- drivers/w1/w1.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index fd630cec0e7..8d7821899cc 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -522,10 +522,11 @@ void w1_slave_found(unsigned long data, u64 rn) slave_count++; } - if (slave_count == dev->slave_count && rn ) { - tmp = cpu_to_le64(rn); - if(((rn >> 56) & 0xff) == w1_calc_crc8((u8 *)&tmp, 7)) - w1_attach_slave_device(dev, (struct w1_reg_num *) &rn); + rn = cpu_to_le64(rn); + + if (slave_count == dev->slave_count && + rn && ((le64_to_cpu(rn) >> 56) & 0xff) == w1_calc_crc8((u8 *)&rn, 7)) { + w1_attach_slave_device(dev, tmp); } atomic_dec(&dev->refcnt); -- cgit v1.2.3 From 05985715756b8667cb35a3e05e1668bb8afe3298 Mon Sep 17 00:00:00 2001 From: "johnpol@2ka.mipt.ru" Date: Mon, 18 Apr 2005 21:16:57 -0700 Subject: [PATCH] w1_smem: w1 ID is only 8 bytes long. w1 ID is only 8 bytes long. Signed-off-by: Evgeniy Polyakov Signed-off-by: Greg Kroah-Hartman --- drivers/w1/w1_smem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/w1/w1_smem.c b/drivers/w1/w1_smem.c index ab82eb7ed74..a54e425217a 100644 --- a/drivers/w1/w1_smem.c +++ b/drivers/w1/w1_smem.c @@ -60,7 +60,7 @@ static ssize_t w1_smem_read_val(struct device *dev, char *buf) int i; ssize_t count = 0; - for (i = 0; i < 9; ++i) + for (i = 0; i < 8; ++i) count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); count += sprintf(buf + count, "\n"); @@ -87,7 +87,7 @@ static ssize_t w1_smem_read_bin(struct kobject *kobj, char *buf, loff_t off, siz count = 0; goto out; } - for (i = 0; i < 9; ++i) + for (i = 0; i < 8; ++i) count += sprintf(buf + count, "%02x ", ((u8 *)&sl->reg_num)[i]); count += sprintf(buf + count, "\n"); -- cgit v1.2.3 From 86b5ac878d4a63c772d03c5017b72cc799a8f2f2 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 18 Apr 2005 21:16:58 -0700 Subject: [PATCH] I2C: via686a cleanups Here comes a small cleanup patch for the via686a driver. I noticed the following two non-fatal problems: 1* The device parent is explicitely set, but it's not needed because the i2c core will do as the client is registered. 2* snprintf is used where strlcpy would suffice. Fixing them brings the via686a driver in line with what other similar drivers do. Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/via686a.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index 9b948f4531f..ecd1e1de3f0 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c @@ -651,10 +651,9 @@ static int via686a_detect(struct i2c_adapter *adapter, int address, int kind) new_client->adapter = adapter; new_client->driver = &via686a_driver; new_client->flags = 0; - new_client->dev.parent = &adapter->dev; /* Fill in the remaining client fields and put into the global list */ - snprintf(new_client->name, I2C_NAME_SIZE, client_name); + strlcpy(new_client->name, client_name, I2C_NAME_SIZE); data->valid = 0; init_MUTEX(&data->update_lock); -- cgit v1.2.3 From 1d66c64c3cee10a465cd3f8bd9191bbeb718f650 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 18 Apr 2005 21:16:59 -0700 Subject: [PATCH] I2C: Fix incorrect sysfs file permissions in it87 and via686a drivers The it87 and via686a hardware monitoring drivers each create a sysfs file named "alarms" in R/W mode, while they should really create it in read-only mode. Since we don't provide a store function for these files, write attempts to these files will do something undefined (I guess) and bad (I am sure). My own try resulted in a locked terminal (where I attempted the write) and a 100% CPU load until next reboot. As a side note, wouldn't it make sense to check, when creating sysfs files, that readable files have a non-NULL show method, and writable files have a non-NULL store method? I know drivers are not supposed to do stupid things, but there is already a BUG_ON for several conditions in sysfs_create_file, so maybe we could add two more? Signed-off-by: Jean Delvare Signed-off-by: Greg Kroah-Hartman --- drivers/i2c/chips/it87.c | 2 +- drivers/i2c/chips/via686a.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c index 3d484a7aff1..cf7e6898754 100644 --- a/drivers/i2c/chips/it87.c +++ b/drivers/i2c/chips/it87.c @@ -668,7 +668,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) struct it87_data *data = it87_update_device(dev); return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); } -static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL); +static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); static ssize_t show_vrm_reg(struct device *dev, char *buf) diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c index ecd1e1de3f0..6614a59cecd 100644 --- a/drivers/i2c/chips/via686a.c +++ b/drivers/i2c/chips/via686a.c @@ -574,7 +574,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) { struct via686a_data *data = via686a_update_device(dev); return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms)); } -static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL); +static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); /* The driver. I choose to use type i2c_driver, as at is identical to both smbus_driver and isa_driver, and clients could be of either kind */ -- cgit v1.2.3