From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 E2FDC33B6C2 for ; Sat, 16 May 2026 15:38:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778945886; cv=none; b=Qx3YHsppTVEF8e57YIsTBpgdwxk7mtp87duVEDiRAgk1DU9wRGXAJSuVfZW0ddGE+OhjgMIwaAv99pHY7FFmXZ7gn64nLC1+eQitKzKd6NVqXcTUyLJF8F3YKMF5xjQZq+BULUIrUeFzxZBycUNtr+phD/XDxrpd/HkLLANqfeQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778945886; c=relaxed/simple; bh=/75PCE3sU4ZNcHGvR8zG5bXzbL2Lu8dYaiJn+oAx7u4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nluZjMHws5lJegm41p5zrk1jDYEb2PbmF3qUhHKaZ1F27rCUEl17/GfnzBlwnAFVV/etKGr+cnFVKsdpnkkKVOHPvpsaLs1liOGt8avmUpAZ0oEyEIWR8BF6seX4z0K5q8qZDSM4VekUx2Qd8A1nhdhlxW4rkbYHceUZ8tcHJZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b=K13K4uM1; arc=none smtp.client-ip=209.85.210.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20251104.gappssmtp.com header.i=@baylibre-com.20251104.gappssmtp.com header.b="K13K4uM1" Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-7dcdca9aa0bso2305209a34.0 for ; Sat, 16 May 2026 08:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20251104.gappssmtp.com; s=20251104; t=1778945884; x=1779550684; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=dG6BOi9eKWLoGvRvvTy/2CJLijhAKB9xvisswsHOsMg=; b=K13K4uM1o0j51hwxARFj46h2H5Dl3t5bP2yyW0rk+S2Kk5DUAgaRoxcyK0mXq0iEIw H9nBA1Ugn/YowmfqEQhHY76wbe6drUvza/20xbdpXcM4s0JCYmlPidPLUjsQRveHc0r3 Nyi6jBmp47E6fIqDisaTSyL+wiVNtil7sZ2/W7d5hlXwGn2TgnzBpkZCWP5qBL8vGLLA dcYiyYZPvx7NcOPl0laFrvwdI8T548IWn30yb+S4JwkJ78GQxRdQ8vYKxtFBvwuDp4VZ lCiwKmQZJyk1YvotxrChS/RXecICkGB5+SOqpGkM5CxATDVqmQre2ZeVIepTd4HhPn8p iJ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778945884; x=1779550684; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=dG6BOi9eKWLoGvRvvTy/2CJLijhAKB9xvisswsHOsMg=; b=GHYJCORj2UyTjeELfuOFprGNtcgB9yBRzx+0S1pheSjpJJIQoqJaKJmy9r1p6JTj+z OaVaYXHyQ8Kvs1kXRkw/98cpx7j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:17a6:c06b with SMTP id 006d021491bc7-69c77a88e61mr4282706eaf.17.1778945883897; Sat, 16 May 2026 08:38:03 -0700 (PDT) Received: from ?IPV6:2600:8803:e7e4:500:b36d:bd18:7c02:29e2? ([2600:8803:e7e4:500:b36d:bd18:7c02:29e2]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-69d049384f6sm2758905eaf.14.2026.05.16.08.38.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 16 May 2026 08:38:02 -0700 (PDT) Message-ID: <827b665d-7341-4ec8-b00e-11d5a7f9cf07@baylibre.com> Date: Sat, 16 May 2026 10:38:02 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] iio: proximity: vl53l0x: notify trigger and clear IRQ on error paths To: Stepan Ionichev , jic23@kernel.org Cc: songqiang1304521@gmail.com, nuno.sa@analog.com, andy@kernel.org, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260514143711.23648-1-sozdayvek@gmail.com> Content-Language: en-US From: David Lechner In-Reply-To: <20260514143711.23648-1-sozdayvek@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 5/14/26 9:37 AM, Stepan Ionichev wrote: > vl53l0x_trigger_handler() returns directly on the I2C read failure > paths without calling iio_trigger_notify_done() or vl53l0x_clear_irq(). > > 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 > --- > v2: > - Drop the cited error-path code from the commit body; the diff > already shows it (per Andy) > > 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) This can just be 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); >