static int __devinit tps6586x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct tps6586x_platform_data *pdata = client->dev.platform_data; struct tps6586x *tps6586x; int ret; if (!pdata) { dev_err(&client->dev, "tps6586x requires platform data\n"); return -ENOTSUPP; } ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); if (ret < 0) { dev_err(&client->dev, "Chip ID read failed: %d\n", ret); return -EIO; } if (ret != TPS658621A_VERSIONCRC) { dev_err(&client->dev, "Unsupported chip ID: %x\n", ret); return -ENODEV; } tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); if (tps6586x == NULL) return -ENOMEM; tps6586x->client = client; tps6586x->dev = &client->dev; i2c_set_clientdata(client, tps6586x); mutex_init(&tps6586x->lock); ret = tps6586x_add_subdevs(tps6586x, pdata); if (ret) { dev_err(&client->dev, "add devices failed: %d\n", ret); goto err_add_devs; } tps6586x_gpio_init(tps6586x, pdata->gpio_base); return 0; err_add_devs: kfree(tps6586x); return ret; }
static int __devinit tps6586x_i2c_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct tps6586x_platform_data *pdata = client->dev.platform_data; struct tps6586x *tps6586x; int ret; if (!pdata) { dev_err(&client->dev, "tps6586x requires platform data\n"); return -ENOTSUPP; } ret = i2c_smbus_read_byte_data(client, TPS6586X_VERSIONCRC); if (ret < 0) { dev_err(&client->dev, "Chip ID read failed: %d\n", ret); return -EIO; } dev_info(&client->dev, "VERSIONCRC is %02x\n", ret); tps6586x = kzalloc(sizeof(struct tps6586x), GFP_KERNEL); if (tps6586x == NULL) return -ENOMEM; tps6586x->client = client; tps6586x->dev = &client->dev; i2c_set_clientdata(client, tps6586x); mutex_init(&tps6586x->lock); if (client->irq) { ret = tps6586x_irq_init(tps6586x, client->irq, pdata->irq_base); if (ret) { dev_err(&client->dev, "IRQ init failed: %d\n", ret); goto err_irq_init; } } ret = tps6586x_gpio_init(tps6586x, pdata->gpio_base); if (ret) { dev_err(&client->dev, "GPIO registration failed: %d\n", ret); goto err_gpio_init; } ret = tps6586x_add_subdevs(tps6586x, pdata); if (ret) { dev_err(&client->dev, "add devices failed: %d\n", ret); goto err_add_devs; } tps6586x_i2c_client = client; return 0; err_add_devs: if (pdata->gpio_base) { ret = gpiochip_remove(&tps6586x->gpio); if (ret) dev_err(&client->dev, "Can't remove gpio chip: %d\n", ret); } err_gpio_init: if (client->irq) free_irq(client->irq, tps6586x); err_irq_init: kfree(tps6586x); return ret; }