static int htc_headset_gpio_probe(struct platform_device *pdev) { int ret; struct htc_headset_gpio_platform_data *pdata = pdev->dev.platform_data; HS_LOG("++++++++++++++++++++"); hi = kzalloc(sizeof(struct htc_headset_gpio_info), GFP_KERNEL); if (!hi) { HS_ERR("Failed to allocate memory for headset info"); return -ENOMEM; } if (pdata->config_headset_gpio) pdata->config_headset_gpio(); hi->pdata.eng_cfg = pdata->eng_cfg; hi->pdata.hpin_gpio = pdata->hpin_gpio; hi->pdata.key_gpio = pdata->key_gpio; hi->pdata.key_enable_gpio = pdata->key_enable_gpio; hi->pdata.mic_select_gpio = pdata->mic_select_gpio; hi->hpin_debounce = HS_JIFFIES_ZERO; hi->key_irq_type = IRQF_TRIGGER_LOW; hi->headset_state = 0; if ((hi->pdata.eng_cfg == HS_QUO_F_U)) { /* HW power connet cable issue */ /* EVT XB WORKAROUND Only */ if (PROJECT_PHASE_XB == htc_get_pcbid_info()) { HS_ERR("=====FORCED RETURN!!!!!====="); return -ENOMEM; } } detect_wq = create_workqueue("HS_GPIO_DETECT"); if (detect_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create detect workqueue"); goto err_create_detect_work_queue; } button_wq = create_workqueue("HS_GPIO_BUTTON"); if (button_wq == NULL){ ret = -ENOMEM; HS_ERR("Failed to create button workqueue"); goto err_create_button_work_queue; } wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME); if (hi->pdata.hpin_gpio) { ret = hs_gpio_request_irq(hi->pdata.hpin_gpio, &hi->hpin_irq, detect_irq_handler, IRQF_TRIGGER_LOW, "HS_GPIO_DETECT", 1); if (ret < 0) { HS_ERR("Failed to request GPIO HPIN IRQ (0x%X)", ret); goto err_request_detect_irq; } } if (hi->pdata.key_gpio) { ret = hs_gpio_request(hi->pdata.key_gpio, "HS_GPIO_BUTTON"); if (ret < 0) HS_ERR("Failed to request GPIO HPIN IRQ (0x%X)", ret); } hs_gpio_register(); hs_notify_driver_ready(DRIVER_NAME); HS_LOG("--------------------"); return 0; err_request_detect_irq: wake_lock_destroy(&hi->hs_wake_lock); destroy_workqueue(button_wq); err_create_button_work_queue: destroy_workqueue(detect_wq); err_create_detect_work_queue: kfree(hi); HS_ERR("Failed to register %s driver", DRIVER_NAME); return ret; }
static int htc_headset_gpio_probe(struct platform_device *pdev) { int ret = 0; struct htc_headset_gpio_platform_data *pdata; HS_LOG("++++++++++++++++++++"); hi = kzalloc(sizeof(struct htc_headset_gpio_info), GFP_KERNEL); if (!hi) { HS_ERR("Failed to allocate memory for headset info"); return -ENOMEM; } if (pdev->dev.of_node) { pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) ret = -ENOMEM; ret = htc_headset_gpio_parse_dt(&pdev->dev, pdata); } else { HS_LOG("old style\n"); pdata = pdev->dev.platform_data; } if (pdata->config_headset_gpio) pdata->config_headset_gpio(); hi->pdata.uart_gpio = pdata->uart_gpio; hi->pdata.hpin_gpio = pdata->hpin_gpio; hi->pdata.key_gpio = pdata->key_gpio; hi->pdata.key_enable_gpio = pdata->key_enable_gpio; hi->pdata.mic_select_gpio = pdata->mic_select_gpio; hi->hpin_debounce = HS_JIFFIES_ZERO; hi->key_irq_type = IRQF_TRIGGER_NONE; hi->headset_state = 0; detect_wq = create_workqueue("HS_GPIO_DETECT"); if (detect_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create detect workqueue"); goto err_create_detect_work_queue; } button_wq = create_workqueue("HS_GPIO_BUTTON"); if (button_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create button workqueue"); goto err_create_button_work_queue; } wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME); if (hi->pdata.uart_gpio) { ret = hs_gpio_request_output(hi->pdata.uart_gpio, "HS_GPIO_UART", 0); if (ret < 0) { HS_ERR("Fail to request GPIO UART(0x%x)", ret); } } if (hi->pdata.hpin_gpio) { ret = hs_gpio_request_irq(hi->pdata.hpin_gpio, &hi->hpin_irq, detect_irq_handler, IRQF_TRIGGER_NONE, "HS_GPIO_DETECT", 1); if (ret < 0) { HS_ERR("Failed to request GPIO HPIN IRQ (0x%X)", ret); goto err_request_detect_irq; } disable_irq(hi->hpin_irq); } if (hi->pdata.key_gpio) { ret = hs_gpio_request_irq(hi->pdata.key_gpio, &hi->key_irq, button_irq_handler, hi->key_irq_type, "HS_GPIO_BUTTON", 1); if (ret < 0) { HS_ERR("Failed to request GPIO button IRQ (0x%X)", ret); goto err_request_button_irq; } disable_irq(hi->key_irq); } queue_delayed_work(detect_wq, &irq_init_work, HS_JIFFIES_IRQ_INIT); hs_gpio_register(); #ifndef CONFIG_OF hs_notify_driver_ready(DRIVER_NAME); #endif HS_LOG("--------------------"); return 0; err_request_button_irq: if (hi->pdata.hpin_gpio) { free_irq(hi->hpin_irq, 0); gpio_free(hi->pdata.hpin_gpio); } err_request_detect_irq: wake_lock_destroy(&hi->hs_wake_lock); destroy_workqueue(button_wq); err_create_button_work_queue: destroy_workqueue(detect_wq); err_create_detect_work_queue: kfree(hi); HS_ERR("Failed to register %s driver", DRIVER_NAME); return ret; }
static int audiojack_probe(struct platform_device *pdev) { int ret; struct htc_headset_gpio_platform_data *pdata = pdev->dev.platform_data; SYS_MSG("++++++++++++++++++++"); pjack_info = kzalloc(sizeof(struct audio_jack_info), GFP_KERNEL); if (!pjack_info) return -ENOMEM; pjack_info->audio_jack_detect = pdata->hpin_gpio; pjack_info->key_enable_gpio = pdata->key_enable_gpio; pjack_info->mic_select_gpio = pdata->mic_select_gpio; pjack_info->audio_jack_flag = 0; pjack_info->debounce_time = ktime_set(0, 500000000); hrtimer_init(&pjack_info->detection_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); pjack_info->detection_timer.function = detect_35mm_event_timer_func; INIT_WORK(&pjack_info->work, audiojack_work_func); spin_lock_init(&pjack_info->spin_lock); wake_lock_init(&pjack_info->audiojack_wake_lock, WAKE_LOCK_SUSPEND, "audiojack"); if (pjack_info->audio_jack_detect) { ret = gpio_request(pjack_info->audio_jack_detect, "3.5mm_detect"); if (ret < 0) goto err_request_detect_gpio; ret = gpio_direction_input(pjack_info->audio_jack_detect); if (ret < 0) goto err_set_detect_gpio; pjack_info->irq_jack = gpio_to_irq(pjack_info->audio_jack_detect); if (pjack_info->irq_jack < 0) { ret = pjack_info->irq_jack; goto err_request_detect_irq; } ret = request_irq(pjack_info->irq_jack, detect_irq_handler, IRQF_TRIGGER_LOW, "35mm_headset", NULL); if (ret < 0) goto err_request_detect_irq; ret = set_irq_wake(pjack_info->irq_jack, 1); if (ret < 0) goto err_set_irq_wake; } hs_gpio_register(); SYS_MSG("--------------------"); return 0; err_set_irq_wake: if (pjack_info->audio_jack_detect) free_irq(pjack_info->irq_jack, 0); err_request_detect_irq: err_set_detect_gpio: if (pjack_info->audio_jack_detect) gpio_free(pjack_info->audio_jack_detect); err_request_detect_gpio: printk(KERN_ERR "Audiojack: Failed in audiojack_probe\n"); return ret; }
static int htc_headset_gpio_probe(struct platform_device *pdev) { int ret; struct htc_headset_gpio_platform_data *pdata = pdev->dev.platform_data; HS_LOG("++++++++++++++++++++"); hi = kzalloc(sizeof(struct htc_headset_gpio_info), GFP_KERNEL); if (!hi) { HS_ERR("Failed to allocate memory for headset info"); return -ENOMEM; } if (pdata->config_headset_gpio) pdata->config_headset_gpio(); hi->pdata.hpin_gpio = pdata->hpin_gpio; hi->pdata.key_gpio = pdata->key_gpio; hi->pdata.key_enable_gpio = pdata->key_enable_gpio; hi->pdata.mic_select_gpio = pdata->mic_select_gpio; hi->hpin_debounce = HS_JIFFIES_ZERO; hi->key_irq_type = IRQF_TRIGGER_LOW; hi->headset_state = 0; detect_wq = create_workqueue("HS_GPIO_DETECT"); if (detect_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create detect workqueue"); goto err_create_detect_work_queue; } button_wq = create_workqueue("HS_GPIO_BUTTON"); if (button_wq == NULL) { ret = -ENOMEM; HS_ERR("Failed to create button workqueue"); goto err_create_button_work_queue; } wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME); if (hi->pdata.hpin_gpio) { ret = hs_gpio_request_irq(hi->pdata.hpin_gpio, &hi->hpin_irq, detect_irq_handler, IRQF_TRIGGER_LOW, "HS_GPIO_DETECT", 1); if (ret < 0) { HS_ERR("Failed to request GPIO HPIN IRQ (0x%X)", ret); goto err_request_detect_irq; } } if (hi->pdata.key_gpio) { ret = hs_gpio_request_irq(hi->pdata.key_gpio, &hi->key_irq, button_irq_handler, hi->key_irq_type, "HS_GPIO_BUTTON", 1); if (ret < 0) { HS_ERR("Failed to request GPIO button IRQ (0x%X)", ret); goto err_request_button_irq; } } hs_gpio_register(); hs_notify_driver_ready(DRIVER_NAME); HS_LOG("--------------------"); return 0; err_request_button_irq: if (hi->pdata.hpin_gpio) { free_irq(hi->hpin_irq, 0); gpio_free(hi->pdata.hpin_gpio); } err_request_detect_irq: wake_lock_destroy(&hi->hs_wake_lock); destroy_workqueue(button_wq); err_create_button_work_queue: destroy_workqueue(detect_wq); err_create_detect_work_queue: kfree(hi); HS_ERR("Failed to register %s driver", DRIVER_NAME); return ret; }
static int htc_headset_gpio_probe(struct platform_device *pdev) { int ret; struct htc_headset_gpio_platform_data *pdata = pdev->dev.platform_data; HS_LOG("++++++++++++++++++++"); hi = kzalloc(sizeof(struct htc_headset_gpio_info), GFP_KERNEL); if (!hi) { HS_LOG("Failed to allocate memory for headset info"); return -ENOMEM; } hi->pdata.hpin_gpio = pdata->hpin_gpio; hi->pdata.key_enable_gpio = pdata->key_enable_gpio; hi->pdata.mic_select_gpio = pdata->mic_select_gpio; hi->hpin_debounce = HS_JIFFIES_INSERT; hi->headset_state = 0; detect_wq = create_workqueue("detect"); if (detect_wq == NULL) { ret = -ENOMEM; HS_LOG("Failed to create detect workqueue"); goto err_create_detect_work_queue; } wake_lock_init(&hi->hs_wake_lock, WAKE_LOCK_SUSPEND, DRIVER_NAME); if (hi->pdata.hpin_gpio) { ret = gpio_request(hi->pdata.hpin_gpio, "HS_GPIO_DETECT"); if (ret < 0) goto err_gpio_request; ret = gpio_direction_input(hi->pdata.hpin_gpio); if (ret < 0) goto err_set_detect_gpio; ret = gpio_to_irq(hi->pdata.hpin_gpio); if (ret < 0) goto err_gpio_to_irq; else hi->hpin_irq = (unsigned int) ret; ret = request_irq(hi->hpin_irq, detect_irq_handler, IRQF_TRIGGER_LOW, "HS_GPIO_DETECT", NULL); if (ret < 0) goto err_request_irq; ret = set_irq_wake(hi->hpin_irq, 1); if (ret < 0) goto err_set_irq_wake; } hs_gpio_register(); hs_notify_driver_ready(DRIVER_NAME); HS_LOG("--------------------"); return 0; err_set_irq_wake: if (hi->pdata.hpin_gpio) free_irq(hi->hpin_irq, 0); err_request_irq: err_gpio_to_irq: err_set_detect_gpio: if (hi->pdata.hpin_gpio) gpio_free(hi->pdata.hpin_gpio); err_gpio_request: wake_lock_destroy(&hi->hs_wake_lock); destroy_workqueue(detect_wq); err_create_detect_work_queue: kfree(hi); HS_LOG("Failed to register %s driver", DRIVER_NAME); return ret; }