zpa2326.c (1ac731c529cd4d6adbce134754b51ff7d822b145) zpa2326.c (8d0c93761606ffc97af0cd00901579c5972017ca)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Murata ZPA2326 pressure and temperature sensor IIO driver
4 *
5 * Copyright (c) 2016 Parrot S.A.
6 *
7 * Author: Gregor Boirie <gregor.boirie@parrot.com>
8 */

--- 847 unchanged lines hidden (view full) ---

856 * @private: Internal private state related to @indio_dev.
857 *
858 * Return: Zero when successful, a negative error code otherwise.
859 */
860static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
861 struct zpa2326_private *private)
862{
863 unsigned int val;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Murata ZPA2326 pressure and temperature sensor IIO driver
4 *
5 * Copyright (c) 2016 Parrot S.A.
6 *
7 * Author: Gregor Boirie <gregor.boirie@parrot.com>
8 */

--- 847 unchanged lines hidden (view full) ---

856 * @private: Internal private state related to @indio_dev.
857 *
858 * Return: Zero when successful, a negative error code otherwise.
859 */
860static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev,
861 struct zpa2326_private *private)
862{
863 unsigned int val;
864 long timeout;
864 long time_left;
865
866 zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
867
865
866 zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
867
868 timeout = wait_for_completion_interruptible_timeout(
868 time_left = wait_for_completion_interruptible_timeout(
869 &private->data_ready, ZPA2326_CONVERSION_JIFFIES);
869 &private->data_ready, ZPA2326_CONVERSION_JIFFIES);
870 if (timeout > 0)
870 if (time_left > 0)
871 /*
872 * Interrupt handler completed before timeout: return operation
873 * status.
874 */
875 return private->result;
876
877 /* Clear all interrupts just to be sure. */
878 regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
879
871 /*
872 * Interrupt handler completed before timeout: return operation
873 * status.
874 */
875 return private->result;
876
877 /* Clear all interrupts just to be sure. */
878 regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
879
880 if (!timeout) {
880 if (!time_left) {
881 /* Timed out. */
882 zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
881 /* Timed out. */
882 zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
883 timeout);
883 time_left);
884 return -ETIME;
885 }
886
887 zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled");
888 return -ERESTARTSYS;
889}
890
891static int zpa2326_init_managed_irq(struct device *parent,

--- 825 unchanged lines hidden ---
884 return -ETIME;
885 }
886
887 zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled");
888 return -ERESTARTSYS;
889}
890
891static int zpa2326_init_managed_irq(struct device *parent,

--- 825 unchanged lines hidden ---