static void ms5607_disable(struct ms5607_data *ms5607) { if (ms5607->powered) { cancel_delayed_work_sync(&ms5607->input_work); ms5607_power_off(ms5607); ms5607->powered = false; } }
static int __devexit ms5607_remove(struct i2c_client *client) { struct ms5607_data *ms5607 = i2c_get_clientdata(client); input_unregister_device(ms5607->input_dev); flush_workqueue(ms5607->workqueue); destroy_workqueue(ms5607->workqueue); ms5607_power_off(ms5607); if (ms5607->pdata->exit) ms5607->pdata->exit(); kfree(ms5607->pdata); sysfs_remove_group(&client->dev.kobj, &ms5607_attribute_group); kfree(ms5607); return 0; }
static int __devexit ms5607_remove(struct i2c_client *client) { struct ms5607_data *ms5607 = i2c_get_clientdata(client); input_unregister_device(ms5607->input_dev); flush_workqueue(ms5607->workqueue); destroy_workqueue(ms5607->workqueue); #ifdef CONFIG_HAS_EARLYSUSPEND unregister_early_suspend(&ms5607->es); #endif ms5607_power_off(ms5607); if (ms5607->pdata->exit) ms5607->pdata->exit(); kfree(ms5607->pdata); sysfs_remove_group(&client->dev.kobj, &ms5607_attribute_group); kfree(ms5607); return 0; }
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; }