/* * Rockchip machine ASoC driver for boards using a RT5645/RT5650 CODEC. * * Copyright (c) 2015, ROCKCHIP CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, * version 2, as published by the Free Software Foundation. * * This program is distributed in the hope it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include #include #include #include #include #include #include #include #include #include #include #include "rockchip_i2s.h" #define DRV_NAME "rockchip-snd-rt5645" static struct snd_soc_jack headset_jack; /* Jack detect via rt5645 driver. */ extern int rt5645_set_jack_detect(struct snd_soc_codec *codec, struct snd_soc_jack *hp_jack, struct snd_soc_jack *mic_jack, struct snd_soc_jack *btn_jack); static const struct snd_soc_dapm_widget rk_dapm_widgets[] = { SND_SOC_DAPM_HP("Headphones", NULL), SND_SOC_DAPM_SPK("Speakers", NULL), SND_SOC_DAPM_MIC("Headset Mic", NULL), SND_SOC_DAPM_MIC("Int Mic", NULL), }; static const struct snd_soc_dapm_route rk_audio_map[] = { /* Input Lines */ {"DMIC L2", NULL, "Int Mic"}, {"DMIC R2", NULL, "Int Mic"}, {"RECMIXL", NULL, "Headset Mic"}, {"RECMIXR", NULL, "Headset Mic"}, /* Output Lines */ {"Headphones", NULL, "HPOR"}, {"Headphones", NULL, "HPOL"}, {"Speakers", NULL, "SPOL"}, {"Speakers", NULL, "SPOR"}, }; static const struct snd_kcontrol_new rk_mc_controls[] = { SOC_DAPM_PIN_SWITCH("Headphones"), SOC_DAPM_PIN_SWITCH("Speakers"), SOC_DAPM_PIN_SWITCH("Headset Mic"), SOC_DAPM_PIN_SWITCH("Int Mic"), }; static int rk_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { int ret = 0; struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; int mclk; switch (params_rate(params)) { case 8000: case 16000: case 24000: case 32000: case 48000: case 64000: case 96000: mclk = 12288000; break; case 11025: case 22050: case 44100: case 88200: mclk = 11289600; break; default: return -EINVAL; } ret = snd_soc_dai_set_sysclk(cpu_dai, 0, mclk, SND_SOC_CLOCK_OUT); if (ret < 0) { dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); return ret; } ret = snd_soc_dai_set_sysclk(codec_dai, 0, mclk, SND_SOC_CLOCK_IN); if (ret < 0) { dev_err(codec_dai->dev, "Can't set codec clock %d\n", ret); return ret; } return ret; } static int rk_init(struct snd_soc_pcm_runtime *runtime) { struct snd_soc_card *card = runtime->card; int ret; /* Enable Headset and 4 Buttons Jack detection */ ret = snd_soc_card_jack_new(card, "Headset Jack", SND_JACK_HEADPHONE | SND_JACK_MICROPHONE | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 | SND_JACK_BTN_3, &headset_jack, NULL, 0); if (ret) { dev_err(card->dev, "New Headset Jack failed! (%d)\n", ret); return ret; } return rt5645_set_jack_detect(runtime->codec, &headset_jack, &headset_jack, &headset_jack); } static const struct snd_soc_ops rk_aif1_ops = { .hw_params = rk_aif1_hw_params, }; static struct snd_soc_dai_link rk_dailink = { .name = "rt5645", .stream_name = "rt5645 PCM", .codec_dai_name = "rt5645-aif1", .init = rk_init, .ops = &rk_aif1_ops, /* set rt5645 as slave */ .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, }; static struct snd_soc_card snd_soc_card_rk = { .name = "I2S-RT5650", .owner = THIS_MODULE, .dai_link = &rk_dailink, .num_links = 1, .dapm_widgets = rk_dapm_widgets, .num_dapm_widgets = ARRAY_SIZE(rk_dapm_widgets), .dapm_routes = rk_audio_map, .num_dapm_routes = ARRAY_SIZE(rk_audio_map), .controls = rk_mc_controls, .num_controls = ARRAY_SIZE(rk_mc_controls), }; static int snd_rk_mc_probe(struct platform_device *pdev) { int ret = 0; struct snd_soc_card *card = &snd_soc_card_rk; struct device_node *np = pdev->dev.of_node; /* register the soc card */ card->dev = &pdev->dev; rk_dailink.codec_of_node = of_parse_phandle(np, "rockchip,audio-codec", 0); if (!rk_dailink.codec_of_node) { dev_err(&pdev->dev, "Property 'rockchip,audio-codec' missing or invalid\n"); return -EINVAL; } rk_dailink.cpu_of_node = of_parse_phandle(np, "rockchip,i2s-controller", 0); if (!rk_dailink.cpu_of_node) { dev_err(&pdev->dev, "Property 'rockchip,i2s-controller' missing or invalid\n"); return -EINVAL; } rk_dailink.platform_of_node = rk_dailink.cpu_of_node; ret = snd_soc_of_parse_card_name(card, "rockchip,model"); if (ret) { dev_err(&pdev->dev, "Soc parse card name failed %d\n", ret); return ret; } ret = devm_snd_soc_register_card(&pdev->dev, card); if (ret) { dev_err(&pdev->dev, "Soc register card failed %d\n", ret); return ret; } return ret; } static const struct of_device_id rockchip_rt5645_of_match[] = { { .compatible = "rockchip,rockchip-audio-rt5645", }, {}, }; MODULE_DEVICE_TABLE(of, rockchip_rt5645_of_match); static struct platform_driver snd_rk_mc_driver = { .probe = snd_rk_mc_probe, .driver = { .name = DRV_NAME, .pm = &snd_soc_pm_ops, .of_match_table = rockchip_rt5645_of_match, }, }; module_platform_driver(snd_rk_mc_driver); MODULE_AUTHOR("Xing Zheng "); MODULE_DESCRIPTION("Rockchip rt5645 machine ASoC driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRV_NAME); e1830320d1db8215ef77ecebae0'>diff)
can: Fix kernel panic at security_sock_rcv_skb
Zhang Yanmin reported crashes [1] and provided a patch adding a synchronize_rcu() call in can_rx_unregister() The main problem seems that the sockets themselves are not RCU protected. If CAN uses RCU for delivery, then sockets should be freed only after one RCU grace period. Recent kernels could use sock_set_flag(sk, SOCK_RCU_FREE), but let's ease stable backports with the following fix instead. [1] BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff81495e25>] selinux_socket_sock_rcv_skb+0x65/0x2a0 Call Trace: <IRQ> [<ffffffff81485d8c>] security_sock_rcv_skb+0x4c/0x60 [<ffffffff81d55771>] sk_filter+0x41/0x210 [<ffffffff81d12913>] sock_queue_rcv_skb+0x53/0x3a0 [<ffffffff81f0a2b3>] raw_rcv+0x2a3/0x3c0 [<ffffffff81f06eab>] can_rcv_filter+0x12b/0x370 [<ffffffff81f07af9>] can_receive+0xd9/0x120 [<ffffffff81f07beb>] can_rcv+0xab/0x100 [<ffffffff81d362ac>] __netif_receive_skb_core+0xd8c/0x11f0 [<ffffffff81d36734>] __netif_receive_skb+0x24/0xb0 [<ffffffff81d37f67>] process_backlog+0x127/0x280 [<ffffffff81d36f7b>] net_rx_action+0x33b/0x4f0 [<ffffffff810c88d4>] __do_softirq+0x184/0x440 [<ffffffff81f9e86c>] do_softirq_own_stack+0x1c/0x30 <EOI> [<ffffffff810c76fb>] do_softirq.part.18+0x3b/0x40 [<ffffffff810c8bed>] do_softirq+0x1d/0x20 [<ffffffff81d30085>] netif_rx_ni+0xe5/0x110 [<ffffffff8199cc87>] slcan_receive_buf+0x507/0x520 [<ffffffff8167ef7c>] flush_to_ldisc+0x21c/0x230 [<ffffffff810e3baf>] process_one_work+0x24f/0x670 [<ffffffff810e44ed>] worker_thread+0x9d/0x6f0 [<ffffffff810e4450>] ? rescuer_thread+0x480/0x480 [<ffffffff810ebafc>] kthread+0x12c/0x150 [<ffffffff81f9ccef>] ret_from_fork+0x3f/0x70 Reported-by: Zhang Yanmin <yanmin.zhang@intel.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Acked-by: Oliver Hartkopp <socketcan@hartkopp.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/usb/host/ohci-tmio.c')