From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEA0843B3FA; Tue, 21 Jul 2026 21:55:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670936; cv=none; b=iRQK924VtpRdxPkMzRLzlg22YAtLRYZ6362EWOoVn+1b8Z5+g6Pd1goHTSUl5UG1VE8HGblRCJmTBjDqVNwpMcB7XLXAiARVEoj6noImYYQ7aZLRxIYef6h7QJuBAy8uzA5MjmISoQ4z7eCFeSs5Lpv94nJowPQTxUPjSDOdDtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670936; c=relaxed/simple; bh=oh3Iyk2vnPMdyG+YBkBtWcbj2KwtYBzWPOeyqaz3yeg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nyd+kZGA4K1de4btj/FRpy/7Nx2mfhmZqLQwFSU0++J8Df3ZYtiu5ePLSuGS0lR5ImkxL/E6hRDa+biBNK0SJjTXuO1AJ8VzlZQDiDPLm9dZqAmEYjkI+m/3PuiFoRxFMxeFbeZOAnH3vROIy0/g6sfjO2CnY6CTiOVuPUv88Rc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uIdCTQJf; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uIdCTQJf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1AF1F00A3D; Tue, 21 Jul 2026 21:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670934; bh=Y3pt4coZiSDv8Cj8DhCSgVlr6DF64cSM56mbi7S0ROc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uIdCTQJfoP9LZ15j75tfCU6CiCdMLUIgIdlZlXV0TVgXp0cjoYdr/6WVTZYbhfnKA 2ISnpRrUgA/eXD4UTzMVlMhydi+hURPWpgcaQta6e084IfTHolzMWFd9uAz4+39Eki 3NI82jEJPC+a8p8W9luZwcQTyKInT0PznzNSx3X0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Stepan Ionichev , Stable@vger.kernel.org, Jonathan Cameron Subject: [PATCH 5.15 056/843] iio: gyro: bmg160: wait full startup time after mode change at probe Date: Tue, 21 Jul 2026 17:14:51 +0200 Message-ID: <20260721152407.244841037@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Stepan Ionichev commit 088fcb9b567f8723074ad9eb1bf5cb46f8a0096b upstream. bmg160_chip_init() calls bmg160_set_mode(BMG160_MODE_NORMAL) and then waits only 500-1000 us. Per the BMG160 datasheet (BST-BMG160-DS000-07 Rev. 1.0, May 2013), the start-up and wake-up times (tsu, twusm) are 30 ms. The same file already waits BMG160_MAX_STARTUP_TIME_MS (80 ms) in bmg160_runtime_resume() after the same set_mode(NORMAL) operation. The 500 us value at probe was likely a unit mix-up; the old comment said "500 ms" while the code used microseconds. Reuse the same constant via msleep() and add a code comment explaining the datasheet basis for the wait. Without this, register writes that follow the mode change can hit the chip before it is ready. Fixes: 22b46c45fb9b ("iio:gyro:bmg160 Gyro Sensor driver") Signed-off-by: Stepan Ionichev Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/gyro/bmg160_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) --- a/drivers/iio/gyro/bmg160_core.c +++ b/drivers/iio/gyro/bmg160_core.c @@ -268,8 +268,14 @@ static int bmg160_chip_init(struct bmg16 if (ret < 0) return ret; - /* Wait upto 500 ms to be ready after changing mode */ - usleep_range(500, 1000); + /* + * Wait for the chip to be ready after switching to normal mode. + * The BMG160 datasheet (BST-BMG160-DS000-07 Rev. 1.0, May 2013) + * specifies a start-up / wake-up time (tsu, twusm) of 30 ms; use + * BMG160_MAX_STARTUP_TIME_MS (80 ms) as a safety margin, matching + * what bmg160_runtime_resume() already does. + */ + msleep(BMG160_MAX_STARTUP_TIME_MS); /* Set Bandwidth */ ret = bmg160_set_bw(data, BMG160_DEF_BW);