Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: iio: light: isl29028: Use devm_iio_device_alloc

Using devm_iio_device_alloc makes code simpler.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Cc: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Sachin Kamat and committed by
Jonathan Cameron
80cab1da e434dcf3

+4 -9
+4 -9
drivers/staging/iio/light/isl29028.c
··· 482 482 struct iio_dev *indio_dev; 483 483 int ret; 484 484 485 - indio_dev = iio_device_alloc(sizeof(*chip)); 485 + indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); 486 486 if (!indio_dev) { 487 487 dev_err(&client->dev, "iio allocation fails\n"); 488 488 return -ENOMEM; ··· 498 498 if (IS_ERR(chip->regmap)) { 499 499 ret = PTR_ERR(chip->regmap); 500 500 dev_err(chip->dev, "regmap initialization failed: %d\n", ret); 501 - goto exit_iio_free; 501 + return ret; 502 502 } 503 503 504 504 ret = isl29028_chip_init(chip); 505 505 if (ret < 0) { 506 506 dev_err(chip->dev, "chip initialization failed: %d\n", ret); 507 - goto exit_iio_free; 507 + return ret; 508 508 } 509 509 510 510 indio_dev->info = &isl29028_info; ··· 517 517 if (ret < 0) { 518 518 dev_err(chip->dev, "iio registration fails with error %d\n", 519 519 ret); 520 - goto exit_iio_free; 520 + return ret; 521 521 } 522 522 return 0; 523 - 524 - exit_iio_free: 525 - iio_device_free(indio_dev); 526 - return ret; 527 523 } 528 524 529 525 static int isl29028_remove(struct i2c_client *client) ··· 527 531 struct iio_dev *indio_dev = i2c_get_clientdata(client); 528 532 529 533 iio_device_unregister(indio_dev); 530 - iio_device_free(indio_dev); 531 534 return 0; 532 535 } 533 536