From patchwork Wed Dec 5 19:53:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1008428 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=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PTRqDakk"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4398cz3BJMz9s8J for ; Thu, 6 Dec 2018 06:56:35 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id CF5C9C22714; Wed, 5 Dec 2018 19:55:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 305F1C224EE; Wed, 5 Dec 2018 19:54:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 355D5C226DB; Wed, 5 Dec 2018 19:54:28 +0000 (UTC) Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by lists.denx.de (Postfix) with ESMTPS id A7235C22062 for ; Wed, 5 Dec 2018 19:54:27 +0000 (UTC) Received: by mail-io1-f70.google.com with SMTP id n25so18777300iog.13 for ; Wed, 05 Dec 2018 11:54:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=O39LeAGO/TGF6etRwFfw4Yn79Xsxw2bIHXWIiUuiKcU=; b=PTRqDakkfZv6ZSxYk/LoSYUWbi8K4vBdte6BgjatLRKusaAY3ag3Bj7KhwNMs9jWOT tG7Kq8ToYa5VcNwZ4fYFsHaq6OHZZ1HKhHsnm9VA1d6wovDqmsI7jT4K4enMFDK1LDzm O3S5oObTq6seAt3ixKLNwz43neLcaOtU92L60= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=O39LeAGO/TGF6etRwFfw4Yn79Xsxw2bIHXWIiUuiKcU=; b=FfH0r5w9xSu58I9wQkYSnD/yN7yP6b6M5N5f3zQP9vsq3r6Fpvz3YE0NN6j+5tGyDv ZN1KbY0Tgcqe0rb4gxvtBrLr6RAiwe0kGoy/2bnboETqan9N16p+PBurrHB+PuytGNu7 qwh/nTBmUCANf1rT2qsxQWFt4JjFgV8ILlOtI6rZxhbPXqXMaqdK+98QBE0Mk+27/O7A 1yjSsFR4kHynSMYhuQIdnzdGY3B6wjMi9tVAFF8A5aAymDmzcHErbthyi9/1mQmSaend JjDJJ5beGmNtb7AikpbehU7PHebkwNPm19LxXbTVL+P2YduZb+Jdx0gA/SV5clKeDmgw wdHg== X-Gm-Message-State: AA+aEWZUbojZywB1SVoV1otIqtNT5oe9UTfzLS5feoOvAOnpCo21ZX3Y uSKoFOUqukTE/cYHA5DXPJm1Ilqy+vZwEOdU X-Google-Smtp-Source: AFSGD/WjfXFTTRqwqxkFq1CYQF34QUbQe2BI1yYy8V/1dZ/aO8FYT17LCXYD/gnLMJYcucd8g84mE59/srjH01gI X-Received: by 2002:a24:7381:: with SMTP id y123mr13334854itb.32.1544039666279; Wed, 05 Dec 2018 11:54:26 -0800 (PST) Date: Wed, 5 Dec 2018 12:53:51 -0700 In-Reply-To: <20181205195353.246542-1-sjg@chromium.org> Message-Id: <20181205195353.246542-4-sjg@chromium.org> Mime-Version: 1.0 References: <20181205195353.246542-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc1.387.gf8505762e3-goog From: Simon Glass To: U-Boot Mailing List Cc: Alexander Graf , Andy Shevchenko Subject: [U-Boot] [PATCH 3/5] dm: serial: Adjust serial_setconfig() to use proper API X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" All driver-model functions should have a device as the first parameter. Update this function accordingly. Signed-off-by: Simon Glass --- drivers/serial/serial-uclass.c | 9 +++------ include/serial.h | 2 +- test/dm/serial.c | 11 +++++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/serial/serial-uclass.c b/drivers/serial/serial-uclass.c index 81f1067f422..669c82f3793 100644 --- a/drivers/serial/serial-uclass.c +++ b/drivers/serial/serial-uclass.c @@ -305,16 +305,13 @@ int serial_getconfig(struct udevice *dev, uint *config) return 0; } -int serial_setconfig(uint config) +int serial_setconfig(struct udevice *dev, uint config) { struct dm_serial_ops *ops; - if (!gd->cur_serial_dev) - return 0; - - ops = serial_get_ops(gd->cur_serial_dev); + ops = serial_get_ops(dev); if (ops->setconfig) - return ops->setconfig(gd->cur_serial_dev, config); + return ops->setconfig(dev, config); return 0; } diff --git a/include/serial.h b/include/serial.h index 5ba031ab534..8a05a090898 100644 --- a/include/serial.h +++ b/include/serial.h @@ -282,7 +282,7 @@ struct serial_dev_priv { #define serial_get_ops(dev) ((struct dm_serial_ops *)(dev)->driver->ops) int serial_getconfig(struct udevice *dev, uint *config); -int serial_setconfig(uint config); +int serial_setconfig(struct udevice *dev, uint config); int serial_getinfo(struct serial_device_info *info); void atmel_serial_initialize(void); diff --git a/test/dm/serial.c b/test/dm/serial.c index 972755face3..f82b4a19e8f 100644 --- a/test/dm/serial.c +++ b/test/dm/serial.c @@ -23,7 +23,7 @@ static int dm_test_serial(struct unit_test_state *uts) * test with default config which is the only one supported by * sandbox_serial driver */ - ut_assertok(serial_setconfig(SERIAL_DEFAULT_CONFIG)); + ut_assertok(serial_setconfig(dev_serial, SERIAL_DEFAULT_CONFIG)); ut_assertok(serial_getconfig(dev_serial, &value_serial)); ut_assert(value_serial == SERIAL_DEFAULT_CONFIG); ut_assertok(serial_getinfo(&info_serial)); @@ -39,7 +39,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong parity */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_ODD, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_ODD, SERIAL_8_BITS, SERIAL_ONE_STOP))); /* @@ -47,7 +48,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_6_BITS, SERIAL_ONE_STOP))); @@ -56,7 +58,8 @@ static int dm_test_serial(struct unit_test_state *uts) * sandbox_serial driver: test with wrong stop bits number */ ut_asserteq(-ENOTSUPP, - serial_setconfig(SERIAL_CONFIG(SERIAL_PAR_NONE, + serial_setconfig(dev_serial, + SERIAL_CONFIG(SERIAL_PAR_NONE, SERIAL_8_BITS, SERIAL_TWO_STOP)));