From patchwork Wed Dec 4 23:19:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180856 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp1246906ile; Wed, 4 Dec 2019 15:21:45 -0800 (PST) X-Google-Smtp-Source: APXvYqwWOi6ITTEJcyFT9jz3ZpHoqid4h3Kt4EBhSTqJIq3jOYnZJIiVdHUbd/u0ixaEAii/Gyx+ X-Received: by 2002:a9d:7a8f:: with SMTP id l15mr4342120otn.109.1575501705269; Wed, 04 Dec 2019 15:21:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575501705; cv=none; d=google.com; s=arc-20160816; b=CXCoHuz50edM/vsLV6DWExhz8hkX/lO2Q/n64G10qOOmGOWQJHnl4Ms7RrN4rcXXpN nOi2fpk89PaelCK5NFQTguK0J4W19LUBLe9eM+gltiF8J6PmdKeDqQ2jOt3KxgaVI9tu iLPdWm+K6NFWf95jZ99vuZO077HHYaomDBXzgjnKC50Z9Mm2NOgZnFw0bu9xYrc0zlD5 TyG6ExAgFCT/ngdR/0UsbhpDnO2ksPi/HfeP8yNxBmgEwtmk14VqAq0B2hXGdlt6xMQX BGc2JG90K9Nu/y+bouP8NBHNg60Bh+kXV+32519vfAUMQBVkK3n6vHvUns4z9R5YQWbS zyxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=cl8V4L186TosF/Foo+q0QrKTNn4dTHR6LIi9ACqiBcU=; b=NORwy6dxQmnSSXCNWgmvw8lz29b7JvKwPmRNcPc2NZFvkPZnozw/ndMJSecFhjz36Z TOztzLkl8j66V3O10VnJ+hC4KGRSpobiwpEvJ+58ELitsCi77zDygoaXzVGXCgS86oLq 3+7TOaX+8kR3IrSHu0Rfwvr9lxcqg3/CaRcGrI05MOFp3nwxRjnTdNVFfHGQ1b1WYIHO VBvm/sOP4iROzaZemprVb26piR4vXf1B9xCEwCszM/S0C4w1a9lEh9jXHMm5Dn82VBQ5 D3fjslPL5L8DnRMgCA4B644vWt+sret7ziBM+A80DdoRYoS8HQ+Pi9kOyFJqRcuZWNbY K2fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AE0BRV5b; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si4121012oib.104.2019.12.04.15.21.45; Wed, 04 Dec 2019 15:21:45 -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; dkim=pass header.i=@linaro.org header.s=google header.b=AE0BRV5b; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728593AbfLDXVo (ORCPT + 27 others); Wed, 4 Dec 2019 18:21:44 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:43112 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbfLDXVn (ORCPT ); Wed, 4 Dec 2019 18:21:43 -0500 Received: by mail-lj1-f195.google.com with SMTP id a13so1240699ljm.10 for ; Wed, 04 Dec 2019 15:21:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cl8V4L186TosF/Foo+q0QrKTNn4dTHR6LIi9ACqiBcU=; b=AE0BRV5bLa+uNHAmKvhtTBvjE80e4SGtol/mGUZwRXzmA9JbICpa/9qcgzzUtLz7/M 9j4dSuNkgY7Bmzcpq78KE7Ss8vruQEIoUqSOyyqle9kuADuWUFtK1lgwhUB3DjU1DTz8 2Ysvd7vuFYaTyCI2mu2If7sx7doKGn7Mvw42bcbAwp7eZjbuBTjd6gfT93CXR2ux8PWh 8YK7wvYDnQh+cjQS9SDg3qRDLbAkRspbI3QIL32RBl3wuYOPKhF7sBW52xTU/qylgda8 gQwg6IDikZDt4i32x8F98uAyPY+J5nB7Gge0GoE3bIOKkn+3WW9wcZ2trO/Q6xMQaAih 0I4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=cl8V4L186TosF/Foo+q0QrKTNn4dTHR6LIi9ACqiBcU=; b=euwP1ghw0PueesvOKWYhdo+9FSw0PIIjM1zForJxdv6UkgjgM9M7upQJ4193zoAIMX Gl9vO6IRtbWVe9lgQza+j7lCaCarvEmisd4nMaRUkZ6ZQa/mrf7DT247TWmrMz3HPcYv xrb4IDgnwR18Eld+jT/+rStjLwaNE3J+oshb1iZULfwHakh8e0dBEhcwLW9uR+fQL7HE 8lnzx992Xa+kEaKuJ5au0UIv4cB8d1HPNlSBb7ujIM1wXW2zJIYYGepuFfyHFqA3hCVp JRKB8/0T6PKUFOE6frvWIcPTKLNjqvcTx8huSX4ptQ3AEQw9kt138d230G8ImomyraUO fUGA== X-Gm-Message-State: APjAAAUYsnD0kkgPUkMrPjktcjMnhld0AmNNxNRZXMv3pUv/9ldrS55x ma2+rcPxdxkRk5kADOm5MEzeIA== X-Received: by 2002:a2e:9194:: with SMTP id f20mr3599265ljg.154.1575501701983; Wed, 04 Dec 2019 15:21:41 -0800 (PST) Received: from localhost.localdomain (c-21cd225c.014-348-6c756e10.bbcust.telenor.se. [92.34.205.33]) by smtp.gmail.com with ESMTPSA id q186sm3975832ljq.30.2019.12.04.15.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 15:21:40 -0800 (PST) From: Linus Walleij To: lee.jones@linaro.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Mark Brown Subject: [PATCH] mfd: motorola-cpcap: Do not hardcode SPI mode flags Date: Thu, 5 Dec 2019 00:19:31 +0100 Message-Id: <20191204231931.21378-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current use of mode flags to us SPI_MODE_0 and SPI_CS_HIGH is fragile: it overwrites anything already assigned by the SPI core. Change it thusly: - Just |= the SPI_MODE_0 so we keep other flags - Assign ^= SPI_CS_HIGH since we might be active high already, and that is usually the case with GPIOs used for chip select, even if they are in practice active low. Add a comment clarifying why ^= SPI_CS_HIGH is the right choice here. Reported-by: Mark Brown Signed-off-by: Linus Walleij --- drivers/mfd/motorola-cpcap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.23.0 diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c index 52f38e57cdc1..a3bc61b8008c 100644 --- a/drivers/mfd/motorola-cpcap.c +++ b/drivers/mfd/motorola-cpcap.c @@ -279,7 +279,13 @@ static int cpcap_probe(struct spi_device *spi) spi_set_drvdata(spi, cpcap); spi->bits_per_word = 16; - spi->mode = SPI_MODE_0 | SPI_CS_HIGH; + spi->mode |= SPI_MODE_0; + /* + * Active high should be defined as "inverse polarity" as GPIO-based + * chip selects can be logically active high but inverted by the GPIO + * library. + */ + spi->mode ^= SPI_CS_HIGH; ret = spi_setup(spi); if (ret)