Message ID | 20200106140931.1136-3-rasmus.villemoes@prevas.dk |
---|---|
State | Superseded |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="TsPKOe57"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47ry873xHXz9sQp for <incoming@patchwork.ozlabs.org>; Tue, 7 Jan 2020 01:10:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69EFF81717; Mon, 6 Jan 2020 15:09:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="TsPKOe57"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BF3181717; Mon, 6 Jan 2020 15:09:53 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FORGED_SPF_HELO, SPF_HELO_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::70a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 415998170A for <u-boot@lists.denx.de>; Mon, 6 Jan 2020 15:09:48 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RepUlDzAoKKX70HkrkDOr5OPwXsMvUlz8QpURKQsD3cb/t5OgVWgm6QVfBoQ+9Nohq0Zi5gh6lq3TpdzcRf8LKUJPjfl7CBMjfYgVoqRXhUtuEfuct/du3W0qDPRYe0e77ba10hb3K227mC67S4+ZSjeTd/pTQjAITPFJKoO6fcpHEJ99HACaUcoRnnewchhTsVg42LIcK1OW6rTw3ypiz7hPDOqSohtPbd2Yjjh6967Vy90PADg3n6OJIprbqbFzN/5n88BkV55FFNyco2+xhqqjV5Mx8orTXNiQPvVHplK0a+DV00GaKX2XJfCy0jpIdnIV5coVoIktbqu7AO1lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGqeJ4Ssw64f8IMeHvv3LwyJrEiwxIVLv5qHp6V4kUg=; b=bwrzDkY7DOsdmM5NE1O+cFzaJvPqdaF/jx1fIBBii9RvBSZYxGAsrVXuupa/3+xUwDuydrmrMGk13oinTXwk4muP4exdCjpNy3I2PE94RQL5mfEjcFKdOxn1mP0qxiYCESJAIIOXOn1e0gkR5lDIRyhTpl8wE305pby0ah9Mhtj61nN0HaOxGd70Oyu1yi4ZSba81rM8S+XHRDqBM9U+q8ef8MVaSH1xeO6vTctQYW8lxScG9B12hJgApnOQxHrrWblEJy9CoCbypbCSkhYYPEsjWQRJP0R/APKzjC5Au+Cvd/GqUsWbee2gYDokzwChumqtg5Xxio5dj6RCXxdWLw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kGqeJ4Ssw64f8IMeHvv3LwyJrEiwxIVLv5qHp6V4kUg=; b=TsPKOe574nKVZ2zF0WuQ79l4kT5hjcrSJxqMgGz0jsOSEZAwE5NJMmg2HltBP2mP7CsVxWrQ6LbF61Q2K0A6xEp8zkeIzhXo0tQZJcO3TPqPEWXhsdaQbYAYlSLQQiU2xZThym4d1J02GLIps8mj+Xr13jCYnvwvV6JauDNSSLY= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2144.EURPRD10.PROD.OUTLOOK.COM (20.177.62.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.15; Mon, 6 Jan 2020 14:09:47 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::8175:5aa2:2870:766d]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::8175:5aa2:2870:766d%6]) with mapi id 15.20.2602.015; Mon, 6 Jan 2020 14:09:47 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 14:09:47 +0000 From: Rasmus Villemoes <rasmus.villemoes@prevas.dk> To: "u-boot@lists.denx.de" <u-boot@lists.denx.de> Subject: [PATCH 2/4] mpc8xxx_spi: put max_cs to use Thread-Topic: [PATCH 2/4] mpc8xxx_spi: put max_cs to use Thread-Index: AQHVxJr0Br7leptVgkKYNtF/lRXIHw== Date: Mon, 6 Jan 2020 14:09:47 +0000 Message-ID: <20200106140931.1136-3-rasmus.villemoes@prevas.dk> References: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) x-mailer: git-send-email 2.23.0 authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [81.216.59.226] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 938a064f-7f9a-448f-1ddf-08d792b2166c x-ms-traffictypediagnostic: VI1PR10MB2144: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: <VI1PR10MB214401A79628F153108A9039933C0@VI1PR10MB2144.EURPRD10.PROD.OUTLOOK.COM> x-ms-oob-tlc-oobclassifiers: OLM:418; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(136003)(366004)(39850400004)(376002)(189003)(199004)(66476007)(8676002)(64756008)(66446008)(66556008)(66946007)(54906003)(86362001)(6486002)(81166006)(81156014)(16526019)(52116002)(186003)(26005)(6506007)(316002)(4326008)(36756003)(5660300002)(71200400001)(2906002)(44832011)(6916009)(1076003)(2616005)(6512007)(107886003)(8976002)(8936002)(956004)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2144; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: WUt6wd0EZ9KVYv7GYb4FouR/4TrgBDJ9gdZ2VxYxlQy9kobnx3yyPayAhsVQ0NyNuVVff/ijP1QkqpLiMuR8rB3ZOzfLgAQPmHGbh/YAbdg6EeoPjl0/b5WS65A2kqmVO4w6PAmnBZpG43QnnUJU11fYKr4tMFNwYftOYuWYVbhWTMIZHWRGo6AnkZ5AFEgrUqjODGkMeLIxKk5V2yhmkugYwKOJR46sfuwheobnNk4B8csLrbonYladeyJFOMqNXtzavBDDWClHdo9UQuoedZPcLX42UGWAe4wX3MEKDVXzbvY9jjD/w3Mu5VQZTReMGGAVyj4hhfxkAonI2cCnQLlH4g4rti5FY8ZIH7StAHItLfw8y2WDwyp6RVXocmQHb8ypTBcvLVAe9eEmeDFW8TbNg+HAY6BDy/czyhkSXuiDmDOJFcjz3q3/xcuONtm0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 938a064f-7f9a-448f-1ddf-08d792b2166c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:09:47.7091 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: epXne2IBva1T6taLzfuPlh4D0ZxKIEtUYHoBX0Lwg/orhI2Tig1YXpJ7m0cnsDNKk3m4xoaU964pA1CTN4he05JMTzFaT3Onhz8uJRCt2HA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2144 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Cc: =?iso-8859-1?q?Klaus_Henning_S=F8rensen?= <Klaus.Sorensen@prevas.dk> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean |
Series | spi: mpc8xxx_spi: bug fixes and real ->set_speed | expand |
diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 1c7bf10f91..ac4d0a9bae 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -35,7 +35,7 @@ enum { struct mpc8xxx_priv { spi8xxx_t *spi; struct gpio_desc gpios[16]; - int max_cs; + int cs_count; }; static inline u32 to_prescale_mod(u32 val) @@ -74,7 +74,7 @@ static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) if (ret < 0) return -EINVAL; - priv->max_cs = ret; + priv->cs_count = ret; return 0; } @@ -131,6 +131,11 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, debug("%s: slave %s:%u dout %08X din %08X bitlen %u\n", __func__, bus->name, platdata->cs, *(uint *)dout, *(uint *)din, bitlen); + if (platdata->cs >= priv->cs_count) { + dev_err(dev, "chip select index %d too large (cs_count=%d)\n", + platdata->cs, priv->cs_count); + return -EINVAL; + } if (flags & SPI_XFER_BEGIN) mpc8xxx_spi_cs_activate(dev);
Currently, max_cs is write-only; it's just set in mpc8xxx_spi_ofdata_to_platdata and not otherwise used. My mpc8309 was always resetting during an "sf probe 0". It turns out dm_gpio_set_dir_flags() was being called with garbage, since nothing had initialized priv->gpios[0] - our device tree used "cs-gpios" rather than "gpios", so gpio_request_list_by_name() had returned 0. That would have been a lot easier to figure out if the chip select index was sanity checked, so rename max_cs to cs_count, and reject a xfer with a too large cs index. Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> --- drivers/spi/mpc8xxx_spi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)