Lines Matching refs:counter
31 struct counter_device counter; member
42 struct counter_device *const counter = in counter_device_release() local
45 counter_chrdev_remove(counter); in counter_device_release()
48 kfree(container_of(counter, struct counter_device_allochelper, counter)); in counter_device_release()
69 void *counter_priv(const struct counter_device *const counter) in counter_priv() argument
72 container_of(counter, struct counter_device_allochelper, counter); in counter_priv()
90 struct counter_device *counter; in counter_alloc() local
98 counter = &ch->counter; in counter_alloc()
99 dev = &counter->dev; in counter_alloc()
107 mutex_init(&counter->ops_exist_lock); in counter_alloc()
112 err = counter_chrdev_add(counter); in counter_alloc()
122 return counter; in counter_alloc()
126 counter_chrdev_remove(counter); in counter_alloc()
138 void counter_put(struct counter_device *counter) in counter_put() argument
140 put_device(&counter->dev); in counter_put()
152 int counter_add(struct counter_device *counter) in counter_add() argument
155 struct device *dev = &counter->dev; in counter_add()
157 if (counter->parent) { in counter_add()
158 dev->parent = counter->parent; in counter_add()
159 dev->of_node = counter->parent->of_node; in counter_add()
162 err = counter_sysfs_add(counter); in counter_add()
167 return cdev_device_add(&counter->chrdev, dev); in counter_add()
177 void counter_unregister(struct counter_device *const counter) in counter_unregister() argument
179 if (!counter) in counter_unregister()
182 cdev_device_del(&counter->chrdev, &counter->dev); in counter_unregister()
184 mutex_lock(&counter->ops_exist_lock); in counter_unregister()
186 counter->ops = NULL; in counter_unregister()
187 wake_up(&counter->events_wait); in counter_unregister()
189 mutex_unlock(&counter->ops_exist_lock); in counter_unregister()
193 static void devm_counter_release(void *counter) in devm_counter_release() argument
195 counter_unregister(counter); in devm_counter_release()
198 static void devm_counter_put(void *counter) in devm_counter_put() argument
200 counter_put(counter); in devm_counter_put()
213 struct counter_device *counter; in devm_counter_alloc() local
216 counter = counter_alloc(sizeof_priv); in devm_counter_alloc()
217 if (!counter) in devm_counter_alloc()
220 err = devm_add_action_or_reset(dev, devm_counter_put, counter); in devm_counter_alloc()
224 return counter; in devm_counter_alloc()
237 struct counter_device *const counter) in devm_counter_add() argument
241 err = counter_add(counter); in devm_counter_add()
245 return devm_add_action_or_reset(dev, devm_counter_release, counter); in devm_counter_add()