diff options
-rw-r--r-- | drivers/w1/masters/sgi_w1.c | 2 | ||||
-rw-r--r-- | drivers/w1/slaves/Kconfig | 4 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_ds2438.c | 2 | ||||
-rw-r--r-- | drivers/w1/slaves/w1_therm.c | 37 | ||||
-rw-r--r-- | drivers/w1/w1.c | 55 |
5 files changed, 42 insertions, 58 deletions
diff --git a/drivers/w1/masters/sgi_w1.c b/drivers/w1/masters/sgi_w1.c index e8c7fa68d3cc..d7fbc3c146e1 100644 --- a/drivers/w1/masters/sgi_w1.c +++ b/drivers/w1/masters/sgi_w1.c @@ -93,7 +93,7 @@ static int sgi_w1_probe(struct platform_device *pdev) pdata = dev_get_platdata(&pdev->dev); if (pdata) { - strlcpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); + strscpy(sdev->dev_id, pdata->dev_id, sizeof(sdev->dev_id)); sdev->bus_master.dev_id = sdev->dev_id; } diff --git a/drivers/w1/slaves/Kconfig b/drivers/w1/slaves/Kconfig index 687753889c34..32b8a757744e 100644 --- a/drivers/w1/slaves/Kconfig +++ b/drivers/w1/slaves/Kconfig @@ -71,8 +71,8 @@ config W1_SLAVE_DS2805 help Say Y here if you want to use a 1-wire is a 112-byte user-programmable EEPROM is - organized as 7 pages of 16 bytes each with 64bit - unique number. Requires OverDrive Speed to talk to. + organized as 7 pages of 16 bytes each with 64bit + unique number. Requires OverDrive Speed to talk to. config W1_SLAVE_DS2430 tristate "256b EEPROM family support (DS2430)" diff --git a/drivers/w1/slaves/w1_ds2438.c b/drivers/w1/slaves/w1_ds2438.c index ca64f99c8f3d..e008c27b3db9 100644 --- a/drivers/w1/slaves/w1_ds2438.c +++ b/drivers/w1/slaves/w1_ds2438.c @@ -66,8 +66,6 @@ static int w1_ds2438_get_page(struct w1_slave *sl, int pageno, u8 *buf) size_t count; while (retries--) { - crc = 0; - if (w1_reset_select_slave(sl)) continue; w1_buf[0] = W1_DS2438_RECALL_MEMORY; diff --git a/drivers/w1/slaves/w1_therm.c b/drivers/w1/slaves/w1_therm.c index 067692626cf0..c85e80c7e130 100644 --- a/drivers/w1/slaves/w1_therm.c +++ b/drivers/w1/slaves/w1_therm.c @@ -284,7 +284,7 @@ static int read_powermode(struct w1_slave *sl); * trigger_bulk_read() - function to trigger a bulk read on the bus * @dev_master: the device master of the bus * - * Send a SKIP ROM follow by a CONVERT T commmand on the bus. + * Send a SKIP ROM follow by a CONVERT T command on the bus. * It also set the status flag in each slave &struct w1_therm_family_data * to signal that a conversion is in progress. * @@ -454,7 +454,7 @@ static const struct hwmon_channel_info w1_temp = { .config = w1_temp_config, }; -static const struct hwmon_channel_info *w1_info[] = { +static const struct hwmon_channel_info * const w1_info[] = { &w1_temp, NULL }; @@ -1159,29 +1159,26 @@ static int convert_t(struct w1_slave *sl, struct therm_info *info) w1_write_8(dev_master, W1_CONVERT_TEMP); - if (strong_pullup) { /*some device need pullup */ + if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { + ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); + if (ret) { + dev_dbg(&sl->dev, "%s: Timeout\n", __func__); + goto mt_unlock; + } + mutex_unlock(&dev_master->bus_mutex); + } else if (!strong_pullup) { /*no device need pullup */ sleep_rem = msleep_interruptible(t_conv); if (sleep_rem != 0) { ret = -EINTR; goto mt_unlock; } mutex_unlock(&dev_master->bus_mutex); - } else { /*no device need pullup */ - if (SLAVE_FEATURES(sl) & W1_THERM_POLL_COMPLETION) { - ret = w1_poll_completion(dev_master, W1_POLL_CONVERT_TEMP); - if (ret) { - dev_dbg(&sl->dev, "%s: Timeout\n", __func__); - goto mt_unlock; - } - mutex_unlock(&dev_master->bus_mutex); - } else { - /* Fixed delay */ - mutex_unlock(&dev_master->bus_mutex); - sleep_rem = msleep_interruptible(t_conv); - if (sleep_rem != 0) { - ret = -EINTR; - goto dec_refcnt; - } + } else { /*some device need pullup */ + mutex_unlock(&dev_master->bus_mutex); + sleep_rem = msleep_interruptible(t_conv); + if (sleep_rem != 0) { + ret = -EINTR; + goto dec_refcnt; } } ret = read_scratchpad(sl, info); @@ -1515,7 +1512,7 @@ static int trigger_bulk_read(struct w1_master *dev_master) if (bulk_read_support(sl)) { int t_cur = conversion_time(sl); - t_conv = t_cur > t_conv ? t_cur : t_conv; + t_conv = max(t_cur, t_conv); strong_pullup = strong_pullup || (w1_strong_pullup == 2 || (!SLAVE_POWERMODE(sl) && diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index 9d199fed9628..5353cbd75126 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c @@ -32,7 +32,7 @@ static int w1_timeout = 10; module_param_named(timeout, w1_timeout, int, 0); MODULE_PARM_DESC(timeout, "time in seconds between automatic slave searches"); -static int w1_timeout_us = 0; +static int w1_timeout_us; module_param_named(timeout_us, w1_timeout_us, int, 0); MODULE_PARM_DESC(timeout_us, "time in microseconds between automatic slave searches"); @@ -58,11 +58,6 @@ MODULE_PARM_DESC(slave_ttl, DEFINE_MUTEX(w1_mlock); LIST_HEAD(w1_masters); -static int w1_master_match(struct device *dev, struct device_driver *drv) -{ - return 1; -} - static int w1_master_probe(struct device *dev) { return -ENODEV; @@ -174,7 +169,6 @@ static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env); static struct bus_type w1_bus_type = { .name = "w1", - .match = w1_master_match, .uevent = w1_uevent, }; @@ -301,17 +295,13 @@ static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct devic static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, char *buf) { - ssize_t count; - count = sprintf(buf, "%d\n", w1_timeout); - return count; + return sprintf(buf, "%d\n", w1_timeout); } static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, struct device_attribute *attr, char *buf) { - ssize_t count; - count = sprintf(buf, "%d\n", w1_timeout_us); - return count; + return sprintf(buf, "%d\n", w1_timeout_us); } static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, @@ -501,7 +491,7 @@ static ssize_t w1_master_attribute_store_remove(struct device *dev, struct w1_master *md = dev_to_w1_master(dev); struct w1_reg_num rn; struct w1_slave *sl; - ssize_t result = count; + ssize_t result; if (w1_atoreg_num(dev, buf, count, &rn)) return -EINVAL; @@ -702,6 +692,7 @@ static int __w1_attach_slave_device(struct w1_slave *sl) dev_err(&sl->dev, "Device registration [%s] failed. err=%d\n", dev_name(&sl->dev), err); + of_node_put(sl->dev.of_node); put_device(&sl->dev); return err; } @@ -830,49 +821,47 @@ int w1_slave_detach(struct w1_slave *sl) struct w1_master *w1_search_master_id(u32 id) { - struct w1_master *dev; - int found = 0; + struct w1_master *dev = NULL, *iter; mutex_lock(&w1_mlock); - list_for_each_entry(dev, &w1_masters, w1_master_entry) { - if (dev->id == id) { - found = 1; - atomic_inc(&dev->refcnt); + list_for_each_entry(iter, &w1_masters, w1_master_entry) { + if (iter->id == id) { + dev = iter; + atomic_inc(&iter->refcnt); break; } } mutex_unlock(&w1_mlock); - return (found)?dev:NULL; + return dev; } struct w1_slave *w1_search_slave(struct w1_reg_num *id) { struct w1_master *dev; - struct w1_slave *sl = NULL; - int found = 0; + struct w1_slave *sl = NULL, *iter; mutex_lock(&w1_mlock); list_for_each_entry(dev, &w1_masters, w1_master_entry) { mutex_lock(&dev->list_mutex); - list_for_each_entry(sl, &dev->slist, w1_slave_entry) { - if (sl->reg_num.family == id->family && - sl->reg_num.id == id->id && - sl->reg_num.crc == id->crc) { - found = 1; + list_for_each_entry(iter, &dev->slist, w1_slave_entry) { + if (iter->reg_num.family == id->family && + iter->reg_num.id == id->id && + iter->reg_num.crc == id->crc) { + sl = iter; atomic_inc(&dev->refcnt); - atomic_inc(&sl->refcnt); + atomic_inc(&iter->refcnt); break; } } mutex_unlock(&dev->list_mutex); - if (found) + if (sl) break; } mutex_unlock(&w1_mlock); - return (found)?sl:NULL; + return sl; } void w1_reconnect_slaves(struct w1_family *f, int attach) @@ -1263,10 +1252,10 @@ err_out_exit_init: static void __exit w1_fini(void) { - struct w1_master *dev; + struct w1_master *dev, *n; /* Set netlink removal messages and some cleanup */ - list_for_each_entry(dev, &w1_masters, w1_master_entry) + list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) __w1_remove_master_device(dev); w1_fini_netlink(); |