mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alan Cox <gnomes@lxorguk.ukuu.org.uk>
To: "Martin Hundebøll" <martin@geanix.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Jiri Slaby" <jslaby@suse.com>,
	linux-kernel@vger.kernel.org, "Sean Nyekjær" <sean@geanix.com>,
	"Esben Haabendal" <esben@geanix.com>
Subject: Re: [PATCHv2 3/4] tty: n_gsm: add helper to convert mux-num to/from tty-base
Date: Wed, 10 Jul 2019 12:48:32 +0100	[thread overview]
Message-ID: <20190710124832.5a9a1daa@alans-desktop> (raw)
In-Reply-To: <20190709064633.45411-3-martin@geanix.com>

On Tue,  9 Jul 2019 08:46:32 +0200
Martin Hundebøll <martin@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 <martin@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	other threads:[~2019-07-10 11:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-09  6:46 [PATCHv2 1/4] tty: n_gsm: remove obsolete mknod doc example Martin Hundebøll
2019-07-09  6:46 ` [PATCHv2 2/4] tty: n_gsm: update doc example to use header for N_GSM0710 define Martin Hundebøll
2019-07-09  6:46 ` [PATCHv2 3/4] tty: n_gsm: add helper to convert mux-num to/from tty-base Martin Hundebøll
2019-07-10 11:48   ` Alan Cox [this message]
2019-07-09  6:46 ` [PATCHv2 4/4] tty: n_gsm: add ioctl to map serial device to mux'ed tty Martin Hundebøll
2019-07-09  6:49   ` Jiri Slaby
2019-07-09  6:52     ` Martin Hundebøll

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190710124832.5a9a1daa@alans-desktop \
    --to=gnomes@lxorguk.ukuu.org.uk \
    --cc=esben@geanix.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin@geanix.com \
    --cc=sean@geanix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®