hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/leds/leds-mt6323.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * LED driver for Mediatek MT6323 PMIC
34 *
45 * Copyright (C) 2017 Sean Wang <sean.wang@mediatek.com>
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License as
8
- * published by the Free Software Foundation; either version 2 of
9
- * the License, or (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
156 */
167 #include <linux/kernel.h>
178 #include <linux/leds.h>
....@@ -258,15 +249,6 @@
258249 int ret;
259250
260251 /*
261
- * Units are in ms, if over the hardware able
262
- * to support, fallback into software blink
263
- */
264
- period = *delay_on + *delay_off;
265
-
266
- if (period > MT6323_MAX_PERIOD)
267
- return -EINVAL;
268
-
269
- /*
270252 * LED subsystem requires a default user
271253 * friendly blink pattern for the LED so using
272254 * 1Hz duty cycle 50% here if without specific
....@@ -276,6 +258,15 @@
276258 *delay_on = 500;
277259 *delay_off = 500;
278260 }
261
+
262
+ /*
263
+ * Units are in ms, if over the hardware able
264
+ * to support, fallback into software blink
265
+ */
266
+ period = *delay_on + *delay_off;
267
+
268
+ if (period > MT6323_MAX_PERIOD)
269
+ return -EINVAL;
279270
280271 /*
281272 * Calculate duty_hw based on the percentage of period during
....@@ -351,11 +342,6 @@
351342 const char *state;
352343 int ret = 0;
353344
354
- led->cdev.name = of_get_property(np, "label", NULL) ? : np->name;
355
- led->cdev.default_trigger = of_get_property(np,
356
- "linux,default-trigger",
357
- NULL);
358
-
359345 state = of_get_property(np, "default-state", NULL);
360346 if (state) {
361347 if (!strcmp(state, "keep")) {
....@@ -378,9 +364,9 @@
378364 static int mt6323_led_probe(struct platform_device *pdev)
379365 {
380366 struct device *dev = &pdev->dev;
381
- struct device_node *np = pdev->dev.of_node;
367
+ struct device_node *np = dev_of_node(dev);
382368 struct device_node *child;
383
- struct mt6397_chip *hw = dev_get_drvdata(pdev->dev.parent);
369
+ struct mt6397_chip *hw = dev_get_drvdata(dev->parent);
384370 struct mt6323_leds *leds;
385371 struct mt6323_led *led;
386372 int ret;
....@@ -411,6 +397,8 @@
411397 }
412398
413399 for_each_available_child_of_node(np, child) {
400
+ struct led_init_data init_data = {};
401
+
414402 ret = of_property_read_u32(child, "reg", &reg);
415403 if (ret) {
416404 dev_err(dev, "Failed to read led 'reg' property\n");
....@@ -446,13 +434,14 @@
446434 goto put_child_node;
447435 }
448436
449
- ret = devm_led_classdev_register(dev, &leds->led[reg]->cdev);
437
+ init_data.fwnode = of_fwnode_handle(child);
438
+
439
+ ret = devm_led_classdev_register_ext(dev, &leds->led[reg]->cdev,
440
+ &init_data);
450441 if (ret) {
451
- dev_err(&pdev->dev, "Failed to register LED: %d\n",
452
- ret);
442
+ dev_err(dev, "Failed to register LED: %d\n", ret);
453443 goto put_child_node;
454444 }
455
- leds->led[reg]->cdev.dev->of_node = child;
456445 }
457446
458447 return 0;