Lines Matching refs:sl
97 struct w1_slave *sl = dev_to_w1_slave(dev); in w1_slave_release() local
99 dev_dbg(dev, "%s: Releasing %s [%p]\n", __func__, sl->name, sl); in w1_slave_release()
101 w1_family_put(sl->family); in w1_slave_release()
102 sl->master->slave_count--; in w1_slave_release()
107 struct w1_slave *sl = dev_to_w1_slave(dev); in name_show() local
109 return sprintf(buf, "%s\n", sl->name); in name_show()
116 struct w1_slave *sl = dev_to_w1_slave(dev); in id_show() local
117 ssize_t count = sizeof(sl->reg_num); in id_show()
119 memcpy(buf, (u8 *)&sl->reg_num, count); in id_show()
137 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_write() local
139 mutex_lock(&sl->master->mutex); in rw_write()
140 if (w1_reset_select_slave(sl)) { in rw_write()
145 w1_write_block(sl->master, buf, count); in rw_write()
148 mutex_unlock(&sl->master->mutex); in rw_write()
156 struct w1_slave *sl = kobj_to_w1_slave(kobj); in rw_read() local
158 mutex_lock(&sl->master->mutex); in rw_read()
159 w1_read_block(sl->master, buf, count); in rw_read()
160 mutex_unlock(&sl->master->mutex); in rw_read()
389 struct w1_slave *sl = NULL; in w1_master_attribute_show_slaves() local
394 sl = list_entry(ent, struct w1_slave, w1_slave_entry); in w1_master_attribute_show_slaves()
396 c -= snprintf(buf + PAGE_SIZE - c, c, "%s\n", sl->name); in w1_master_attribute_show_slaves()
398 if (!sl) in w1_master_attribute_show_slaves()
460 struct w1_slave *sl; in w1_slave_search_device() local
462 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_slave_search_device()
463 if (sl->reg_num.family == rn->family && in w1_slave_search_device()
464 sl->reg_num.id == rn->id && in w1_slave_search_device()
465 sl->reg_num.crc == rn->crc) { in w1_slave_search_device()
467 return sl; in w1_slave_search_device()
480 struct w1_slave *sl; in w1_master_attribute_store_add() local
487 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_add()
492 if (sl) { in w1_master_attribute_store_add()
493 dev_info(dev, "Device %s already exists\n", sl->name); in w1_master_attribute_store_add()
518 struct w1_slave *sl; in w1_master_attribute_store_remove() local
525 sl = w1_slave_search_device(md, &rn); in w1_master_attribute_store_remove()
526 if (sl) { in w1_master_attribute_store_remove()
527 result = w1_slave_detach(sl); in w1_master_attribute_store_remove()
598 struct w1_slave *sl = NULL; in w1_uevent() local
607 sl = container_of(dev, struct w1_slave, dev); in w1_uevent()
609 name = sl->name; in w1_uevent()
618 if (dev->driver != &w1_slave_driver || !sl) in w1_uevent()
621 err = add_uevent_var(env, "W1_FID=%02X", sl->reg_num.family); in w1_uevent()
626 (unsigned long long)sl->reg_num.id); in w1_uevent()
631 static int w1_family_notify(unsigned long action, struct w1_slave *sl) in w1_family_notify() argument
636 fops = sl->family->fops; in w1_family_notify()
645 err = fops->add_slave(sl); in w1_family_notify()
647 dev_err(&sl->dev, in w1_family_notify()
654 err = sysfs_create_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
656 dev_err(&sl->dev, in w1_family_notify()
666 sl->family->fops->remove_slave(sl); in w1_family_notify()
668 sysfs_remove_groups(&sl->dev.kobj, fops->groups); in w1_family_notify()
674 static int __w1_attach_slave_device(struct w1_slave *sl) in __w1_attach_slave_device() argument
678 sl->dev.parent = &sl->master->dev; in __w1_attach_slave_device()
679 sl->dev.driver = &w1_slave_driver; in __w1_attach_slave_device()
680 sl->dev.bus = &w1_bus_type; in __w1_attach_slave_device()
681 sl->dev.release = &w1_slave_release; in __w1_attach_slave_device()
682 sl->dev.groups = w1_slave_groups; 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()
705 w1_family_notify(BUS_NOTIFY_ADD_DEVICE, sl); in __w1_attach_slave_device()
707 dev_set_uevent_suppress(&sl->dev, false); in __w1_attach_slave_device()
708 kobject_uevent(&sl->dev.kobj, KOBJ_ADD); in __w1_attach_slave_device()
710 mutex_lock(&sl->master->list_mutex); in __w1_attach_slave_device()
711 list_add_tail(&sl->w1_slave_entry, &sl->master->slist); in __w1_attach_slave_device()
712 mutex_unlock(&sl->master->list_mutex); in __w1_attach_slave_device()
719 struct w1_slave *sl; in w1_attach_slave_device() local
724 sl = kzalloc(sizeof(struct w1_slave), GFP_KERNEL); in w1_attach_slave_device()
725 if (!sl) { in w1_attach_slave_device()
733 sl->owner = THIS_MODULE; in w1_attach_slave_device()
734 sl->master = dev; in w1_attach_slave_device()
735 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_attach_slave_device()
738 memcpy(&sl->reg_num, rn, sizeof(sl->reg_num)); in w1_attach_slave_device()
739 atomic_set(&sl->refcnt, 1); in w1_attach_slave_device()
740 atomic_inc(&sl->master->refcnt); in w1_attach_slave_device()
758 sl->family = f; in w1_attach_slave_device()
761 err = __w1_attach_slave_device(sl); in w1_attach_slave_device()
764 sl->name); in w1_attach_slave_device()
765 w1_family_put(sl->family); in w1_attach_slave_device()
766 kfree(sl); in w1_attach_slave_device()
770 sl->ttl = dev->slave_ttl; in w1_attach_slave_device()
780 int w1_unref_slave(struct w1_slave *sl) in w1_unref_slave() argument
782 struct w1_master *dev = sl->master; in w1_unref_slave()
785 refcnt = atomic_sub_return(1, &sl->refcnt); in w1_unref_slave()
789 dev_dbg(&sl->dev, "%s: detaching %s [%p].\n", __func__, in w1_unref_slave()
790 sl->name, sl); in w1_unref_slave()
792 list_del(&sl->w1_slave_entry); in w1_unref_slave()
795 memcpy(msg.id.id, &sl->reg_num, sizeof(msg.id)); in w1_unref_slave()
797 w1_netlink_send(sl->master, &msg); in w1_unref_slave()
799 w1_family_notify(BUS_NOTIFY_DEL_DEVICE, sl); in w1_unref_slave()
800 device_unregister(&sl->dev); in w1_unref_slave()
802 memset(sl, 0, sizeof(*sl)); in w1_unref_slave()
804 kfree(sl); in w1_unref_slave()
811 int w1_slave_detach(struct w1_slave *sl) in w1_slave_detach() argument
815 mutex_lock(&sl->master->list_mutex); in w1_slave_detach()
816 destroy_now = !test_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
817 set_bit(W1_SLAVE_DETACH, &sl->flags); in w1_slave_detach()
818 mutex_unlock(&sl->master->list_mutex); in w1_slave_detach()
821 destroy_now = !w1_unref_slave(sl); in w1_slave_detach()
846 struct w1_slave *sl = NULL; in w1_search_slave() local
852 list_for_each_entry(sl, &dev->slist, w1_slave_entry) { in w1_search_slave()
853 if (sl->reg_num.family == id->family && in w1_search_slave()
854 sl->reg_num.id == id->id && in w1_search_slave()
855 sl->reg_num.crc == id->crc) { in w1_search_slave()
858 atomic_inc(&sl->refcnt); in w1_search_slave()
869 return (found)?sl:NULL; in w1_search_slave()
874 struct w1_slave *sl, *sln; in w1_reconnect_slaves() local
883 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_reconnect_slaves()
889 if ((attach && sl->family->fid == W1_FAMILY_DEFAULT in w1_reconnect_slaves()
890 && sl->reg_num.family == f->fid) || in w1_reconnect_slaves()
891 (!attach && sl->family->fid == f->fid)) { in w1_reconnect_slaves()
895 memcpy(&rn, &sl->reg_num, sizeof(rn)); in w1_reconnect_slaves()
899 if (!w1_slave_detach(sl)) in w1_reconnect_slaves()
914 struct w1_slave *sl; in w1_slave_found() local
922 sl = w1_slave_search_device(dev, tmp); in w1_slave_found()
923 if (sl) { in w1_slave_found()
924 set_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_slave_found()
1061 struct w1_slave *sl, *sln; in w1_search_process_cb() local
1064 list_for_each_entry(sl, &dev->slist, w1_slave_entry) in w1_search_process_cb()
1065 clear_bit(W1_SLAVE_ACTIVE, &sl->flags); in w1_search_process_cb()
1071 list_for_each_entry_safe(sl, sln, &dev->slist, w1_slave_entry) { in w1_search_process_cb()
1072 if (!test_bit(W1_SLAVE_ACTIVE, &sl->flags) && !--sl->ttl) { in w1_search_process_cb()
1074 w1_slave_detach(sl); in w1_search_process_cb()
1077 else if (test_bit(W1_SLAVE_ACTIVE, &sl->flags)) in w1_search_process_cb()
1078 sl->ttl = dev->slave_ttl; in w1_search_process_cb()