diff options
Diffstat (limited to 'drivers/w1/w1.c')
-rw-r--r-- | drivers/w1/w1.c | 55 |
1 files changed, 22 insertions, 33 deletions
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(); |