static int aat2870_i2c_suspend(struct i2c_client *client, pm_message_t state) { struct aat2870_data *aat2870 = i2c_get_clientdata(client); aat2870_disable(aat2870); return 0; }
static int aat2870_i2c_suspend(struct device *dev) { struct i2c_client *client = to_i2c_client(dev); struct aat2870_data *aat2870 = i2c_get_clientdata(client); aat2870_disable(aat2870); return 0; }
static int aat2870_i2c_remove(struct i2c_client *client) { struct aat2870_data *aat2870 = i2c_get_clientdata(client); aat2870_uninit_debugfs(aat2870); mfd_remove_devices(aat2870->dev); aat2870_disable(aat2870); if (aat2870->uninit) aat2870->uninit(aat2870); return 0; }
static int aat2870_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct aat2870_platform_data *pdata = client->dev.platform_data; struct aat2870_data *aat2870; int i, j; int ret = 0; aat2870 = kzalloc(sizeof(struct aat2870_data), GFP_KERNEL); if (!aat2870) { dev_err(&client->dev, "Failed to allocate memory for aat2870\n"); ret = -ENOMEM; goto out; } aat2870->dev = &client->dev; dev_set_drvdata(aat2870->dev, aat2870); aat2870->client = client; i2c_set_clientdata(client, aat2870); aat2870->reg_cache = aat2870_regs; if (pdata->en_pin < 0) aat2870->en_pin = -1; else aat2870->en_pin = pdata->en_pin; aat2870->init = pdata->init; aat2870->uninit = pdata->uninit; aat2870->read = aat2870_read; aat2870->write = aat2870_write; aat2870->update = aat2870_update; mutex_init(&aat2870->io_lock); if (aat2870->init) aat2870->init(aat2870); if (aat2870->en_pin >= 0) { ret = gpio_request_one(aat2870->en_pin, GPIOF_OUT_INIT_HIGH, "aat2870-en"); if (ret < 0) { dev_err(&client->dev, "Failed to request GPIO %d\n", aat2870->en_pin); goto out_kfree; } } aat2870_enable(aat2870); for (i = 0; i < pdata->num_subdevs; i++) { for (j = 0; j < ARRAY_SIZE(aat2870_devs); j++) { if ((pdata->subdevs[i].id == aat2870_devs[j].id) && !strcmp(pdata->subdevs[i].name, aat2870_devs[j].name)) { aat2870_devs[j].platform_data = pdata->subdevs[i].platform_data; break; } } } ret = mfd_add_devices(aat2870->dev, 0, aat2870_devs, ARRAY_SIZE(aat2870_devs), NULL, 0, NULL); if (ret != 0) { dev_err(aat2870->dev, "Failed to add subdev: %d\n", ret); goto out_disable; } aat2870_init_debugfs(aat2870); return 0; out_disable: aat2870_disable(aat2870); if (aat2870->en_pin >= 0) gpio_free(aat2870->en_pin); out_kfree: kfree(aat2870); out: return ret; }