From patchwork Sun Apr 2 20:58:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 78305 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1924917vqo; Sun, 2 Apr 2023 14:30:58 -0700 (PDT) X-Google-Smtp-Source: AKy350YhrUtQOXkwQkNbDDzJC0cGHFVwPanXXhnk1MJZb0wyGPLZJRgM8GVkOSyxNQnapsUf4sbc X-Received: by 2002:a17:906:a983:b0:92c:16cc:2dcd with SMTP id jr3-20020a170906a98300b0092c16cc2dcdmr32438572ejb.33.1680471058462; Sun, 02 Apr 2023 14:30:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680471058; cv=none; d=google.com; s=arc-20160816; b=CmoQqElQGoTX6itLH9v+t0Sfa0+tSuEYt0cFi/rwmXhZTyJtLeNvFkQk+YqXC62jax fKQ6i0W1zazhj5pfqIkqcX0W/JBOufXvsPt3r6AHuTdNRSDdLurQJWMCgUY16c8Rk+3D AAhAiAkn+LcNiA4WFdMvX+IGr0XdE7RtwNfTlfKjQeCrVht5GPOXRtoT2R0wRUtBjmhq cqui3V+8pTrs+th+EZK6SC9kU21nmZxcequwGv6cvSCaClNuIGsKM6ZmW+iY5wjMjZrr gQ6DlPDyuAJzQw4G20fmZXPN68zFvzF4i6uT9OhAwkXkCUiHYTAv1leQvuAI3SEdjr/6 ZSCw== 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=wi8IChLXx27OPEc9o13u7S2/5K0uz5m0NPJXqZa476k=; b=xHfkuIesiXXzNLsKpeaUfPyCxShGNGpFhnsf9KgFtwSdwmxQAtdpiwgp7q0KLTXksi lUw2hXbjMTFC9a3JMDrKBQe9cA4O2S7ABpcxZOLm+n/wlWD45iRhdsSWYMx1Ms9QGt5q Ljo7BmRoudx/3tfok3OZneXxBHdCNFzxW5KVhsNkURclu5wDI2yrXDMg+sb2z57A80To hEXs63AzTsF3gqZ1kcbJBvRSkA97NEXyA5SJxxNMLL2RwGnQGxnaalzU8oowFnm9sTbz qoPvUYrsyfqe0vkmDVyLD1IqwkRgC1hqImcbO3+IUznx56ra6mk2H8cCB28Ddd+7vC+c PgbQ== 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 a19-20020aa7d753000000b004faec71d331si6060470eds.436.2023.04.02.14.30.35; Sun, 02 Apr 2023 14:30:58 -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 S230177AbjDBU63 (ORCPT + 99 others); Sun, 2 Apr 2023 16:58:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbjDBU62 (ORCPT ); Sun, 2 Apr 2023 16:58:28 -0400 Received: from smtp.smtpout.orange.fr (smtp-26.smtpout.orange.fr [80.12.242.26]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D805393D9 for ; Sun, 2 Apr 2023 13:58:26 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id j4mJp3wID985Cj4mJp2a4R; Sun, 02 Apr 2023 22:58:24 +0200 X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sun, 02 Apr 2023 22:58:24 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jonathan Cameron , Lars-Peter Clausen , Mike Looijmans , Linus Walleij Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , Jonathan Cameron , linux-iio@vger.kernel.org Subject: [PATCH v2] iio: accel: bmi088: Correctly compute the address of the struct spi_device Date: Sun, 2 Apr 2023 22:58:18 +0200 Message-Id: <8da05ad95015e048e3058f275bd57d382420b46f.1680469082.git.christophe.jaillet@wanadoo.fr> 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?1762101621093285381?= 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. Also update bmi088_regmap_spi_read() in the same way. Fixes: c19ae6be7555 ("iio: accel: Add support for the Bosch-Sensortec BMI088") Signed-off-by: Christophe JAILLET --- v2: do the same for bmi088_regmap_spi_read() --- drivers/iio/accel/bmi088-accel-spi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iio/accel/bmi088-accel-spi.c b/drivers/iio/accel/bmi088-accel-spi.c index ee540edd8412..79e4b5392312 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); @@ -24,7 +25,8 @@ static int bmi088_regmap_spi_write(void *context, const void *data, size_t count static int bmi088_regmap_spi_read(void *context, const void *reg, size_t reg_size, void *val, size_t val_size) { - struct spi_device *spi = context; + struct device *dev = context; + struct spi_device *spi = to_spi_device(dev); u8 addr[2]; addr[0] = *(u8 *)reg;