From patchwork Thu Feb 11 15:09:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1439549 X-Patchwork-Delegate: trini@ti.com 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=) 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 4Dc0SQ4VlQz9rx6 for ; Fri, 12 Feb 2021 02:10:46 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8F98582694; Thu, 11 Feb 2021 16:10:31 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id A2B888269F; Thu, 11 Feb 2021 16:09:57 +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=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 62B5382656 for ; Thu, 11 Feb 2021 16:09:50 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com IronPort-SDR: 7aVuMUuBlIeDx0c7w6uhAmDAdLUbHexrW4t9lyZ7rxxol584w4yCmesfv5vLR2HVxF3UMyk+7s mQG39obZTTew== X-IronPort-AV: E=McAfee;i="6000,8403,9891"; a="182388539" X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="182388539" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Feb 2021 07:09:48 -0800 IronPort-SDR: CLXgHz/vElo+SbaK5TzXKoOFNQ5NcFGeQ52eBxNQbcw7qb003PobyDN5wBJhk6S0zMSWTFg2cr DyL3KOHkEWIg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,170,1610438400"; d="scan'208";a="362527558" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 11 Feb 2021 07:09:46 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 684C535A; Thu, 11 Feb 2021 17:09:45 +0200 (EET) From: Andy Shevchenko To: marex@denx.de, sjg@chromium.org, trini@konsulko.com, u-boot@lists.denx.de, mbrugger@suse.com Cc: Andy Shevchenko Subject: [PATCH v1 04/11] console: Switch to use stdio_file_to_flags() Date: Thu, 11 Feb 2021 17:09:37 +0200 Message-Id: <20210211150944.73252-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210211150944.73252-1-andriy.shevchenko@linux.intel.com> References: <20210211150944.73252-1-andriy.shevchenko@linux.intel.com> 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 Deduplicate code by replacing with stdio_file_to_flags() helper. Signed-off-by: Andy Shevchenko --- common/console.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/common/console.c b/common/console.c index f3cc45cab548..b1c3ed17cc03 100644 --- a/common/console.c +++ b/common/console.c @@ -854,17 +854,9 @@ int console_assign(int file, const char *devname) struct stdio_dev *dev; /* Check for valid file */ - switch (file) { - case stdin: - flag = DEV_FLAGS_INPUT; - break; - case stdout: - case stderr: - flag = DEV_FLAGS_OUTPUT; - break; - default: - return -1; - } + flag = stdio_file_to_flags(file); + if (flag < 0) + return flag; /* Check for valid device name */