From patchwork Sat Nov 19 20:49:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 696955 X-Patchwork-Delegate: jagannadh.teki@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3tLn6x5s9Cz9snm for ; Sun, 20 Nov 2016 07:50:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vS1rgIsH"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 96A63A754C; Sat, 19 Nov 2016 21:49:59 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a7ETAAbgUfqQ; Sat, 19 Nov 2016 21:49:59 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 09C2FA754E; Sat, 19 Nov 2016 21:49:59 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 827BAA754E for ; Sat, 19 Nov 2016 21:49:56 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lUCsGNWbxk4z for ; Sat, 19 Nov 2016 21:49:56 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-ua0-f196.google.com (mail-ua0-f196.google.com [209.85.217.196]) by theia.denx.de (Postfix) with ESMTPS id 1EF5FA754C for ; Sat, 19 Nov 2016 21:49:52 +0100 (CET) Received: by mail-ua0-f196.google.com with SMTP id 12so21401705uas.3 for ; Sat, 19 Nov 2016 12:49:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=0EtZaNMYy9pGTo2VM9F95DHCLKHLvelgRyuLuEnZszA=; b=vS1rgIsHAhQepsoBJS9m5sJEPnlAgzGsZWhkKAK178AL9LDJzOfejNKiJUq+G6ZqFj QXcxjLL30QL88SehjdLoTnJWF9XHx4dNTf4Dfc3YT8myVqyTIIRnbWLlTspHs4ryaQvl 1jwZbt1xoJzFwYIntS3krc05w1CLtBygIiko/EmmLCbWNsCrPahu3fTFUwv0BRD/ksd6 4Hb9fB9FBpOl5jFxZiZRZ9l8yfuCymRJueRQwxS6y9jrwEDCB50LcErVstaEXPT+cUI5 8Nn0lHTBKlWkRnAxw3q7Yotd6x1WqNwGXFRoxTzi4O88gW/lkOHRY7nraB5qvI9Am8uy 7AVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=0EtZaNMYy9pGTo2VM9F95DHCLKHLvelgRyuLuEnZszA=; b=B+w5i1GSjs9N0YKIj0xcn+WDc8gqO/7hhlE7UQrOgaOUiEGrLrkuzLclVgF4v5Pm9x Lvsw6TsAtp0M5npzL95iHuK3jxH3E+Pj/l0c8FvP+EpMjm7EuEmhEP3GE5EnGIzOdE1b red7px0RBGuEywM8ZZn2yAliwlZ+exjFTc/biPUeH0z1H0YMHMRBrhxQpoLgJ5eVpbnS 2clnJyGJNRy6OownfzMklehXuxcrFE5Vln+3XYr3lPET1kCMz9mxXYH1gNfkFHDpdPLg d/YWExy59m3MoQHe7HAtzSs3I6+X7aYIIqTVF2yQ35AyUV+c9UnhDj8QTbzqE9Na/EiF vLfQ== X-Gm-Message-State: AKaTC032YYjOfbF+Ds0CgvMFj+avWpRig5cd4tR9xKoUsOfZtJeTeEPhkCB0y+Zij3CEvHo5Ae38ZcSV2c+7Xw== X-Received: by 10.159.39.230 with SMTP id b93mr3714082uab.87.1479588591430; Sat, 19 Nov 2016 12:49:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.81.133 with HTTP; Sat, 19 Nov 2016 12:49:50 -0800 (PST) In-Reply-To: References: <1479072136-14246-1-git-send-email-sjg@chromium.org> <1479072136-14246-11-git-send-email-sjg@chromium.org> From: Fabio Estevam Date: Sat, 19 Nov 2016 18:49:50 -0200 Message-ID: To: Simon Glass Cc: Jagan Teki , U-Boot Mailing List , Jeffy Chen , Stephen Warren , huang lin Subject: Re: [U-Boot] [PATCH v2 10/22] spi: Add error checking for invalid bus widths X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" On Sat, Nov 19, 2016 at 6:04 PM, Simon Glass wrote: >> EPROTONOSUPPORT means: /* Protocol not supported */, which does not >> seem to be very appropriate here. > > This is a protocol as far as I can see - you can either use one pin or > four pins. Actually they are SPI modes: one, two or four pins. >> Why not return -EINVAL instead? > > The value is valid but is not supported. If we just return -EINVAL for > anything we don't like, it makes it harder to root-cause the error. In > particular we use -EINVAL when decoding the device tree. But > EPROTONOSUPPORT is not widely used. I think the current behaviour of not returning an error code on an invalid mode is correct and it matches what the kernel does in drivers/spi/spi.c. If an invalid mode is passed we just ignore it and operate in single mode instead. Maybe we can make this clearer by printing a message like this: @@ -423,7 +423,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, mode |= SPI_RX_QUAD; break; default: - error("spi-rx-bus-width %d not supported\n", value); + printf("spi-rx-bus-width %d not supported, operating in single mode\n", value); break; } --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -408,7 +408,7 @@ int spi_slave_ofdata_to_platdata(const void *blob, int node, mode |= SPI_TX_QUAD; break; default: - error("spi-tx-bus-width %d not supported\n", value); + printf("spi-tx-bus-width %d not supported, operating in single mode\n", value); break; }