From patchwork Sat Nov 24 04:29:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1002587 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="EOXrPTMW"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 4320mM0gzkz9s7W for ; Sat, 24 Nov 2018 15:38:11 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id C977FC22459; Sat, 24 Nov 2018 04:34:15 +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=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 D302FC22464; Sat, 24 Nov 2018 04:31:01 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 258F9C2245D; Sat, 24 Nov 2018 04:30:29 +0000 (UTC) Received: from mail-vs1-f72.google.com (mail-vs1-f72.google.com [209.85.217.72]) by lists.denx.de (Postfix) with ESMTPS id D124AC22462 for ; Sat, 24 Nov 2018 04:30:25 +0000 (UTC) Received: by mail-vs1-f72.google.com with SMTP id u29so5521287vsj.1 for ; Fri, 23 Nov 2018 20:30:25 -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=2zvea5rhmg4bv25hEML4W4bzT8IuBdvNDiOMXXcle0o=; b=EOXrPTMW21d4sWszU2ZDQ69JWfhdfneJtkdDzNjdhhnR7IY3zoUdups4JbJ1jRGd66 AUocslAiTMWISsyuNoWaZj5EDOKvMQpOvAJ76WKgziaP8AyKe4p3yxT6n4+WhBLHWKM/ Nh1ejlgvk6Q5n066nlTv0gq1ZZH5tkj4nlong= 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=2zvea5rhmg4bv25hEML4W4bzT8IuBdvNDiOMXXcle0o=; b=rUtF4WO13hbj60RcuwHA2uZ5luSZNxf9OJnia02C+ozp9vf8SQI0B+xkXslFdjznAr q/T7SDcDdNMhyxNq2/nPSfugJMl7+9Uu99sFV/xm25MeM3uNhCECXlqJ1MFSHGlgyERq qRV5KFDrv7k9iXjRSlrXhKNDFjSUGL+gtbrbO3spxWlp90uNIeCGED+NVPRr6QsV8bYw UeytQeH4tWLkH4oUiE24Yhmsas5jzeTUPe1EhUludscafVqMJ+yZH47UlBRQqtHzOH07 nPJ5rSV+zp+9N404Rvqz2S9Km6qzaqdDt/wWL+SiRw3n7l0X9CWnxtoHQMfzJYh9z3gQ YCKw== X-Gm-Message-State: AA+aEWZF7oWVBoEnVKl11Di6co7hkfg9MSyGH45b2pPV3s0pbbShdy4J noPTbOPAYlsiOSRVdv4DCMJFwLM7VvUEVCOV X-Google-Smtp-Source: AFSGD/U5kWm1spWEdCbNBL84KwnQrPPMBA7rTVjtTn510h4+kbWBPl2Rialo2JkV3BG+X7rrSkafhyv+mEk6RfCs X-Received: by 2002:a1f:29d3:: with SMTP id p202mr13093388vkp.0.1543033824834; Fri, 23 Nov 2018 20:30:24 -0800 (PST) Date: Fri, 23 Nov 2018 21:29:38 -0700 In-Reply-To: <20181124042944.239106-1-sjg@chromium.org> Message-Id: <20181124042944.239106-16-sjg@chromium.org> Mime-Version: 1.0 References: <20181124042944.239106-1-sjg@chromium.org> X-Mailer: git-send-email 2.20.0.rc0.387.gc7a69e6b6c-goog From: Simon Glass To: U-Boot Mailing List Subject: [U-Boot] [PATCH 15/21] input: i8042: Use remove() instead of exported functions 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" We should not have exported functions in a driver. The i8042_disable() function is used to disable the keyboard. Provide a remove() method instead, which is the standard way of disabling a device. We could potentially add a method to flush input but that does not seem necessary. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- drivers/input/i8042.c | 35 ++++++++++++++++++++--------------- include/i8042.h | 15 --------------- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/drivers/input/i8042.c b/drivers/input/i8042.c index 5678f8e3cfb..9a5dc46207c 100644 --- a/drivers/input/i8042.c +++ b/drivers/input/i8042.c @@ -167,19 +167,8 @@ static int kbd_controller_present(void) return in8(I8042_STS_REG) != 0xff; } -/* - * Implement a weak default function for boards that optionally - * need to skip the i8042 initialization. - * - * TODO(sjg@chromium.org): Use device tree for this? - */ -int __weak board_i8042_skip(void) -{ - /* As default, don't skip */ - return 0; -} - -void i8042_flush(void) +/** Flush all buffer from keyboard controller to host*/ +static void i8042_flush(void) { int timeout; @@ -202,7 +191,13 @@ void i8042_flush(void) } } -int i8042_disable(void) +/** + * Disables the keyboard so that key strokes no longer generate scancodes to + * the host. + * + * @return 0 if ok, -1 if keyboard input was found while disabling + */ +static int i8042_disable(void) { if (kbd_input_empty() == 0) return -1; @@ -266,7 +261,7 @@ static int i8042_start(struct udevice *dev) char *penv; int ret; - if (!kbd_controller_present() || board_i8042_skip()) { + if (!kbd_controller_present()) { debug("i8042 keyboard controller is not present\n"); return -ENOENT; } @@ -294,6 +289,15 @@ static int i8042_start(struct udevice *dev) return 0; } +static int i8042_kbd_remove(struct udevice *dev) +{ + if (i8042_disable()) + log_debug("i8042_disable() failed. fine, continue.\n"); + i8042_flush(); + + return 0; +} + /** * Set up the i8042 keyboard. This is called by the stdio device handler * @@ -348,6 +352,7 @@ U_BOOT_DRIVER(i8042_kbd) = { .id = UCLASS_KEYBOARD, .of_match = i8042_kbd_ids, .probe = i8042_kbd_probe, + .remove = i8042_kbd_remove, .ops = &i8042_kbd_ops, .priv_auto_alloc_size = sizeof(struct i8042_kbd_priv), }; diff --git a/include/i8042.h b/include/i8042.h index 2b9e5c4d371..8d69fa13bc2 100644 --- a/include/i8042.h +++ b/include/i8042.h @@ -72,19 +72,4 @@ #define BRK 0x0100 /* make break flag for keyboard */ #define ALT 0x0200 /* right alt */ -/* exports */ - -/** - * Flush all buffer from keyboard controller to host. - */ -void i8042_flush(void); - -/** - * Disables the keyboard so that key strokes no longer generate scancodes to - * the host. - * - * @return 0 if ok, -1 if keyboard input was found while disabling - */ -int i8042_disable(void); - #endif /* _I8042_H_ */