From patchwork Mon Sep 15 12:57:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 389353 X-Patchwork-Delegate: sjg@chromium.org 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 64F65140142 for ; Mon, 15 Sep 2014 22:59:18 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7AA12A7A8A; Mon, 15 Sep 2014 14:59:02 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 0Iqm3ej5NXLv; Mon, 15 Sep 2014 14:59:02 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 83DCFA7A5D; Mon, 15 Sep 2014 14:58:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 82183A73E2 for ; Mon, 15 Sep 2014 14:58:15 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de 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 wZsFJ8KyJYlP for ; Mon, 15 Sep 2014 14:58:12 +0200 (CEST) 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-qc0-f201.google.com (mail-qc0-f201.google.com [209.85.216.201]) by theia.denx.de (Postfix) with ESMTPS id 4F04EA7A55 for ; Mon, 15 Sep 2014 14:58:00 +0200 (CEST) Received: by mail-qc0-f201.google.com with SMTP id o8so260540qcw.4 for ; Mon, 15 Sep 2014 05:57:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=TOGodMy5DVZbkrxZ4LAc1S7eLojKIyVsrWI7bkT/kfI=; b=ZaXbeMQaVcLiFnnK/bb2EfnPY22K87jhoMrUYGNGFyqcgI6hvnyio73iRdv+tX6Hjl 9sTjFLWcmVegqfFZp/WZf1XJX2zpOc5VC/ft3YFKTGh3dsQqYkDqqrxU8PWHjswpoeyt vxcUAvYcVopXA1jypXt8W/sUSbDNNipDhHEUIbm2xceRqBv1BjubnoWVb9zjbdWFNP3M MYtp0UYRMJj8S1jN6+6AVpvek8+16iF1TiKwhnbHdfwm1ieqJlnhvGUfRR86MHZC39I3 CvIQO1oVSQryKmgh3SzWqufqhoQr5Efqt1GkgTz80wGwbCBmq7rcRkTvtAsTIPuSR3hG 7qqw== X-Gm-Message-State: ALoCoQlDbEFfIKngdCkY5MYEd8eIFPw4LDULqERc9iC8lpPEh3/75KmUE68ealpEGuFdbi9cxc7l X-Received: by 10.236.148.2 with SMTP id u2mr48980yhj.55.1410785879466; Mon, 15 Sep 2014 05:57:59 -0700 (PDT) Received: from corpmail-nozzle1-1.hot.corp.google.com ([100.108.1.104]) by gmr-mx.google.com with ESMTPS id l45si536319yha.2.2014.09.15.05.57.59 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Sep 2014 05:57:59 -0700 (PDT) Received: from kaki.bld.corp.google.com ([172.29.216.32]) by corpmail-nozzle1-1.hot.corp.google.com with ESMTP id v8Vh0kvN.1; Mon, 15 Sep 2014 05:57:59 -0700 Received: by kaki.bld.corp.google.com (Postfix, from userid 121222) id 9EF6D2224F0; Mon, 15 Sep 2014 06:57:58 -0600 (MDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 15 Sep 2014 06:57:40 -0600 Message-Id: <1410785865-27946-6-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 2.1.0.rc2.206.gedb03e5 In-Reply-To: <1410785865-27946-1-git-send-email-sjg@chromium.org> References: <1410785865-27946-1-git-send-email-sjg@chromium.org> Subject: [U-Boot] [PATCH 05/10] dm: serial: Put common code into separate functions X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Avoid duplicating the code which deals with getc() and putc(). It is fairly simple, but may expand later. Signed-off-by: Simon Glass --- drivers/serial/serial-uclass.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 1ac943f..e93c624 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -71,7 +71,7 @@ void serial_initialize(void) serial_find_console_or_panic(); } -void serial_putc(char ch) +static void serial_putc_dev(struct udevice *dev, char ch) { struct dm_serial_ops *ops = serial_get_ops(cur_dev); int err; @@ -83,6 +83,11 @@ void serial_putc(char ch) serial_putc('\r'); } +void serial_putc(char ch) +{ + serial_putc_dev(cur_dev, ch); +} + void serial_setbrg(void) { struct dm_serial_ops *ops = serial_get_ops(cur_dev); @@ -107,28 +112,32 @@ int serial_tstc(void) return 1; } -int serial_getc(void) +static int serial_getc_dev(struct udevice *dev) { - struct dm_serial_ops *ops = serial_get_ops(cur_dev); + struct dm_serial_ops *ops = serial_get_ops(dev); int err; do { - err = ops->getc(cur_dev); + err = ops->getc(dev); } while (err == -EAGAIN); return err >= 0 ? err : 0; } +int serial_getc(void) +{ + return serial_getc_dev(cur_dev); +} + void serial_stdio_init(void) { } -void serial_stub_putc(struct stdio_dev *sdev, const char ch) +static void serial_stub_putc(struct stdio_dev *sdev, const char ch) { struct udevice *dev = sdev->priv; - struct dm_serial_ops *ops = serial_get_ops(dev); - ops->putc(dev, ch); + serial_putc_dev(dev, ch); } void serial_stub_puts(struct stdio_dev *sdev, const char *str) @@ -140,15 +149,8 @@ void serial_stub_puts(struct stdio_dev *sdev, const char *str) int serial_stub_getc(struct stdio_dev *sdev) { struct udevice *dev = sdev->priv; - struct dm_serial_ops *ops = serial_get_ops(dev); - - int err; - do { - err = ops->getc(dev); - } while (err == -EAGAIN); - - return err >= 0 ? err : 0; + return serial_getc_dev(dev); } int serial_stub_tstc(struct stdio_dev *sdev)