From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CA6DC2D0DB for ; Fri, 24 Jan 2020 15:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 473E9208C4 for ; Fri, 24 Jan 2020 15:59:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731211AbgAXP7l (ORCPT ); Fri, 24 Jan 2020 10:59:41 -0500 Received: from mga18.intel.com ([134.134.136.126]:37307 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727306AbgAXP7i (ORCPT ); Fri, 24 Jan 2020 10:59:38 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2020 07:57:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,358,1574150400"; d="scan'208";a="293080681" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 24 Jan 2020 07:57:34 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id BB36F3F4; Fri, 24 Jan 2020 17:57:33 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v2 5/5] console: Introduce ->exit() callback Date: Fri, 24 Jan 2020 17:57:32 +0200 Message-Id: <20200124155733.54799-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200124155733.54799-1-andriy.shevchenko@linux.intel.com> References: <20200124155733.54799-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Some consoles might require special operations on unregistering. For example, serial console, when registered in the kernel, keeps power on for entire time, until it gets unregistered. For such cases to have a balance we would provide ->exit() callback. Signed-off-by: Andy Shevchenko --- v2: new patch include/linux/console.h | 1 + kernel/printk/printk.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/linux/console.h b/include/linux/console.h index f33016b3a401..54759ad0c36b 100644 --- a/include/linux/console.h +++ b/include/linux/console.h @@ -148,6 +148,7 @@ struct console { struct tty_driver *(*device)(struct console *, int *); void (*unblank)(void); int (*setup)(struct console *, char *); + void (*exit)(struct console *); int (*match)(struct console *, char *name, int idx, char *options); short flags; short index; diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index da6a9bdf76b6..0319bb698d05 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2850,6 +2850,9 @@ int unregister_console(struct console *console) if (console_drivers != NULL && console->flags & CON_CONSDEV) console_drivers->flags |= CON_CONSDEV; + if (console->exit) + console->exit(console); + console->flags &= ~CON_ENABLED; console_unlock(); console_sysfs_notify(); -- 2.24.1