Lines Matching refs:dev
61 static int w1_master_probe(struct device *dev) in w1_master_probe() argument
66 static void w1_master_release(struct device *dev) in w1_master_release() argument
68 struct w1_master *md = dev_to_w1_master(dev); in w1_master_release()
70 dev_dbg(dev, "%s: Releasing %s.\n", __func__, md->name); in w1_master_release()
75 static void w1_slave_release(struct device *dev) in w1_slave_release() argument
77 struct w1_slave *sl = dev_to_w1_slave(dev); in w1_slave_release()
79 dev_dbg(dev, "%s: Releasing %s [%p]\n", __func__, sl->name, sl); in w1_slave_release()
85 static ssize_t name_show(struct device *dev, struct device_attribute *attr, char *buf) in name_show() argument
87 struct w1_slave *sl = dev_to_w1_slave(dev); in name_show()
93 static ssize_t id_show(struct device *dev, in id_show() argument
96 struct w1_slave *sl = dev_to_w1_slave(dev); in id_show()
168 static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env);
204 static ssize_t w1_master_attribute_show_name(struct device *dev, struct device_attribute *attr, cha… in w1_master_attribute_show_name() argument
206 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_name()
216 static ssize_t w1_master_attribute_store_search(struct device * dev, in w1_master_attribute_store_search() argument
221 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_store_search()
238 static ssize_t w1_master_attribute_show_search(struct device *dev, in w1_master_attribute_show_search() argument
242 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_search()
252 static ssize_t w1_master_attribute_store_pullup(struct device *dev, in w1_master_attribute_store_pullup() argument
257 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_store_pullup()
271 static ssize_t w1_master_attribute_show_pullup(struct device *dev, in w1_master_attribute_show_pullup() argument
275 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_pullup()
285 static ssize_t w1_master_attribute_show_pointer(struct device *dev, struct device_attribute *attr, … in w1_master_attribute_show_pointer() argument
287 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_pointer()
296 static ssize_t w1_master_attribute_show_timeout(struct device *dev, struct device_attribute *attr, … in w1_master_attribute_show_timeout() argument
301 static ssize_t w1_master_attribute_show_timeout_us(struct device *dev, in w1_master_attribute_show_timeout_us() argument
307 static ssize_t w1_master_attribute_store_max_slave_count(struct device *dev, in w1_master_attribute_store_max_slave_count() argument
311 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_store_max_slave_count()
325 static ssize_t w1_master_attribute_show_max_slave_count(struct device *dev, struct device_attribute… in w1_master_attribute_show_max_slave_count() argument
327 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_max_slave_count()
336 static ssize_t w1_master_attribute_show_attempts(struct device *dev, struct device_attribute *attr,… in w1_master_attribute_show_attempts() argument
338 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_attempts()
347 static ssize_t w1_master_attribute_show_slave_count(struct device *dev, struct device_attribute *at… in w1_master_attribute_show_slave_count() argument
349 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_slave_count()
358 static ssize_t w1_master_attribute_show_slaves(struct device *dev, in w1_master_attribute_show_slaves() argument
361 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_show_slaves()
381 static ssize_t w1_master_attribute_show_add(struct device *dev, in w1_master_attribute_show_add() argument
390 static int w1_atoreg_num(struct device *dev, const char *buf, size_t count, in w1_atoreg_num() argument
407 dev_err(dev, "%s", error_msg); in w1_atoreg_num()
412 dev_err(dev, "%s", error_msg); in w1_atoreg_num()
422 dev_info(dev, "With CRC device is %02x.%012llx.%02x.\n", in w1_atoreg_num()
432 struct w1_slave *w1_slave_search_device(struct w1_master *dev, in w1_slave_search_device() argument
436 mutex_lock(&dev->list_mutex); in w1_slave_search_device()
437 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_slave_search_device()
441 mutex_unlock(&dev->list_mutex); in w1_slave_search_device()
445 mutex_unlock(&dev->list_mutex); in w1_slave_search_device()
449 static ssize_t w1_master_attribute_store_add(struct device *dev, in w1_master_attribute_store_add() argument
453 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_store_add()
458 if (w1_atoreg_num(dev, buf, count, &rn)) in w1_master_attribute_store_add()
468 dev_info(dev, "Device %s already exists\n", sl->name); in w1_master_attribute_store_add()
478 static ssize_t w1_master_attribute_show_remove(struct device *dev, in w1_master_attribute_show_remove() argument
487 static ssize_t w1_master_attribute_store_remove(struct device *dev, in w1_master_attribute_store_remove() argument
491 struct w1_master *md = dev_to_w1_master(dev); in w1_master_attribute_store_remove()
496 if (w1_atoreg_num(dev, buf, count, &rn)) in w1_master_attribute_store_remove()
507 dev_info(dev, "Device %02x-%012llx doesn't exists\n", rn.family, in w1_master_attribute_store_remove()
562 return sysfs_create_group(&master->dev.kobj, &w1_master_defattr_group); in w1_create_master_attributes()
567 sysfs_remove_group(&master->dev.kobj, &w1_master_defattr_group); in w1_destroy_master_attributes()
570 static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env) in w1_uevent() argument
577 if (dev->driver == &w1_master_driver) { in w1_uevent()
578 md = container_of(dev, struct w1_master, dev); in w1_uevent()
581 } else if (dev->driver == &w1_slave_driver) { in w1_uevent()
582 sl = container_of(dev, struct w1_slave, dev); in w1_uevent()
586 dev_dbg(dev, "Unknown event.\n"); in w1_uevent()
590 dev_dbg(dev, "Hotplug event for %s %s, bus_id=%s.\n", in w1_uevent()
591 event_owner, name, dev_name(dev)); in w1_uevent()
593 if (dev->driver != &w1_slave_driver || !sl) in w1_uevent()
622 dev_err(&sl->dev, in w1_family_notify()
629 err = sysfs_create_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
631 dev_err(&sl->dev, in w1_family_notify()
639 = hwmon_device_register_with_info(&sl->dev, in w1_family_notify()
644 dev_warn(&sl->dev, in w1_family_notify()
658 sysfs_remove_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
668 sl->dev.parent = &sl->master->dev; in __w1_attach_slave_device()
669 sl->dev.driver = &w1_slave_driver; in __w1_attach_slave_device()
670 sl->dev.bus = &w1_bus_type; in __w1_attach_slave_device()
671 sl->dev.release = &w1_slave_release; in __w1_attach_slave_device()
672 sl->dev.groups = w1_slave_groups; in __w1_attach_slave_device()
673 sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node, in __w1_attach_slave_device()
676 dev_set_name(&sl->dev, "%02x-%012llx", in __w1_attach_slave_device()
684 dev_dbg(&sl->dev, "%s: registering %s as %p.\n", __func__, in __w1_attach_slave_device()
685 dev_name(&sl->dev), sl); in __w1_attach_slave_device()
688 dev_set_uevent_suppress(&sl->dev, true); in __w1_attach_slave_device()
690 err = device_register(&sl->dev); in __w1_attach_slave_device()
692 dev_err(&sl->dev, in __w1_attach_slave_device()
694 dev_name(&sl->dev), err); in __w1_attach_slave_device()
695 of_node_put(sl->dev.of_node); in __w1_attach_slave_device()
696 put_device(&sl->dev); in __w1_attach_slave_device()
701 dev_set_uevent_suppress(&sl->dev, false); in __w1_attach_slave_device()
702 kobject_uevent(&sl->dev.kobj, KOBJ_ADD); in __w1_attach_slave_device()
711 int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) in w1_attach_slave_device() argument
720 dev_err(&dev->dev, in w1_attach_slave_device()
728 sl->master = dev; in w1_attach_slave_device()
735 dev->slave_count++; in w1_attach_slave_device()
736 dev_info(&dev->dev, "Attaching one wire slave %02x.%012llx crc %02x\n", in w1_attach_slave_device()
740 mutex_unlock(&dev->mutex); in w1_attach_slave_device()
742 mutex_lock(&dev->mutex); in w1_attach_slave_device()
748 dev_info(&dev->dev, "Family %x for %02x.%012llx.%02x is not registered.\n", in w1_attach_slave_device()
759 dev_err(&dev->dev, "%s: Attaching %s failed.\n", __func__, in w1_attach_slave_device()
761 dev->slave_count--; in w1_attach_slave_device()
768 sl->ttl = dev->slave_ttl; in w1_attach_slave_device()
772 w1_netlink_send(dev, &msg); in w1_attach_slave_device()
779 struct w1_master *dev = sl->master; in w1_unref_slave() local
781 mutex_lock(&dev->list_mutex); in w1_unref_slave()
786 dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__, in w1_unref_slave()
797 device_unregister(&sl->dev); in w1_unref_slave()
803 atomic_dec(&dev->refcnt); in w1_unref_slave()
804 mutex_unlock(&dev->list_mutex); in w1_unref_slave()
824 struct w1_master *dev = NULL, *iter; in w1_search_master_id() local
829 dev = iter; in w1_search_master_id()
836 return dev; in w1_search_master_id()
841 struct w1_master *dev; in w1_search_slave() local
845 list_for_each_entry(dev, &w1_masters, w1_master_entry) { in w1_search_slave()
846 mutex_lock(&dev->list_mutex); in w1_search_slave()
847 list_for_each_entry(iter, &dev->slist, w1_slave_entry) { in w1_search_slave()
852 atomic_inc(&dev->refcnt); in w1_search_slave()
857 mutex_unlock(&dev->list_mutex); in w1_search_slave()
870 struct w1_master *dev; in w1_reconnect_slaves() local
873 list_for_each_entry(dev, &w1_masters, w1_master_entry) { in w1_reconnect_slaves()
874 dev_dbg(&dev->dev, "Reconnecting slaves in device %s " in w1_reconnect_slaves()
875 "for family %02x.\n", dev->name, f->fid); in w1_reconnect_slaves()
876 mutex_lock(&dev->mutex); in w1_reconnect_slaves()
877 mutex_lock(&dev->list_mutex); in w1_reconnect_slaves()
878 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_reconnect_slaves()
889 mutex_unlock(&dev->list_mutex); in w1_reconnect_slaves()
895 w1_attach_slave_device(dev, &rn); in w1_reconnect_slaves()
896 mutex_lock(&dev->list_mutex); in w1_reconnect_slaves()
899 dev_dbg(&dev->dev, "Reconnecting slaves in device %s " in w1_reconnect_slaves()
900 "has been finished.\n", dev->name); in w1_reconnect_slaves()
901 mutex_unlock(&dev->list_mutex); in w1_reconnect_slaves()
902 mutex_unlock(&dev->mutex); in w1_reconnect_slaves()
907 static int w1_addr_crc_is_valid(struct w1_master *dev, u64 rn) in w1_addr_crc_is_valid() argument
929 dev_info(&dev->dev, "DS28E04 crc workaround on %02x.%012llx.%02x\n", in w1_addr_crc_is_valid()
934 dev_dbg(&dev->dev, "w1 addr crc mismatch: %02x.%012llx.%02x != 0x%02x.\n", in w1_addr_crc_is_valid()
941 void w1_slave_found(struct w1_master *dev, u64 rn) in w1_slave_found() argument
946 atomic_inc(&dev->refcnt); in w1_slave_found()
950 sl = w1_slave_search_device(dev, tmp); in w1_slave_found()
954 if (rn && w1_addr_crc_is_valid(dev, rn)) in w1_slave_found()
955 w1_attach_slave_device(dev, tmp); in w1_slave_found()
958 atomic_dec(&dev->refcnt); in w1_slave_found()
978 void w1_search(struct w1_master *dev, u8 search_type, w1_slave_found_callback cb) in w1_search() argument
987 rn = dev->search_id; in w1_search()
994 while ( !last_device && (slave_count++ < dev->max_slave_count) ) { in w1_search()
1004 mutex_lock(&dev->bus_mutex); in w1_search()
1005 if (w1_reset_bus(dev)) { in w1_search()
1006 mutex_unlock(&dev->bus_mutex); in w1_search()
1007 dev_dbg(&dev->dev, "No devices present on the wire.\n"); in w1_search()
1012 if (dev->max_slave_count == 1) { in w1_search()
1014 w1_write_8(dev, W1_READ_ROM); in w1_search()
1015 rv = w1_read_block(dev, (u8 *)&rn, 8); in w1_search()
1016 mutex_unlock(&dev->bus_mutex); in w1_search()
1019 cb(dev, rn); in w1_search()
1025 w1_write_8(dev, search_type); in w1_search()
1036 triplet_ret = w1_triplet(dev, search_bit); in w1_search()
1050 if (test_bit(W1_ABORT_SEARCH, &dev->flags)) { in w1_search()
1051 mutex_unlock(&dev->bus_mutex); in w1_search()
1052 dev_dbg(&dev->dev, "Abort w1_search\n"); in w1_search()
1056 mutex_unlock(&dev->bus_mutex); in w1_search()
1061 dev->search_id = 0; in w1_search()
1063 dev->search_id = rn; in w1_search()
1066 cb(dev, rn); in w1_search()
1069 if (!last_device && slave_count == dev->max_slave_count && in w1_search()
1070 !test_bit(W1_WARN_MAX_COUNT, &dev->flags)) { in w1_search()
1078 dev_info(&dev->dev, "%s: max_slave_count %d reached, " in w1_search()
1080 dev->max_slave_count); in w1_search()
1081 set_bit(W1_WARN_MAX_COUNT, &dev->flags); in w1_search()
1086 void w1_search_process_cb(struct w1_master *dev, u8 search_type, in w1_search_process_cb() argument
1091 mutex_lock(&dev->list_mutex); in w1_search_process_cb()
1092 list_for_each_entry(sl, &dev->slist, w1_slave_entry) in w1_search_process_cb()
1094 mutex_unlock(&dev->list_mutex); in w1_search_process_cb()
1096 w1_search_devices(dev, search_type, cb); in w1_search_process_cb()
1098 mutex_lock(&dev->list_mutex); in w1_search_process_cb()
1099 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_search_process_cb()
1101 mutex_unlock(&dev->list_mutex); in w1_search_process_cb()
1103 mutex_lock(&dev->list_mutex); in w1_search_process_cb()
1106 sl->ttl = dev->slave_ttl; in w1_search_process_cb()
1108 mutex_unlock(&dev->list_mutex); in w1_search_process_cb()
1110 if (dev->search_count > 0) in w1_search_process_cb()
1111 dev->search_count--; in w1_search_process_cb()
1114 static void w1_search_process(struct w1_master *dev, u8 search_type) in w1_search_process() argument
1116 w1_search_process_cb(dev, search_type, w1_slave_found); in w1_search_process()
1127 int w1_process_callbacks(struct w1_master *dev) in w1_process_callbacks() argument
1133 while (!list_empty(&dev->async_list)) { in w1_process_callbacks()
1134 list_for_each_entry_safe(async_cmd, async_n, &dev->async_list, in w1_process_callbacks()
1138 mutex_unlock(&dev->list_mutex); in w1_process_callbacks()
1139 async_cmd->cb(dev, async_cmd); in w1_process_callbacks()
1141 mutex_lock(&dev->list_mutex); in w1_process_callbacks()
1149 struct w1_master *dev = (struct w1_master *) data; in w1_process() local
1158 atomic_inc(&dev->refcnt); in w1_process()
1162 if (!jremain && dev->search_count) { in w1_process()
1163 mutex_lock(&dev->mutex); in w1_process()
1164 w1_search_process(dev, W1_SEARCH); in w1_process()
1165 mutex_unlock(&dev->mutex); in w1_process()
1168 mutex_lock(&dev->list_mutex); in w1_process()
1172 if (!w1_process_callbacks(dev) && jremain) { in w1_process()
1185 mutex_unlock(&dev->list_mutex); in w1_process()
1193 if (dev->search_count) { in w1_process()
1202 atomic_dec(&dev->refcnt); in w1_process()
1255 struct w1_master *dev, *n; in w1_fini() local
1258 list_for_each_entry_safe(dev, n, &w1_masters, w1_master_entry) in w1_fini()
1259 __w1_remove_master_device(dev); in w1_fini()