From patchwork Mon Nov 9 03:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1396494 X-Patchwork-Delegate: sjg@chromium.org Return-Path: 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=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=jh/a6oZc; 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CTxXv3MJXz9sRK for ; Mon, 9 Nov 2020 14:38:23 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BACF38254C; Mon, 9 Nov 2020 04:37:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="jh/a6oZc"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 05B3182543; Mon, 9 Nov 2020 04:37:00 +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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x144.google.com (mail-il1-x144.google.com [IPv6:2607:f8b0:4864:20::144]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 168518253E for ; Mon, 9 Nov 2020 04:36:54 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x144.google.com with SMTP id p10so7023029ile.3 for ; Sun, 08 Nov 2020 19:36:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dw01D9/1Nwhvw+Wgi9sleStSzSByfM+xCREjnOk2l7A=; b=jh/a6oZc5mvIR+njbxhM1CpAivyvEQjXwoeoWI5y5juT8Kgm8fwS1xhxRmrgwPTHgY QiS93Hud6yUt1EaZrBQSd2aaqtEq/gf1qmomRd5wJBhTOhj5ecTW8AQx+/nkWbSGKtoP TxcUrWkOwC4xkCTAx4GrNkmBL49p0unpcTxUs= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dw01D9/1Nwhvw+Wgi9sleStSzSByfM+xCREjnOk2l7A=; b=gNxU6NsuluIXj2r/qAfVnHXeeC7HSFGNtJe1m4Y6hlIfRCekS5LRGSm4WX8gy+OlY8 Ii/XRTXPbIyIFPjZ3/2agSZFTgTZJCk/R3FUIWwx6fk/PZii53YNwzC2QZyXkBXDAwsm Byivla0BdP7LM+G5z/YWQx2lVcswX8AJX0/8d0zkv8YBUq/9R98RYcxXUFCKI814yByg d7QHkKJTKVw+Hgva9/4WdOaDszqXbSP30QDgk83dSGmW0PtGfto1IhrF2OWnhaQUBTxL Xm02IHrllpQrSiYCw3ov7WN7iAVEXb74qWHYLkN59CQNpnlCCAo62W9pVKy1HBibgvnz JB3A== X-Gm-Message-State: AOAM532Tv6WbZR9Ykp5VYyO3WYvfnHmrkcEMBrdC42sIonRTlOrGLisO z7vIUANqOTmZxq076aqnHcci8duxja4kLQ== X-Google-Smtp-Source: ABdhPJynozbjZU3nJ9GDzTtvhf7hdiqGBIVHmP9jpQdByTsmUkm30tkSQng5Kbty4tzCmZNmtonXJw== X-Received: by 2002:a05:6e02:106c:: with SMTP id q12mr8693966ilj.41.1604893013258; Sun, 08 Nov 2020 19:36:53 -0800 (PST) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r3sm5098792iot.21.2020.11.08.19.36.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 19:36:52 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andy Shevchenko , Bin Meng , Heinrich Schuchardt , Walter Lozano Subject: [PATCH 1/3] serial: sandbox: Drop unnecessary #ifdefs Date: Sun, 8 Nov 2020 20:36:48 -0700 Message-Id: <20201108203644.1.I075d0e4c28f1b9d05e68b1abc928ee7c01c9e6ab@changeid> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog In-Reply-To: <20201109033650.1860135-1-sjg@chromium.org> References: <20201109033650.1860135-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean CONFIG_OF_CONTROL is always enabled for sandbox (as it should be for all boards), so we can drop it. Also use IS_ENABLED() for the SPL check. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/serial/sandbox.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index db2fbac6295..e3967deaaf2 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -22,8 +22,6 @@ DECLARE_GLOBAL_DATA_PTR; -#if CONFIG_IS_ENABLED(OF_CONTROL) - /* * * serial_buf: A buffer that holds keyboard characters for the @@ -122,9 +120,8 @@ static int sandbox_serial_pending(struct udevice *dev, bool input) return 0; os_usleep(100); -#ifndef CONFIG_SPL_BUILD - video_sync_all(); -#endif + if (!IS_ENABLED(CONFIG_SPL_BUILD)) + video_sync_all(); if (next_index == serial_buf_read) return 1; /* buffer full */ @@ -146,7 +143,6 @@ static int sandbox_serial_getc(struct udevice *dev) serial_buf_read = increment_buffer_index(serial_buf_read); return result; } -#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ #ifdef CONFIG_DEBUG_UART_SANDBOX @@ -211,7 +207,6 @@ static int sandbox_serial_getinfo(struct udevice *dev, return 0; } -#if CONFIG_IS_ENABLED(OF_CONTROL) static const char * const ansi_colour[] = { "black", "red", "green", "yellow", "blue", "megenta", "cyan", "white", @@ -277,5 +272,3 @@ U_BOOT_DEVICE(serial_sandbox_non_fdt) = { .platdata = &platdata_non_fdt, }; #endif - -#endif /* CONFIG_IS_ENABLED(OF_CONTROL) */ From patchwork Mon Nov 9 03:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1396495 X-Patchwork-Delegate: sjg@chromium.org Return-Path: 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=MdOEKgD8; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CTxXz6sDbz9sRK for ; Mon, 9 Nov 2020 14:38:27 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 786AC82558; Mon, 9 Nov 2020 04:37:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="MdOEKgD8"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 72F2E82547; Mon, 9 Nov 2020 04:37:07 +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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 19F6A82547 for ; Mon, 9 Nov 2020 04:37:02 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd42.google.com with SMTP id t8so3888405iov.8 for ; Sun, 08 Nov 2020 19:37:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VO2zgD9u14YInSMtuOEwtXmivEwe0GNsKTS9rBaw6ds=; b=MdOEKgD8uy2c3axI6KBbVvKAGQfm9Ae6nrm4sn6E2MySLsTi/sZIt/IcGcNadTZtNz nTjsXMPelIaMi874FEkB40P+jdPX8pLzmGMBhbmYpTTzgjsn9Q0lxBvsJRWk/Y7QXMga 7vvp6ZtpE4T8ka87DNJHkDKdv455/+v0ytFuc= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VO2zgD9u14YInSMtuOEwtXmivEwe0GNsKTS9rBaw6ds=; b=r3qWYJyPywcomKpUbmIByASC9DZ7hayqcdaikFLwdqYNSWs+VYM+FhLSnU+BCN2ZRy kkdTBhkUyq3BR3NnGC3TAEwmdmucBHd7og/qz5JJrrl4NTU0LxhnpL/7OufKtGE+Dd7i wJqKsUgijnKWuf/KZlTxDobpFgve2g2ihLz/rSaMwNibLQHSmi2yQ6MdSqY5Sgh4RRZj 1V8nIiT+xlQb0xg6mL0X/ujn5u2aPoVJRB9c9oyyqTD116NJo3DgJe1+y8fP1XLfEKs1 3TK+jw8NVebBYZE/J5RJmM5nR9N3yJ+NYSEoxyFezngHPjws5e5nyprrgz2eCyY5Da5D KcSA== X-Gm-Message-State: AOAM53277EL2HwC1JgvkbLOhRYQbLcMSAlPCm+lfJfiEdPZb7tkwdCIM mD2G2nJBl3o/36TOQoekjSMlwn5Cu5/d2g== X-Google-Smtp-Source: ABdhPJzRRv3XVtGPtVYUGC8NkuDjiMAqgAlRTZMI0XEZ6hmTqLlvf8vVQnhRm/IboEl1XaTHBDBA0A== X-Received: by 2002:a05:6638:10ef:: with SMTP id g15mr9659071jae.85.1604893014129; Sun, 08 Nov 2020 19:36:54 -0800 (PST) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r3sm5098792iot.21.2020.11.08.19.36.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 19:36:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andy Shevchenko , Bin Meng , Heinrich Schuchardt , Walter Lozano Subject: [PATCH 2/3] sandbox: serial: Convert to livetree Date: Sun, 8 Nov 2020 20:36:49 -0700 Message-Id: <20201108203644.2.I6749710ab82d3e6cb2b0091e62164916e5d86619@changeid> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog In-Reply-To: <20201109033650.1860135-1-sjg@chromium.org> References: <20201109033650.1860135-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Use a livetree function to read the colour. Signed-off-by: Simon Glass --- drivers/serial/sandbox.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index e3967deaaf2..8c74c3a1b8c 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -221,8 +220,7 @@ static int sandbox_serial_ofdata_to_platdata(struct udevice *dev) if (CONFIG_IS_ENABLED(OF_PLATDATA)) return 0; plat->colour = -1; - colour = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), - "sandbox,text-colour", NULL); + colour = dev_read_string(dev, "sandbox,text-colour"); if (colour) { for (i = 0; i < ARRAY_SIZE(ansi_colour); i++) { if (!strcmp(colour, ansi_colour[i])) { From patchwork Mon Nov 9 03:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1396496 X-Patchwork-Delegate: sjg@chromium.org Return-Path: 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=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=T7silO9Q; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CTxY95S1Hz9sRK for ; Mon, 9 Nov 2020 14:38:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 762D98256C; Mon, 9 Nov 2020 04:37:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="T7silO9Q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3F3C782563; Mon, 9 Nov 2020 04:37:11 +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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 4B00582544 for ; Mon, 9 Nov 2020 04:37:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd43.google.com with SMTP id o11so8371112ioo.11 for ; Sun, 08 Nov 2020 19:37:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=dA6KUp8E36D/foQdJkX1zxvfMjainGFUR3WRG0jDOFY=; b=T7silO9Qhb1UJHFWUjenb3QAdzcPb24WEJ3oVfMQ0j/9KIIrXLM0x4FYkgIsRA1B35 VaNEn15b+TkTRJnJoEjNi0Mo3ITPgLRfDZZZpKF7IHNauDlTSTEH42okTB8W3UeWdfmx b8RZtDH04yAUSOKkrTktvxKsOhXEeJQupubWc= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=dA6KUp8E36D/foQdJkX1zxvfMjainGFUR3WRG0jDOFY=; b=gh7hmbdxbEfObNC/dLsdxbZSfKk0rf08cyLECPprWk0LaFsT6/7pEKnbGjcg3Xg9Vs rr80X6Ff3j4DSqbL/2XbrK7a32IzzQbjaoHCUpdJU/r12dyMudnBAnzz4G8RnE5cDPmq e0BiarVTF87pU2tEUmrzI/VkPM+EM33GYJH2G1Df5V+qDfrFOjK7x90erDtL4fAF3jw2 59wulKdY0ffnByMDUdrioLgFFXbflu3JNtfdAPAtEYWSeOZ4LpxMzA7smUD+5V/5XAHC s3xLfc+ULVFDga/PiGUj3v7LK8QXCgmjD1SblcrsTwZJTbzRSOlezN1U+IauXiDd83mM 8kvw== X-Gm-Message-State: AOAM532QEeUAhfsePqV1N5/sGicEyibWfRv1jAgt9fQqVNIh1aSrkE5y 3DwQvn0AlxvEvjDS9QW+YGNaRDNNU8/pFw== X-Google-Smtp-Source: ABdhPJxdpeO1ZtJxPs66Si2n+oel6UJjm9ffU2SWHgw+VGEdiPApsp8s4wgGoEOtwPQ/gk/OFgRZUw== X-Received: by 2002:a05:6602:5de:: with SMTP id w30mr4974222iox.64.1604893014996; Sun, 08 Nov 2020 19:36:54 -0800 (PST) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id r3sm5098792iot.21.2020.11.08.19.36.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Nov 2020 19:36:54 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Andy Shevchenko , Bin Meng , Heinrich Schuchardt , Walter Lozano Subject: [PATCH 3/3] sandbox: serial: Update to use membuff Date: Sun, 8 Nov 2020 20:36:50 -0700 Message-Id: <20201108203644.3.I124d1e372667a17aa3f63684be7b8fd0cb03c6e8@changeid> X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog In-Reply-To: <20201109033650.1860135-1-sjg@chromium.org> References: <20201109033650.1860135-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Rather than implementing our own circular queue, use membuff. This allows us to read multiple bytes at once into the serial input. Signed-off-by: Simon Glass --- drivers/serial/sandbox.c | 48 ++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/drivers/serial/sandbox.c b/drivers/serial/sandbox.c index 8c74c3a1b8c..8e269a205d7 100644 --- a/drivers/serial/sandbox.c +++ b/drivers/serial/sandbox.c @@ -21,24 +21,18 @@ DECLARE_GLOBAL_DATA_PTR; -/* - * - * serial_buf: A buffer that holds keyboard characters for the - * Sandbox U-Boot. - * - * invariants: - * serial_buf_write == serial_buf_read -> empty buffer - * (serial_buf_write + 1) % 16 == serial_buf_read -> full buffer - */ -static unsigned char serial_buf[16]; -static unsigned int serial_buf_write; -static unsigned int serial_buf_read; - struct sandbox_serial_platdata { int colour; /* Text colour to use for output, -1 for none */ }; +/** + * struct sandbox_serial_priv - Private data for this driver + * + * @buf: holds input characters available to be read by this driver + */ struct sandbox_serial_priv { + struct membuff buf; + char serial_buf[16]; bool start_of_line; }; @@ -71,6 +65,7 @@ static int sandbox_serial_probe(struct udevice *dev) if (state->term_raw != STATE_TERM_RAW) disable_ctrlc(1); + membuff_init(&priv->buf, priv->serial_buf, sizeof(priv->serial_buf)); return 0; } @@ -104,16 +99,12 @@ static int sandbox_serial_putc(struct udevice *dev, const char ch) return 0; } -static unsigned int increment_buffer_index(unsigned int index) -{ - return (index + 1) % ARRAY_SIZE(serial_buf); -} - static int sandbox_serial_pending(struct udevice *dev, bool input) { - const unsigned int next_index = - increment_buffer_index(serial_buf_write); + struct sandbox_serial_priv *priv = dev_get_priv(dev); ssize_t count; + char *data; + int avail; if (!input) return 0; @@ -121,26 +112,25 @@ static int sandbox_serial_pending(struct udevice *dev, bool input) os_usleep(100); if (!IS_ENABLED(CONFIG_SPL_BUILD)) video_sync_all(); - if (next_index == serial_buf_read) + avail = membuff_putraw(&priv->buf, 100, false, &data); + if (!avail) return 1; /* buffer full */ - count = os_read(0, &serial_buf[serial_buf_write], 1); - if (count == 1) - serial_buf_write = next_index; + count = os_read(0, data, avail); + if (count > 0) + membuff_putraw(&priv->buf, count, true, &data); - return serial_buf_write != serial_buf_read; + return membuff_avail(&priv->buf); } static int sandbox_serial_getc(struct udevice *dev) { - int result; + struct sandbox_serial_priv *priv = dev_get_priv(dev); if (!sandbox_serial_pending(dev, true)) return -EAGAIN; /* buffer empty */ - result = serial_buf[serial_buf_read]; - serial_buf_read = increment_buffer_index(serial_buf_read); - return result; + return membuff_getbyte(&priv->buf); } #ifdef CONFIG_DEBUG_UART_SANDBOX