diff options
Diffstat (limited to 'drivers/w1/w1_int.c')
-rw-r--r-- | drivers/w1/w1_int.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/w1/w1_int.c b/drivers/w1/w1_int.c index ed3228017dad..36ff40250b61 100644 --- a/drivers/w1/w1_int.c +++ b/drivers/w1/w1_int.c | |||
@@ -61,6 +61,9 @@ static struct w1_master * w1_alloc_dev(u32 id, int slave_count, int slave_ttl, | |||
61 | dev->slave_ttl = slave_ttl; | 61 | dev->slave_ttl = slave_ttl; |
62 | dev->search_count = -1; /* continual scan */ | 62 | dev->search_count = -1; /* continual scan */ |
63 | 63 | ||
64 | /* 1 for w1_process to decrement | ||
65 | * 1 for __w1_remove_master_device to decrement | ||
66 | */ | ||
64 | atomic_set(&dev->refcnt, 2); | 67 | atomic_set(&dev->refcnt, 2); |
65 | 68 | ||
66 | INIT_LIST_HEAD(&dev->slist); | 69 | INIT_LIST_HEAD(&dev->slist); |
@@ -109,23 +112,23 @@ int w1_add_master_device(struct w1_bus_master *master) | |||
109 | if (!dev) | 112 | if (!dev) |
110 | return -ENOMEM; | 113 | return -ENOMEM; |
111 | 114 | ||
115 | retval = w1_create_master_attributes(dev); | ||
116 | if (retval) | ||
117 | goto err_out_free_dev; | ||
118 | |||
119 | memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); | ||
120 | |||
121 | dev->initialized = 1; | ||
122 | |||
112 | dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); | 123 | dev->thread = kthread_run(&w1_process, dev, "%s", dev->name); |
113 | if (IS_ERR(dev->thread)) { | 124 | if (IS_ERR(dev->thread)) { |
114 | retval = PTR_ERR(dev->thread); | 125 | retval = PTR_ERR(dev->thread); |
115 | dev_err(&dev->dev, | 126 | dev_err(&dev->dev, |
116 | "Failed to create new kernel thread. err=%d\n", | 127 | "Failed to create new kernel thread. err=%d\n", |
117 | retval); | 128 | retval); |
118 | goto err_out_free_dev; | 129 | goto err_out_rm_attr; |
119 | } | 130 | } |
120 | 131 | ||
121 | retval = w1_create_master_attributes(dev); | ||
122 | if (retval) | ||
123 | goto err_out_kill_thread; | ||
124 | |||
125 | memcpy(dev->bus_master, master, sizeof(struct w1_bus_master)); | ||
126 | |||
127 | dev->initialized = 1; | ||
128 | |||
129 | mutex_lock(&w1_mlock); | 132 | mutex_lock(&w1_mlock); |
130 | list_add(&dev->w1_master_entry, &w1_masters); | 133 | list_add(&dev->w1_master_entry, &w1_masters); |
131 | mutex_unlock(&w1_mlock); | 134 | mutex_unlock(&w1_mlock); |
@@ -137,8 +140,13 @@ int w1_add_master_device(struct w1_bus_master *master) | |||
137 | 140 | ||
138 | return 0; | 141 | return 0; |
139 | 142 | ||
143 | #if 0 /* Thread cleanup code, not required currently. */ | ||
140 | err_out_kill_thread: | 144 | err_out_kill_thread: |
145 | set_bit(W1_MASTER_NEED_EXIT, &dev->flags); | ||
141 | kthread_stop(dev->thread); | 146 | kthread_stop(dev->thread); |
147 | #endif | ||
148 | err_out_rm_attr: | ||
149 | w1_destroy_master_attributes(dev); | ||
142 | err_out_free_dev: | 150 | err_out_free_dev: |
143 | w1_free_dev(dev); | 151 | w1_free_dev(dev); |
144 | 152 | ||