diff options
-rw-r--r-- | drivers/staging/iio/cdc/ad7150.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/drivers/staging/iio/cdc/ad7150.c b/drivers/staging/iio/cdc/ad7150.c index 687dd2c91437..f4a0341cc70c 100644 --- a/drivers/staging/iio/cdc/ad7150.c +++ b/drivers/staging/iio/cdc/ad7150.c | |||
@@ -558,11 +558,9 @@ static int ad7150_probe(struct i2c_client *client, | |||
558 | struct ad7150_chip_info *chip; | 558 | struct ad7150_chip_info *chip; |
559 | struct iio_dev *indio_dev; | 559 | struct iio_dev *indio_dev; |
560 | 560 | ||
561 | indio_dev = iio_device_alloc(sizeof(*chip)); | 561 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*chip)); |
562 | if (indio_dev == NULL) { | 562 | if (!indio_dev) |
563 | ret = -ENOMEM; | 563 | return -ENOMEM; |
564 | goto error_ret; | ||
565 | } | ||
566 | chip = iio_priv(indio_dev); | 564 | chip = iio_priv(indio_dev); |
567 | mutex_init(&chip->state_lock); | 565 | mutex_init(&chip->state_lock); |
568 | /* this is only used for device removal purposes */ | 566 | /* this is only used for device removal purposes */ |
@@ -581,7 +579,7 @@ static int ad7150_probe(struct i2c_client *client, | |||
581 | indio_dev->modes = INDIO_DIRECT_MODE; | 579 | indio_dev->modes = INDIO_DIRECT_MODE; |
582 | 580 | ||
583 | if (client->irq) { | 581 | if (client->irq) { |
584 | ret = request_threaded_irq(client->irq, | 582 | ret = devm_request_threaded_irq(&client->dev, client->irq, |
585 | NULL, | 583 | NULL, |
586 | &ad7150_event_handler, | 584 | &ad7150_event_handler, |
587 | IRQF_TRIGGER_RISING | | 585 | IRQF_TRIGGER_RISING | |
@@ -590,11 +588,11 @@ static int ad7150_probe(struct i2c_client *client, | |||
590 | "ad7150_irq1", | 588 | "ad7150_irq1", |
591 | indio_dev); | 589 | indio_dev); |
592 | if (ret) | 590 | if (ret) |
593 | goto error_free_dev; | 591 | return ret; |
594 | } | 592 | } |
595 | 593 | ||
596 | if (client->dev.platform_data) { | 594 | if (client->dev.platform_data) { |
597 | ret = request_threaded_irq(*(unsigned int *) | 595 | ret = devm_request_threaded_irq(&client->dev, *(unsigned int *) |
598 | client->dev.platform_data, | 596 | client->dev.platform_data, |
599 | NULL, | 597 | NULL, |
600 | &ad7150_event_handler, | 598 | &ad7150_event_handler, |
@@ -604,28 +602,17 @@ static int ad7150_probe(struct i2c_client *client, | |||
604 | "ad7150_irq2", | 602 | "ad7150_irq2", |
605 | indio_dev); | 603 | indio_dev); |
606 | if (ret) | 604 | if (ret) |
607 | goto error_free_irq; | 605 | return ret; |
608 | } | 606 | } |
609 | 607 | ||
610 | ret = iio_device_register(indio_dev); | 608 | ret = iio_device_register(indio_dev); |
611 | if (ret) | 609 | if (ret) |
612 | goto error_free_irq2; | 610 | return ret; |
613 | 611 | ||
614 | dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n", | 612 | dev_info(&client->dev, "%s capacitive sensor registered,irq: %d\n", |
615 | id->name, client->irq); | 613 | id->name, client->irq); |
616 | 614 | ||
617 | return 0; | 615 | return 0; |
618 | error_free_irq2: | ||
619 | if (client->dev.platform_data) | ||
620 | free_irq(*(unsigned int *)client->dev.platform_data, | ||
621 | indio_dev); | ||
622 | error_free_irq: | ||
623 | if (client->irq) | ||
624 | free_irq(client->irq, indio_dev); | ||
625 | error_free_dev: | ||
626 | iio_device_free(indio_dev); | ||
627 | error_ret: | ||
628 | return ret; | ||
629 | } | 616 | } |
630 | 617 | ||
631 | static int ad7150_remove(struct i2c_client *client) | 618 | static int ad7150_remove(struct i2c_client *client) |
@@ -633,13 +620,6 @@ static int ad7150_remove(struct i2c_client *client) | |||
633 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | 620 | struct iio_dev *indio_dev = i2c_get_clientdata(client); |
634 | 621 | ||
635 | iio_device_unregister(indio_dev); | 622 | iio_device_unregister(indio_dev); |
636 | if (client->irq) | ||
637 | free_irq(client->irq, indio_dev); | ||
638 | |||
639 | if (client->dev.platform_data) | ||
640 | free_irq(*(unsigned int *)client->dev.platform_data, indio_dev); | ||
641 | |||
642 | iio_device_free(indio_dev); | ||
643 | 623 | ||
644 | return 0; | 624 | return 0; |
645 | } | 625 | } |