Lines Matching refs:edev
37 int devfreq_event_enable_edev(struct devfreq_event_dev *edev) in devfreq_event_enable_edev() argument
41 if (!edev || !edev->desc) in devfreq_event_enable_edev()
44 mutex_lock(&edev->lock); in devfreq_event_enable_edev()
45 if (edev->desc->ops && edev->desc->ops->enable in devfreq_event_enable_edev()
46 && edev->enable_count == 0) { in devfreq_event_enable_edev()
47 ret = edev->desc->ops->enable(edev); in devfreq_event_enable_edev()
51 edev->enable_count++; in devfreq_event_enable_edev()
53 mutex_unlock(&edev->lock); in devfreq_event_enable_edev()
69 int devfreq_event_disable_edev(struct devfreq_event_dev *edev) in devfreq_event_disable_edev() argument
73 if (!edev || !edev->desc) in devfreq_event_disable_edev()
76 mutex_lock(&edev->lock); in devfreq_event_disable_edev()
77 if (edev->enable_count <= 0) { in devfreq_event_disable_edev()
78 dev_warn(&edev->dev, "unbalanced enable_count\n"); in devfreq_event_disable_edev()
83 if (edev->desc->ops && edev->desc->ops->disable in devfreq_event_disable_edev()
84 && edev->enable_count == 1) { in devfreq_event_disable_edev()
85 ret = edev->desc->ops->disable(edev); in devfreq_event_disable_edev()
89 edev->enable_count--; in devfreq_event_disable_edev()
91 mutex_unlock(&edev->lock); in devfreq_event_disable_edev()
106 bool devfreq_event_is_enabled(struct devfreq_event_dev *edev) in devfreq_event_is_enabled() argument
110 if (!edev || !edev->desc) in devfreq_event_is_enabled()
113 mutex_lock(&edev->lock); in devfreq_event_is_enabled()
115 if (edev->enable_count > 0) in devfreq_event_is_enabled()
118 mutex_unlock(&edev->lock); in devfreq_event_is_enabled()
131 int devfreq_event_set_event(struct devfreq_event_dev *edev) in devfreq_event_set_event() argument
135 if (!edev || !edev->desc) in devfreq_event_set_event()
138 if (!edev->desc->ops || !edev->desc->ops->set_event) in devfreq_event_set_event()
141 if (!devfreq_event_is_enabled(edev)) in devfreq_event_set_event()
144 mutex_lock(&edev->lock); in devfreq_event_set_event()
145 ret = edev->desc->ops->set_event(edev); in devfreq_event_set_event()
146 mutex_unlock(&edev->lock); in devfreq_event_set_event()
160 int devfreq_event_get_event(struct devfreq_event_dev *edev, in devfreq_event_get_event() argument
165 if (!edev || !edev->desc) in devfreq_event_get_event()
168 if (!edev->desc->ops || !edev->desc->ops->get_event) in devfreq_event_get_event()
171 if (!devfreq_event_is_enabled(edev)) in devfreq_event_get_event()
176 mutex_lock(&edev->lock); in devfreq_event_get_event()
177 ret = edev->desc->ops->get_event(edev, edata); in devfreq_event_get_event()
180 mutex_unlock(&edev->lock); in devfreq_event_get_event()
193 int devfreq_event_reset_event(struct devfreq_event_dev *edev) in devfreq_event_reset_event() argument
197 if (!edev || !edev->desc) in devfreq_event_reset_event()
200 if (!devfreq_event_is_enabled(edev)) in devfreq_event_reset_event()
203 mutex_lock(&edev->lock); in devfreq_event_reset_event()
204 if (edev->desc->ops && edev->desc->ops->reset) in devfreq_event_reset_event()
205 ret = edev->desc->ops->reset(edev); in devfreq_event_reset_event()
206 mutex_unlock(&edev->lock); in devfreq_event_reset_event()
225 struct devfreq_event_dev *edev; in devfreq_event_get_edev_by_phandle() local
235 list_for_each_entry(edev, &devfreq_event_list, node) { in devfreq_event_get_edev_by_phandle()
236 if (edev->dev.parent && device_match_of_node(edev->dev.parent, node)) in devfreq_event_get_edev_by_phandle()
240 list_for_each_entry(edev, &devfreq_event_list, node) { in devfreq_event_get_edev_by_phandle()
241 if (of_node_name_eq(node, edev->desc->name)) in devfreq_event_get_edev_by_phandle()
244 edev = NULL; in devfreq_event_get_edev_by_phandle()
248 if (!edev) { in devfreq_event_get_edev_by_phandle()
255 return edev; in devfreq_event_get_edev_by_phandle()
290 struct devfreq_event_dev *edev = to_devfreq_event(dev); in devfreq_event_release_edev() local
292 kfree(edev); in devfreq_event_release_edev()
307 struct devfreq_event_dev *edev; in devfreq_event_add_edev() local
320 edev = kzalloc(sizeof(struct devfreq_event_dev), GFP_KERNEL); in devfreq_event_add_edev()
321 if (!edev) in devfreq_event_add_edev()
324 mutex_init(&edev->lock); in devfreq_event_add_edev()
325 edev->desc = desc; in devfreq_event_add_edev()
326 edev->enable_count = 0; in devfreq_event_add_edev()
327 edev->dev.parent = dev; in devfreq_event_add_edev()
328 edev->dev.class = devfreq_event_class; in devfreq_event_add_edev()
329 edev->dev.release = devfreq_event_release_edev; in devfreq_event_add_edev()
331 dev_set_name(&edev->dev, "event%d", atomic_inc_return(&event_no)); in devfreq_event_add_edev()
332 ret = device_register(&edev->dev); in devfreq_event_add_edev()
334 put_device(&edev->dev); in devfreq_event_add_edev()
337 dev_set_drvdata(&edev->dev, edev); in devfreq_event_add_edev()
339 INIT_LIST_HEAD(&edev->node); in devfreq_event_add_edev()
342 list_add(&edev->node, &devfreq_event_list); in devfreq_event_add_edev()
345 return edev; in devfreq_event_add_edev()
355 int devfreq_event_remove_edev(struct devfreq_event_dev *edev) in devfreq_event_remove_edev() argument
357 if (!edev) in devfreq_event_remove_edev()
360 WARN_ON(edev->enable_count); in devfreq_event_remove_edev()
363 list_del(&edev->node); in devfreq_event_remove_edev()
366 device_unregister(&edev->dev); in devfreq_event_remove_edev()
400 struct devfreq_event_dev **ptr, *edev; in devm_devfreq_event_add_edev() local
407 edev = devfreq_event_add_edev(dev, desc); in devm_devfreq_event_add_edev()
408 if (IS_ERR(edev)) { in devm_devfreq_event_add_edev()
413 *ptr = edev; in devm_devfreq_event_add_edev()
416 return edev; in devm_devfreq_event_add_edev()
429 struct devfreq_event_dev *edev) in devm_devfreq_event_remove_edev() argument
432 devm_devfreq_event_match, edev)); in devm_devfreq_event_remove_edev()
442 struct devfreq_event_dev *edev = to_devfreq_event(dev); in name_show() local
444 if (!edev || !edev->desc) in name_show()
447 return sprintf(buf, "%s\n", edev->desc->name); in name_show()
454 struct devfreq_event_dev *edev = to_devfreq_event(dev); in enable_count_show() local
456 if (!edev || !edev->desc) in enable_count_show()
459 return sprintf(buf, "%d\n", edev->enable_count); in enable_count_show()