Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp536024imu; Fri, 7 Dec 2018 05:10:50 -0800 (PST) X-Google-Smtp-Source: AFSGD/VzkUamVBYOCkwCZS9oVPUraFeV2CXkNNNWEyXDn6efvWiyUYB0MiUW+PnpEpcmjU+BxoYg X-Received: by 2002:a63:4566:: with SMTP id u38mr1907002pgk.4.1544188250007; Fri, 07 Dec 2018 05:10:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544188249; cv=none; d=google.com; s=arc-20160816; b=u86I6MSFm/JGq1bhwvDr9x6r6dvSRxVNf+fwzWsoN5lPzYnSdNuajNPdxqJRPE6Ly6 7tmRnEzaKpXRoIopQCtB9uujYgMAtVNNn7p7jX6FNnX9S1N1m600x+r34Z9tLRJtdYI4 jiG0GzfTeqpG08FCgp35/n4IZ+1VglYNZABr7BvDCyv2a1bSxqIJSPRcl3al0AY3G/S4 Tml21x2Bt/XfnhiacctZknW4DxopRCSZntRcdnUpxEUEntBB8HPNh1t4Cbe12WtVGYWF i5uAO4InJx4HhZJPLuWYrlNiVRLBV4rGTOULe1i4lpUTdzadBk3tK9HZUU734z4JKP0t G2dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id; bh=T+n2rf2kmpZSO6kXhE+hPD/R5knIl4WolSzswFhcOQg=; b=RdyGadKEKPrjtSLstK5HL7UZkzOiMfFJaVqzKaDxq96fdWi+4XQpsX4OHOJHamQv9A uZ4gDhrTw3vUkgglIsHx7+BKYoaD+K1KXMUiVn7N5ei2iNM/jHErzXjTH9BhorZ9pXtQ Lyh2Gh036jFsewXg9iRkAwO2LCo8XS0L+v6Fdu2rndUPkm+CpY11YQxK5SAFOroE3uEk e3SMZcuQd0aGGMXy1SGi4zah54j/tMJ0/xI3VekC5bCYqu06N4oRk6GF6/RieTVo5hNg 3YWYEKwBcI9PzbmiWBWvM4DjrJDDPGa6fbVQ9Bjf7bwHgZ6HQwaKcYxvqTY52+UxKAWw teZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si2683409pgl.503.2018.12.07.05.10.34; Fri, 07 Dec 2018 05:10:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726280AbeLGNH5 (ORCPT + 99 others); Fri, 7 Dec 2018 08:07:57 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:59244 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbeLGNH5 (ORCPT ); Fri, 7 Dec 2018 08:07:57 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 43BCSV4Ql1z9vGFZ; Fri, 7 Dec 2018 14:07:54 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id VxlKMXXptY3Y; Fri, 7 Dec 2018 14:07:54 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 43BCSV3yZ1z9v11c; Fri, 7 Dec 2018 14:07:54 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id D4C428B8E5; Fri, 7 Dec 2018 14:07:55 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id Z7inp1bGw1yG; Fri, 7 Dec 2018 14:07:55 +0100 (CET) Received: from po14163vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id A30FA8B8DF; Fri, 7 Dec 2018 14:07:55 +0100 (CET) Received: by po14163vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 4429B716A7; Fri, 7 Dec 2018 13:07:55 +0000 (UTC) Message-Id: <3f9179c9a1c8e2486cdd15d28530cd2e381a8830.1544152023.git.christophe.leroy@c-s.fr> From: Christophe Leroy Subject: [PATCH] gpio: max7301: fix driver for use with CONFIG_VMAP_STACK To: Linus Walleij , Bartosz Golaszewski Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-gpio@vger.kernel.org, stable@vger.kernel.org Date: Fri, 7 Dec 2018 13:07:55 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org spi_read() and spi_write() require DMA-safe memory. When CONFIG_VMAP_STACK is selected, those functions cannot be used with buffers on stack. This patch replaces calls to spi_read() and spi_write() by spi_write_then_read() which doesn't require DMA-safe buffers. Fixes: 0c36ec314735 ("gpio: gpio driver for max7301 SPI GPIO expander") Cc: Signed-off-by: Christophe Leroy --- drivers/gpio/gpio-max7301.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-max7301.c b/drivers/gpio/gpio-max7301.c index 68c7942d0a3c..6f7d12ba2f74 100644 --- a/drivers/gpio/gpio-max7301.c +++ b/drivers/gpio/gpio-max7301.c @@ -25,7 +25,7 @@ static int max7301_spi_write(struct device *dev, unsigned int reg, struct spi_device *spi = to_spi_device(dev); u16 word = ((reg & 0x7F) << 8) | (val & 0xFF); - return spi_write(spi, (const u8 *)&word, sizeof(word)); + return spi_write_then_read(spi, &word, sizeof(word), NULL, 0); } /* A read from the MAX7301 means two transfers; here, one message each */ @@ -37,14 +37,8 @@ static int max7301_spi_read(struct device *dev, unsigned int reg) struct spi_device *spi = to_spi_device(dev); word = 0x8000 | (reg << 8); - ret = spi_write(spi, (const u8 *)&word, sizeof(word)); - if (ret) - return ret; - /* - * This relies on the fact, that a transfer with NULL tx_buf shifts out - * zero bytes (=NOOP for MAX7301) - */ - ret = spi_read(spi, (u8 *)&word, sizeof(word)); + ret = spi_write_then_read(spi, &word, sizeof(word), &word, + sizeof(word)); if (ret) return ret; return word & 0xff; -- 2.13.3