hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/devfreq/devfreq-event.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * devfreq-event: a framework to provide raw data and events of devfreq devices
34 *
45 * Copyright (C) 2015 Samsung Electronics
56 * 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.
107 *
118 * This driver is based on drivers/devfreq/devfreq.c.
129 */
....@@ -216,20 +213,21 @@
216213 * devfreq_event_get_edev_by_phandle() - Get the devfreq-event dev from
217214 * devicetree.
218215 * @dev : the pointer to the given device
216
+ * @phandle_name: name of property holding a phandle value
219217 * @index : the index into list of devfreq-event device
220218 *
221219 * Note that this function return the pointer of devfreq-event device.
222220 */
223221 struct devfreq_event_dev *devfreq_event_get_edev_by_phandle(struct device *dev,
224
- int index)
222
+ const char *phandle_name, int index)
225223 {
226224 struct device_node *node;
227225 struct devfreq_event_dev *edev;
228226
229
- if (!dev->of_node)
227
+ if (!dev->of_node || !phandle_name)
230228 return ERR_PTR(-EINVAL);
231229
232
- node = of_parse_phandle(dev->of_node, "devfreq-events", index);
230
+ node = of_parse_phandle(dev->of_node, phandle_name, index);
233231 if (!node)
234232 return ERR_PTR(-ENODEV);
235233
....@@ -240,7 +238,7 @@
240238 }
241239
242240 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))
244242 goto out;
245243 }
246244 edev = NULL;
....@@ -261,19 +259,20 @@
261259 /**
262260 * devfreq_event_get_edev_count() - Get the count of devfreq-event dev
263261 * @dev : the pointer to the given device
262
+ * @phandle_name: name of property holding a phandle value
264263 *
265264 * Note that this function return the count of devfreq-event devices.
266265 */
267
-int devfreq_event_get_edev_count(struct device *dev)
266
+int devfreq_event_get_edev_count(struct device *dev, const char *phandle_name)
268267 {
269268 int count;
270269
271
- if (!dev->of_node) {
270
+ if (!dev->of_node || !phandle_name) {
272271 dev_err(dev, "device does not have a device node entry\n");
273272 return -EINVAL;
274273 }
275274
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,
277276 sizeof(u32));
278277 if (count < 0) {
279278 dev_err(dev,
....@@ -296,7 +295,7 @@
296295 /**
297296 * devfreq_event_add_edev() - Add new devfreq-event device.
298297 * @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
300299 * data for devfreq-event device.
301300 *
302301 * Note that this function add new devfreq-event device to devfreq-event class
....@@ -349,9 +348,9 @@
349348
350349 /**
351350 * devfreq_event_remove_edev() - Remove the devfreq-event device registered.
352
- * @dev : the devfreq-event device
351
+ * @edev : the devfreq-event device
353352 *
354
- * Note that this function remove the registered devfreq-event device.
353
+ * Note that this function removes the registered devfreq-event device.
355354 */
356355 int devfreq_event_remove_edev(struct devfreq_event_dev *edev)
357356 {
....@@ -388,7 +387,7 @@
388387 /**
389388 * devm_devfreq_event_add_edev() - Resource-managed devfreq_event_add_edev()
390389 * @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
392391 * data for devfreq-event device.
393392 *
394393 * Note that this function manages automatically the memory of devfreq-event