Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1871163ybl; Thu, 30 Jan 2020 07:28:43 -0800 (PST) X-Google-Smtp-Source: APXvYqxCMtrrWqW0YcLhFF09DZVxTY3kKLRKOCDmnCF2OTnmeKRoA0P9eSNO50lzTemi7zteHRSV X-Received: by 2002:a9d:7315:: with SMTP id e21mr4131121otk.255.1580398123749; Thu, 30 Jan 2020 07:28:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580398123; cv=none; d=google.com; s=arc-20160816; b=oxY3j4feANo5ng9HOm00orlgQM0eh0TQolFjHV0cZS8fmnW45OAlOSmMbpMfRXfeNX GYyNhE+H0NQfhVwAMTEvSvOsnLA2VbyRu4d8TsAPizV1S+mhKZnAggSechYUwlWk3Kz4 92Vw4WTcIS8P/sQpey32gv+4mhX0JODsWn1Bzd5viOl2n+kVxhdi0sIy44JzXql3X7ka yu7xNM1xLFk6D7XVaLxTNd/35G9Kxq0BhubXg9x0w5FoLIg96lttBa07/qk8ezrXM+Td 7SVjGBzzBFYXSk9yrXDLdilmywGz1fI6W1NjtuFMj95BzTfNLeE/Yx7xVcBeOy7ZAGXe Tuiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=BOs99XJ6bIx3oJWtNAfdgkr3BZ/qxGzGdHUja2Buv9c=; b=b72F0CKox37ruQLZDu/xqMe9Rug+ybhwZ0olfNrSpEZwDTW7O07eVov5o6fDRGpA/y bH7Qxd1J4hXESc4YPLyQ10OFincLPVlhRSIT0WWDh89UDZVmEtiHm2Wlk3LNgKBsMaTT Z9Lh0WvG4QeXroRD4vSj8YX3J5R+YTj8RD19IC74fL6SPBMegxbahcgYT/qHxYqLDLw1 rzcGcblhKrly4hKAdUpJNkcY/iT6u71KiNStNw2VuOeZh6XVPXld859TCLTKyWJoqCay NySD/oGEOCu4OxABOFg/J7b3RJG/j2WBGhJ13s8q4WEtHfGoaomj5W0PpzSKJGB3K1Kf pbag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s11si2818785otd.245.2020.01.30.07.28.31; Thu, 30 Jan 2020 07:28:43 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727224AbgA3P0C (ORCPT + 99 others); Thu, 30 Jan 2020 10:26:02 -0500 Received: from mga09.intel.com ([134.134.136.24]:4226 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727158AbgA3P0C (ORCPT ); Thu, 30 Jan 2020 10:26:02 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jan 2020 07:26:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,382,1574150400"; d="scan'208";a="247417855" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 30 Jan 2020 07:26:00 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 6F7291EA; Thu, 30 Jan 2020 17:25:59 +0200 (EET) From: Andy Shevchenko To: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org Cc: Andy Shevchenko Subject: [PATCH v4 5/6] console: Introduce ->exit() callback Date: Thu, 30 Jan 2020 17:25:57 +0200 Message-Id: <20200130152558.51839-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200130152558.51839-1-andriy.shevchenko@linux.intel.com> References: <20200130152558.51839-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 instance, serial console, when registered in the kernel, keeps power on for entire time, until it gets unregistered. Example of use: ->setup(console): pm_runtime_get(...); ->exit(console): pm_runtime_put(...); For such cases to have a balance we would provide ->exit() callback. Signed-off-by: Andy Shevchenko --- v4: Don't rely on CON_ENABLED at all (Sergey, Petr), update commit message (Petr) include/linux/console.h | 1 + kernel/printk/printk.c | 4 ++++ 2 files changed, 5 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 932345e6cd71..0117d4d92a8e 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2850,6 +2850,10 @@ int unregister_console(struct console *console) console->flags &= ~CON_ENABLED; console_unlock(); console_sysfs_notify(); + + if (!res && console->exit) + console->exit(console); + return res; } EXPORT_SYMBOL(unregister_console); -- 2.24.1