From patchwork Sun Oct 2 12:22:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9359607 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 851386075E for ; Sun, 2 Oct 2016 12:24:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77FB528AE9 for ; Sun, 2 Oct 2016 12:24:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C96B28AFC; Sun, 2 Oct 2016 12:24:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4420F28AE9 for ; Sun, 2 Oct 2016 12:24:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751788AbcJBMYP (ORCPT ); Sun, 2 Oct 2016 08:24:15 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34181 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751006AbcJBMYP (ORCPT ); Sun, 2 Oct 2016 08:24:15 -0400 Received: by mail-wm0-f65.google.com with SMTP id b201so5217141wmb.1 for ; Sun, 02 Oct 2016 05:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=MPDcbQDW07aFWigj1j6hhKwW9Pzao68roAeVKIk1GAs=; b=R4fabmZIL1UivEPP7wcrLOfxSLn43FSTgbeSR+jD5pfqZXH7PpNOxBl4tZSMYNYY24 sFhnS5GdXF+MbIH4W8w7H+z2jur69YIN/A9wjYDKxd1ZekJkmBHf/s0Utln9fMcLpR3V JNstsGNMSNDVy7wm/FmmqX3Wglx5RxjHfNY9aZlNkBH/pS/Hdv+gvDiMwa3SsPxinIls q5cMohcJzptty+H9WWoFnrBSUacFLmwMXv/xU52MAO6Q3kBH9MrTQRls3Mg4hOR5qw2c 4t7C1cYpYwk/9vniwRpy1RYmYJ4EQwcIW5iq2QQw/QoCCnytLzcrQCsdboQEsVQJYCGL +ZCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=MPDcbQDW07aFWigj1j6hhKwW9Pzao68roAeVKIk1GAs=; b=LCdndsYHupQA1JXQicsmYeafp35j6AQhbbWMVBzBz44EBbx9byUS3h5XDNAXFXrAg2 GNDjYBdngYtM+a89GC8Zr6pFzF7I500Eo0icK8pSqAmc1XbAnwQHdnNxRdz6wvLKg0tA 8eNkmJdcjJ4K+AqjgqHs43RPZI9PzMubtB0RkhjHLarBINF/3jSCgcqpzelw98Ukejxz 87fy10XOaEdkCZ952T0kxl6q/Jz1fzNUX9OXRwHem+ILvQoOI0kCvWZbSOZH+veAQbfT mGQ1WU7wOTfyXdVZZt3tkzV5ktjasHj+v2LxPi+rp/fGmqLvt5Lt3POHJrQnXwPzLaRu 8F4A== X-Gm-Message-State: AA6/9RktURLxG66E/WMkn2xwIkEGKU20LzagQv1j0uXOP4EQAfEs0um5Mf/Z1S5guA+Lyw== X-Received: by 10.194.191.162 with SMTP id gz2mr12912509wjc.182.1475411053601; Sun, 02 Oct 2016 05:24:13 -0700 (PDT) Received: from ?IPv6:2003:62:5f1b:3000:8dbc:eb8a:fb9c:9173? ([2003:62:5f1b:3000:8dbc:eb8a:fb9c:9173]) by smtp.googlemail.com with ESMTPSA id 4sm13744521wmu.2.2016.10.02.05.24.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Oct 2016 05:24:13 -0700 (PDT) From: Heiner Kallweit Subject: [PATCH 01/11] spi: fsl-espi: reject MSB-first transfers with word sizes other than 8 or 16 To: Mark Brown References: Cc: "linux-spi@vger.kernel.org" Message-ID: Date: Sun, 2 Oct 2016 14:22:35 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP According to the ESPI spec MSB-first transfers are supported for word size 8 and 16 only. Check for this and reject MSB-first transfers with other word sizes. Signed-off-by: Heiner Kallweit --- drivers/spi/spi-fsl-espi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/spi/spi-fsl-espi.c b/drivers/spi/spi-fsl-espi.c index 1f97cce..65bb70d 100644 --- a/drivers/spi/spi-fsl-espi.c +++ b/drivers/spi/spi-fsl-espi.c @@ -153,6 +153,7 @@ static int fsl_espi_check_message(struct spi_message *m) first = list_first_entry(&m->transfers, struct spi_transfer, transfer_list); + list_for_each_entry(t, &m->transfers, transfer_list) { if (first->bits_per_word != t->bits_per_word || first->speed_hz != t->speed_hz) { @@ -161,6 +162,15 @@ static int fsl_espi_check_message(struct spi_message *m) } } + /* ESPI supports MSB-first transfers for word size 8 / 16 only */ + if (!(m->spi->mode & SPI_LSB_FIRST) && first->bits_per_word != 8 && + first->bits_per_word != 16) { + dev_err(mspi->dev, + "MSB-first transfer not supported for wordsize %u\n", + first->bits_per_word); + return -EINVAL; + } + return 0; }