.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * TI LP8501 9 channel LED Driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (C) 2013 Texas Instruments |
---|
5 | 6 | * |
---|
6 | 7 | * 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 | | - * |
---|
12 | 8 | */ |
---|
13 | 9 | |
---|
14 | 10 | #include <linux/delay.h> |
---|
.. | .. |
---|
310 | 306 | struct lp55xx_chip *chip; |
---|
311 | 307 | struct lp55xx_led *led; |
---|
312 | 308 | 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; |
---|
314 | 316 | |
---|
315 | 317 | if (!pdata) { |
---|
316 | 318 | if (np) { |
---|
317 | | - pdata = lp55xx_of_populate_pdata(&client->dev, np); |
---|
| 319 | + pdata = lp55xx_of_populate_pdata(&client->dev, np, |
---|
| 320 | + chip); |
---|
318 | 321 | if (IS_ERR(pdata)) |
---|
319 | 322 | return PTR_ERR(pdata); |
---|
320 | 323 | } else { |
---|
.. | .. |
---|
323 | 326 | } |
---|
324 | 327 | } |
---|
325 | 328 | |
---|
326 | | - chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
---|
327 | | - if (!chip) |
---|
328 | | - return -ENOMEM; |
---|
329 | | - |
---|
330 | 329 | led = devm_kcalloc(&client->dev, |
---|
331 | 330 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
---|
332 | 331 | if (!led) |
---|
.. | .. |
---|
334 | 333 | |
---|
335 | 334 | chip->cl = client; |
---|
336 | 335 | chip->pdata = pdata; |
---|
337 | | - chip->cfg = &lp8501_cfg; |
---|
338 | 336 | |
---|
339 | 337 | mutex_init(&chip->lock); |
---|
340 | 338 | |
---|
.. | .. |
---|
348 | 346 | |
---|
349 | 347 | ret = lp55xx_register_leds(led, chip); |
---|
350 | 348 | if (ret) |
---|
351 | | - goto err_register_leds; |
---|
| 349 | + goto err_out; |
---|
352 | 350 | |
---|
353 | 351 | ret = lp55xx_register_sysfs(chip); |
---|
354 | 352 | if (ret) { |
---|
355 | 353 | dev_err(&client->dev, "registering sysfs failed\n"); |
---|
356 | | - goto err_register_sysfs; |
---|
| 354 | + goto err_out; |
---|
357 | 355 | } |
---|
358 | 356 | |
---|
359 | 357 | return 0; |
---|
360 | 358 | |
---|
361 | | -err_register_sysfs: |
---|
362 | | - lp55xx_unregister_leds(led, chip); |
---|
363 | | -err_register_leds: |
---|
| 359 | +err_out: |
---|
364 | 360 | lp55xx_deinit_device(chip); |
---|
365 | 361 | err_init: |
---|
366 | 362 | return ret; |
---|
.. | .. |
---|
373 | 369 | |
---|
374 | 370 | lp8501_stop_engine(chip); |
---|
375 | 371 | lp55xx_unregister_sysfs(chip); |
---|
376 | | - lp55xx_unregister_leds(led, chip); |
---|
377 | 372 | lp55xx_deinit_device(chip); |
---|
378 | 373 | |
---|
379 | 374 | return 0; |
---|