Lines Matching refs:sl

77 	struct w1_slave *sl = dev_to_w1_slave(dev);  in w1_slave_release()  local
79 dev_dbg(dev, "%s: Releasing %s [%p]\n", __func__, sl->name, sl); in w1_slave_release()
81 w1_family_put(sl->family); in w1_slave_release()
82 sl->master->slave_count--; in w1_slave_release()
87 struct w1_slave *sl = dev_to_w1_slave(dev); in name_show() local
89 return sprintf(buf, "%s\n", sl->name); in name_show()
96 struct w1_slave *sl = dev_to_w1_slave(dev); in id_show() local
97 ssize_t count = sizeof(sl->reg_num); in id_show()
99 memcpy(buf, (u8 *)&sl->reg_num, count); in id_show()
117 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_write() local
119 mutex_lock(&sl->master->mutex); in rw_write()
120 if (w1_reset_select_slave(sl)) { in rw_write()
125 w1_write_block(sl->master, buf, count); in rw_write()
128 mutex_unlock(&sl->master->mutex); in rw_write()
136 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_read() local
138 mutex_lock(&sl->master->mutex); in rw_read()
139 w1_read_block(sl->master, buf, count); in rw_read()
140 mutex_unlock(&sl->master->mutex); in rw_read()
364 struct w1_slave *sl = NULL; in w1_master_attribute_show_slaves() local
369 sl = list_entry(ent, struct w1_slave, w1_slave_entry); in w1_master_attribute_show_slaves()
371 c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", sl->name); in w1_master_attribute_show_slaves()
373 if (!sl) in w1_master_attribute_show_slaves()
435 struct w1_slave *sl; in w1_slave_search_device() local
437 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_slave_search_device()
438 if (sl->reg_num.family == rn->family && in w1_slave_search_device()
439 sl->reg_num.id == rn->id && in w1_slave_search_device()
440 sl->reg_num.crc == rn->crc) { in w1_slave_search_device()
442 return sl; in w1_slave_search_device()
455 struct w1_slave *sl; in w1_master_attribute_store_add() local
462 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_add()
467 if (sl) { in w1_master_attribute_store_add()
468 dev_info(dev, "Device %s already exists\n", sl->name); in w1_master_attribute_store_add()
493 struct w1_slave *sl; in w1_master_attribute_store_remove() local
500 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_remove()
501 if (sl) { in w1_master_attribute_store_remove()
502 result = w1_slave_detach(sl); in w1_master_attribute_store_remove()
573 const struct w1_slave *sl = NULL; in w1_uevent() local
582 sl = container_of(dev, struct w1_slave, dev); in w1_uevent()
584 name = sl->name; in w1_uevent()
593 if (dev->driver != &w1_slave_driver || !sl) in w1_uevent()
596 err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family); in w1_uevent()
601 (unsigned long long)sl->reg_num.id); in w1_uevent()
606 static int w1_family_notify(unsigned long action, struct w1_slave *sl) in w1_family_notify() argument
611 fops = sl->family->fops; in w1_family_notify()
620 err = fops->add_slave(sl); in w1_family_notify()
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()
640 "w1_slave_temp", sl, in w1_family_notify()
644 dev_warn(&sl->dev, in w1_family_notify()
647 sl->hwmon = hwmon; in w1_family_notify()
653 sl->hwmon) in w1_family_notify()
654 hwmon_device_unregister(sl->hwmon); in w1_family_notify()
656 sl->family->fops->remove_slave(sl); in w1_family_notify()
658 sysfs_remove_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
664 static int __w1_attach_slave_device(struct w1_slave *sl) in __w1_attach_slave_device() argument
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()
674 sl->family->of_match_table); in __w1_attach_slave_device()
676 dev_set_name(&sl->dev, "%02x-%012llx", in __w1_attach_slave_device()
677 (unsigned int) sl->reg_num.family, in __w1_attach_slave_device()
678 (unsigned long long) sl->reg_num.id); in __w1_attach_slave_device()
679 snprintf(&sl->name[0], sizeof(sl->name), in __w1_attach_slave_device()
681 (unsigned int) sl->reg_num.family, in __w1_attach_slave_device()
682 (unsigned long long) sl->reg_num.id); 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()
699 w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); 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()
704 mutex_lock(&sl->master->list_mutex); in __w1_attach_slave_device()
705 list_add_tail(&sl->w1_slave_entry, &sl->master->slist); in __w1_attach_slave_device()
706 mutex_unlock(&sl->master->list_mutex); in __w1_attach_slave_device()
713 struct w1_slave *sl; in w1_attach_slave_device() local
718 sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL); in w1_attach_slave_device()
719 if (!sl) { in w1_attach_slave_device()
727 sl->owner = THIS_MODULE; in w1_attach_slave_device()
728 sl->master = dev; in w1_attach_slave_device()
729 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_attach_slave_device()
732 memcpy(&sl->reg_num, rn, sizeof(sl->reg_num)); in w1_attach_slave_device()
733 atomic_set(&sl->refcnt, 1); in w1_attach_slave_device()
734 atomic_inc(&sl->master->refcnt); in w1_attach_slave_device()
755 sl->family = f; in w1_attach_slave_device()
757 err = __w1_attach_slave_device(sl); in w1_attach_slave_device()
760 sl->name); in w1_attach_slave_device()
762 w1_family_put(sl->family); in w1_attach_slave_device()
763 atomic_dec(&sl->master->refcnt); in w1_attach_slave_device()
764 kfree(sl); in w1_attach_slave_device()
768 sl->ttl = dev->slave_ttl; in w1_attach_slave_device()
777 int w1_unref_slave(struct w1_slave *sl) in w1_unref_slave() argument
779 struct w1_master *dev = sl->master; in w1_unref_slave()
782 refcnt = atomic_sub_return(1, &sl->refcnt); in w1_unref_slave()
786 dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__, in w1_unref_slave()
787 sl->name, sl); in w1_unref_slave()
789 list_del(&sl->w1_slave_entry); in w1_unref_slave()
792 memcpy(msg.id.id, &sl->reg_num, sizeof(msg.id)); in w1_unref_slave()
794 w1_netlink_send(sl->master, &msg); in w1_unref_slave()
796 w1_family_notify(BUS_NOTIFY_DEL_DEVICE, sl); in w1_unref_slave()
797 device_unregister(&sl->dev); in w1_unref_slave()
799 memset(sl, 0, sizeof(*sl)); in w1_unref_slave()
801 kfree(sl); in w1_unref_slave()
808 int w1_slave_detach(struct w1_slave *sl) in w1_slave_detach() argument
812 mutex_lock(&sl->master->list_mutex); in w1_slave_detach()
813 destroy_now = !test_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
814 set_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
815 mutex_unlock(&sl->master->list_mutex); in w1_slave_detach()
818 destroy_now = !w1_unref_slave(sl); in w1_slave_detach()
842 struct w1_slave *sl = NULL, *iter; in w1_search_slave() local
851 sl = iter; in w1_search_slave()
859 if (sl) in w1_search_slave()
864 return sl; in w1_search_slave()
869 struct w1_slave *sl, *sln; in w1_reconnect_slaves() local
878 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_reconnect_slaves()
884 if ((attach && sl->family->fid == W1_FAMILY_DEFAULT in w1_reconnect_slaves()
885 && sl->reg_num.family == f->fid) || in w1_reconnect_slaves()
886 (!attach && sl->family->fid == f->fid)) { in w1_reconnect_slaves()
890 memcpy(&rn, &sl->reg_num, sizeof(rn)); in w1_reconnect_slaves()
894 if (!w1_slave_detach(sl)) in w1_reconnect_slaves()
943 struct w1_slave *sl; in w1_slave_found() local
950 sl = w1_slave_search_device(dev, tmp); in w1_slave_found()
951 if (sl) { in w1_slave_found()
952 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_slave_found()
1089 struct w1_slave *sl, *sln; in w1_search_process_cb() local
1092 list_for_each_entry(sl, &dev->slist, w1_slave_entry) in w1_search_process_cb()
1093 clear_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_search_process_cb()
1099 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_search_process_cb()
1100 if (!test_bit(W1_SLAVE_ACTIVE, &sl->flags) && !--sl->ttl) { in w1_search_process_cb()
1102 w1_slave_detach(sl); in w1_search_process_cb()
1105 else if (test_bit(W1_SLAVE_ACTIVE, &sl->flags)) in w1_search_process_cb()
1106 sl->ttl = dev->slave_ttl; in w1_search_process_cb()