From: Joshua Crofts Date: Mon, 04 May 2026 11:48:15 +0200 Subject: [PATCH v4 03/17] iio: magnetometer: ak8975: replace usleep_range() with fsleep() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260504-magnetometer-fixes-v4-3-a291c2a7c71a@gmail.com> References: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> In-Reply-To: <20260504-magnetometer-fixes-v4-0-a291c2a7c71a@gmail.com> To: Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Joshua Crofts X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1777888111; l=1188; i=joshua.crofts1@gmail.com; s=20260422; h=from:subject:message-id; bh=pYNXSLcsScB1UFEjU4yV7Zvmf3IflZ84nydrNj+FmrM=; b=kdSsSuCWY1z/qJqtyJXW2Q6dxOy7BKEipYDgYV/AEIYkLhgB/KS9PsBNQ0WHoG3Wdusn3ra4Z o8vIWwb6VZ1Afn3qXEoiDz7PRAiTaKcLgaEKXWnirZljidtmii020NI X-Developer-Key: i=joshua.crofts1@gmail.com; a=ed25519; pk=Xd+UVoRPiiI0K3LHQ2XIcXmO0jvVuFTv9eTx3lgBphI= X-Endpoint-Received: by B4 Relay for joshua.crofts1@gmail.com/20260422 with auth_id=746 List-Id: B4 Relay Submissions Replace usleep_range() calls with fsleep(), passing the minimum value required by the sensor for hardware delays. fsleep() automatically selects the optimal sleep mechanism, simplifying driver code and time management. Signed-off-by: Joshua Crofts --- drivers/iio/magnetometer/ak8975.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index dac0a90c33eebd43f8aeed846c9cbf5fd1a6ab91..a84a05a1b64280e26c428e9752a39380e386c234 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -461,7 +461,8 @@ static int ak8975_power_on(const struct ak8975_data *data) * and the minimum wait time before mode setting is 100us, in * total 300us. Add some margin and say minimum 500us here. */ - usleep_range(500, 1000); + fsleep(500); + return 0; } @@ -551,7 +552,7 @@ static int ak8975_set_mode(struct ak8975_data *data, enum ak_ctrl_mode mode) data->cntl_cache = regval; /* After mode change wait at least 100us */ - usleep_range(100, 500); + fsleep(100); return 0; } -- 2.47.3