From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (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 1110D3ED118 for ; Wed, 6 May 2026 10:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=209.85.221.47 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778064624; cv=pass; b=qvqaIZ1wG9xcmx36Suw1ZI61S+U9mmRpSidGMrW+o0H2iQuIidjpt+mVdyz9fsPNZrrIz0p+gKc9doBpOYU4bid6YzpD47J1j2PtzlUOvzIeY1pCxpMYKgr03gkOGkKIIEMZnrBSxFfnouL0cD+M0A5VFSX+TSXJ911g6ibXeZE= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778064624; c=relaxed/simple; bh=BlnRLkwyMPeNTSpP/iAXHGFXC3tn9AcP8drkGiekx8U=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VmdVFbNwJ3svN1UHJ/afXnAXDLWTaumMqQgBJ3zveunHqHyY2C+PSvT3I2Br4z2czwZP/zQk7lrqq8TNNX7GBJHXhNQIF0JhoPgx6YLZmlQHGBw11IWMBtwT04ZBvZwWnRbPwZRK5GrFh3RHcdz1sAGRVqxQhvoPrqV1gWVwyFU= ARC-Authentication-Results:i=2; 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=aG60U0eJ; arc=pass smtp.client-ip=209.85.221.47 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="aG60U0eJ" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-43fe608cb92so3708930f8f.2 for ; Wed, 06 May 2026 03:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1778064621; cv=none; d=google.com; s=arc-20240605; b=KZo5sO0ItV1EjSIj8dBFw7BQuR88JD3zPMgrMqzNu1nWXEfuL1nWHz31hF2k268uxn ZcxnDNwj71DTNk4w/VQ+3Dgwqw/N47OF6INr7sXoVJaRkb6iNdZsl6zUr9E8VeBzve0O ullHHvSBlqbVcXlTuHChVcEgxAfaDEe7zfsfEdUDsgT+6LaU0cRYaHmsIzhqmmzf5yKr hezHouA7XOKOC+nejQzQlvcome+XH/KVu83OUj1qdRo14ShwwERBES+6u1UAanEKG1RE LQLVMc/c800QCBeX0NXaMXO9n3kYIG26cV2wy7B2boiaxYQj4oNTplG+NIy6iyESSSPn zozQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=nSCPfabPiukH8olRD+jOmb+DxOr4x9Cg9JzaPxixMEw=; fh=BXl5gfnj/bnWBXjvpcqJ51GtM73X8Tl6gEw3s96nGfg=; b=YjE7k6dcogYmDoXPP8Aqw9/G/spmU7dS7RYPdIy2jtM6eVYJcq95r6eFDiaofLGAan ABTDR3e2UxDfMRqZgr94NdTOVX7xJUp8ZEx/LsT+vprDOCJ11XRYW0rJva1xvwjrIhqv fpCY7IA6oK/1K907CiJmxDxfKFv1TMpK8zLS52PlL2k/7W7AF9V7o/4vna79045cH2bP nmyzRplH1QL2d6Ot4fgC/5L3qcyeLYIbyOYljAEckvEXvXkD8xZU1B/YA1UuWn6ZQVEJ F9YMa/fHi0IkhOvIM0D1BLOYOkacqwBW5Omfw4tiIyN+gBzEjgGWlHLlpLn8Zn9lUEpe CxdA==; darn=vger.kernel.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778064621; x=1778669421; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=nSCPfabPiukH8olRD+jOmb+DxOr4x9Cg9JzaPxixMEw=; b=aG60U0eJmIwHNO3JkarUp8SIncgCDAzoA6AUHU/4NSXGHgRRdVM7aFvhLA0G9F+/p0 ViBDfIq+sHdxTurRftFL3vpgsKnMdqulex5BtYHv1J+IOEvpMjtND8gSGXkumhjpikov ysUBAFMnqENmhlh6PQd+paiNABFlAU4YPqV2pl+dZoP0YUeDF2Zw/ZgC3sfTYSf029Hj S8bWtmzsXZl6oWD7KMVgEcMR1knuEsHAoyqs+zaE7Yd1jWvJu4MTgcWG6BU3pqCAvMfO 1q7lxAsL2n2WpbSkiWLRw0U4kww0MshszwY8Q/hCLD6D9/raVSdB6pGn6kakg6ja5CpH 3Q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778064621; x=1778669421; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=nSCPfabPiukH8olRD+jOmb+DxOr4x9Cg9JzaPxixMEw=; b=DZHSPg6tZkMjrlMXM8cHa4XoUibUhmmIEMZNn0KTmiUj3s08PQypqfGTb4Cz3niuEg 1vJZU/H8MSxFWNeQDiIgx28nYpTTJ0nBN/e/ORTvqlDqqW2oOwZLC8j1AIyPpF8qwJUl yDF+7gVksKX7qEWwI6G2c1EiA5Of7CYp8ZlV4PcqZqd1VzA3GK/bMHlIk50FX8aGH0q2 fdn2veWNnYlwilTbZEkyJ8gbwVZLCKakp0W73nt1cm/wrmZJJX8pBZMKY8WJlIYiCd3v IYGk4aNrUpoeEtdiJqMDjRT2dltv9kxU0/i6bdn9ZLhT7GosWInNBNLkadu3y8Eh6QQz JuMA== X-Forwarded-Encrypted: i=1; AFNElJ96X9KmtWxIkiwt+cgj+/hUxyAXLnkoNWKSmmKBdgn2qb8Ypl29piZ1vFgsOKpntuuRmLkNX1FbtbWiBH4=@vger.kernel.org X-Gm-Message-State: AOJu0YxTmCHJqQfYFsMC1L1WWUw6177VklJIwFwdm6rRaLKqrwewHOX6 hvzYPxOY9Oixb4Vsf5tdLng4RTNYfArvMnMU8NMHL5kgL2J4vuOEQdL+P1qbMqP1tsIQojZQD8+ 25S0lnNJPIrstdbRSwT6dPNx3bCuSYck= X-Gm-Gg: AeBDievDqkfRKbV8W9o4rqg4d5ktPpTXMHxIGfqRLsWoiJFPX++gXF62PsADO3OqB0H u8SOgUEE5m3/BloJEJNmnR7lPDcGlWm7WJiMUwHF6fBMf0M4Ij5dRnJtTPF8jnrs+J9PqqoBbqs Vhy1XKKlmcSUURb0OaYOxm8Lv+lJMXzwS6mJs4jWngHFPq2E3C2nHM633tsDwprkbg+6CBKMDCt VLXn2dUTBl/aT19KWUCOmdkukUlqFVFvC2Hu4M4Nx7de6+FboTXd44iB7XcTHdL5K/vpn/8FkOA Malx0spGSV3yW+Oa8T75GfCa6W0K74uuag3ch15wcmLuVf1ntJYx/qG+PyOAPFBQHUHf5/DAVjo 5QFoBZCXsoyE8URsj/b/UT6XEL4OMgEDYh8fNdOQn7RJmHLY4uwGnWO+bhnhFEkjs9pGRUMKXUL m5GsGkVnAAuoiML29X X-Received: by 2002:a05:600c:4448:b0:48e:526e:1040 with SMTP id 5b1f17b1804b1-48e526e1226mr45049025e9.23.1778064621189; Wed, 06 May 2026 03:50:21 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20260505-magnetometer-fixes-v5-0-831b9b5550fc@gmail.com> <20260505-magnetometer-fixes-v5-7-831b9b5550fc@gmail.com> In-Reply-To: From: Joshua Crofts Date: Wed, 6 May 2026 12:50:09 +0200 X-Gm-Features: AVHnY4I9mFVaaKUBKKDkhwm5BhseTDrJ6-kcXr--u9nfK6vNY6PpKHTgOEBkXog Message-ID: Subject: Re: [PATCH v5 07/18] iio: magnetometer: ak8975: modernize polling loops with iopoll() macros To: Andy Shevchenko Cc: Jonathan Cameron , David Lechner , =?UTF-8?B?TnVubyBTw6E=?= , Andy Shevchenko , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" On Wed, 6 May 2026 at 09:01, Joshua Crofts wrote: > > On Wed, 6 May 2026 at 08:53, Andy Shevchenko > wrote: > > > > On Tue, May 05, 2026 at 01:46:03PM +0200, Joshua Crofts via B4 Relay wrote: > > > > > The driver currently uses while loops and msleep() for polling during > > > conversion waits. > > > > > > Replace the custom polling loops with readx_poll_timeout() and > > > read_poll_timeout() macros from . This reduces > > > boilerplate, standardizes timeout handling and improves overall code > > > readability, keeping the original timing and error behaviour. Add > > > for USEC_PER_MSEC macro instead of using magic numbers. > > > > ... > > > > > + ret = read_poll_timeout(i2c_smbus_read_byte_data, val, val != 0, > > > + poll_ms * USEC_PER_MSEC, > > > + timeout_ms * USEC_PER_MSEC, > > > + true, > > > + client, data->def->ctrl_regs[ST1]); > > > + if (ret) > > > + return ret; > > > + if (val < 0) { > > > + dev_err(&client->dev, "Error in reading ST1\n"); > > > + return val; > > > } > > > - if (!timeout_ms) > > > - return -ETIMEDOUT; > > > > > > - return read_status; > > > + return val; > > > > Besides the unneeded return val duplication, I think this is the wrong location > > for this check and it changes behaviour (really subtle change!). Hmm, rechecking this, I agree with the unnecessary return, but I don't think it changes the behaviour of the function. > > Before if the last iteration gives an error from the device, we return > > -ETIMEDOUT instead of the whatever the i2c_smbus_read_byte_data() returns. Looking at the original function, it always prioritized returning the i2c_smbus_read_byte_data() error code before returning -ETIMEDOUT (even on the final iteration). In the new version, if the i2c read is bad, the read_poll_timeout() code will still be zero, therefore allowing the code to jump to the i2c value check and then return if bad (this is still the same behaviour IMO). Maybe I'm looking at it from the wrong angle though. AFAIC Sashiko nitpicked everything except this (but yes, it's still an AI so we have to tread lightly). Same goes for the other patch where you raised this issue. -- Kind regards CJD