| .. | .. |
|---|
| 456 | 456 | dev_err(card->dev, "Failed to request headset detect irq"); |
|---|
| 457 | 457 | return ret; |
|---|
| 458 | 458 | } |
|---|
| 459 | | - |
|---|
| 460 | | - queue_delayed_work(system_power_efficient_wq, |
|---|
| 461 | | - &mc_data->handler, msecs_to_jiffies(50)); |
|---|
| 462 | 459 | } |
|---|
| 463 | 460 | } |
|---|
| 464 | 461 | |
|---|
| .. | .. |
|---|
| 590 | 587 | struct device_node *node; |
|---|
| 591 | 588 | struct input_dev *input; |
|---|
| 592 | 589 | u32 val; |
|---|
| 593 | | - int count, value; |
|---|
| 590 | + int count, value, irq; |
|---|
| 594 | 591 | int ret = 0, i = 0, idx = 0; |
|---|
| 595 | 592 | const char *prefix = "rockchip,"; |
|---|
| 596 | 593 | |
|---|
| .. | .. |
|---|
| 722 | 719 | |
|---|
| 723 | 720 | input = devm_input_allocate_device(&pdev->dev); |
|---|
| 724 | 721 | if (IS_ERR(input)) { |
|---|
| 725 | | - dev_err(&pdev->dev, "failed to allocate input device\n"); |
|---|
| 722 | + dev_err(&pdev->dev, "Failed to allocate input device\n"); |
|---|
| 726 | 723 | return PTR_ERR(input); |
|---|
| 727 | 724 | } |
|---|
| 728 | 725 | |
|---|
| .. | .. |
|---|
| 745 | 742 | mc_data->input = input; |
|---|
| 746 | 743 | ret = mc_keys_setup_polling(mc_data, mc_keys_poll); |
|---|
| 747 | 744 | if (ret) { |
|---|
| 748 | | - dev_err(&pdev->dev, "Unable to set up polling: %d\n", ret); |
|---|
| 745 | + dev_err(&pdev->dev, "Failed to set up polling: %d\n", ret); |
|---|
| 749 | 746 | return ret; |
|---|
| 750 | 747 | } |
|---|
| 751 | 748 | |
|---|
| .. | .. |
|---|
| 754 | 751 | |
|---|
| 755 | 752 | ret = input_register_device(mc_data->input); |
|---|
| 756 | 753 | if (ret) { |
|---|
| 757 | | - dev_err(&pdev->dev, "Unable to register input device: %d\n", ret); |
|---|
| 754 | + dev_err(&pdev->dev, "Failed to register input device: %d\n", ret); |
|---|
| 758 | 755 | return ret; |
|---|
| 759 | 756 | } |
|---|
| 760 | 757 | } |
|---|
| .. | .. |
|---|
| 779 | 776 | |
|---|
| 780 | 777 | mc_data->extcon = devm_extcon_dev_allocate(&pdev->dev, headset_extcon_cable); |
|---|
| 781 | 778 | if (IS_ERR(mc_data->extcon)) { |
|---|
| 782 | | - dev_err(&pdev->dev, "allocate extcon failed\n"); |
|---|
| 779 | + dev_err(&pdev->dev, "Failed to allocate extcon\n"); |
|---|
| 783 | 780 | return PTR_ERR(mc_data->extcon); |
|---|
| 784 | 781 | } |
|---|
| 785 | 782 | |
|---|
| 786 | 783 | ret = devm_extcon_dev_register(&pdev->dev, mc_data->extcon); |
|---|
| 787 | 784 | if (ret) { |
|---|
| 788 | | - dev_err(&pdev->dev, "failed to register extcon: %d\n", ret); |
|---|
| 785 | + dev_err(&pdev->dev, "Failed to register extcon: %d\n", ret); |
|---|
| 789 | 786 | return ret; |
|---|
| 790 | 787 | } |
|---|
| 791 | 788 | |
|---|
| 792 | | - ret = snd_soc_of_parse_audio_routing(card, "rockchip,audio-routing"); |
|---|
| 793 | | - if (ret < 0) |
|---|
| 794 | | - dev_warn(&pdev->dev, "Audio routing invalid/unspecified\n"); |
|---|
| 789 | + snd_soc_of_parse_audio_routing(card, "rockchip,audio-routing"); |
|---|
| 795 | 790 | |
|---|
| 796 | 791 | snd_soc_card_set_drvdata(card, mc_data); |
|---|
| 792 | + platform_set_drvdata(pdev, card); |
|---|
| 797 | 793 | |
|---|
| 798 | 794 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
|---|
| 799 | | - if (ret == -EPROBE_DEFER) |
|---|
| 800 | | - return -EPROBE_DEFER; |
|---|
| 801 | 795 | if (ret) { |
|---|
| 802 | | - dev_err(&pdev->dev, "card register failed %d\n", ret); |
|---|
| 796 | + dev_err(&pdev->dev, "Failed to register card: %d\n", ret); |
|---|
| 803 | 797 | return ret; |
|---|
| 804 | 798 | } |
|---|
| 805 | 799 | |
|---|
| 806 | | - platform_set_drvdata(pdev, card); |
|---|
| 800 | + irq = gpiod_to_irq(mc_data->hp_det_gpio); |
|---|
| 801 | + if (irq >= 0) |
|---|
| 802 | + queue_delayed_work(system_power_efficient_wq, |
|---|
| 803 | + &mc_data->handler, msecs_to_jiffies(50)); |
|---|
| 807 | 804 | |
|---|
| 808 | 805 | return ret; |
|---|
| 806 | +} |
|---|
| 807 | + |
|---|
| 808 | +static int rk_multicodec_remove(struct platform_device *pdev) |
|---|
| 809 | +{ |
|---|
| 810 | + struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 811 | + struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(card); |
|---|
| 812 | + |
|---|
| 813 | + cancel_delayed_work_sync(&mc_data->handler); |
|---|
| 814 | + |
|---|
| 815 | + return 0; |
|---|
| 816 | +} |
|---|
| 817 | + |
|---|
| 818 | +static void rk_multicodec_shutdown(struct platform_device *pdev) |
|---|
| 819 | +{ |
|---|
| 820 | + struct snd_soc_card *card = platform_get_drvdata(pdev); |
|---|
| 821 | + struct multicodecs_data *mc_data = snd_soc_card_get_drvdata(card); |
|---|
| 822 | + |
|---|
| 823 | + cancel_delayed_work_sync(&mc_data->handler); |
|---|
| 809 | 824 | } |
|---|
| 810 | 825 | |
|---|
| 811 | 826 | static const struct of_device_id rockchip_multicodecs_of_match[] = { |
|---|
| .. | .. |
|---|
| 817 | 832 | |
|---|
| 818 | 833 | static struct platform_driver rockchip_multicodecs_driver = { |
|---|
| 819 | 834 | .probe = rk_multicodecs_probe, |
|---|
| 835 | + .remove = rk_multicodec_remove, |
|---|
| 836 | + .shutdown = rk_multicodec_shutdown, |
|---|
| 820 | 837 | .driver = { |
|---|
| 821 | 838 | .name = DRV_NAME, |
|---|
| 822 | 839 | .pm = &snd_soc_pm_ops, |
|---|