From patchwork Sun Apr 2 20:49:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 13197566 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FA5C7619A for ; Sun, 2 Apr 2023 20:49:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230141AbjDBUtR (ORCPT ); Sun, 2 Apr 2023 16:49:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbjDBUtR (ORCPT ); Sun, 2 Apr 2023 16:49:17 -0400 Received: from smtp.smtpout.orange.fr (smtp-29.smtpout.orange.fr [80.12.242.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5175F30C0 for ; Sun, 2 Apr 2023 13:49:15 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id j4dRpeQhaB8bjj4dRpk4Bs; Sun, 02 Apr 2023 22:49:12 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Apr 2023 22:49:12 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jonathan Cameron , Lars-Peter Clausen , Linus Walleij , Mike Looijmans Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Jonathan Cameron , linux-iio@vger.kernel.org Subject: [PATCH] iio: accel: bmi088: Correctly compute the address of the struct spi_device Date: Sun, 2 Apr 2023 22:49:08 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org 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 --- 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);