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 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; 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; }