summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/staging/iio/light/tsl2563.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/staging/iio/light/tsl2563.c b/drivers/staging/iio/light/tsl2563.c
index aca1e0380ef8..546c95a4ea9e 100644
--- a/drivers/staging/iio/light/tsl2563.c
+++ b/drivers/staging/iio/light/tsl2563.c
@@ -708,7 +708,6 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
708 struct tsl2563_chip *chip; 708 struct tsl2563_chip *chip;
709 struct tsl2563_platform_data *pdata = client->dev.platform_data; 709 struct tsl2563_platform_data *pdata = client->dev.platform_data;
710 int err = 0; 710 int err = 0;
711 int ret;
712 u8 id = 0; 711 u8 id = 0;
713 712
714 indio_dev = iio_allocate_device(sizeof(*chip)); 713 indio_dev = iio_allocate_device(sizeof(*chip));
@@ -722,13 +721,15 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
722 721
723 err = tsl2563_detect(chip); 722 err = tsl2563_detect(chip);
724 if (err) { 723 if (err) {
725 dev_err(&client->dev, "device not found, error %d\n", -err); 724 dev_err(&client->dev, "detect error %d\n", -err);
726 goto fail1; 725 goto fail1;
727 } 726 }
728 727
729 err = tsl2563_read_id(chip, &id); 728 err = tsl2563_read_id(chip, &id);
730 if (err) 729 if (err) {
730 dev_err(&client->dev, "read id error %d\n", -err);
731 goto fail1; 731 goto fail1;
732 }
732 733
733 mutex_init(&chip->lock); 734 mutex_init(&chip->lock);
734 735
@@ -751,40 +752,52 @@ static int __devinit tsl2563_probe(struct i2c_client *client,
751 indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels); 752 indio_dev->num_channels = ARRAY_SIZE(tsl2563_channels);
752 indio_dev->dev.parent = &client->dev; 753 indio_dev->dev.parent = &client->dev;
753 indio_dev->modes = INDIO_DIRECT_MODE; 754 indio_dev->modes = INDIO_DIRECT_MODE;
755
754 if (client->irq) 756 if (client->irq)
755 indio_dev->info = &tsl2563_info; 757 indio_dev->info = &tsl2563_info;
756 else 758 else
757 indio_dev->info = &tsl2563_info_no_irq; 759 indio_dev->info = &tsl2563_info_no_irq;
760
758 if (client->irq) { 761 if (client->irq) {
759 ret = request_threaded_irq(client->irq, 762 err = request_threaded_irq(client->irq,
760 NULL, 763 NULL,
761 &tsl2563_event_handler, 764 &tsl2563_event_handler,
762 IRQF_TRIGGER_RISING | IRQF_ONESHOT, 765 IRQF_TRIGGER_RISING | IRQF_ONESHOT,
763 "tsl2563_event", 766 "tsl2563_event",
764 indio_dev); 767 indio_dev);
765 if (ret) 768 if (err) {
766 goto fail2; 769 dev_err(&client->dev, "irq request error %d\n", -err);
770 goto fail1;
771 }
767 } 772 }
773
768 err = tsl2563_configure(chip); 774 err = tsl2563_configure(chip);
769 if (err) 775 if (err) {
770 goto fail3; 776 dev_err(&client->dev, "configure error %d\n", -err);
777 goto fail2;
778 }
771 779
772 INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work); 780 INIT_DELAYED_WORK(&chip->poweroff_work, tsl2563_poweroff_work);
781
773 /* The interrupt cannot yet be enabled so this is fine without lock */ 782 /* The interrupt cannot yet be enabled so this is fine without lock */
774 schedule_delayed_work(&chip->poweroff_work, 5 * HZ); 783 schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
775 784
776 ret = iio_device_register(indio_dev); 785 err = iio_device_register(indio_dev);
777 if (ret) 786 if (err) {
787 dev_err(&client->dev, "iio registration error %d\n", -err);
778 goto fail3; 788 goto fail3;
789 }
779 790
780 return 0; 791 return 0;
792
781fail3: 793fail3:
794 cancel_delayed_work(&chip->poweroff_work);
795 flush_scheduled_work();
796fail2:
782 if (client->irq) 797 if (client->irq)
783 free_irq(client->irq, indio_dev); 798 free_irq(client->irq, indio_dev);
784fail2:
785 iio_free_device(indio_dev);
786fail1: 799fail1:
787 kfree(chip); 800 iio_free_device(indio_dev);
788 return err; 801 return err;
789} 802}
790 803