All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Cc: outreachy-kernel@googlegroups.com
Subject: Re: [Outreachy kernel] [PATCH v2 2/4] staging: comedi: amplc_pci224: Convert macro CLK_CONFIG to static inline function
Date: Mon, 21 Mar 2016 18:04:44 -0400	[thread overview]
Message-ID: <20160321220444.GC5091@kroah.com> (raw)
In-Reply-To: <28884b9d0d2f9a209f034a9eb2343293a0711628.1458500647.git.bhaktipriya96@gmail.com>

On Mon, Mar 21, 2016 at 12:45:06AM +0530, Bhaktipriya Shridhar wrote:
> Convert macro CLK_CONFIG to static inline function as static inline
> functions are preferred over macros. Since every single user of this
> macro passes the argument into the outb() function, with
> (dev->iobase + ...) as the address, the two calls have been merged
> into one.
> 
> This was done using Coccinelle:
> 
> @r@
> identifier f;
> expression e;
> @@
> - #define CLK_CONFIG(chan, src) e
> + static inline void pci224_clk_config(struct pci224_private *devpriv,
> +                                      unsigned int reg, unsigned int chan,
> +                                      unsigned int src)
> +{
> +       outb(((chan & 3) << 3) | (src & 7), devpriv->iobase1 + reg);
> +}
> 
> @r1@
> expression devp,reg,chan,src;
> @@
> -outb(CLK_CONFIG(chan, src), devp->iobase1 + reg);
> +pci224_clk_config(devp, reg, chan, src);
> 
> Also, the comment describing the macro has been removed manually.
> 
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
>  Changes in v2:
> 	-Since every single user of this macro passes the argument
> 	 into the outb() function, with (devpriv->iobase1 + ...)
> 	 as the address, the two calls have been merged into one.
> 
>  drivers/staging/comedi/drivers/amplc_pci224.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
> index cac011f..5bc1377 100644
> --- a/drivers/staging/comedi/drivers/amplc_pci224.c
> +++ b/drivers/staging/comedi/drivers/amplc_pci224.c
> @@ -201,8 +201,12 @@
>  #define CLK_1KHZ	5	/* internal 1 kHz clock */
>  #define CLK_OUTNM1	6	/* output of channel-1 modulo total */
>  #define CLK_EXT		7	/* external clock */
> -/* Macro to construct clock input configuration register value. */
> -#define CLK_CONFIG(chan, src)	((((chan) & 3) << 3) | ((src) & 7))
> +static inline void pci224_clk_config(struct pci224_private *devpriv,
> +				     unsigned int reg, unsigned int chan,
> +				     unsigned int src)
> +{
> +	outb(((chan & 3) << 3) | (src & 7), devpriv->iobase1 + reg);
> +}

If you were to do this, you need a blank line before the function.  But
again, I don't think this is a good change, it doesn't help much...

thanks,

greg k-h


  reply	other threads:[~2016-03-21 22:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-20 19:07 [PATCH v2 0/4] Convert macros to static inline functions Bhaktipriya Shridhar
2016-03-20 19:11 ` [PATCH v2 1/4] staging: comedi: amplc_pci230: Convert macro CLK_CONFIG to static inline function Bhaktipriya Shridhar
2016-03-21 22:04   ` [Outreachy kernel] " Greg KH
2016-03-20 19:15 ` [PATCH v2 2/4] staging: comedi: amplc_pci224: " Bhaktipriya Shridhar
2016-03-21 22:04   ` Greg KH [this message]
2016-03-20 19:16 ` [PATCH v2 3/4] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG " Bhaktipriya Shridhar
2016-03-21 22:04   ` [Outreachy kernel] " Greg KH
2016-03-20 19:20 ` [PATCH v2 4/4] staging: comedi: amplc_pci230: " Bhaktipriya Shridhar
2016-03-21 22:04   ` [Outreachy kernel] " Greg KH

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=20160321220444.GC5091@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bhaktipriya96@gmail.com \
    --cc=outreachy-kernel@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.