Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1598647

Re: [PATCH] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG to static inline function

Path csiph.com!feeder.erje.net!2.eu.feeder.erje.net!news.mb-net.net!open-news-network.org!aioe.org!bofh.it!news.nic.it!robomod
From SIMRAN SINGHAL <singhalsimran0@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG to static inline function
Date Sun, 12 Mar 2017 15:50:01 +0100
Message-ID <tkcYN-2Pm-5@gated-at.bofh.it> (permalink)
References <tjs9B-43z-47@gated-at.bofh.it> <tkccp-2gk-5@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=75/GjD5TwEwpo8QkwVNq1ahf7n9sAxH2xNAMvEYN1HU=; b=G2PiFiv2pIIUEWPztIexfSO8vJ2DlS4HaCHstTwxI0FOC+jnikq5zcHRwjvFQToNki gtSon5W0WliO0/VXsodIs2+uy6bzSfBd7i8IMq+TLJRzQjFW/i6+KaaR9bOM2cnOuk6F Ncb/T9RSHNo2EOBjuw5Wr8NhJOQl3xit9XJIOO5/Fpm0qODFTZyOh22KvRWZcwf1XjzV fp+EZ1dS/kn9Rv+Vp1l+EjIb6WmYgQGOsr1JEAimPsudioCkVauSZM/28KpKHMgeOfDE EkquAwOh6ngxtBrW12LGGJOsopuGMd30vGgVZ/Reoz5UHQgRiASOjeeHypgH6dnYUNj6 CyHw==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=75/GjD5TwEwpo8QkwVNq1ahf7n9sAxH2xNAMvEYN1HU=; b=mJWEXcpB42Fmqx7C0A0c6TRJRjaJCrBk8iHSj7HF/M69T/iz1LZGklKhj0eE6clNHV eFIqcuvCdGLV05uedDhsKxbNut/n/dpO3VOMZZSWk6nOLoRacyYsdGFWoMI3jOMQDeku P+1jeM6KD/42eyA+ArWsJe1efuE2ZhgAKVkalc4TUIoWdyrg0RP9HGEFiqitwOcdyl+o Imae9vqHKrn5MLTtbW8nbbiyB5hfum4a+tVFgowFBZVBvfDINfrKtM1Z7+AdQ6bnKJ1E u0/dSjJqY2+TbfZAYdhFN9eSFytckjR2xXlyDps+ZZa3C1OBuK7E1rB5f3f3lxtgUE48 YvBw==
X-Gm-Message-State AMke39nGHNdgJC3uVfpKwTXoEgQ/XbSblOuqUWuABeAoYQkf7vZptD5SYzrOmGBQ62bcQNNGlsaAjj1o94tMXw==
X-Received by 10.25.233.201 with SMTP id j70mr7180440lfk.20.1489329645713; Sun, 12 Mar 2017 07:40:45 -0700 (PDT)
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 85
Organization linux.* mail to news gateway
X-Original-Cc Ian Abbott <abbotti@mev.co.uk>, devel@driverdev.osuosl.org, outreachy-kernel@googlegroups.com, linux-kernel@vger.kernel.org
X-Original-Date Sun, 12 Mar 2017 20:10:45 +0530
X-Original-Message-ID <CALrZqyMLZ73rC5yb_rD_P-GO3+DcY1+es+RZemXsTfe3OVU62w@mail.gmail.com>
X-Original-References <20170310124231.GA24231@singhal-Inspiron-5558> <20170312135640.GB1209@kroah.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1598647

Show key headers only | View raw


On Sun, Mar 12, 2017 at 7:26 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Fri, Mar 10, 2017 at 06:12:31PM +0530, simran singhal 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)
>
> Where did you get the name from?
>
Actually the name should be pci224_gat_config as when I checked the other
drivers like amplc_pci230.c then its using pci230_gat_config so according to
what other drivers are using I should use pci224_gat_config.

I will correct this and will resend it.

>> +{
>> +       return ((chan & 3) << 3) | (src & 7);
>> +}
>>
>> @r1@
>> expression dev,reg,chan,src;
>> @@
>> -GAT_CONFIG(chan, src)
>> +pci230_gat_config(chan, src)
>>
>> Also, the comment describing the macro has been removed manually.
>>
>> Signed-off-by: simran singhal <singhalsimran0@gmail.com>
>> ---
>>  drivers/staging/comedi/drivers/amplc_pci224.c | 14 ++++++++++----
>>  1 file changed, 10 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c
>> index 2e6decf..46026f5 100644
>> --- a/drivers/staging/comedi/drivers/amplc_pci224.c
>> +++ b/drivers/staging/comedi/drivers/amplc_pci224.c
>> @@ -216,8 +216,12 @@
>>  #define GAT_GND              1       /* GND (i.e. disabled) */
>>  #define GAT_EXT              2       /* reserved (external gate input) */
>>  #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);
>> +}
>>
>>  /*
>>   * Summary of CLK_OUTNM1 and GAT_NOUTNM2 connections for PCI224 and PCI234:
>> @@ -817,10 +821,12 @@ static void pci224_ao_start_pacer(struct comedi_device *dev,
>>        * source.
>>        */
>>       /* Make sure Z2-0 is gated on.  */
>> -     outb(GAT_CONFIG(0, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE);
>> +     outb(pci230_gat_config(0, GAT_VCC),
>> +          devpriv->iobase1 + PCI224_ZGAT_SCE);
>
> Why put this on 2 lines?

I'll check this again and if their will be no problem in putting this
on one line then
I'll resend it with the change.

>
>>       /* Cascading with Z2-2. */
>>       /* Make sure Z2-2 is gated on.  */
>> -     outb(GAT_CONFIG(2, GAT_VCC), devpriv->iobase1 + PCI224_ZGAT_SCE);
>> +     outb(pci230_gat_config(2, GAT_VCC),
>> +          devpriv->iobase1 + PCI224_ZGAT_SCE);
>
> Same here?
>
> thanks,
>
> greg k-h

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG to  static inline function simran singhal <singhalsimran0@gmail.com> - 2017-03-10 13:50 +0100
  Re: [PATCH] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG  to static inline function Greg KH <gregkh@linuxfoundation.org> - 2017-03-12 15:00 +0100
    Re: [PATCH] staging: comedi: amplc_pci224: Convert macro GAT_CONFIG  to static inline function SIMRAN SINGHAL <singhalsimran0@gmail.com> - 2017-03-12 15:50 +0100

csiph-web