Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp533427ybl; Fri, 31 Jan 2020 03:29:35 -0800 (PST) X-Google-Smtp-Source: APXvYqws/v6u0O+GIZdHWSwi2Ne0ZR9UY6JAiVl9cXn+ZrZJBOtYqhwpiQ8IQBYLz4xlUxasDpbw X-Received: by 2002:a05:6830:22cc:: with SMTP id q12mr7446623otc.110.1580470174967; Fri, 31 Jan 2020 03:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580470174; cv=none; d=google.com; s=arc-20160816; b=sQfuM0jCpIQH/+L990hwUwm/3yZ0AFaJcPZYeqfDqJod4U510hNaAqtde+H4ksKvP/ aLBP3WpxU5PvcCUF+qPHwi6SEmvT3fiXgtqegKmFtO0h2sW1t/Stp3S1yydpvCP1zAvU OraH2AyjMh/XxZgao5H4ZCm8kJtJOHBsFFXjTPRh7fX8IRlirmPmSLBB9p1K/UvGy4x7 FCV6ZHs4Pck0WCcGy5HJW0ctxHXRFowBV3FrTmeMpuO1DeOTMkfVQRCeKD67ztDe8Tee yzf8g7C8nzFZXJxNRex0HLeWLpGLbwqVATMPDlVIioXrEEj4D/JedMrISS2S9hel32OK 1dRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1eqgkxa8dyNdHC+uzRi5JxmfairZnxQnZD98fLK3rdo=; b=JZY/+x8Dq9+Vr0tKmHQeEIgYXJwgIG4K2vLdu7YU4BnPHN1UBQSwJYH6U9MYLfPqmw WT1aTZEOh/eX2wbFODumvWTvl/m9FUorFEPlX+aA2qNsqdcG/FFsJXu5bSXssVSvcCBs m35grOQjWxakCwwC5w0sMvUbo7JwB3Mj3R8mKjeuOL1Fc3blNiVyYnETEfK7eYvdV6V3 uRd1aNHp6FaZS5AvCkot6Yu33cIGukmg4Bkl17YpH2ccFnOCsmXxnv4bVxbL+k4WAhu4 sPaNFqCzI4b9pL0GZBtkGAvPpwRkdziOlAjd3eDEtmLIAerKo5YLr3ul7ESf4Wk01ecG WOcg== 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 l9si4583520oti.229.2020.01.31.03.29.22; Fri, 31 Jan 2020 03:29:34 -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 S1728423AbgAaL1Y (ORCPT + 99 others); Fri, 31 Jan 2020 06:27:24 -0500 Received: from mga05.intel.com ([192.55.52.43]:31358 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbgAaL1Y (ORCPT ); Fri, 31 Jan 2020 06:27:24 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 Jan 2020 03:27:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,385,1574150400"; d="scan'208";a="428685092" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga005.fm.intel.com with ESMTP; 31 Jan 2020 03:27:22 -0800 Received: from andy by smile with local (Exim 4.93) (envelope-from ) id 1ixUSK-00032f-D7; Fri, 31 Jan 2020 13:27:24 +0200 Date: Fri, 31 Jan 2020 13:27:24 +0200 From: Andy Shevchenko To: Sergey Senozhatsky Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 5/6] console: Introduce ->exit() callback Message-ID: <20200131112724.GM32742@smile.fi.intel.com> References: <20200130152558.51839-1-andriy.shevchenko@linux.intel.com> <20200130152558.51839-5-andriy.shevchenko@linux.intel.com> <20200131013154.GH115889@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200131013154.GH115889@google.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 31, 2020 at 10:31:54AM +0900, Sergey Senozhatsky wrote: > On (20/01/30 17:25), Andy Shevchenko wrote: > [..] > > 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 *); > > Should console ->exit() be able to return an error code? Let's do it! > > 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; > > } > > I would probably push it a bit further (I posted this snippet in another > thread). If console is not on the list then there is nothing for us to do > and sysfs notify is pointless. I didn't see post in the other thread, but I suppose that this snipped is for patch 4 in the series, correct? > > --- > > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c > index 0117d4d92a8e..7116e421210b 100644 > --- a/kernel/printk/printk.c > +++ b/kernel/printk/printk.c > @@ -2837,7 +2837,13 @@ int unregister_console(struct console *console) > } > } > > - if (!res && (console->flags & CON_EXTENDED)) > + if (res) { > + console->flags &= ~CON_ENABLED; > + console_unlock(); > + return res; > + } > + > + if (console->flags & CON_EXTENDED) > nr_ext_console_drivers--; > > /* > @@ -2851,7 +2857,7 @@ int unregister_console(struct console *console) > console_unlock(); > console_sysfs_notify(); > > - if (!res && console->exit) > + if (console->exit) > console->exit(console); > > return res; ...then something like return console->exit(console); return 0; ...or... res = console->exit(console); Which one is preferable? -- With Best Regards, Andy Shevchenko