Re: [PATCH 1/9] tty: move the non-file related parts of tty_release to new tty_release_struct

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

 



Hi,

On Fri, Jan 06, 2017 at 10:26:27AM -0600, Rob Herring wrote:
> For in-kernel tty users, we need to be able to create and destroy
> 'struct tty' that are not associated with a file. The creation side is
> fine, but tty_release() needs to be split into the file handle portion
> and the struct tty portion. Introduce a new function, tty_release_struct,
> to handle just the destroying of a struct tty.
> 
> Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
> ---
>  drivers/tty/tty_io.c | 42 ++++++++++++++++++++++++------------------
>  include/linux/tty.h  |  1 +
>  2 files changed, 25 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
> index 734a635e7363..5ebc090ec47f 100644
> --- a/drivers/tty/tty_io.c
> +++ b/drivers/tty/tty_io.c
> @@ -1744,6 +1744,29 @@ static int tty_release_checks(struct tty_struct *tty, int idx)
>  	return 0;
>  }
>  
> +void tty_release_struct(struct tty_struct *tty, int idx)
> +{
> +	/*
> +	 * Ask the line discipline code to release its structures
> +	 */
> +	tty_ldisc_release(tty);
> +
> +	/* Wait for pending work before tty destruction commmences */
> +	tty_flush_works(tty);
> +
> +	tty_debug_hangup(tty, "freeing structure\n");
> +	/*
> +	 * The release_tty function takes care of the details of clearing
> +	 * the slots and preserving the termios structure. The tty_unlock_pair
> +	 * should be safe as we keep a kref while the tty is locked (so the
> +	 * unlock never unlocks a freed tty).
> +	 */
> +	mutex_lock(&tty_mutex);
> +	release_tty(tty, idx);
> +	mutex_unlock(&tty_mutex);
> +}
> +EXPORT_SYMBOL_GPL(tty_release_struct);

tty_release_struct() is missing kernel docs.

> [...]

-- Sebastian

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux