From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7A6D3AD53F for ; Wed, 13 May 2026 19:31:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778700702; cv=none; b=IA1riItfF0jIr0IIv8BoPMrE7qAoFLWnsA+bhwKlF+FeHcJormZyR1hBrkSJpXJHl1nE04SSm5J7nwiNH2sdEQOy2TGIvqDlwoGRf2/rjA4NAzwY8lpETEgkTilkiP9VK99KHErzWWBIpCAa50cL4jv2/0Zm9IqACOc0X0zWuuM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778700702; c=relaxed/simple; bh=umbnwUIl9frFTfgsM6LbA4PbzVggLUwsmKrLc75l5E0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=kHegj1WaT+y5ybWpWudglgUiG08Ss7QMksX9ylgejtdPLaYZ6cwpejhKngkYVRJJCrzxbW4gD1uHhQbpp/iOIIquQH2Z74Wbzf/SENv7LyKTTgD6oVdX+FF/44JJp6JyjWZREVge2nada1Zbee0bxl6Qybt89yuN+g/zWOkpZEc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HsqzX+BH; arc=none smtp.client-ip=209.85.221.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HsqzX+BH" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4493cf2f982so516093f8f.2 for ; Wed, 13 May 2026 12:31:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778700699; x=1779305499; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=H2toTd1xQSyQBGtF16IY83ToLBXQpvwDfOkzh0q3FOU=; b=HsqzX+BHjtKOB1aO6jB+KPgLWCzfKcjZm8sY8VHFUPiNaY8VmDoqcmzq7cAiMYTjjx ujriM0nilIO00o8Tifpwv1h1AhzFjoHxpNskUEki/7RpkGrvweDnTCy8F+enJs+KXMpy LWSlcUbBtXGl/UktnOpB1rjPT0vXPwKP2h+z2U2nZ+ItwccVdAZCA7UW7UqQDIQ/tyyf GiJ/7Ujwwk2rWFoi4u20VteSMJxhLb7BvunqJYyXKGACnG5K897/cp/+OfSeAjbJpWU4 b9b++FBz4sXxsia4cg+uK27HBv4G4JuAIJCAH5QOxElHoieSG13ttiFafWQEPcnolllL Lf+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778700699; x=1779305499; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=H2toTd1xQSyQBGtF16IY83ToLBXQpvwDfOkzh0q3FOU=; b=EAmlzmRMAox0aAZ5C140+bXvJe0OeSofTT6asuAcJcKfPQzhic7MDXu9/cruHbRNhE 6i5Lswnsh6f90ufOHJfG70ZSrCYHCfmThtzDsvPfLlHR8IuGgtgUr7E4uiU1LG9Jnk/r dLlJJO+XjPqdpkdTMvVmDVRNhCCZm4htVQEtzDK8AG6dL8wKQo13VZ4G8Ejgg+xIBVXA ujlNGnMh5aI7L+ICQKKECZgZUKbbUuIfb9AjDGBmijY5lj3IifSrRGtfc3EmBe75KRGi D/ySk0u/ozkFtm5LHeYLJIcWKMaF+U9AH/PlIH+zuxOkEibVd+4jXUiO0Gl0xHdoRnnC 6gFA== X-Forwarded-Encrypted: i=1; AFNElJ+wyKle2m6a8mPYINR9OjEwXqnN1UhbNDPh4xhXhc3HBp7eUOdU+1J1DZB0T02fybydRkSzJnMIQ5ztzOE=@vger.kernel.org X-Gm-Message-State: AOJu0YzAR7KD1LgI5zTKB/mGiVSC7AvCWxG/JIiK7Z5yfUBik4zQ7OUh ctF8x5tSD2xbpA+2oIj/K251HEVvA9Nh1UrSYfVvtGdu8LdQ/noSdI0x X-Gm-Gg: Acq92OFJY8c91UBM7zozdF4NH4mK6hPPLUxK+rqpkqQyyD0qiT/HlA7xJD+5BMHs5IC o/wumjAiRRGz3rvetD/D8RmzohKrt9pznbBSh39d9XEhaZHOjejJMyJ4SrftaGqWsdl29LnboHH lhLQH818kHig11jsgCnNVE58ebaLGqYVHu8RI2AWuL2XcD7+jI7IQmcJ/90+IbCQiTAR+EZ1daK P0vQ7SZVuFleLsZ0hK9a3mrur7zylbez0LXsU2Im5M9+NrRKBrjWv8wx4Bnqhu5y72OzAG4fTnn o/hKgSFdxXmweUM8Ksp/K3PScIC6Gctgrw6lfRr5s8IQs36gxn1NzbWHhXq4pDjePxZXHV1G/Ht //wSfds+wxCgbNo7LJLvchsgl2gq2dbofXqLKl+LS3ulqwzJTc+BHPCQ+TZgJ9LXAXB4bBHIW+J 6l4cBG6jA2mPCvEL9Hl0qjxxsiKdW3nRHPKijps30DJ4V0 X-Received: by 2002:a05:600c:3b16:b0:48a:79da:c87 with SMTP id 5b1f17b1804b1-48fc9a51444mr32161395e9.8.1778700698702; Wed, 13 May 2026 12:31:38 -0700 (PDT) Received: from localhost.localdomain ([82.215.118.79]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fd64cead5sm9314965e9.10.2026.05.13.12.31.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 May 2026 12:31:38 -0700 (PDT) From: Stepan Ionichev To: jic23@kernel.org Cc: songqiang1304521@gmail.com, dlechner@baylibre.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, sozdayvek@gmail.com Subject: [PATCH] iio: proximity: vl53l0x: notify trigger and clear IRQ on error paths Date: Thu, 14 May 2026 00:31:19 +0500 Message-Id: <20260513193119.17884-1-sozdayvek@gmail.com> X-Mailer: git-send-email 2.33.0.windows.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit vl53l0x_trigger_handler() returns directly on the I2C read failure paths without calling iio_trigger_notify_done() or vl53l0x_clear_irq(): ret = i2c_smbus_read_i2c_block_data(...); if (ret < 0) return ret; else if (ret != 12) return -EREMOTEIO; A single transient i2c_smbus_read_i2c_block_data() failure (negative errno or a short read) therefore leaves two pieces of state behind: - iio_trigger_notify_done() never decrements the trigger's use_count, so iio_trigger_poll_nested() silently drops further dispatches (see industrialio-trigger.c, the !atomic_read(&trig->use_count) guard); - vl53l0x_clear_irq() never writes SYSTEM_INTERRUPT_CLEAR, so the chip keeps the DRDY interrupt asserted. The sensor's buffer mode stays wedged from then on, recoverable only by re-binding the driver. The sibling driver vl53l1x-i2c.c handles exactly the same case correctly by jumping to a "notify_and_clear_irq" label that always calls both helpers; mirror that here. The bogus negative-int return value cast to irqreturn_t also goes away as a side effect. Fixes: 762186c6e7b1 ("iio: proximity: vl53l0x-i2c: Added continuous mode support") Signed-off-by: Stepan Ionichev --- drivers/iio/proximity/vl53l0x-i2c.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iio/proximity/vl53l0x-i2c.c b/drivers/iio/proximity/vl53l0x-i2c.c index ad3e46d47..7acb94acc 100644 --- a/drivers/iio/proximity/vl53l0x-i2c.c +++ b/drivers/iio/proximity/vl53l0x-i2c.c @@ -87,15 +87,14 @@ static irqreturn_t vl53l0x_trigger_handler(int irq, void *priv) ret = i2c_smbus_read_i2c_block_data(data->client, VL_REG_RESULT_RANGE_STATUS, sizeof(buffer), buffer); - if (ret < 0) - return ret; - else if (ret != 12) - return -EREMOTEIO; + if (ret < 0 || ret != 12) + goto done; scan.chan = get_unaligned_be16(&buffer[10]); iio_push_to_buffers_with_ts(indio_dev, &scan, sizeof(scan), iio_get_time_ns(indio_dev)); +done: iio_trigger_notify_done(indio_dev->trig); vl53l0x_clear_irq(data); -- 2.43.0