lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun,  2 Apr 2023 22:49:08 +0200
From:   Christophe JAILLET <christophe.jaillet@...adoo.fr>
To:     Jonathan Cameron <jic23@...nel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Linus Walleij <linus.walleij@...aro.org>,
        Mike Looijmans <mike.looijmans@...ic.nl>
Cc:     linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org,
        Christophe JAILLET <christophe.jaillet@...adoo.fr>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>,
        linux-iio@...r.kernel.org
Subject: [PATCH] iio: accel: bmi088: Correctly compute the address of the struct spi_device

bmi088_regmap_spi_write() is said to be similar to the SPI generic write
function.
However, regmap_spi_write() calls to_spi_device() in order to find the
reference to the "struct spi_device", instead of considering that 'context'
is already the correct value.

This works because "struct device	dev" is the first entry of
"struct spi_device".

Align bmi088_regmap_spi_write() and regmap_spi_write() to be more
future proof, should "struct spi_device" be shuffled one day.

Fixes: c19ae6be7555 ("iio: accel: Add support for the Bosch-Sensortec BMI088")
Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
---
 drivers/iio/accel/bmi088-accel-spi.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c
index ee540edd8412..e3447c277947 100644
--- a/drivers/iio/accel/bmi088-accel-spi.c
+++ b/drivers/iio/accel/bmi088-accel-spi.c
@@ -15,7 +15,8 @@
 
 static int bmi088_regmap_spi_write(void *context, const void *data, size_t count)
 {
-	struct spi_device *spi = context;
+	struct device *dev = context;
+	struct spi_device *spi = to_spi_device(dev);
 
 	/* Write register is same as generic SPI */
 	return spi_write(spi, data, count);
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ