From da212a307e7bf2e112ebc73ba95c836380056dfb Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E9=82=B1=E5=BB=BA=E6=96=8C?= Date: Wed, 4 Sep 2013 19:40:28 +0800 Subject: [PATCH] heaset driver: fixed headset driver fail handling process risks --- drivers/headset_observe/rk_headset.c | 2 +- drivers/headset_observe/rk_headset_irq_hook_adc.c | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/headset_observe/rk_headset.c b/drivers/headset_observe/rk_headset.c index 21cac4ee505a..1cf717b1c6f1 100755 --- a/drivers/headset_observe/rk_headset.c +++ b/drivers/headset_observe/rk_headset.c @@ -449,7 +449,7 @@ static int rockchip_headsetobserve_probe(struct platform_device *pdev) //------------------------------------------------------------------ if (pdata->Headset_gpio) { if(pdata->Headset_gpio == NULL){ - dev_err(&pdev->dev,"failed init hook,please full hook_io_init function in board\n"); + dev_err(&pdev->dev,"failed init headset,please full hook_io_init function in board\n"); goto failed_free_dev; } ret = pdata->headset_io_init(pdata->Headset_gpio); diff --git a/drivers/headset_observe/rk_headset_irq_hook_adc.c b/drivers/headset_observe/rk_headset_irq_hook_adc.c index 3e417b25c2f6..74ed75a063c1 100755 --- a/drivers/headset_observe/rk_headset_irq_hook_adc.c +++ b/drivers/headset_observe/rk_headset_irq_hook_adc.c @@ -506,9 +506,13 @@ static int rockchip_headsetobserve_probe(struct platform_device *pdev) input_set_capability(headset->input_dev, EV_KEY, pdata->hook_key_code); //------------------------------------------------------------------ if (pdata->Headset_gpio) { - ret = pdata->headset_io_init(pdata->Headset_gpio, pdata->headset_gpio_info.iomux_name, pdata->headset_gpio_info.iomux_mode); + if(pdata->Headset_gpio == NULL){ + dev_err(&pdev->dev,"failed init headset,please full hook_io_init function in board\n"); + goto failed_free_dev; + } + ret = pdata->headset_io_init(pdata->Headset_gpio); if (ret) - goto failed_free; + goto failed_free_dev; headset->irq[HEADSET] = gpio_to_irq(pdata->Headset_gpio); @@ -518,11 +522,11 @@ static int rockchip_headsetobserve_probe(struct platform_device *pdev) headset->irq_type[HEADSET] = IRQF_TRIGGER_LOW|IRQF_ONESHOT; ret = request_threaded_irq(headset->irq[HEADSET], NULL,headset_interrupt, headset->irq_type[HEADSET]|IRQF_NO_SUSPEND, "headset_input", NULL); if (ret) - goto failed_free; + goto failed_free_dev; enable_irq_wake(headset->irq[HEADSET]); } else - goto failed_free; + goto failed_free_dev; //------------------------------------------------------------------ if(pdata->Hook_adc_chn>=0 && 3>=pdata->Hook_adc_chn) { @@ -530,7 +534,7 @@ static int rockchip_headsetobserve_probe(struct platform_device *pdev) if(!headset->client) { printk("hook adc register error\n"); ret = -EINVAL; - goto failed_free; + goto failed_free_dev; } setup_timer(&headset->hook_timer,hook_timer_callback, (unsigned long)headset); printk("headset adc default value = %d\n",adc_sync_read(headset->client)); -- 2.34.1