hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/leds/leds-lp5562.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * LP5562 LED driver
34 *
45 * Copyright (C) 2013 Texas Instruments
56 *
67 * Author: Milo(Woogyom) Kim <milo.kim@ti.com>
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129
1310 #include <linux/delay.h>
....@@ -521,11 +518,18 @@
521518 struct lp55xx_chip *chip;
522519 struct lp55xx_led *led;
523520 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
524
- struct device_node *np = client->dev.of_node;
521
+ struct device_node *np = dev_of_node(&client->dev);
522
+
523
+ chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
524
+ if (!chip)
525
+ return -ENOMEM;
526
+
527
+ chip->cfg = &lp5562_cfg;
525528
526529 if (!pdata) {
527530 if (np) {
528
- pdata = lp55xx_of_populate_pdata(&client->dev, np);
531
+ pdata = lp55xx_of_populate_pdata(&client->dev, np,
532
+ chip);
529533 if (IS_ERR(pdata))
530534 return PTR_ERR(pdata);
531535 } else {
....@@ -534,9 +538,6 @@
534538 }
535539 }
536540
537
- chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
538
- if (!chip)
539
- return -ENOMEM;
540541
541542 led = devm_kcalloc(&client->dev,
542543 pdata->num_channels, sizeof(*led), GFP_KERNEL);
....@@ -545,7 +546,6 @@
545546
546547 chip->cl = client;
547548 chip->pdata = pdata;
548
- chip->cfg = &lp5562_cfg;
549549
550550 mutex_init(&chip->lock);
551551
....@@ -557,19 +557,17 @@
557557
558558 ret = lp55xx_register_leds(led, chip);
559559 if (ret)
560
- goto err_register_leds;
560
+ goto err_out;
561561
562562 ret = lp55xx_register_sysfs(chip);
563563 if (ret) {
564564 dev_err(&client->dev, "registering sysfs failed\n");
565
- goto err_register_sysfs;
565
+ goto err_out;
566566 }
567567
568568 return 0;
569569
570
-err_register_sysfs:
571
- lp55xx_unregister_leds(led, chip);
572
-err_register_leds:
570
+err_out:
573571 lp55xx_deinit_device(chip);
574572 err_init:
575573 return ret;
....@@ -583,7 +581,6 @@
583581 lp5562_stop_engine(chip);
584582
585583 lp55xx_unregister_sysfs(chip);
586
- lp55xx_unregister_leds(led, chip);
587584 lp55xx_deinit_device(chip);
588585
589586 return 0;