Re: [PATCH 1/4] console: replace set_active by open/close

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 24, 2017 at 03:24:58PM +0100, Bastian Stender wrote:
> Opening and closing consoles should be independent from setting them
> active. This way it is possible to open e.g. a framebuffer console and
> display text on it without showing stdout/stderr.
> 
> Signed-off-by: Bastian Stender <bst@xxxxxxxxxxxxxx>
> ---
>  common/console.c          | 19 +++++++++++++++----
>  drivers/video/fbconsole.c | 28 ++++++++++++++++++----------
>  include/console.h         |  3 ++-
>  net/netconsole.c          | 27 +++++++++++++++++----------
>  4 files changed, 52 insertions(+), 25 deletions(-)
> 
> diff --git a/common/console.c b/common/console.c
> index 74ccfcfc3e..43890b3da8 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -71,10 +71,21 @@ int console_set_active(struct console_device *cdev, unsigned flag)
>  	if (!flag && cdev->f_active && cdev->flush)
>  		cdev->flush(cdev);
>  
> -	if (cdev->set_active) {
> -		ret = cdev->set_active(cdev, flag);
> -		if (ret)
> -			return ret;
> +	if (flag == cdev->f_active)
> +		return 0;
> +
> +	if (!flag) {
> +		if (cdev->close) {
> +			ret = cdev->close(cdev);
> +			if (ret)
> +				return ret;
> +		}
> +	} else {
> +		if (cdev->open) {
> +			ret = cdev->open(cdev);
> +			if (ret)
> +				return ret;
> +		}
>  	}

instead of calling into cdev->open/close directly here I would prefer
console_open() / console_close() functions which get called here.
In these functions you can call the driver hooks on first open and last
close.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux