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: 78303 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1913750vqo; Sun, 2 Apr 2023 13:56:44 -0700 (PDT) X-Google-Smtp-Source: AKy350ZdzF9THLl9zHSiVDDyOPFET9VjzBq6qeUo5o29eFN4KCqI9AA+VO5N3JRb3o1lort7tvi+ X-Received: by 2002:a17:907:3f97:b0:93f:505b:9742 with SMTP id hr23-20020a1709073f9700b0093f505b9742mr35307397ejc.65.1680469004317; Sun, 02 Apr 2023 13:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680469004; cv=none; d=google.com; s=arc-20160816; b=bmloYerJ2lHJ8b5PPiUQzRPZMnXM8Cd5YNoSWvA1wH+bitN8qALO8HsfJdWXjV0oo7 v9ATh+3hjWQpWAuKQuLmd+clAjuG2ij87ZuyQS9wvbsZx3HbDf8ZUFG2wiv/4h2LqgFQ SEVaqTxeRLodW6itqoYxwUF7hhF9v3PyZ3GJfHJVCqs3HxiWqmT8hbn01ryPBMw5vSKA 90Si7RfCyaWUlFteIRiAXgWatomisKmt4zyDZ8efaaLMfoYY3s3igBToMC1oi3vI7B4/ sl9IQgzW5+Z8zRzmy6IoJ2cYupaNTM98ag96nn6Pminc5Jzp9ksU4O7DZXMhBAgGiNsy 8BCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QoQZL1cyGFxECwxSie0ZoTmFX1duBkuSs/DAzwfkxSU=; b=oFpwlYDA4rI/PA3AlLcqpFpCG44RGPO8Uu0R6LLZfo74/PzGU4sdQBv+c2rtuQePZU GlRHk9NfiJN5NHWwmryZZlOqGGyr5otmYSM1F0f5r921fkB4GBelyO3Qt46lDDDx5lj/ Nztz7Uqqyt9OFjs3bjPNxx3ytiP/OAczxHpHczb+z9QTpP/xDSkoRD+qkjQyPHosOsB9 0TW4mXrF9dQJNeu/vo7DnmwSPZmTvNJuFavtOWEI0NtPDAohjbk/AWBgT71+f5URBsY3 5p4Ai2SmtGv3u6NYQpcv2Wzo7sVKhbzDVfGQHisOxO8mP9ZPq+5NESvTUirsryfgRT6Y nThw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a170906d10c00b0093956a5d4f8si4113511ejz.1000.2023.04.02.13.56.19; Sun, 02 Apr 2023 13:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229933AbjDBUtS (ORCPT + 99 others); Sun, 2 Apr 2023 16:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbjDBUtR (ORCPT ); Sun, 2 Apr 2023 16:49:17 -0400 Received: from smtp.smtpout.orange.fr (smtp-30.smtpout.orange.fr [80.12.242.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6866B728F 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 X-Spam-Status: No, score=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762099466655735354?= X-GMAIL-MSGID: =?utf-8?q?1762099466655735354?= 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);