static int __devexit msm_red_led_remove(struct platform_device *pdev) { struct pdm_led_data *led = platform_get_drvdata(pdev); struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); //[Arima Edison] disable it, since indicator leds were controled by PowerManager++ #ifdef CONFIG_LED_SLEEP #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&led->early_suspend); #endif #endif //[Arima Edison] disable it, since indicator leds were controled by PowerManager++ pm_runtime_set_suspended(&pdev->dev); pm_runtime_disable(&pdev->dev); led_classdev_unregister(&led->cdev); msm_led_brightness_set_percent(led, 0); iounmap(led->perph_base); release_mem_region(res->start, resource_size(res)); kfree(led); return 0; }
static int __devexit lp8556_remove(struct i2c_client *client) { struct lp8556_data *led_data = i2c_get_clientdata(client); #ifdef DEBUG device_remove_file(led_data->led_dev.dev, &dev_attr_registers); #endif #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&led_data->early_suspender); #endif led_data->led_dev.brightness = LED_OFF; lp8556_brightness_write(led_data); if (led_data->bl_dev) backlight_device_unregister(led_data->bl_dev); led_classdev_unregister(&led_data->led_dev); gpio_free(led_data->pdata->enable_gpio); if (!IS_ERR(led_data->regulator)) regulator_put(led_data->regulator); kfree(led_data); i2c_set_clientdata(client, NULL); return 0; }
static void __exit android_power_exit(void) { unregister_early_suspend(&stop_drawing_early_suspend_desc); sysfs_remove_group(power_kobj, &attr_group); }
static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct yas_state *st; struct iio_dev *indio_dev; int ret, i; this_client = i2c; indio_dev = iio_allocate_device(sizeof(*st)); if (!indio_dev) { ret = -ENOMEM; goto error_ret; } i2c_set_clientdata(i2c, indio_dev); indio_dev->name = id->name; indio_dev->dev.parent = &i2c->dev; indio_dev->info = &yas_info; indio_dev->channels = yas_channels; indio_dev->num_channels = ARRAY_SIZE(yas_channels); indio_dev->modes = INDIO_DIRECT_MODE; st = iio_priv(indio_dev); st->client = i2c; st->sampling_frequency = 20; st->acc.callback.device_open = yas_device_open; st->acc.callback.device_close = yas_device_close; st->acc.callback.device_read = yas_device_read; st->acc.callback.device_write = yas_device_write; st->acc.callback.usleep = yas_usleep; st->acc.callback.current_time = yas_current_time; INIT_DELAYED_WORK(&st->work, yas_work_func); mutex_init(&st->lock); #ifdef CONFIG_HAS_EARLYSUSPEND st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; st->sus.suspend = yas_early_suspend; st->sus.resume = yas_late_resume; register_early_suspend(&st->sus); #endif for (i = 0; i < 3; i++) { st->compass_data[i] = 0; st->calib_bias[i] = 0; } ret = yas_probe_buffer(indio_dev); if (ret) goto error_free_dev; ret = yas_probe_trigger(indio_dev); if (ret) goto error_remove_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_remove_trigger; ret = yas_acc_driver_init(&st->acc); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.init(); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.set_enable(1); if (ret < 0) { ret = -EFAULT; goto error_driver_term; } return 0; error_driver_term: st->acc.term(); error_unregister_iio: iio_device_unregister(indio_dev); error_remove_trigger: yas_remove_trigger(indio_dev); error_remove_buffer: yas_remove_buffer(indio_dev); error_free_dev: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&st->sus); #endif iio_free_device(indio_dev); error_ret: i2c_set_clientdata(i2c, NULL); this_client = NULL; return ret; }
static int yas_acc_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct yas_acc_private_data *data; int err; #ifdef WILLOW_SENSOR_REGULATOR_CONTROL int ret; #endif /* Setup private data */ data = kzalloc(sizeof(struct yas_acc_private_data), GFP_KERNEL); if (!data) { err = -ENOMEM; goto ERR1; } yas_acc_set_data(data); #ifdef WILLOW_SENSOR_REGULATOR_CONTROL data->regulator = regulator_get(&client->dev, "vdd_sensor"); if(IS_ERR(data->regulator)) { printk(KERN_ERR "[accelerometer] failed to get regulator\n"); err = -EINVAL; goto regulator_err; } ret = regulator_enable(data->regulator); if(ret<0) { printk(KERN_ERR "[accelerometer] failed to enable regulator\n"); err = -EINVAL; goto regulator_err; } mdelay(3); #endif mutex_init(&data->driver_mutex); mutex_init(&data->data_mutex); /* Setup i2c client */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { err = -ENODEV; goto ERR2; } i2c_set_clientdata(client, data); data->client = client; /* Setup accelerometer core driver */ err = yas_acc_core_driver_init(data); if (err < 0) { goto ERR2; } /* Setup driver interface */ INIT_DELAYED_WORK(&data->work, yas_acc_work_func); /* Setup input device interface */ err = yas_acc_input_init(data); if (err < 0) { goto ERR3; } #ifdef CONFIG_HAS_EARLYSUSPEND data->early_suspend.suspend = yas_acc_early_suspend; data->early_suspend.resume = yas_acc_late_resume; data->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB; register_early_suspend(&data->early_suspend); #endif /* Setup sysfs */ err = sysfs_create_group(&data->input->dev.kobj, &yas_acc_attribute_group); if (err < 0) { goto ERR4; } return 0; ERR4: #ifdef CONIFG_HAS_EARLYSUSPEND unregister_early_suspend(&data->early_suspend); #endif yas_acc_input_fini(data); ERR3: yas_acc_core_driver_fini(data); #ifdef WILLOW_SENSOR_REGULATOR_CONTROL regulator_err: regulator_disable(data->regulator); regulator_put(data->regulator); #endif ERR2: kfree(data); ERR1: return err; }
static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { int ret = 0, i; struct ct36x_data *ts = NULL; struct ct36x_platform_data *pdata = client->dev.platform_data; if(!pdata){ dev_err(&client->dev, "no platform data\n"); return -EINVAL; }; if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { dev_err(&client->dev, "I2C-Adapter doesn't support I2C_FUNC_I2C\n"); return -ENODEV; } ts = kzalloc(sizeof(struct ct36x_data), GFP_KERNEL); if(!ts){ dev_err(&client->dev, "No memory for ct36x"); return -ENOMEM; } ts->model = pdata->model; ts->x_max = pdata->x_max; ts->y_max = pdata->y_max; ts->rst_io = pdata->rst_io; ts->irq_io = pdata->irq_io; for(i = 0; i < 4; i++) ts->orientation[i] = pdata->orientation[i]; ts->client = client; ts->dev = &client->dev; i2c_set_clientdata(client, ts); ret = ct36x_set_ops(ts, pdata->model); if(ret < 0){ dev_err(ts->dev, "Failed to set ct36x ops\n"); goto err_ct36x_set_ops; } if(ts->ops->init){ ret = ts->ops->init(ts); if(ret < 0){ dev_err(ts->dev, "Failed to init ct36x chip\n"); goto err_input_allocate_device; } } ret = ct36x_chip_get_ver(ts); if(ret < 0){ dev_warn(ts->dev, "CT363 TOUCHSCREEN is no exist\n"); goto err_input_allocate_device; } printk("CT363 ver=[%x]\n", ret); ts->input = input_allocate_device(); if(!ts->input){ ret = -ENODEV; dev_err(ts->dev, "Failed to allocate input device\n"); goto err_input_allocate_device; } ts->input->name = CT36X_NAME; ts->input->dev.parent = &client->dev; set_bit(EV_ABS, ts->input->evbit); set_bit(INPUT_PROP_DIRECT, ts->input->propbit); input_mt_init_slots(ts->input, ts->point_num); input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0); input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); ret = input_register_device(ts->input); if(ret < 0){ dev_err(ts->dev, "Failed to register input device\n"); goto err_input_register_devcie; } #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = ct36x_ts_early_suspend; ts->early_suspend.resume = ct36x_ts_late_resume; register_early_suspend(&ts->early_suspend); #endif ts->irq = gpio_to_irq(ts->irq_io.gpio); ret = request_threaded_irq(ts->irq, NULL, ct36x_irq_handler, IRQF_TRIGGER_FALLING|IRQF_ONESHOT, CT36X_NAME, ts); if(ret < 0){ dev_err(ts->dev, "Failed to request threaded irq\n"); goto err_request_threaded_irq; } dev_info(ts->dev, "CT363 Successfully initialized\n"); return 0; err_request_threaded_irq: unregister_early_suspend(&ts->early_suspend); input_unregister_device(ts->input); err_input_register_devcie: input_free_device(ts->input); err_input_allocate_device: if(ts->ops->deinit) ts->ops->deinit(ts); err_ct36x_init_chip: err_ct36x_set_ops: i2c_set_clientdata(client, NULL); kfree(ts); return ret; }
static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: " "Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { pr_err("gpio_event_probe: Unable to register %s " "input device\n", ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } #if (defined(CONFIG_MACH_EUROPA) || defined(CONFIG_MACH_CALLISTO)|| defined(CONFIG_MACH_COOPER) || defined(CONFIG_MACH_BENI) || defined(CONFIG_MACH_TASS) || defined(CONFIG_MACH_LUCAS)) /* sys fs */ key_class = class_create(THIS_MODULE, "key"); if (IS_ERR(key_class)) pr_err("Failed to create class(key)!\n"); key_dev = device_create(key_class, NULL, 0, NULL, "key"); if (IS_ERR(key_dev)) pr_err("Failed to create device(key)!\n"); if (device_create_file(key_dev, &dev_attr_key) < 0) pr_err("Failed to create device file(%s)!\n", dev_attr_key.attr.name); /* sys fs */ #endif #ifndef CONFIG_MACH_LUCAS //for landscape UI (temporary patch) for (i = 0; i < registered; i++) { input_report_switch(ip->input_devs->dev[i], SW_LID, 1); input_sync(ip->input_devs->dev[i]); } #endif return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static void __exit ledtrig_sleep_exit(void) { unregister_early_suspend(&ledtrig_sleep_early_suspend_handler); unregister_pm_notifier(&ledtrig_sleep_pm_notifier); led_trigger_unregister_simple(ledtrig_sleep); }
s32 earlysuspend_test_unregister() { unregister_early_suspend(&earlysuspend_struct_test01); unregister_early_suspend(&earlysuspend_struct_test02); return 0; }
static int __devinit sec_keyboard_probe(struct platform_device *pdev) { struct sec_keyboard_platform_data *pdata = pdev->dev.platform_data; struct sec_keyboard_drvdata *ddata; struct input_dev *input; int i, error; ddata = kzalloc(sizeof(struct sec_keyboard_drvdata), GFP_KERNEL); if (NULL == ddata) { error = -ENOMEM; goto err_free_mem; } input = input_allocate_device(); if (NULL == input) { printk(KERN_ERR "[Keyboard] Fail to allocate input device.\n"); error = -ENOMEM; goto err_free_mem; } ddata->input_dev = input; ddata->acc_power = pdata->acc_power; ddata->check_uart_path = pdata->check_uart_path; ddata->acc_int_gpio = pdata->accessory_irq_gpio; ddata->buf_front = ddata->buf_rear = 0; ddata->led_on = false; ddata->dockconnected = false; ddata->pre_connected = false; ddata->remap_key = 0; ddata->kl = UNKOWN_KEYLAYOUT; ddata->callbacks.check_keyboard_dock = check_keyboard_dock; if (pdata->register_cb) pdata->register_cb(&ddata->callbacks); memcpy(ddata->keycode, sec_keycodes, sizeof(sec_keycodes)); mutex_init(&ddata->mutex); INIT_WORK(&ddata->work_msg, key_event_work); INIT_WORK(&ddata->work_timer, timer_work); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdev->name; input->dev.parent = &pdev->dev; input->id.bustype = BUS_RS232; input->event = sec_keyboard_event; set_bit(EV_SYN, input->evbit); set_bit(EV_KEY, input->evbit); set_bit(EV_LED, input->evbit); set_bit(LED_CAPSL, input->ledbit); /* framework doesn't use repeat event */ /* set_bit(EV_REP, input->evbit); */ for (i = 0; i < KEYBOARD_SIZE; i++) { if (KEY_RESERVED != ddata->keycode[i]) input_set_capability(input, EV_KEY, ddata->keycode[i]); } /* for the UK keyboard */ input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND); /* for the remaped keys */ input_set_capability(input, EV_KEY, KEY_NEXTSONG); input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG); /* for the wakeup key */ input_set_capability(input, EV_KEY, KEY_WAKEUP); error = input_register_device(input); if (error < 0) { printk(KERN_ERR "[Keyboard] Fail to register input device.\n"); error = -ENOMEM; goto err_input_allocate_device; } #ifdef CONFIG_HAS_EARLYSUSPEND ddata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ddata->early_suspend.suspend = keyboard_early_suspend; ddata->early_suspend.resume = keyboard_late_resume; register_early_suspend(&ddata->early_suspend); #endif /* CONFIG_HAS_EARLYSUSPEND */ init_timer(&ddata->timer); ddata->timer.expires = jiffies + HZ; ddata->timer.function = keyboard_timer; ddata->timer.data = (unsigned long)ddata; init_timer(&ddata->key_timer); ddata->key_timer.expires = jiffies + HZ/3; ddata->key_timer.function = remapkey_timer; ddata->key_timer.data = (unsigned long)ddata; ddata->keyboard_dev = device_create(sec_class, NULL, 0, ddata, "sec_keyboard"); if (IS_ERR(ddata->keyboard_dev)) { pr_err("Failed to create device for the sysfs\n"); error = -ENODEV; goto err_sysfs_create_group; } error = sysfs_create_group(&ddata->keyboard_dev->kobj, &attr_group); if (error) { pr_err("Failed to create sysfs group\n"); goto err_sysfs_create_group; } g_data = ddata; return 0; err_sysfs_create_group: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ddata->early_suspend); #endif del_timer_sync(&ddata->timer); del_timer_sync(&ddata->key_timer); err_input_allocate_device: input_free_device(input); err_free_mem: kfree(ddata); return error; }
static int ftt_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct ftt_charger_pdata *pdata = pdev->dev.platform_data; struct ftt_charger_device *ftt_pdev; int err; int retval = 0; #ifdef CONFIG_OF struct device_node *np = pdev->dev.of_node; #endif #ifdef CONFIG_OF printk("[FTT] +ftt_probe()\n"); if (pdev->dev.of_node) { pdata = devm_kzalloc(&pdev->dev, sizeof(struct ftt_charger_pdata), GFP_KERNEL); if (!pdata) { printk("ftt : cannot allocate\n"); return -ENOMEM; } pdev->dev.platform_data = pdata; pdata->chg_ctrl_gpio = of_get_named_gpio(np, "chg_ctrl_gpio", 0); pdata->half_chg_ctrl_gpio = of_get_named_gpio(np, "half_chg_ctrl_gpio", 0); pdata->active_n_gpio = of_get_named_gpio(np, "active_n_gpio", 0); pdata->otg_ctrl_gpio= of_get_named_gpio(np, "otg_ctrl_gpio", 0); pdata->wlc_ts_mpp = of_get_named_gpio(np, "wlc_ts_mpp", 0); pdata->ftt_gpio = of_get_named_gpio(np, "track_gpio", 0); pdata->get_ftt_gpio = get_ftt_gpio; pdata->online_fn = wireless_online; pdata->on_change_level_fn = on_change_level; } #endif ftt_pdev = kzalloc(sizeof(struct ftt_charger_device), GFP_KERNEL); if (!ftt_pdev) { dev_dbg(&pdev->dev, "out of memory\n"); retval = -ENOMEM; goto err_out; } ftt_pdev->pdev = pdev; pdata = ftt_pdev->pdev->dev.platform_data; #ifdef CONFIG_OF ftt_pdev->chg_ctrl_gpio = pdata->chg_ctrl_gpio; printk("[FTT] - chg_ctrl_gpio : %d\n", ftt_pdev->chg_ctrl_gpio); ftt_pdev->half_chg_ctrl_gpio = pdata->half_chg_ctrl_gpio; printk("[FTT] - half_chg_ctrl_gpio : %d\n", ftt_pdev->half_chg_ctrl_gpio); ftt_pdev->active_n_gpio = pdata->active_n_gpio; printk("[FTT] - active_n_gpio : %d\n", ftt_pdev->active_n_gpio); ftt_pdev->otg_ctrl_gpio = pdata->otg_ctrl_gpio; printk("[FTT] - otg_ctrl_gpio : %d\n", ftt_pdev->otg_ctrl_gpio); ftt_pdev->wlc_ts_mpp = pdata->wlc_ts_mpp; printk("[FTT] - wlc_ts_mpp : %d\n", ftt_pdev->wlc_ts_mpp); ftt_pdev->ftt_gpio = pdata->ftt_gpio; printk("[FTT] - track_gpio : %d\n", ftt_pdev->ftt_gpio); ftt_hw_init(ftt_pdev); #endif /* initalize member start */ set_ftt_charger_init_data(ftt_pdev); set_ftt_charger_reset_status(ftt_pdev); set_ftt_charger_reset_data(ftt_pdev); /* initalize member end */ if (!pdata) { dev_err(dev, "Cannot find platform data.\n"); retval = -ENXIO; goto err_kzalloc; } DPRINT(FTT_INFO, "%s\n", __FUNCTION__); #if (FTT_CHIP_ENABLE_PIN_USE == 1) err = gpio_request(pdata->en1, "FTT_CHIP_ENABLE"); if (err) printk(KERN_ERR "#### failed to request FTT_CHIP_ENABLE ####\n"); gpio_direction_output(pdata->en1, ftt_chip_enable_flag); #endif if (pdata->get_ftt_gpio == NULL) { retval = -ENXIO; goto err_kzalloc; } err = gpio_request(ftt_pdev->ftt_gpio, "FTT_FREQUANCY"); if (err) { printk(KERN_ERR "#### failed to request FTT_FREQUANCY ####\n"); retval = ENODEV; goto err_kzalloc; } gpio_direction_input(ftt_pdev->ftt_gpio); ftt_pdev->ftt_irq = gpio_to_irq(ftt_pdev->ftt_gpio); ftt_pdev->ftt_charger_status_timer.function = ftt_charger_status_timer_handler; ftt_pdev->ftt_charger_status_timer.data = (unsigned long)ftt_pdev; init_timer(&ftt_pdev->ftt_charger_status_timer); err = request_irq(ftt_pdev->ftt_irq, ftt_interrupt_pin_cb, IRQF_TRIGGER_RISING, DEVICE_NAME, (void *)ftt_pdev); if (err) { printk(KERN_ERR "gpio-ftt-charger: Unable to claim irq %d; error %d\n", ftt_pdev->ftt_irq, err); retval = err; goto err_gpio; } ftt_interrupt_disable(ftt_pdev); ftt_pdev->ftt_interrupt_booting_enable_flag = true; set_ftt_charger_reset_status(ftt_pdev); #ifndef FTT_FILE_OPEN_ENABLE ftt_enable(ftt_pdev); #endif /* FTT_FILE_OPEN_ENABLE */ #if defined(CONFIG_HAS_EARLYSUSPEND) /************************************************************** EARLYSUSPEND/LATERESUME **************************************************************/ ftt_pdev->power.suspend = ftt_suspend; ftt_pdev->power.resume = ftt_resume; ftt_pdev->power.level = EARLY_SUSPEND_LEVEL_DISABLE_FB-1; register_early_suspend(&ftt_pdev->power); #endif #if FTT_UEVENT ftt_uevent_init(ftt_pdev); if ((err = power_supply_register(dev, &ftt_pdev->ftt_supply))) { dev_err(dev, "failed: power supply ftt wireless register.\n"); retval = err; goto err_suspend; } else { dev_info(dev, "power supply ftt wireless registerd.\n"); } #endif #if FTT_CHARACTER_DEVICE ftt_pdev->ftt_misc.fops = &ftt_fops; ftt_pdev->ftt_misc.name = FTT_CHAR_DEVICE_NAME; ftt_pdev->ftt_misc.minor = MISC_DYNAMIC_MINOR;//FTT_MINOR; if ((err = misc_register(&ftt_pdev->ftt_misc))) { retval = err; goto err_power_supply; } else { dev_info(dev, "misc device ftt wireless registerd.\n"); } #endif /* FTT_CHARACTER_DEVICE */ init_waitqueue_head(&ftt_pdev->wait); INIT_LIST_HEAD(&ftt_pdev->read_cmd_queue); #ifdef CONFIG_FTT_SYSFS err = sysfs_create_group(&pdev->dev.kobj, &ftt_sysfs_attr_group); if (err) { printk(KERN_ERR "#### failed to sysfs_create_group ####\n"); retval = err; goto err_character_device; } #endif /* CONFIG_FTT_SYSFS */ platform_set_drvdata(pdev, ftt_pdev); printk(DEVICE_NAME " Initialized\n"); return 0; /******************************************************************************************* ERROR *******************************************************************************************/ err_character_device: #if FTT_CHARACTER_DEVICE misc_deregister(&ftt_pdev->ftt_misc); #endif /* FTT_CHARACTER_DEVICE */ err_power_supply: #if FTT_UEVENT power_supply_unregister(&ftt_pdev->ftt_supply); #endif err_suspend: #if defined(CONFIG_HAS_EARLYSUSPEND) unregister_early_suspend(&ftt_pdev->power); #endif free_irq(ftt_pdev->ftt_irq, ftt_pdev); #if FTT_CHARGER_STATUS_TIMER del_timer(&ftt_pdev->ftt_charger_status_timer); #endif err_gpio: gpio_free(ftt_pdev->ftt_gpio); err_kzalloc: kfree(ftt_pdev); err_out: return retval; }
static int __devinit dock_keyboard_probe(struct platform_device *pdev) { struct dock_keyboard_platform_data *pdata = pdev->dev.platform_data; struct dock_keyboard_data *data; struct input_dev *input; int i; int ret; pr_debug("kbd: probe\n"); data = kzalloc(sizeof(struct dock_keyboard_data), GFP_KERNEL); if (unlikely(IS_ERR(data))) { ret = -ENOMEM; goto err_alloc_mem; } sec_dock_kbd_driver.private_data = data; INIT_WORK(&data->work_msg, key_event_work); platform_set_drvdata(pdev, data); input = input_allocate_device(); if (unlikely(IS_ERR(input))) { pr_err("kbd: failed to allocate input device.\n"); ret = -ENOMEM; goto err_alloc_input_dev; } data->input_dev = input; input_set_drvdata(data->input_dev, data); data->kl = UNKNOWN_KEYLAYOUT; input->name = pdev->name; input->dev.parent = &pdev->dev; input->id.bustype = BUS_RS232; input->event = dock_keyboard_event; set_bit(EV_SYN, input->evbit); set_bit(EV_KEY, input->evbit); set_bit(EV_LED, input->evbit); set_bit(LED_CAPSL, input->ledbit); for (i = 0; i < KEYBOARD_SIZE; i++) { if (KEY_RESERVED != dock_keycodes[i].keycode) { input_set_capability(input, EV_KEY, dock_keycodes[i].keycode); } } /* for the UK keyboard */ input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND); /* for the remaped keys */ input_set_capability(input, EV_KEY, KEY_NEXTSONG); input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG); ret = input_register_device(data->input_dev); if (unlikely(ret)) { pr_err("kbd: failed to register input device.\n"); goto err_reg_input_dev; } data->dock_irq_gpio = pdata->dock_irq_gpio; data->power = pdata->power; if (pdata->register_cb) pdata->register_cb(input, dock_keyboard_cb); #ifdef CONFIG_HAS_EARLYSUSPEND data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; data->early_suspend.suspend = dock_keyboard_early_suspend; data->early_suspend.resume = dock_keyboard_late_resume; register_early_suspend(&data->early_suspend); #endif /* CONFIG_HAS_EARLYSUSPEND */ init_timer(&data->key_timer); data->key_timer.data = (unsigned long)data; data->key_timer.expires = jiffies + HZ / 3; data->key_timer.function = remapkey_timer; init_timer(&data->off_timer); data->off_timer.data = (unsigned long)data; data->off_timer.expires = jiffies + HZ * 2 / 3; data->off_timer.function = power_off_timer; ret = serio_register_driver(&sec_dock_kbd_driver.serio_drv); if (unlikely(ret)) { pr_err("kbd: failed to register serio driver!\n"); goto err_reg_serio_drv; } return 0; err_reg_serio_drv: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&data->early_suspend); #endif if (pdata->register_cb) pdata->register_cb(NULL, NULL); input_unregister_device(input); err_reg_input_dev: input_free_device(input); input_set_drvdata(input, NULL); err_alloc_input_dev: kfree(data); err_alloc_mem: return ret; }
static void cm3217_shutdown(struct i2c_client *client) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&cm3217_early_suspend); #endif }
static void intel_kpd_led_rpmsg_remove(struct rpmsg_channel *rpdev) { intel_keypad_led_set(&intel_kpd_led, LED_OFF); unregister_early_suspend(&intel_kpd_led_suspend_desc); led_classdev_unregister(&intel_kpd_led); }
int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = -1; int binchksum, fwchksum; int updcnt; struct ct36x_ts_info *ts; struct ct36x_platform_data *pdata; struct device *dev; if ( CT36X_TS_CORE_DEBUG ) printk(">>>>> %s() called <<<<< \n", __FUNCTION__); dev = &client->dev; pdata = dev->platform_data; if ( pdata ) { ct36x_ts.i2c_address = client->addr; ct36x_ts.irq = pdata->irq; //ct36x_ts.rst = pdata->rst; //ct36x_ts.ss = pdata->ss; ct36x_platform_get_cfg(&ct36x_ts); ct36x_ts.client = client; i2c_set_clientdata(client, &ct36x_ts); } else { printk("No platform data for device %s.\n", DRIVER_NAME); } plat_data = dev->platform_data; ts = (struct ct36x_ts_info *)i2c_get_clientdata(client); /* Create Proc Entry File */ ts->proc_entry = create_proc_entry(DRIVER_NAME, 0666/*S_IFREG | S_IRUGO | S_IWUSR*/, NULL); if ( ts->proc_entry == NULL ) { dev_err(dev, "Failed creating proc dir entry file.\n"); } else { ts->proc_entry->proc_fops = &ct36x_ts_fops; } /* register early suspend */ #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = ct36x_early_suspend; ts->early_suspend.resume = ct36x_early_resume; register_early_suspend(&ts->early_suspend); #endif /* Check I2C Functionality */ err = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if ( !err ) { dev_err(dev, "Check I2C Functionality Failed.\n"); goto ERR_I2C_CHK; } /* Request platform resources (gpio/interrupt pins) */ err = ct36x_platform_get_resource(ts); if ( err ) { dev_err(dev, "Unable to request platform resource for device %s.\n", DRIVER_NAME); goto ERR_PLAT_RSC; } /* Hardware reset */ ct36x_platform_hw_reset(pdata); // Get binary Checksum binchksum = ct36x_chip_get_binchksum(ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Bin checksum: 0x%x\n", binchksum); // Get firmware Checksum fwchksum = ct36x_chip_get_fwchksum(client, ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Fw checksum: 0x%x\n", fwchksum); //while(1){} updcnt = 5; while ( binchksum != fwchksum && updcnt--) { /* Update Firmware */ ct36x_chip_go_bootloader(client, ts->data.buf); /* Hardware reset */ ct36x_platform_hw_reset(pdata); // Get firmware Checksum fwchksum = ct36x_chip_get_fwchksum(client, ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Fw checksum: 0x%x\n", fwchksum); } printk("Fw update %s. 0x%x, 0x%x\n", binchksum != fwchksum ? "Failed" : "Success", binchksum, fwchksum); /* Hardware reset */ ct36x_platform_hw_reset(pdata); /* allocate input device */ ts->input = input_allocate_device(); if ( !ts->input ) { dev_err(dev, "Unable to allocate input device for device %s.\n", DRIVER_NAME); err = -ENOMEM; goto ERR_INPUT_ALLOC; } /* config input device */ __set_bit(EV_SYN, ts->input->evbit); __set_bit(EV_KEY, ts->input->evbit); __set_bit(EV_ABS, ts->input->evbit); __set_bit(INPUT_PROP_DIRECT, ts->input->propbit); //input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, CT36X_TS_ABS_X_MAX, 0, 0); //input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, CT36X_TS_ABS_Y_MAX, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, pdata->x_max, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, pdata->y_max, 0, 0); ts->input->name = DRIVER_NAME; ts->input->id.bustype = BUS_I2C; /* register input device */ err = input_register_device(ts->input); if ( err ) { dev_err(dev, "Unable to register input device for device %s.\n", DRIVER_NAME); goto ERR_INPUT_REGIS; } /* Create work queue */ INIT_WORK(&ts->event_work, ct36x_ts_workfunc); ts->workqueue = create_singlethread_workqueue(dev_name(&client->dev)); /* Init irq */ //gpio_set_status(GPIO_FT_IRQ, gpio_status_in); //gpio_irq_set(170, GPIO_IRQ(FT_IRQ-INT_GPIO_0, GPIO_IRQ_FALLING)); if (pdata->init_gpio) { pdata->init_gpio(); } //err = request_irq(ts->irq, ct36x_ts_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, DRIVER_NAME, ts); err = request_irq(ts->irq, ct36x_ts_irq, IRQF_DISABLED, DRIVER_NAME, ts); if ( err ) { dev_err(dev, "Unable to request irq for device %s.\n", DRIVER_NAME); goto ERR_IRQ_REQ; } /* Set device is ready */ ts->state = CT36X_STATE_NORMAL; /* power denoisy*/ //ct36x_chip_set_adapter_on(client, ts->data.buf); //ct36x_chip_set_adapter_off(client, ts->data.buf); ct36x_ts_adapter(0); return 0; ERR_IRQ_REQ: destroy_workqueue(ts->workqueue); ERR_INPUT_REGIS: input_free_device(ts->input); ERR_INPUT_ALLOC: ERR_PLAT_RSC: ct36x_platform_put_resource(ts); ERR_I2C_CHK: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ts->early_suspend); #endif remove_proc_entry(DRIVER_NAME, NULL); return err; }
int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err = -1; int binchksum; int updcnt; struct ct36x_ts_info *ts; struct device *dev; if ( CT36X_TS_CORE_DEBUG ) printk(">>>>> %s() called <<<<< \n", __FUNCTION__); dev = &client->dev; #ifdef CONFIG_OF if (ts_com->owner != NULL) return -ENODEV; memset(ts_com, 0 ,sizeof(struct touch_pdata)); ts_com = (struct touch_pdata*)client->dev.platform_data; printk("ts_com->owner = %s\n", ts_com->owner); ct36x_platform_get_cfg(&ct36x_ts); ct36x_ts.client = client; i2c_set_clientdata(client, &ct36x_ts); ts_com->hardware_reset = ct36x_hw_reset; ts_com->read_version = ct36x_read_version; ts_com->upgrade_touch = ct36x_upgrade_touch; #else struct ct36x_platform_data *pdata; pdata = dev->platform_data; if ( pdata ) { ct36x_ts.i2c_address = client->addr; ct36x_ts.irq = pdata->irq; ct36x_ts.rst = pdata->rst; ct36x_ts.ss = pdata->ss; ct36x_platform_get_cfg(&ct36x_ts); ct36x_ts.client = client; i2c_set_clientdata(client, &ct36x_ts); } else { printk("No platform data for device %s.\n", DRIVER_NAME); } plat_data = dev->platform_data; #endif ts = (struct ct36x_ts_info *)i2c_get_clientdata(client); /* Create Proc Entry File */ //ts->proc_entry = create_proc_entry(DRIVER_NAME, 0666/*S_IFREG | S_IRUGO | S_IWUSR*/, NULL); ts->proc_entry = proc_create(DRIVER_NAME, 0666/*S_IFREG | S_IRUGO | S_IWUSR*/, NULL, &ct36x_ts_fops); if ( ts->proc_entry == NULL ) { dev_err(dev, "Failed creating proc dir entry file.\n"); } //else { //ts->proc_entry->proc_fops = &ct36x_ts_fops; //} /* register early suspend */ #ifdef CONFIG_HAS_EARLYSUSPEND ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = ct36x_early_suspend; ts->early_suspend.resume = ct36x_early_resume; register_early_suspend(&ts->early_suspend); #endif /* Check I2C Functionality */ err = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if ( !err ) { dev_err(dev, "Check I2C Functionality Failed.\n"); goto ERR_I2C_CHK; } /* Request platform resources (gpio/interrupt pins) */ err = ct36x_platform_get_resource(ts); if ( err ) { dev_err(dev, "Unable to request platform resource for device %s.\n", DRIVER_NAME); goto ERR_PLAT_RSC; } /* Hardware reset */ #ifdef CONFIG_OF ct36x_platform_hw_reset(ts); #else ct36x_platform_hw_reset(pdata); #endif updcnt = 5; while (updcnt--) { if (ct36x_test_read(client, client->addr, (char *)&binchksum, 1) == 1) break; } if (updcnt <= 0) { printk("ct36x touch not exit!\n"); goto ERR_PLAT_RSC; } binchksum = 0; #ifdef LATE_UPGRADE ts_com->upgrade_task = kthread_run(ct36x_late_upgrade, NULL, "ct36x_late_upgrade"); if (!ts_com->upgrade_task) printk("%s creat upgrade process failed\n", __func__); else printk("%s creat upgrade process sucessful\n", __func__); #else // Get binary Checksum binchksum = ct36x_chip_get_binchksum(ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Bin checksum: 0x%x\n", binchksum); // Get firmware Checksum fwchksum = ct36x_chip_get_fwchksum(client, ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Fw checksum: 0x%x\n", fwchksum); //while(1){} updcnt = 2; while ( binchksum != fwchksum && updcnt--) { /* Update Firmware */ ct36x_chip_go_bootloader(client, ts->data.buf); /* Hardware reset */ #ifdef CONFIG_OF ct36x_platform_hw_reset(&ct36x_ts); #else ct36x_platform_hw_reset(plat_data); #endif // Get firmware Checksum fwchksum = ct36x_chip_get_fwchksum(client, ts->data.buf); if ( CT36X_TS_CORE_DEBUG ) printk("Fw checksum: 0x%x\n", fwchksum); } #if defined(CONFIG_TOUCHSCREEN_CT36X_CHIP_CT365) ct36x_check_trim(ct36x_ts.client); #endif printk("Fw update %s. 0x%x, 0x%x\n", binchksum != fwchksum ? "Failed" : "Success", binchksum, fwchksum); /* Hardware reset */ #ifdef CONFIG_OF ct36x_platform_hw_reset(&ct36x_ts); #else ct36x_platform_hw_reset(plat_data); #endif #endif /* allocate input device */ ts->input = input_allocate_device(); if ( !ts->input ) { dev_err(dev, "Unable to allocate input device for device %s.\n", DRIVER_NAME); err = -ENOMEM; goto ERR_INPUT_ALLOC; } /* config input device */ __set_bit(EV_SYN, ts->input->evbit); __set_bit(EV_KEY, ts->input->evbit); __set_bit(EV_ABS, ts->input->evbit); __set_bit(INPUT_PROP_DIRECT, ts->input->propbit); input_mt_init_slots(ts->input, CT36X_TS_POINT_NUM, 0); //input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, CT36X_TS_ABS_X_MAX, 0, 0); //input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, CT36X_TS_ABS_Y_MAX, 0, 0); #ifdef CONFIG_OF if (ts_com->pol & 4) swap(ts_com->xres, ts_com->yres); input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, ts_com->xres, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, ts_com->yres, 0, 0); #else input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, plat_data->x_max, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, plat_data->y_max, 0, 0); #endif input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); ts->input->name = DRIVER_NAME; ts->input->id.bustype = BUS_I2C; /* register input device */ err = input_register_device(ts->input); if ( err ) { dev_err(dev, "Unable to register input device for device %s.\n", DRIVER_NAME); goto ERR_INPUT_REGIS; } /* Create work queue */ INIT_WORK(&ts->event_work, ct36x_ts_workfunc); ts->workqueue = create_singlethread_workqueue(dev_name(&client->dev)); /* Init irq */ //gpio_set_status(GPIO_FT_IRQ, gpio_status_in); //gpio_irq_set(170, GPIO_IRQ(FT_IRQ-INT_GPIO_0, GPIO_IRQ_FALLING)); //err = request_irq(ts->irq, ct36x_ts_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, DRIVER_NAME, ts); #ifndef CONFIG_OF if (pdata->init_gpio) { pdata->init_gpio(); } #endif err = request_irq(ts->irq, ct36x_ts_irq, IRQF_DISABLED, DRIVER_NAME, ts); #ifdef LATE_UPGRADE disable_irq(ts->irq); #endif if ( err ) { dev_err(dev, "Unable to request irq for device %s.\n", DRIVER_NAME); goto ERR_IRQ_REQ; } /* Set device is ready */ ts->state = CT36X_STATE_NORMAL; /* power denoisy*/ //ct36x_chip_set_adapter_on(client, ts->data.buf); //ct36x_chip_set_adapter_off(client, ts->data.buf); //ct36x_ts_adapter(0); create_init(client->dev, ts_com); printk("%s: over\n",__func__); return 0; ERR_IRQ_REQ: destroy_workqueue(ts->workqueue); ERR_INPUT_REGIS: input_free_device(ts->input); ERR_INPUT_ALLOC: ERR_PLAT_RSC: ct36x_platform_put_resource(ts); ERR_I2C_CHK: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ts->early_suspend); #endif remove_proc_entry(DRIVER_NAME, NULL); ts_com->owner = NULL; return err; }
static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: " "Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; #if defined(CONFIG_PM) if (strcmp(input_dev->name, "tcc-gpiokey") == 0) event_dev = input_dev; else event_dev = NULL; #endif } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_early_suspend; ip->early_suspend.resume = gpio_event_late_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { pr_err("gpio_event_probe: Unable to register %s " "input device\n", ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct yas_state *st; struct iio_dev *indio_dev; int ret, i; s8 *bias; struct yas_acc_platform_data *pdata; I("%s\n", __func__); this_client = i2c; indio_dev = iio_device_alloc(sizeof(*st)); if (!indio_dev) { ret = -ENOMEM; goto error_ret; } i2c_set_clientdata(i2c, indio_dev); indio_dev->name = id->name; indio_dev->dev.parent = &i2c->dev; indio_dev->info = &yas_info; indio_dev->channels = yas_channels; indio_dev->num_channels = ARRAY_SIZE(yas_channels); indio_dev->modes = INDIO_DIRECT_MODE; st = iio_priv(indio_dev); st->client = i2c; st->sampling_frequency = 20; st->acc.callback.device_open = yas_device_open; st->acc.callback.device_close = yas_device_close; st->acc.callback.device_read = yas_device_read; st->acc.callback.device_write = yas_device_write; st->acc.callback.usleep = yas_usleep; st->acc.callback.current_time = yas_current_time; st->indio_dev = indio_dev; INIT_DELAYED_WORK(&st->work, yas_work_func); INIT_WORK(&st->resume_work, yas_resume_work_func); mutex_init(&st->lock); #ifdef CONFIG_HAS_EARLYSUSPEND st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; st->sus.suspend = yas_early_suspend; st->sus.resume = yas_late_resume; register_early_suspend(&st->sus); #endif ret = yas_probe_buffer(indio_dev); if (ret) goto error_free_dev; ret = yas_probe_trigger(indio_dev); if (ret) goto error_remove_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_remove_trigger; ret = yas_acc_driver_init(&st->acc); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.init(); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->acc.set_enable(1); if (ret < 0) { ret = -EFAULT; goto error_driver_term; } pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) E("%s: memory allocation for pdata failed.", __func__); else yas_parse_dt(&i2c->dev, pdata); for (i = 0; i < 3; i++) { st->accel_data[i] = 0; bias = (s8 *)&pdata->gs_kvalue; st->calib_bias[i] = -(bias[2-i] * YAS_GRAVITY_EARTH / 256); I("%s: calib_bias[%d] = %d\n", __func__, i, st->calib_bias[i]); } mutex_lock(&st->lock); if ((pdata->placement < 8) && (pdata->placement >= 0)) { ret = st->acc.set_position(pdata->placement); I("%s: set position = %d\n", __func__, pdata->placement); } else { ret = st->acc.set_position(5); D("%s: set default position = 5\n", __func__); } mutex_unlock(&st->lock); #ifdef CONFIG_CIR_ALWAYS_READY module.IRQ = pdata->intr; I("%s: IRQ = %d\n", __func__, module.IRQ); ret = request_irq(module.IRQ, kxtj2_irq_handler, IRQF_TRIGGER_RISING, "kxtj2", &module); enable_irq_wake(module.IRQ); if (ret) E("%s: Could not request irq = %d\n", __func__, module.IRQ); module.kxtj2_wq = create_singlethread_workqueue("kxtj2_wq"); if (!module.kxtj2_wq) { E("%s: Can't create workqueue\n", __func__); ret = -ENOMEM; goto error_create_singlethread_workqueue; } #endif init_irq_work(&st->iio_irq_work, iio_trigger_work); g_st = st; ret = create_sysfs_interfaces(st); if (ret) { E("%s: create_sysfs_interfaces fail, ret = %d\n", __func__, ret); goto err_create_fixed_sysfs; } I("%s: Successfully probe\n", __func__); return 0; err_create_fixed_sysfs: #ifdef CONFIG_CIR_ALWAYS_READY if (module.kxtj2_wq) destroy_workqueue(module.kxtj2_wq); error_create_singlethread_workqueue: #endif kfree(pdata); error_driver_term: st->acc.term(); error_unregister_iio: iio_device_unregister(indio_dev); error_remove_trigger: yas_remove_trigger(indio_dev); error_remove_buffer: yas_remove_buffer(indio_dev); error_free_dev: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&st->sus); #endif iio_device_free(indio_dev); error_ret: i2c_set_clientdata(i2c, NULL); this_client = NULL; return ret; }
static int __devinit rk616_hdmi_probe (struct platform_device *pdev) { int ret; struct rk616_hdmi *rk616_hdmi; struct resource __maybe_unused *mem; struct resource __maybe_unused *res; rk616_hdmi = devm_kzalloc(&pdev->dev, sizeof(*rk616_hdmi), GFP_KERNEL); if(!rk616_hdmi) { dev_err(&pdev->dev, ">>rk616_hdmi kmalloc fail!"); return -ENOMEM; } hdmi = &rk616_hdmi->g_hdmi; #ifdef CONFIG_ARCH_RK3026 rk616_hdmi->rk616_drv = NULL; #else rk616_hdmi->rk616_drv = dev_get_drvdata(pdev->dev.parent); if(!(rk616_hdmi->rk616_drv)) { dev_err(&pdev->dev,"null mfd device rk616!\n"); return -ENODEV; } #endif hdmi->dev = &pdev->dev; platform_set_drvdata(pdev, hdmi); if(HDMI_SOURCE_DEFAULT == HDMI_SOURCE_LCDC0) hdmi->lcdc = rk_get_lcdc_drv("lcdc0"); else hdmi->lcdc = rk_get_lcdc_drv("lcdc1"); if(hdmi->lcdc == NULL) { dev_err(hdmi->dev, "can not connect to video source lcdc\n"); ret = -ENXIO; goto err0; } hdmi->xscale = 100; hdmi->yscale = 100; hdmi_sys_init(); hdmi->workqueue = create_singlethread_workqueue("hdmi"); INIT_DELAYED_WORK(&(hdmi->delay_work), hdmi_work); #ifdef CONFIG_HAS_EARLYSUSPEND hdmi->early_suspend.suspend = hdmi_early_suspend; hdmi->early_suspend.resume = hdmi_early_resume; hdmi->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 10; register_early_suspend(&hdmi->early_suspend); #endif #ifdef CONFIG_SWITCH hdmi->switch_hdmi.name="hdmi"; switch_dev_register(&(hdmi->switch_hdmi)); #endif spin_lock_init(&hdmi->irq_lock); mutex_init(&hdmi->enable_mutex); INIT_DELAYED_WORK(&rk616_hdmi->rk616_delay_work, rk616_delay_work_func); /* get the IRQ */ // if(rk616->pdata->hdmi_irq != INVALID_GPIO) #ifdef CONFIG_ARCH_RK3026 hdmi->hclk = clk_get(NULL,"pclk_hdmi"); if(IS_ERR(hdmi->hclk)) { dev_err(hdmi->dev, "Unable to get hdmi hclk\n"); ret = -ENXIO; goto err0; } clk_enable(hdmi->hclk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(hdmi->dev, "Unable to get register resource\n"); ret = -ENXIO; goto err0; } hdmi->regbase_phy = res->start; hdmi->regsize_phy = (res->end - res->start) + 1; mem = request_mem_region(res->start, (res->end - res->start) + 1, pdev->name); if (!mem) { dev_err(hdmi->dev, "failed to request mem region for hdmi\n"); ret = -ENOENT; goto err0; } printk("res->start = 0x%x\n, xhc-------res->end = 0x%x\n", res->start, res->end); hdmi->regbase = (int)ioremap(res->start, (res->end - res->start) + 1); if (!hdmi->regbase) { dev_err(hdmi->dev, "cannot ioremap registers\n"); ret = -ENXIO; goto err1; } // rk30_mux_api_set(GPIO0A7_I2C3_SDA_HDMI_DDCSDA_NAME, GPIO0A_HDMI_DDCSDA); // rk30_mux_api_set(GPIO0A6_I2C3_SCL_HDMI_DDCSCL_NAME, GPIO0A_HDMI_DDCSCL); // rk30_mux_api_set(GPIO0B7_HDMI_HOTPLUGIN_NAME, GPIO0B_HDMI_HOTPLUGIN); iomux_set(HDMI_DDCSDA); iomux_set(HDMI_DDCSCL); iomux_set(HDMI_HOTPLUGIN); ret = rk616_hdmi_initial(); /* get the IRQ */ hdmi->irq = platform_get_irq(pdev, 0); if(hdmi->irq <= 0) { dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq); hdmi->irq = 0; } else { /* request the IRQ */ ret = request_irq(hdmi->irq, rk616_hdmi_irq, 0, dev_name(&pdev->dev), hdmi); if (ret) { dev_err(hdmi->dev, "hdmi request_irq failed (%d).\n", ret); goto err1; } } #else ret = rk616_hdmi_initial(); if(rk616_hdmi->rk616_drv->pdata->hdmi_irq != INVALID_GPIO) { INIT_WORK(&rk616_hdmi->rk616_irq_work_struct, rk616_irq_work_func); ret = gpio_request(rk616_hdmi->rk616_drv->pdata->hdmi_irq,"rk616_hdmi_irq"); if(ret < 0) { dev_err(hdmi->dev,"request gpio for rk616 hdmi irq fail\n"); } gpio_direction_input(rk616_hdmi->rk616_drv->pdata->hdmi_irq); hdmi->irq = gpio_to_irq(rk616_hdmi->rk616_drv->pdata->hdmi_irq); if(hdmi->irq <= 0) { dev_err(hdmi->dev, "failed to get hdmi irq resource (%d).\n", hdmi->irq); ret = -ENXIO; goto err1; } /* request the IRQ */ ret = request_irq(hdmi->irq, rk616_hdmi_irq, IRQF_TRIGGER_LOW, dev_name(&pdev->dev), &rk616_hdmi->rk616_irq_work_struct); if (ret) { dev_err(hdmi->dev, "hdmi request_irq failed (%d).\n", ret); goto err1; } } else { /* use roll polling method */ hdmi->irq = 0; } #endif hdmi_register_display_sysfs(hdmi, NULL); #if defined(CONFIG_DEBUG_FS) if(rk616_hdmi->rk616_drv && rk616_hdmi->rk616_drv->debugfs_dir) { debugfs_create_file("hdmi", S_IRUSR, rk616_hdmi->rk616_drv->debugfs_dir, rk616_hdmi->rk616_drv, &rk616_hdmi_reg_fops); } else { rk616_hdmi->debugfs_dir = debugfs_create_dir("rk616", NULL); if (IS_ERR(rk616_hdmi->debugfs_dir)) { dev_err(hdmi->dev,"failed to create debugfs dir for rk616!\n"); } else { debugfs_create_file("hdmi", S_IRUSR, rk616_hdmi->debugfs_dir, rk616_hdmi, &rk616_hdmi_reg_fops); } } #endif //rk616_delay_work_func(NULL); queue_delayed_work(hdmi->workqueue, &rk616_hdmi->rk616_delay_work, msecs_to_jiffies(0)); dev_info(hdmi->dev, "rk616 hdmi probe success.\n"); return 0; err1: #ifdef CONFIG_SWITCH switch_dev_unregister(&(hdmi->switch_hdmi)); #endif hdmi_unregister_display_sysfs(hdmi); #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&hdmi->early_suspend); #endif err0: hdmi_dbg(hdmi->dev, "rk616 hdmi probe error.\n"); kfree(hdmi); hdmi = NULL; return ret; }
static int __devinit ms5607_probe(struct i2c_client *client, const struct i2c_device_id *id) { int err; struct ms5607_data *ms5607; if (client->dev.platform_data == NULL) { dev_err(&client->dev, "platform data is NULL\n"); return -ENODEV; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C | I2C_FUNC_SMBUS_I2C_BLOCK)) { dev_err(&client->dev, "client not i2c capable\n"); return -ENODEV; } ms5607 = kzalloc(sizeof(*ms5607), GFP_KERNEL); if (!ms5607) { dev_err(&client->dev, "failed to allocate memory for module data\n"); return -ENOMEM; } mutex_init(&ms5607->lock); ms5607->client = client; i2c_set_clientdata(client, ms5607); ms5607->pdata = kmalloc(sizeof(*ms5607->pdata), GFP_KERNEL); if (!ms5607->pdata) { dev_err(&client->dev, "insufficient memory\n"); err = -ENOMEM; goto err_alloc_pdata; } memcpy(ms5607->pdata, client->dev.platform_data, sizeof(*ms5607->pdata)); if (ms5607->pdata->init) { err = ms5607->pdata->init(); if (err < 0) { dev_err(&client->dev, "init error\n"); goto err_init; } } ms5607->delay_ms = MS5607_DEFAULT_DELAY; ms5607->workqueue = create_singlethread_workqueue("ms5607"); if (ms5607->workqueue == NULL) { dev_err(&client->dev, "couldn't create workqueue\n"); err = -ENOMEM; goto err_create_qw; } err = ms5607_input_init(ms5607); if (err < 0) { dev_err(&client->dev, "input init error\n"); goto err_input_init; } /* Read coefficiency data */ ms5607_power_on(ms5607); ms5607_read_coeff(ms5607); ms5607_power_off(ms5607); ms5607->enabled = 0; #ifdef CONFIG_HAS_EARLYSUSPEND ms5607->es.level = EARLY_SUSPEND_LEVEL_DISABLE_FB + 10; ms5607->es.suspend = ms5607_early_suspend; ms5607->es.resume = ms5607_late_resume; register_early_suspend(&ms5607->es); #endif err = sysfs_create_group(&client->dev.kobj, &ms5607_attribute_group); if (err) { dev_err(&client->dev, "sysfs can not create group\n"); goto err_sysfs; } return 0; err_sysfs: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ms5607->es); #endif input_unregister_device(ms5607->input_dev); err_input_init: destroy_workqueue(ms5607->workqueue); err_create_qw: if (ms5607->pdata->exit) ms5607->pdata->exit(); err_init: kfree(ms5607->pdata); err_alloc_pdata: kfree(ms5607); return err; }
static void __exit console_early_suspend_exit(void) { unregister_early_suspend(&console_early_suspend_desc); }
static int __devinit rk30_hdmi_probe (struct platform_device *pdev) { int ret; struct resource *res; struct resource *mem; rk30_hdmi = kmalloc(sizeof(struct rk30_hdmi), GFP_KERNEL); if(!rk30_hdmi) { dev_err(&pdev->dev, ">>rk30 hdmi kmalloc fail!"); return -ENOMEM; } memset(rk30_hdmi, 0, sizeof(struct hdmi)); platform_set_drvdata(pdev, rk30_hdmi); rk30_hdmi->pwr_mode = PWR_SAVE_MODE_A; /* get the IRQ */ rk30_hdmi->irq = platform_get_irq(pdev, 0); if(rk30_hdmi->irq <= 0) { dev_err(&pdev->dev, "failed to get hdmi irq resource (%d).\n", rk30_hdmi->irq); ret = -ENXIO; goto err0; } rk30_hdmi->hclk = clk_get(NULL,"hclk_hdmi"); if(IS_ERR(rk30_hdmi->hclk)) { dev_err(&pdev->dev, "Unable to get hdmi hclk\n"); ret = -ENXIO; goto err0; } clk_enable(rk30_hdmi->hclk); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) { dev_err(&pdev->dev, "Unable to get register resource\n"); ret = -ENXIO; goto err0; } rk30_hdmi->regbase_phy = res->start; rk30_hdmi->regsize_phy = (res->end - res->start) + 1; mem = request_mem_region(res->start, (res->end - res->start) + 1, pdev->name); if (!mem) { dev_err(&pdev->dev, "failed to request mem region for hdmi\n"); ret = -ENOENT; goto err0; } rk30_hdmi->regbase = (int)ioremap(res->start, (res->end - res->start) + 1); if (!rk30_hdmi->regbase) { dev_err(&pdev->dev, "cannot ioremap registers\n"); ret = -ENXIO; goto err1; } #ifdef CONFIG_HAS_EARLYSUSPEND rk30_hdmi->early_suspend.suspend = rk30_hdmi_early_suspend; rk30_hdmi->early_suspend.resume = rk30_hdmi_early_resume; rk30_hdmi->early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 10; register_early_suspend(&rk30_hdmi->early_suspend); #endif rk30_hdmi_property.name = (char*)pdev->name; rk30_hdmi_property.priv = rk30_hdmi; rk30_hdmi->hdmi = hdmi_register(&rk30_hdmi_property, &rk30_hdmi_ops); if(rk30_hdmi->hdmi == NULL) { dev_err(&pdev->dev, "register hdmi device failed\n"); ret = -ENOMEM; goto err2; } rk30_hdmi->hdmi->dev = &pdev->dev; rk30_hdmi->hdmi->xscale = 95; rk30_hdmi->hdmi->yscale = 95; hdmi_io_remap(); spin_lock_init(&rk30_hdmi->irq_lock); /* request the IRQ */ ret = request_irq(rk30_hdmi->irq, hdmi_irq, 0, dev_name(&pdev->dev), rk30_hdmi); if (ret) { dev_err(&pdev->dev, "rk30 hdmi request_irq failed (%d).\n", ret); goto err3; } #ifdef CONFIG_RK_HDMI_GPIO_CEC GPIO_CecInit(RK30_PIN2_PA0); #endif dev_info(&pdev->dev, "rk30 hdmi probe sucess.\n"); return 0; err3: hdmi_unregister(rk30_hdmi->hdmi); err2: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&rk30_hdmi->early_suspend); #endif iounmap((void*)rk30_hdmi->regbase); err1: release_mem_region(res->start,(res->end - res->start) + 1); clk_disable(rk30_hdmi->hclk); err0: kfree(rk30_hdmi); rk30_hdmi = NULL; dev_err(&pdev->dev, "rk30 hdmi probe error.\n"); return ret; }
static int ct36x_ts_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct ct36x_ts_info *ts = NULL; struct device *dev = &client->dev; int err = -1; if (dev == NULL) { printk(KERN_ERR "%s(): dev not registered!\n", __func__); goto ERR_HW_INIT; } /* Check I2C Functionality */ err = i2c_check_functionality(client->adapter, I2C_FUNC_I2C); if ( !err ) { dev_err(dev, "Check I2C Functionality Failed.\n"); goto ERR_I2C_CHK; } ts = (struct ct36x_ts_info *)i2c_get_clientdata(client); if (ts == NULL) { printk(KERN_ERR "%s(): Not registered at I2C!\n", __func__); goto ERR_HW_INIT; } ts->ready = 0; // Device is not ready /* Init Hardware */ err = ct36x_ts_hw_init(ts); if ( err ) { dev_err(dev, "Platform HW Init Failed.\n"); goto ERR_HW_INIT; } /* HW Reset when Firmware request and update. */ ct36x_ts_hw_reset(ts); #if (CT36X_TS_CHIP_SEL == CT360_CHIP_VER) // Set I2C scon to 0x0f2f --> read version ts->data.buf[0] = 0xFF; ts->data.buf[1] = 0x0F; ts->data.buf[2] = 0x2A; #elif (CT36X_TS_CHIP_SEL == CT36X_CHIP_VER) // Set I2C scon to 0x3fff --> read version ts->data.buf[0] = 0xFF; ts->data.buf[1] = 0x3F; ts->data.buf[2] = 0xFF; #endif ct36x_ts_reg_write(client, client->addr, (char *) ts->data.buf, 3, CT36X_TS_I2C_SPEED); mdelay(10); ts->data.buf[0] = 0x00; ct36x_ts_reg_write(client, client->addr, (char *) ts->data.buf, 1, CT36X_TS_I2C_SPEED); mdelay(10); // do read version ct36x_ts_reg_read(client, client->addr, (char *) ts->data.buf, 1, CT36X_TS_I2C_SPEED); mdelay(10); dev_info(dev, "FW Version read: 0x%x \n", ts->data.buf[0]); #if defined(CONFIG_CT360_CHIP_UPDATE_SUPPORT) { char fw_ver_upd = Binary_Data[CT36X_TS_FW_VER_OFFSET]; dev_info(dev, "FW Version write: 0x%x \n", fw_ver_upd); if ( fw_ver_upd != ts->data.buf[0] ) { dev_info(dev, "Running bootloader ... \n"); err = ct36x_ts_bootloader(client); dev_info(dev, "Bootloader done, %s \n", err ? "Failed" : "OK"); } } #else dev_info(dev, "Bootloader support disabled, trying without...\n"); #endif // register early suspend #ifdef CONFIG_HAS_EARLYSUSPEND #if (CT36X_TS_HAS_EARLYSUSPEND) ts->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ts->early_suspend.suspend = ct36x_early_suspend; ts->early_suspend.resume = ct36x_early_resume; register_early_suspend(&ts->early_suspend); #endif #endif // allocate input device ts->input = input_allocate_device(); if ( !ts->input ) { dev_err(dev, "Unable to allocate input device for device %s.\n", DRIVER_NAME); err = -ENOMEM; goto ERR_INPUT_ALLOC; } __set_bit(EV_ABS, ts->input->evbit); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) __set_bit(INPUT_PROP_DIRECT, ts->input->propbit); #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)) input_mt_init_slots(ts->input, CT36X_TS_POINT_NUM); #endif input_set_abs_params(ts->input, ABS_MT_POSITION_X, 0, CT36X_TS_ABS_X_MAX, 0, 0); input_set_abs_params(ts->input, ABS_MT_POSITION_Y, 0, CT36X_TS_ABS_Y_MAX, 0, 0); input_set_abs_params(ts->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); input_set_abs_params(ts->input, ABS_MT_WIDTH_MAJOR, 0, 255, 0, 0); ts->input->name = DRIVER_NAME; ts->input->id.bustype = BUS_I2C; // register input device err = input_register_device(ts->input); if ( err ) { dev_err(dev, "Unable to register input device for device %s.\n", DRIVER_NAME); goto ERR_INPUT_REGIS; } /* ct36x_zx */ ts->ts_workqueue = create_singlethread_workqueue(CT36X_TS_WQ); if (!ts->ts_workqueue) { err = -ESRCH; printk(KERN_ERR "create_workqueue falled!\n"); goto ERR_TS_WQ; } // work INIT_WORK(&ts->event_work, ct36x_ts_workfunc); // Init irq ts->irq = gpio_to_irq(CT36X_TS_IRQ_PIN); //err = request_irq(ts->irq, ct36x_ts_irq, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, DRIVER_NAME, ts); err = request_irq(ts->irq, ct36x_ts_irq, IRQF_TRIGGER_FALLING, DRIVER_NAME, ts); /* ct36x_zx */ if ( err ) { dev_err(dev, "Unable to request irq.\n"); goto ERR_IRQ_REQEST; } // ESD timer #if (CT36X_TS_ESD_TIMER_INTERVAL) setup_timer(&ts->timer, ct36x_ts_timer, ts); ts->timer.expires = jiffies + HZ * CT36X_TS_ESD_TIMER_INTERVAL; add_timer(&ts->timer); ts->timer_on = 1; dev_info(dev, "ESD timer, %s \n", ts->timer_on ? "On" : "Off"); #endif /* Add another reset and then state we are ready */ ct36x_ts_hw_reset(ts); ts->ready = 1; // Device is ready return 0; ERR_TS_WQ: ERR_IRQ_REQEST: ERR_INPUT_REGIS: input_free_device(ts->input); ERR_INPUT_ALLOC: ERR_I2C_CHK: #ifdef CONFIG_HAS_EARLYSUSPEND #if (CT36X_TS_HAS_EARLYSUSPEND) unregister_early_suspend(&ts->early_suspend); #endif #endif ERR_HW_INIT: ct36x_ts_hw_exit(ts); return err; }
static int __init gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct input_dev *input_dev; struct gpio_event_platform_data *event_info; event_info = pdev->dev.platform_data; if (event_info == NULL) { pr_err("gpio_event_probe: No pdata\n"); return -ENODEV; } if (event_info->name == NULL || event_info->info == NULL || event_info->info_count == 0) { pr_err("gpio_event_probe: Incomplete pdata\n"); return -ENODEV; } ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate private data\n"); goto err_kp_alloc_failed; } platform_set_drvdata(pdev, ip); input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; pr_err("gpio_event_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); ip->input_dev = input_dev; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } input_dev->name = ip->info->name; input_dev->event = gpio_input_event; err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; err = input_register_device(input_dev); if (err) { pr_err("gpio_event_probe: Unable to register %s input device\n", input_dev->name); goto err_input_register_device_failed; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } input_free_device(input_dev); err_input_dev_alloc_failed: kfree(ip); err_kp_alloc_failed: return err; }
static int cpufreq_governor_interactivex(struct cpufreq_policy *new_policy, unsigned int event) { int rc; unsigned int min_freq = ~0; unsigned int max_freq = 0; unsigned int i; struct cpufreq_frequency_table *freq_table; switch (event) { case CPUFREQ_GOV_START: if (!cpu_online(new_policy->cpu)) return -EINVAL; /* * Do not register the idle hook and create sysfs * entries if we have already done so. */ if (atomic_inc_return(&active_count) > 1) return 0; rc = sysfs_create_group(cpufreq_global_kobject, &interactivex_attr_group); if (rc) return rc; pm_idle_old = pm_idle; pm_idle = cpufreq_idle; policy = new_policy; enabled = 1; register_early_suspend(&interactivex_power_suspend); pr_info("[imoseyon] interactiveX active\n"); freq_table = cpufreq_frequency_get_table(new_policy->cpu); for (i = 0; (freq_table[i].frequency != CPUFREQ_TABLE_END); i++) { unsigned int freq = freq_table[i].frequency; if (freq == CPUFREQ_ENTRY_INVALID) { continue; } if (freq < min_freq) min_freq = freq; if (freq > max_freq) max_freq = freq; } resum_speed = freq_table[(i-1)/2].frequency > min_freq ? freq_table[(i-1)/2].frequency : max_freq; //Value in midrange of available CPU frequencies if sufficient number of freq bins available freq_threshld = max_freq; break; case CPUFREQ_GOV_STOP: if (atomic_dec_return(&active_count) > 1) return 0; sysfs_remove_group(cpufreq_global_kobject, &interactivex_attr_group); pm_idle = pm_idle_old; del_timer(&per_cpu(cpu_timer, new_policy->cpu)); enabled = 0; unregister_early_suspend(&interactivex_power_suspend); pr_info("[imoseyon] interactiveX inactive\n"); break; case CPUFREQ_GOV_LIMITS: if (new_policy->max < new_policy->cur) __cpufreq_driver_target(new_policy, new_policy->max, CPUFREQ_RELATION_H); else if (new_policy->min > new_policy->cur) __cpufreq_driver_target(new_policy, new_policy->min, CPUFREQ_RELATION_L); break; } return 0; }
static int l3g4200d_probe(struct i2c_client *client, const struct i2c_device_id *devid) { struct l3g4200d_data *data; struct gyro_platform_data *platform_data = NULL; int ret = -1; int tempvalue; GYRO_DBG("l3g4200d_probe start!\n"); if (client->dev.platform_data == NULL) { dev_err(&client->dev, "platform data is NULL. exiting.\n"); ret = -ENODEV; goto exit; } /*gyro mate power*/ platform_data = client->dev.platform_data; if(platform_data->gyro_power) { ret = platform_data->gyro_power(IC_PM_ON); if( ret < 0) { dev_err(&client->dev, "gyro power on error!\n"); goto exit; } } if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { ret = -ENODEV; goto exit_pm_off; } if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)){ ret = -ENODEV; goto exit_pm_off; } /* * OK. For now, we presume we have a valid client. We now create the * client structure, even though we cannot fill it completely yet. */ data = kzalloc(sizeof(struct l3g4200d_data), GFP_KERNEL); if (NULL == data) { dev_err(&client->dev, "failed to allocate memory for module data\n"); ret = -ENOMEM; goto exit_pm_off; } mutex_init(&data->mlock); INIT_WORK(&data->work, gy_work_func); i2c_set_clientdata(client, data); data->client = client; data->pdata = platform_data; ret = l3g4200d_validate_pdata(data); if (ret < 0) { dev_err(&client->dev, "failed to validate platform data\n"); goto exit_kfree; } ret = i2c_smbus_read_byte(client); if ( ret < 0) { GYRO_DBG("i2c_smbus_read_byte error!!\n"); goto err_detect_failed; } else { GYRO_DBG("L3G4200D Device detected!\n"); } /* read chip id */ tempvalue = i2c_smbus_read_word_data(client, WHO_AM_I); if ((tempvalue & 0x00FF) == 0x00D3) { GYRO_DBG("I2C driver registered!\n"); } else { data->client = NULL; ret = -ENODEV; goto err_detect_failed; } if (sensor_dev == NULL) { data->input_dev = input_allocate_device(); if (data->input_dev == NULL) { ret = -ENOMEM; printk(KERN_ERR "gs_probe: Failed to allocate input device\n"); goto err_input_dev_alloc_failed; } data->input_dev->name = "gy_sensors"; sensor_dev = data->input_dev; }else{ data->input_dev = sensor_dev; } data->input_dev->id.vendor = VENDOR; #if 0 set_bit(EV_REL,data->input_dev->evbit); set_bit(REL_RX, data->input_dev->absbit); set_bit(REL_RY, data->input_dev->absbit); set_bit(REL_RZ, data->input_dev->absbit); #endif set_bit(EV_ABS,data->input_dev->evbit); /* modify the func of init */ input_set_abs_params(data->input_dev, ABS_RX, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_RY, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_RZ, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_X, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_Y, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_Z, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_THROTTLE, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_RUDDER, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_WHEEL, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_GAS, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_HAT0X, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_HAT0Y, MIN_VALUE, MAX_VALUE, 0, 0); input_set_abs_params(data->input_dev, ABS_BRAKE, MIN_VALUE, MAX_VALUE, 0, 0); set_bit(EV_SYN,data->input_dev->evbit); data->input_dev->id.bustype = BUS_I2C; input_set_drvdata(data->input_dev, data); ret = input_register_device(data->input_dev); if (ret) { printk(KERN_ERR "gy_probe: Unable to register %s input device\n", data->input_dev->name); /* create l3g-dev device class */ goto err_input_register_device_failed; } ret = misc_register(&gysensor_device); if (ret) { printk(KERN_ERR "gy_probe: gysensor_device register failed\n"); goto err_misc_device_register_failed; } hrtimer_init(&data->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); data->timer.function = gy_timer_func; atomic_set(&a_flag, 0); data->flags = -1; #ifdef CONFIG_HAS_EARLYSUSPEND data->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; data->early_suspend.suspend = gy_early_suspend; data->early_suspend.resume = gy_late_resume; register_early_suspend(&data->early_suspend); #endif GYRO_DBG("L3G4200D device created successfully\n"); gy_wq = create_singlethread_workqueue("gy_wq"); /* log for create workqueue fail */ if (!gy_wq) { ret = -ENOMEM; printk(KERN_ERR "%s, line %d: create_singlethread_workqueue fail!\n", __func__, __LINE__); goto err_gy_create_workqueue_failed; } gyro = data; // hrtimer_start(&this_gs_data->timer, ktime_set(0, 500000000), HRTIMER_MODE_REL); #ifdef CONFIG_HUAWEI_HW_DEV_DCT /* detect current device successful, set the flag as present */ set_hw_dev_flag(DEV_I2C_GYROSCOPE); #endif ret = set_sensor_input(GYRO, data->input_dev->dev.kobj.name); if (ret) { dev_err(&client->dev, "%s set_sensor_input failed\n", __func__); goto err_misc_device_register_failed; } printk(KERN_DEBUG "l3g4200d_probe successful"); set_sensors_list(GY_SENSOR); return 0; /*add gyro exception process*/ err_gy_create_workqueue_failed: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&data->early_suspend); #endif hrtimer_cancel(&data->timer); err_misc_device_register_failed: misc_deregister(&gysensor_device); err_input_register_device_failed: input_free_device(gyro->input_dev); err_input_dev_alloc_failed: err_detect_failed: exit_kfree: kfree(gyro); exit_pm_off: /*No need to power down*/ exit: return ret; }
static int __devinit sec_keyboard_probe(struct platform_device *pdev) { struct sec_keyboard_platform_data *pdata = pdev->dev.platform_data; struct sec_keyboard_drvdata *ddata; struct input_dev *input; int i, error; if (pdata == NULL) { printk(KERN_ERR "%s: no pdata\n", __func__); return -ENODEV; } ddata = kzalloc(sizeof(struct sec_keyboard_drvdata), GFP_KERNEL); if (NULL == ddata) { error = -ENOMEM; goto err_free_mem; } input = input_allocate_device(); if (NULL == input) { printk(KERN_ERR "[Keyboard] failed to allocate input device.\n"); error = -ENOMEM; goto err_free_mem; } ddata->input_dev = input; ddata->acc_power = pdata->acc_power; ddata->check_uart_path = pdata->check_uart_path; ddata->acc_int_gpio = pdata->accessory_irq_gpio; ddata->led_on = false; ddata->dockconnected = false; ddata->pre_connected = false; ddata->univ_kbd_dock = false; ddata->remap_key = 0; ddata->kl = UNKOWN_KEYLAYOUT; ddata->callbacks.check_keyboard_dock = check_keyboard_dock; if (pdata->register_cb) pdata->register_cb(&ddata->callbacks); ddata->noti_univ_kbd_dock = pdata->noti_univ_kbd_dock; memcpy(ddata->keycode, sec_keycodes, sizeof(sec_keycodes)); INIT_DELAYED_WORK(&ddata->remap_dwork, sec_keyboard_remapkey); INIT_DELAYED_WORK(&ddata->power_dwork, sec_keyboard_power); INIT_DELAYED_WORK(&ddata->ack_dwork, sec_keyboard_ack); platform_set_drvdata(pdev, ddata); input_set_drvdata(input, ddata); input->name = pdev->name; input->dev.parent = &pdev->dev; input->id.bustype = BUS_RS232; input->event = sec_keyboard_event; __set_bit(EV_KEY, input->evbit); __set_bit(EV_LED, input->evbit); __set_bit(LED_CAPSL, input->ledbit); /* framework doesn't use repeat event */ /* __set_bit(EV_REP, input->evbit); */ for (i = 0; i < KEYBOARD_SIZE; i++) { if (KEY_RESERVED != ddata->keycode[i]) input_set_capability(input, EV_KEY, ddata->keycode[i]); } /* for the UK keyboard */ input_set_capability(input, EV_KEY, KEY_NUMERIC_POUND); /* for the remaped keys */ input_set_capability(input, EV_KEY, KEY_NEXTSONG); input_set_capability(input, EV_KEY, KEY_PREVIOUSSONG); /* for the wakeup key */ input_set_capability(input, EV_KEY, KEY_WAKEUP); error = input_register_device(input); if (error < 0) { printk(KERN_ERR "[Keyboard] failed to register input device.\n"); error = -ENOMEM; goto err_input_allocate_device; } ddata->serio_driver.driver.name = pdev->name; ddata->serio_driver.id_table = sec_serio_ids; ddata->serio_driver.interrupt = sec_keyboard_interrupt, ddata->serio_driver.connect = sec_keyboard_connect, ddata->serio_driver.disconnect = sec_keyboard_disconnect, error = serio_register_driver(&ddata->serio_driver); if (error < 0) { printk(KERN_ERR "[Keyboard] failed to register serio\n"); error = -ENOMEM; goto err_reg_serio; } #ifdef CONFIG_HAS_EARLYSUSPEND ddata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ddata->early_suspend.suspend = keyboard_early_suspend; ddata->early_suspend.resume = keyboard_late_resume; register_early_suspend(&ddata->early_suspend); #endif /* CONFIG_HAS_EARLYSUSPEND */ ddata->keyboard_dev = device_create(sec_class, NULL, 0, ddata, "sec_keyboard"); if (IS_ERR(ddata->keyboard_dev)) { printk(KERN_ERR "[Keyboard] failed to create device for the sysfs\n"); error = -ENODEV; goto err_sysfs_create_group; } error = sysfs_create_group(&ddata->keyboard_dev->kobj, &attr_group); if (error) { printk(KERN_ERR "[Keyboard] failed to create sysfs group\n"); goto err_sysfs_create_group; } return 0; err_sysfs_create_group: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ddata->early_suspend); #endif serio_unregister_driver(&ddata->serio_driver); err_reg_serio: err_input_allocate_device: input_free_device(input); del_timer_sync(&ddata->remap_dwork.timer); del_timer_sync(&ddata->power_dwork.timer); del_timer_sync(&ddata->ack_dwork.timer); err_free_mem: kfree(ddata); return error; }
static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct yas_state *st; struct iio_dev *indio_dev; struct yas53x_platform_data *pdata; int ret; D("%s", __func__); this_client = i2c; indio_dev = iio_allocate_device(sizeof(*st)); if (!indio_dev) { ret = -ENOMEM; goto error_ret; } i2c_set_clientdata(i2c, indio_dev); indio_dev->name = YAS_MAG_NAME; indio_dev->dev.parent = &i2c->dev; indio_dev->info = &yas_info; indio_dev->channels = yas_channels; indio_dev->num_channels = ARRAY_SIZE(yas_channels); indio_dev->modes = INDIO_DIRECT_MODE; printk("YAMAHA id->name[%s]\n", id->name); st = iio_priv(indio_dev); st->client = i2c; st->sampling_frequency = 20; st->mag.callback.device_open = yas_device_open; st->mag.callback.device_close = yas_device_close; st->mag.callback.device_read = yas_device_read; st->mag.callback.device_write = yas_device_write; st->mag.callback.usleep = yas_usleep; st->mag.callback.current_time = yas_current_time; INIT_DELAYED_WORK(&st->work, yas_work_func); mutex_init(&st->lock); #ifdef CONFIG_HAS_EARLYSUSPEND st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; st->sus.suspend = yas_early_suspend; st->sus.resume = yas_late_resume; register_early_suspend(&st->sus); #endif ret = yas_probe_buffer(indio_dev); if (ret) goto error_free_dev; ret = yas_probe_trigger(indio_dev); if (ret) goto error_remove_buffer; ret = iio_device_register(indio_dev); if (ret) goto error_remove_trigger; ret = yas_mag_driver_init(&st->mag); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->mag.init(); if (ret < 0) { ret = -EFAULT; goto error_unregister_iio; } ret = st->mag.set_enable(1); if (ret < 0) { ret = -EFAULT; goto error_driver_term; } pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); if (pdata == NULL) { D("%s: memory allocation for pdata failed.", __func__); } else { yas53x_parse_dt(&i2c->dev , pdata); } mutex_lock(&st->lock); if (pdata->chip_layout<8 && pdata->chip_layout>=0) { ret = st->mag.set_position(pdata->chip_layout); D("%s: set position to %d\n", __func__, pdata->chip_layout); } else { ret = st->mag.set_position(5); D("%s: set default position: 5\n", __func__); } mutex_unlock(&st->lock); return 0; error_driver_term: st->mag.term(); error_unregister_iio: iio_device_unregister(indio_dev); error_remove_trigger: yas_remove_trigger(indio_dev); error_remove_buffer: yas_remove_buffer(indio_dev); error_free_dev: #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&st->sus); #endif iio_free_device(indio_dev); error_ret: i2c_set_clientdata(i2c, NULL); this_client = NULL; return ret; }
static int gpio_event_probe(struct platform_device *pdev) { int err; struct gpio_event *ip; struct gpio_event_platform_data *event_info; int dev_count = 1; int i; int registered = 0; event_info = pdev->dev.platform_data; if (event_info == NULL) { KEY_LOGE("KEY_ERR: %s: No pdata\n", __func__); return -ENODEV; } if ((!event_info->name && !event_info->names[0]) || !event_info->info || !event_info->info_count) { KEY_LOGE("KEY_ERR: %s: Incomplete pdata\n", __func__); return -ENODEV; } if (!event_info->name) while (event_info->names[dev_count]) dev_count++; ip = kzalloc(sizeof(*ip) + sizeof(ip->state[0]) * event_info->info_count + sizeof(*ip->input_devs) + sizeof(ip->input_devs->dev[0]) * dev_count, GFP_KERNEL); if (ip == NULL) { err = -ENOMEM; KEY_LOGE("KEY_ERR: %s: Failed to allocate private data\n", __func__); goto err_kp_alloc_failed; } ip->input_devs = (void*)&ip->state[event_info->info_count]; platform_set_drvdata(pdev, ip); for (i = 0; i < dev_count; i++) { struct input_dev *input_dev = input_allocate_device(); if (input_dev == NULL) { err = -ENOMEM; KEY_LOGE("KEY_ERR: %s: " "Failed to allocate input device\n", __func__); goto err_input_dev_alloc_failed; } input_set_drvdata(input_dev, ip); input_dev->name = event_info->name ? event_info->name : event_info->names[i]; input_dev->event = gpio_input_event; ip->input_devs->dev[i] = input_dev; #ifdef CONFIG_TOUCHSCREEN_CYPRESS_SWEEP2WAKE if (!strcmp(input_dev->name, "keypad_8960")) { sweep2wake_setdev(input_dev); printk(KERN_INFO "[sweep2wake]: set device %s\n", input_dev->name); } #endif } ip->input_devs->count = dev_count; ip->info = event_info; if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND ip->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; ip->early_suspend.suspend = gpio_event_suspend; ip->early_suspend.resume = gpio_event_resume; register_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 1); } err = gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_INIT); if (err) goto err_call_all_func_failed; for (i = 0; i < dev_count; i++) { err = input_register_device(ip->input_devs->dev[i]); if (err) { KEY_LOGE("KEY_ERR: %s: Unable to register %s " "input device\n", __func__, ip->input_devs->dev[i]->name); goto err_input_register_device_failed; } registered++; } return 0; err_input_register_device_failed: gpio_event_call_all_func(ip, GPIO_EVENT_FUNC_UNINIT); err_call_all_func_failed: if (event_info->power) { #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ip->early_suspend); #endif ip->info->power(ip->info, 0); } for (i = 0; i < registered; i++) input_unregister_device(ip->input_devs->dev[i]); for (i = dev_count - 1; i >= registered; i--) { input_free_device(ip->input_devs->dev[i]); err_input_dev_alloc_failed: ; } kfree(ip); err_kp_alloc_failed: return err; }
static void __exit gpu_control_exit(void) { unregister_early_suspend(&gpu_control_suspend_handler); exit_gpu_proc_fs(); }