.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * LP5562 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 modify |
---|
9 | | - * it under the terms of the GNU General Public License version 2 as |
---|
10 | | - * published by the Free Software Foundation. |
---|
11 | 8 | */ |
---|
12 | 9 | |
---|
13 | 10 | #include <linux/delay.h> |
---|
.. | .. |
---|
521 | 518 | struct lp55xx_chip *chip; |
---|
522 | 519 | struct lp55xx_led *led; |
---|
523 | 520 | 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; |
---|
525 | 528 | |
---|
526 | 529 | if (!pdata) { |
---|
527 | 530 | if (np) { |
---|
528 | | - pdata = lp55xx_of_populate_pdata(&client->dev, np); |
---|
| 531 | + pdata = lp55xx_of_populate_pdata(&client->dev, np, |
---|
| 532 | + chip); |
---|
529 | 533 | if (IS_ERR(pdata)) |
---|
530 | 534 | return PTR_ERR(pdata); |
---|
531 | 535 | } else { |
---|
.. | .. |
---|
534 | 538 | } |
---|
535 | 539 | } |
---|
536 | 540 | |
---|
537 | | - chip = devm_kzalloc(&client->dev, sizeof(*chip), GFP_KERNEL); |
---|
538 | | - if (!chip) |
---|
539 | | - return -ENOMEM; |
---|
540 | 541 | |
---|
541 | 542 | led = devm_kcalloc(&client->dev, |
---|
542 | 543 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
---|
.. | .. |
---|
545 | 546 | |
---|
546 | 547 | chip->cl = client; |
---|
547 | 548 | chip->pdata = pdata; |
---|
548 | | - chip->cfg = &lp5562_cfg; |
---|
549 | 549 | |
---|
550 | 550 | mutex_init(&chip->lock); |
---|
551 | 551 | |
---|
.. | .. |
---|
557 | 557 | |
---|
558 | 558 | ret = lp55xx_register_leds(led, chip); |
---|
559 | 559 | if (ret) |
---|
560 | | - goto err_register_leds; |
---|
| 560 | + goto err_out; |
---|
561 | 561 | |
---|
562 | 562 | ret = lp55xx_register_sysfs(chip); |
---|
563 | 563 | if (ret) { |
---|
564 | 564 | dev_err(&client->dev, "registering sysfs failed\n"); |
---|
565 | | - goto err_register_sysfs; |
---|
| 565 | + goto err_out; |
---|
566 | 566 | } |
---|
567 | 567 | |
---|
568 | 568 | return 0; |
---|
569 | 569 | |
---|
570 | | -err_register_sysfs: |
---|
571 | | - lp55xx_unregister_leds(led, chip); |
---|
572 | | -err_register_leds: |
---|
| 570 | +err_out: |
---|
573 | 571 | lp55xx_deinit_device(chip); |
---|
574 | 572 | err_init: |
---|
575 | 573 | return ret; |
---|
.. | .. |
---|
583 | 581 | lp5562_stop_engine(chip); |
---|
584 | 582 | |
---|
585 | 583 | lp55xx_unregister_sysfs(chip); |
---|
586 | | - lp55xx_unregister_leds(led, chip); |
---|
587 | 584 | lp55xx_deinit_device(chip); |
---|
588 | 585 | |
---|
589 | 586 | return 0; |
---|