• Home
  • Raw
  • Download

Lines Matching refs:sl

80 	struct w1_slave *sl = dev_to_w1_slave(dev);  in w1_slave_release()  local
82 dev_dbg(dev, "%s: Releasing %s [%p]\n", __func__, sl->name, sl); in w1_slave_release()
84 w1_family_put(sl->family); in w1_slave_release()
85 sl->master->slave_count--; in w1_slave_release()
90 struct w1_slave *sl = dev_to_w1_slave(dev); in name_show() local
92 return sprintf(buf, "%s\n", sl->name); in name_show()
99 struct w1_slave *sl = dev_to_w1_slave(dev); in id_show() local
100 ssize_t count = sizeof(sl->reg_num); in id_show()
102 memcpy(buf, (u8 *)&sl->reg_num, count); in id_show()
120 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_write() local
122 mutex_lock(&sl->master->mutex); in rw_write()
123 if (w1_reset_select_slave(sl)) { in rw_write()
128 w1_write_block(sl->master, buf, count); in rw_write()
131 mutex_unlock(&sl->master->mutex); in rw_write()
139 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_read() local
141 mutex_lock(&sl->master->mutex); in rw_read()
142 w1_read_block(sl->master, buf, count); in rw_read()
143 mutex_unlock(&sl->master->mutex); in rw_read()
372 struct w1_slave *sl = NULL; in w1_master_attribute_show_slaves() local
377 sl = list_entry(ent, struct w1_slave, w1_slave_entry); in w1_master_attribute_show_slaves()
379 c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", sl->name); in w1_master_attribute_show_slaves()
381 if (!sl) in w1_master_attribute_show_slaves()
443 struct w1_slave *sl; in w1_slave_search_device() local
445 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_slave_search_device()
446 if (sl->reg_num.family == rn->family && in w1_slave_search_device()
447 sl->reg_num.id == rn->id && in w1_slave_search_device()
448 sl->reg_num.crc == rn->crc) { in w1_slave_search_device()
450 return sl; in w1_slave_search_device()
463 struct w1_slave *sl; in w1_master_attribute_store_add() local
470 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_add()
475 if (sl) { in w1_master_attribute_store_add()
476 dev_info(dev, "Device %s already exists\n", sl->name); in w1_master_attribute_store_add()
501 struct w1_slave *sl; in w1_master_attribute_store_remove() local
508 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_remove()
509 if (sl) { in w1_master_attribute_store_remove()
510 result = w1_slave_detach(sl); in w1_master_attribute_store_remove()
581 struct w1_slave *sl = NULL; in w1_uevent() local
590 sl = container_of(dev, struct w1_slave, dev); in w1_uevent()
592 name = sl->name; in w1_uevent()
601 if (dev->driver != &w1_slave_driver || !sl) in w1_uevent()
604 err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family); in w1_uevent()
609 (unsigned long long)sl->reg_num.id); in w1_uevent()
614 static int w1_family_notify(unsigned long action, struct w1_slave *sl) in w1_family_notify() argument
619 fops = sl->family->fops; in w1_family_notify()
628 err = fops->add_slave(sl); in w1_family_notify()
630 dev_err(&sl->dev, in w1_family_notify()
637 err = sysfs_create_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
639 dev_err(&sl->dev, in w1_family_notify()
647 = hwmon_device_register_with_info(&sl->dev, in w1_family_notify()
648 "w1_slave_temp", sl, in w1_family_notify()
652 dev_warn(&sl->dev, in w1_family_notify()
655 sl->hwmon = hwmon; in w1_family_notify()
661 sl->hwmon) in w1_family_notify()
662 hwmon_device_unregister(sl->hwmon); in w1_family_notify()
664 sl->family->fops->remove_slave(sl); in w1_family_notify()
666 sysfs_remove_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
672 static int __w1_attach_slave_device(struct w1_slave *sl) in __w1_attach_slave_device() argument
676 sl->dev.parent = &sl->master->dev; in __w1_attach_slave_device()
677 sl->dev.driver = &w1_slave_driver; in __w1_attach_slave_device()
678 sl->dev.bus = &w1_bus_type; in __w1_attach_slave_device()
679 sl->dev.release = &w1_slave_release; in __w1_attach_slave_device()
680 sl->dev.groups = w1_slave_groups; in __w1_attach_slave_device()
681 sl->dev.of_node = of_find_matching_node(sl->master->dev.of_node, in __w1_attach_slave_device()
682 sl->family->of_match_table); in __w1_attach_slave_device()
684 dev_set_name(&sl->dev, "%02x-%012llx", in __w1_attach_slave_device()
685 (unsigned int) sl->reg_num.family, in __w1_attach_slave_device()
686 (unsigned long long) sl->reg_num.id); in __w1_attach_slave_device()
687 snprintf(&sl->name[0], sizeof(sl->name), in __w1_attach_slave_device()
689 (unsigned int) sl->reg_num.family, in __w1_attach_slave_device()
690 (unsigned long long) sl->reg_num.id); in __w1_attach_slave_device()
692 dev_dbg(&sl->dev, "%s: registering %s as %p.\n", __func__, in __w1_attach_slave_device()
693 dev_name(&sl->dev), sl); in __w1_attach_slave_device()
696 dev_set_uevent_suppress(&sl->dev, true); in __w1_attach_slave_device()
698 err = device_register(&sl->dev); in __w1_attach_slave_device()
700 dev_err(&sl->dev, in __w1_attach_slave_device()
702 dev_name(&sl->dev), err); in __w1_attach_slave_device()
703 put_device(&sl->dev); in __w1_attach_slave_device()
706 w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); in __w1_attach_slave_device()
708 dev_set_uevent_suppress(&sl->dev, false); in __w1_attach_slave_device()
709 kobject_uevent(&sl->dev.kobj, KOBJ_ADD); in __w1_attach_slave_device()
711 mutex_lock(&sl->master->list_mutex); in __w1_attach_slave_device()
712 list_add_tail(&sl->w1_slave_entry, &sl->master->slist); in __w1_attach_slave_device()
713 mutex_unlock(&sl->master->list_mutex); in __w1_attach_slave_device()
720 struct w1_slave *sl; in w1_attach_slave_device() local
725 sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL); in w1_attach_slave_device()
726 if (!sl) { in w1_attach_slave_device()
734 sl->owner = THIS_MODULE; in w1_attach_slave_device()
735 sl->master = dev; in w1_attach_slave_device()
736 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_attach_slave_device()
739 memcpy(&sl->reg_num, rn, sizeof(sl->reg_num)); in w1_attach_slave_device()
740 atomic_set(&sl->refcnt, 1); in w1_attach_slave_device()
741 atomic_inc(&sl->master->refcnt); in w1_attach_slave_device()
762 sl->family = f; in w1_attach_slave_device()
764 err = __w1_attach_slave_device(sl); in w1_attach_slave_device()
767 sl->name); in w1_attach_slave_device()
769 w1_family_put(sl->family); in w1_attach_slave_device()
770 atomic_dec(&sl->master->refcnt); in w1_attach_slave_device()
771 kfree(sl); in w1_attach_slave_device()
775 sl->ttl = dev->slave_ttl; in w1_attach_slave_device()
784 int w1_unref_slave(struct w1_slave *sl) in w1_unref_slave() argument
786 struct w1_master *dev = sl->master; in w1_unref_slave()
789 refcnt = atomic_sub_return(1, &sl->refcnt); in w1_unref_slave()
793 dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__, in w1_unref_slave()
794 sl->name, sl); in w1_unref_slave()
796 list_del(&sl->w1_slave_entry); in w1_unref_slave()
799 memcpy(msg.id.id, &sl->reg_num, sizeof(msg.id)); in w1_unref_slave()
801 w1_netlink_send(sl->master, &msg); in w1_unref_slave()
803 w1_family_notify(BUS_NOTIFY_DEL_DEVICE, sl); in w1_unref_slave()
804 device_unregister(&sl->dev); in w1_unref_slave()
806 memset(sl, 0, sizeof(*sl)); in w1_unref_slave()
808 kfree(sl); in w1_unref_slave()
815 int w1_slave_detach(struct w1_slave *sl) in w1_slave_detach() argument
819 mutex_lock(&sl->master->list_mutex); in w1_slave_detach()
820 destroy_now = !test_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
821 set_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
822 mutex_unlock(&sl->master->list_mutex); in w1_slave_detach()
825 destroy_now = !w1_unref_slave(sl); in w1_slave_detach()
850 struct w1_slave *sl = NULL; in w1_search_slave() local
856 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_search_slave()
857 if (sl->reg_num.family == id->family && in w1_search_slave()
858 sl->reg_num.id == id->id && in w1_search_slave()
859 sl->reg_num.crc == id->crc) { in w1_search_slave()
862 atomic_inc(&sl->refcnt); in w1_search_slave()
873 return (found)?sl:NULL; in w1_search_slave()
878 struct w1_slave *sl, *sln; in w1_reconnect_slaves() local
887 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_reconnect_slaves()
893 if ((attach && sl->family->fid == W1_FAMILY_DEFAULT in w1_reconnect_slaves()
894 && sl->reg_num.family == f->fid) || in w1_reconnect_slaves()
895 (!attach && sl->family->fid == f->fid)) { in w1_reconnect_slaves()
899 memcpy(&rn, &sl->reg_num, sizeof(rn)); in w1_reconnect_slaves()
903 if (!w1_slave_detach(sl)) in w1_reconnect_slaves()
918 struct w1_slave *sl; in w1_slave_found() local
926 sl = w1_slave_search_device(dev, tmp); in w1_slave_found()
927 if (sl) { in w1_slave_found()
928 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_slave_found()
1065 struct w1_slave *sl, *sln; in w1_search_process_cb() local
1068 list_for_each_entry(sl, &dev->slist, w1_slave_entry) in w1_search_process_cb()
1069 clear_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_search_process_cb()
1075 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_search_process_cb()
1076 if (!test_bit(W1_SLAVE_ACTIVE, &sl->flags) && !--sl->ttl) { in w1_search_process_cb()
1078 w1_slave_detach(sl); in w1_search_process_cb()
1081 else if (test_bit(W1_SLAVE_ACTIVE, &sl->flags)) in w1_search_process_cb()
1082 sl->ttl = dev->slave_ttl; in w1_search_process_cb()