.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * devfreq-event: a framework to provide raw data and events of devfreq devices |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2015 Samsung Electronics |
---|
5 | 6 | * Author: Chanwoo Choi <cw00.choi@samsung.com> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | 7 | * |
---|
11 | 8 | * This driver is based on drivers/devfreq/devfreq.c. |
---|
12 | 9 | */ |
---|
.. | .. |
---|
216 | 213 | * devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from |
---|
217 | 214 | * devicetree. |
---|
218 | 215 | * @dev : the pointer to the given device |
---|
| 216 | + * @phandle_name: name of property holding a phandle value |
---|
219 | 217 | * @index : the index into list of devfreq-event device |
---|
220 | 218 | * |
---|
221 | 219 | * Note that this function return the pointer of devfreq-event device. |
---|
222 | 220 | */ |
---|
223 | 221 | struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev, |
---|
224 | | - int index) |
---|
| 222 | + const char *phandle_name, int index) |
---|
225 | 223 | { |
---|
226 | 224 | struct device_node *node; |
---|
227 | 225 | struct devfreq_event_dev *edev; |
---|
228 | 226 | |
---|
229 | | - if (!dev->of_node) |
---|
| 227 | + if (!dev->of_node || !phandle_name) |
---|
230 | 228 | return ERR_PTR(-EINVAL); |
---|
231 | 229 | |
---|
232 | | - node = of_parse_phandle(dev->of_node, "devfreq-events", index); |
---|
| 230 | + node = of_parse_phandle(dev->of_node, phandle_name, index); |
---|
233 | 231 | if (!node) |
---|
234 | 232 | return ERR_PTR(-ENODEV); |
---|
235 | 233 | |
---|
.. | .. |
---|
240 | 238 | } |
---|
241 | 239 | |
---|
242 | 240 | list_for_each_entry(edev, &devfreq_event_list, node) { |
---|
243 | | - if (!strcmp(edev->desc->name, node->name)) |
---|
| 241 | + if (of_node_name_eq(node, edev->desc->name)) |
---|
244 | 242 | goto out; |
---|
245 | 243 | } |
---|
246 | 244 | edev = NULL; |
---|
.. | .. |
---|
261 | 259 | /** |
---|
262 | 260 | * devfreq_event_get_edev_count() - Get the count of devfreq-event dev |
---|
263 | 261 | * @dev : the pointer to the given device |
---|
| 262 | + * @phandle_name: name of property holding a phandle value |
---|
264 | 263 | * |
---|
265 | 264 | * Note that this function return the count of devfreq-event devices. |
---|
266 | 265 | */ |
---|
267 | | -int devfreq_event_get_edev_count(struct device *dev) |
---|
| 266 | +int devfreq_event_get_edev_count(struct device *dev, const char *phandle_name) |
---|
268 | 267 | { |
---|
269 | 268 | int count; |
---|
270 | 269 | |
---|
271 | | - if (!dev->of_node) { |
---|
| 270 | + if (!dev->of_node || !phandle_name) { |
---|
272 | 271 | dev_err(dev, "device does not have a device node entry\n"); |
---|
273 | 272 | return -EINVAL; |
---|
274 | 273 | } |
---|
275 | 274 | |
---|
276 | | - count = of_property_count_elems_of_size(dev->of_node, "devfreq-events", |
---|
| 275 | + count = of_property_count_elems_of_size(dev->of_node, phandle_name, |
---|
277 | 276 | sizeof(u32)); |
---|
278 | 277 | if (count < 0) { |
---|
279 | 278 | dev_err(dev, |
---|
.. | .. |
---|
296 | 295 | /** |
---|
297 | 296 | * devfreq_event_add_edev() - Add new devfreq-event device. |
---|
298 | 297 | * @dev : the device owning the devfreq-event device being created |
---|
299 | | - * @desc : the devfreq-event device's decriptor which include essential |
---|
| 298 | + * @desc : the devfreq-event device's descriptor which include essential |
---|
300 | 299 | * data for devfreq-event device. |
---|
301 | 300 | * |
---|
302 | 301 | * Note that this function add new devfreq-event device to devfreq-event class |
---|
.. | .. |
---|
349 | 348 | |
---|
350 | 349 | /** |
---|
351 | 350 | * devfreq_event_remove_edev() - Remove the devfreq-event device registered. |
---|
352 | | - * @dev : the devfreq-event device |
---|
| 351 | + * @edev : the devfreq-event device |
---|
353 | 352 | * |
---|
354 | | - * Note that this function remove the registered devfreq-event device. |
---|
| 353 | + * Note that this function removes the registered devfreq-event device. |
---|
355 | 354 | */ |
---|
356 | 355 | int devfreq_event_remove_edev(struct devfreq_event_dev *edev) |
---|
357 | 356 | { |
---|
.. | .. |
---|
388 | 387 | /** |
---|
389 | 388 | * devm_devfreq_event_add_edev() - Resource-managed devfreq_event_add_edev() |
---|
390 | 389 | * @dev : the device owning the devfreq-event device being created |
---|
391 | | - * @desc : the devfreq-event device's decriptor which include essential |
---|
| 390 | + * @desc : the devfreq-event device's descriptor which include essential |
---|
392 | 391 | * data for devfreq-event device. |
---|
393 | 392 | * |
---|
394 | 393 | * Note that this function manages automatically the memory of devfreq-event |
---|