On Tue,  9 Jul 2019 08:46:32 +0200
Martin Hundebøll <mar...@geanix.com> wrote:

> Make it obvious how the gsm mux number relates to the virtual tty lines
> by using helper function instead of shifting 6 bits.
> 
> Signed-off-by: Martin Hundebøll <mar...@geanix.com>
> ---
>  drivers/tty/n_gsm.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
> index c4e16b31f9ab..cba06063c44a 100644
> --- a/drivers/tty/n_gsm.c
> +++ b/drivers/tty/n_gsm.c
> @@ -2171,6 +2171,16 @@ static inline void mux_put(struct gsm_mux *gsm)
>       kref_put(&gsm->ref, gsm_free_muxr);
>  }
>  
> +static inline int mux_num_to_base(struct gsm_mux *gsm)
> +{
> +     return gsm->num * NUM_DLCI;
> +}
> +
> +static inline unsigned int mux_line_to_num(int line)
> +{
> +     return line / NUM_DLCI;

If you are going to convert shifts to multiply and divide then used
unsigned maths so the compiler can optimize it nicely on some of the low
end processors.

Alan

Reply via email to