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 4/4] staging: comedi: amplc_pci230: Convert macro GAT_CONFIG to static inline function
Date: Mon, 21 Mar 2016 18:04:33 -0400	[thread overview]
Message-ID: <20160321220433.GA5091@kroah.com> (raw)
In-Reply-To: <58c5d0b92cb0a0e421ea913418919184174caa4f.1458500647.git.bhaktipriya96@gmail.com>

On Mon, Mar 21, 2016 at 12:50:25AM +0530, Bhaktipriya Shridhar wrote:
> Convert macro GAT_CONFIG to static inline function as static inline
> functions are preferred over macros. This change is possible since the
> arguments at all call sites have the same type.
> 
> This was done using Coccinelle:
> 
> @r@
> expression e;
> @@
> - #define GAT_CONFIG(chan, src) e
> + static inline unsigned int pci230_gat_config(unsigned int
> chan,unsigned int src)
> +{
> +       return ((chan & 3) << 3) | (src & 7);
> +}
> 
> @r1@
> expression dev,reg,chan,src;
> @@
> -GAT_CONFIG(chan, src)
> +pci230_gat_config(chan, src)
> 
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
>  Changes in v2:
> 	- Removed the extra () around the arguments.
> 	- Renamed the function and made the changes consistent
> 
>  drivers/staging/comedi/drivers/amplc_pci230.c | 38 ++++++++++++++++-----------
>  1 file changed, 22 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
> index 635cd46..6117fb7 100644
> --- a/drivers/staging/comedi/drivers/amplc_pci230.c
> +++ b/drivers/staging/comedi/drivers/amplc_pci230.c
> @@ -383,8 +383,12 @@ static inline void pci230_clk_config(struct comedi_device *dev,
>  #define GAT_GND		1	/* GND (i.e. disabled) */
>  #define GAT_EXT		2	/* external gate input (PPCn on PCI230) */
>  #define GAT_NOUTNM2	3	/* inverted output of channel-2 modulo total */
> -/* Macro to construct gate input configuration register value. */
> -#define GAT_CONFIG(chan, src)	((((chan) & 3) << 3) | ((src) & 7))
> +
> +static inline unsigned int pci230_gat_config(unsigned int chan,
> +					     unsigned int src)
> +{
> +	return ((chan & 3) << 3) | (src & 7);
> +}

This looks good, but can you properly format this?

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   ` [Outreachy kernel] " Greg KH
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   ` Greg KH [this message]

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=20160321220433.GA5091@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.