void bu52014hfv_irq_south_work_func(struct work_struct *work) { struct bu52014hfv_info *info = container_of(work, struct bu52014hfv_info, irq_south_work); bu52014hfv_update(info, info->gpio_south, info->south_value); enable_irq(info->irq_south); }
static int __devinit bu52014hfv_probe(struct platform_device *pdev) { struct bu52014hfv_platform_data *pdata = pdev->dev.platform_data; struct bu52014hfv_info *info; int ret = -1; info = kzalloc(sizeof(struct bu52014hfv_info), GFP_KERNEL); if (!info) { ret = -ENOMEM; pr_err("%s: could not allocate space for module data: %d\n", __func__, ret); goto error_kmalloc_failed; } /* Initialize hall effect driver data */ info->gpio_north = pdata->docked_north_gpio; info->gpio_south = pdata->docked_south_gpio; info->irq_north = gpio_to_irq(pdata->docked_north_gpio); info->irq_south = gpio_to_irq(pdata->docked_south_gpio); if (pdata->north_is_desk) { info->north_value = DESK_DOCK; info->south_value = CAR_DOCK; } else { info->north_value = CAR_DOCK; info->south_value = DESK_DOCK; } info->work_queue = create_singlethread_workqueue("bu52014hfv_wq"); if (!info->work_queue) { ret = -ENOMEM; pr_err("%s: cannot create work queue: %d\n", __func__, ret); goto error_create_wq_failed; } INIT_WORK(&info->irq_north_work, bu52014hfv_irq_north_work_func); INIT_WORK(&info->irq_south_work, bu52014hfv_irq_south_work_func); ret = request_irq(info->irq_north, bu52014hfv_isr, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, BU52014HFV_MODULE_NAME, info); if (ret) { pr_err("%s: north request irq failed: %d\n", __func__, ret); goto error_request_irq_north_failed; } ret = request_irq(info->irq_south, bu52014hfv_isr, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, BU52014HFV_MODULE_NAME, info); if (ret) { pr_err("%s: south request irq failed: %d\n", __func__, ret); goto error_request_irq_south_failed; } enable_irq_wake(info->irq_north); enable_irq_wake(info->irq_south); info->sdev.name = "dock"; info->sdev.print_name = print_name; ret = switch_dev_register(&info->sdev); if (ret) { pr_err("%s: error registering switch device %d\n", __func__, ret); goto error_switch_device_failed; } platform_set_drvdata(pdev, info); ret = bu52014hfv_update(info, info->gpio_south, info->south_value); if (!ret) bu52014hfv_update(info, info->gpio_north, info->north_value); #ifdef FEATURE_LGE_HOLE_SENSOR_HIDDEN_MENU //20101221 [email protected] for hole sensor hidden menu ret = device_create_file(&pdev->dev, &dev_attr_sensing); if (ret) { pr_err("tegra_touch_probe: grip suppression device_create_file failed\n"); goto error_devfs_failed; } #endif /* FEATURE_LGE_HOLE_SENSOR_HIDDEN_MENU */ return 0; #ifdef FEATURE_LGE_HOLE_SENSOR_HIDDEN_MENU //20101221 [email protected] for hole sensor hidden menu error_devfs_failed: device_remove_file(&pdev->dev, &dev_attr_sensing); #endif /*FEATURE_LGE_HOLE_SENSOR_HIDDEN_MENU*/ error_switch_device_failed: free_irq(info->irq_south, info); error_request_irq_south_failed: free_irq(info->irq_north, info); error_request_irq_north_failed: destroy_workqueue(info->work_queue); error_create_wq_failed: kfree(info); error_kmalloc_failed: return ret; }
static int __devinit bu52014hfv_probe(struct platform_device *pdev) { struct bu52014hfv_platform_data *pdata = pdev->dev.platform_data; struct bu52014hfv_info *info; int ret = -1; info = kzalloc(sizeof(struct bu52014hfv_info), GFP_KERNEL); if (!info) { ret = -ENOMEM; pr_err("%s: could not allocate space for module data: %d\n", __func__, ret); goto error_kmalloc_failed; } /* Initialize hall effect driver data */ info->gpio_north = pdata->docked_north_gpio; info->gpio_south = pdata->docked_south_gpio; info->irq_north = gpio_to_irq(pdata->docked_north_gpio); info->irq_south = gpio_to_irq(pdata->docked_south_gpio); if (pdata->north_is_desk) { info->north_value = DESK_DOCK; info->south_value = CAR_DOCK; } else { info->north_value = CAR_DOCK; info->south_value = DESK_DOCK; } info->work_queue = create_singlethread_workqueue("bu52014hfv_wq"); if (!info->work_queue) { ret = -ENOMEM; pr_err("%s: cannot create work queue: %d\n", __func__, ret); goto error_create_wq_failed; } INIT_WORK(&info->irq_north_work, bu52014hfv_irq_north_work_func); INIT_WORK(&info->irq_south_work, bu52014hfv_irq_south_work_func); ret = request_irq(info->irq_north, bu52014hfv_isr, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, BU52014HFV_MODULE_NAME, info); if (ret) { pr_err("%s: north request irq failed: %d\n", __func__, ret); goto error_request_irq_north_failed; } ret = request_irq(info->irq_south, bu52014hfv_isr, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, BU52014HFV_MODULE_NAME, info); if (ret) { pr_err("%s: south request irq failed: %d\n", __func__, ret); goto error_request_irq_south_failed; } enable_irq_wake(info->irq_north); enable_irq_wake(info->irq_south); info->sdev.name = "dock"; info->sdev.print_name = print_name; ret = switch_dev_register(&info->sdev); if (ret) { pr_err("%s: error registering switch device %d\n", __func__, ret); goto error_switch_device_failed; } platform_set_drvdata(pdev, info); ret = bu52014hfv_update(info, info->gpio_south, info->south_value); if (!ret) bu52014hfv_update(info, info->gpio_north, info->north_value); return 0; error_switch_device_failed: free_irq(info->irq_south, info); error_request_irq_south_failed: free_irq(info->irq_north, info); error_request_irq_north_failed: destroy_workqueue(info->work_queue); error_create_wq_failed: kfree(info); error_kmalloc_failed: return ret; }