hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/leds/leds-lp8501.c
....@@ -1,14 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * TI LP8501 9 channel 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
9
- * modify it under the terms of the GNU General Public License
10
- * version 2 as published by the Free Software Foundation.
11
- *
128 */
139
1410 #include <linux/delay.h>
....@@ -310,11 +306,18 @@
310306 struct lp55xx_chip *chip;
311307 struct lp55xx_led *led;
312308 struct lp55xx_platform_data *pdata = dev_get_platdata(&client->dev);
313
- struct device_node *np = client->dev.of_node;
309
+ struct device_node *np = dev_of_node(&client->dev);
310
+
311
+ chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
312
+ if (!chip)
313
+ return -ENOMEM;
314
+
315
+ chip->cfg = &lp8501_cfg;
314316
315317 if (!pdata) {
316318 if (np) {
317
- pdata = lp55xx_of_populate_pdata(&client->dev, np);
319
+ pdata = lp55xx_of_populate_pdata(&client->dev, np,
320
+ chip);
318321 if (IS_ERR(pdata))
319322 return PTR_ERR(pdata);
320323 } else {
....@@ -323,10 +326,6 @@
323326 }
324327 }
325328
326
- chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL);
327
- if (!chip)
328
- return -ENOMEM;
329
-
330329 led = devm_kcalloc(&client->dev,
331330 pdata->num_channels, sizeof(*led), GFP_KERNEL);
332331 if (!led)
....@@ -334,7 +333,6 @@
334333
335334 chip->cl = client;
336335 chip->pdata = pdata;
337
- chip->cfg = &lp8501_cfg;
338336
339337 mutex_init(&chip->lock);
340338
....@@ -348,19 +346,17 @@
348346
349347 ret = lp55xx_register_leds(led, chip);
350348 if (ret)
351
- goto err_register_leds;
349
+ goto err_out;
352350
353351 ret = lp55xx_register_sysfs(chip);
354352 if (ret) {
355353 dev_err(&client->dev, "registering sysfs failed\n");
356
- goto err_register_sysfs;
354
+ goto err_out;
357355 }
358356
359357 return 0;
360358
361
-err_register_sysfs:
362
- lp55xx_unregister_leds(led, chip);
363
-err_register_leds:
359
+err_out:
364360 lp55xx_deinit_device(chip);
365361 err_init:
366362 return ret;
....@@ -373,7 +369,6 @@
373369
374370 lp8501_stop_engine(chip);
375371 lp55xx_unregister_sysfs(chip);
376
- lp55xx_unregister_leds(led, chip);
377372 lp55xx_deinit_device(chip);
378373
379374 return 0;