From patchwork Wed Dec 4 15:27:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 180800 Delivered-To: patch@linaro.org Received: by 2002:ac9:3d8b:0:0:0:0:0 with SMTP id u11csp772975oce; Wed, 4 Dec 2019 07:29:23 -0800 (PST) X-Google-Smtp-Source: APXvYqxT1tsESHWmhj2l4uWb/iCz+pNjqtf+McrPjLP0Eyt68vzxYbm/fZqIIUdTuM19mZvEhRP+ X-Received: by 2002:a05:6808:103:: with SMTP id b3mr2913968oie.89.1575473362952; Wed, 04 Dec 2019 07:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575473362; cv=none; d=google.com; s=arc-20160816; b=u5LHxQb7C2UoIGxZOyiXS4+wjpja46YymIIYQ0ElpjyWwaH7lJNaWm+RWcetbzsYsY x+8HXA/3hJP5hFMEbCySHmy6TyhOtzqZ/WcmbW/P1RIRhSbMvOGQBpJF3XodKxPp13Lc 7UmKzgJrWx9F/3IAy56tlXCAf4knY2xXILjMDRBZbUWBiEaev4zwcQ0u/OrM5/6i2D4l 1Sd1HhuzgnnHMcvhycZ7h1NfHrH/ZJTINfSq1wsTlJq+49zn3T81X/TovX9aiMySS38E jBIWYWpHyOHnCR+pmZnY1VrbYBAPeOMMEXJ03lNHHYTa1PUhkRs0JVYPiZ08T9808yPw ASrg== 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=JXuW32MEVpBGX+oYxjJlbOSqN8m13R4+8nxsyFB6KSo=; b=MTJdj58eB9mI910O86RlCbbc9XWUcrAInqGzBrkrf6zTIbDtYqE8ieu5K1q/ZeKfhS q9ieRwnxlQ2K4SQmhUAUgwucaZy0VBQ989VsIhExYEyu+a4noFUAQwVla5FO2G/ng4E4 Xaxnuwt0i/S53ke/NPee3BYDM+TmmpblIvHIw3jYZ+lqyFCoCCjuClF1zWS4RmXRl0dm R69vVEVLD+9OcZB/kqC3ckh5c0vefIIt3vACvDgWrNtRlrzyMiCNL/8nK3iy6IfAVYic 2sh7bICuCWJGhH/w2Q0kLuQUQ7xaowtj7rTXT+pHrIZ8HKbm5AUU5O++VyE0cb76GA8h cJ9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NzzfLl3F; 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 t134si2137689oie.148.2019.12.04.07.29.22; Wed, 04 Dec 2019 07:29:22 -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=NzzfLl3F; 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 S1728448AbfLDP3V (ORCPT + 27 others); Wed, 4 Dec 2019 10:29:21 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:34703 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728293AbfLDP3U (ORCPT ); Wed, 4 Dec 2019 10:29:20 -0500 Received: by mail-lj1-f194.google.com with SMTP id m6so8623274ljc.1 for ; Wed, 04 Dec 2019 07:29:19 -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=JXuW32MEVpBGX+oYxjJlbOSqN8m13R4+8nxsyFB6KSo=; b=NzzfLl3Ft2yWy0eGxjDMMRdiFd9HpDaDtBPQfI86Ry+T74t9MJJzS/nEUjgdDWH+Ns l5vCfZPTel14OWP7F4RgXtKZ2zcVC/WkIJrrR5/y2iP5Z59vNoyKfiNMHsYMYn+0a15s svTEJ7nYtBcG1pazF6M7+QWi49eVyFJbT/gSY3vzZRpipA9dPG3Cr25byAsuUX9m295C CG2HjYw45+R+1Ev/YiQ6pwGOQLvypadluuGeWp/CTlcUd6xP56SQ9EY59CPIQXbZLhWv AyYEHBYvLW5GjHaXQhvFWFcKRyl0jkKUlqXg8LGEAHbmyedWQ8ga7zTeo8rF/hP1yzRL 8X2A== 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=JXuW32MEVpBGX+oYxjJlbOSqN8m13R4+8nxsyFB6KSo=; b=DQp7tuZXn9RvT7xMfPej3qj84fMuNRQz/fbr9ePpWIUIXhBz9VPGYqHYVzOf2qWStP Hvx+9NGfybmHRR73sAWVMHTBRz0WJx0O9oHVlOEZrj63OV+BhclUOUHY2iDijJqP5IS2 RTp+4SMRNCQTZcKlZRPmoJkl99RiX5lZype1Wss7HSl24u6AgZLCh5d7lcePDrbnhWtx fMBgEQEYrRy/3mV5+H7GgOSxGOZs6oybsgEzFlO4uWR4k3Cm3br8vuWjwNfvuDg61Bwa 2eSIoOc8bgxZBpMmPN8QBcnZqihdO23Z7ezLHOPRfiM/4hZ2P2Twf8StG03DVV/rVZp7 B73g== X-Gm-Message-State: APjAAAWduIMkXYsJFSXqo9eZqv90dy5LUl+wJF4jheLbB3mIK0a2BUQN q8wxVKPoUzbzGNe8xkFXq+YLEcQv7Ay0nA== X-Received: by 2002:a2e:294e:: with SMTP id u75mr2399912lje.173.1575473359152; Wed, 04 Dec 2019 07:29:19 -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 n11sm3266870ljg.15.2019.12.04.07.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Dec 2019 07:29:17 -0800 (PST) From: Linus Walleij To: lee.jones@linaro.org, linux-kernel@vger.kernel.org Cc: Linus Walleij , Mark Brown Subject: [PATCH] mfd: mc13xxx-spi: Do not hardcode SPI mode flags Date: Wed, 4 Dec 2019 16:27:15 +0100 Message-Id: <20191204152715.12553-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/mc13xxx-spi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.23.0 diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 286ddcf5ddc6..9885e5f8210a 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c @@ -134,7 +134,13 @@ static int mc13xxx_spi_probe(struct spi_device *spi) dev_set_drvdata(&spi->dev, mc13xxx); - spi->mode = SPI_MODE_0 | SPI_CS_HIGH; + spi->mode |= SPI_MODE_0; + /* + * We want the inverse of what is set in the SPI core, if this + * is accomplished with a GPIO line then inversion semantics may + * be handled in the GPIO library. + */ + spi->mode ^= SPI_CS_HIGH; mc13xxx->irq = spi->irq;