Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: comedi: amplc_pci230: Convert macro GAT_CONFIG to static inline function

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)

Also, the comment describing the macro has been removed manually.

Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Bhaktipriya Shridhar and committed by
Greg Kroah-Hartman
094c0741 896802a8

+22 -16
+22 -16
drivers/staging/comedi/drivers/amplc_pci230.c
··· 379 379 #define GAT_GND 1 /* GND (i.e. disabled) */ 380 380 #define GAT_EXT 2 /* external gate input (PPCn on PCI230) */ 381 381 #define GAT_NOUTNM2 3 /* inverted output of channel-2 modulo total */ 382 - /* Macro to construct gate input configuration register value. */ 383 - #define GAT_CONFIG(chan, src) ((((chan) & 3) << 3) | ((src) & 7)) 382 + 383 + static inline unsigned int pci230_gat_config(unsigned int chan, 384 + unsigned int src) 385 + { 386 + return ((chan & 3) << 3) | (src & 7); 387 + } 384 388 385 389 /* 386 390 * Summary of CLK_OUTNM1 and GAT_NOUTNM2 connections for PCI230 and PCI260: ··· 1267 1263 irqflags); 1268 1264 } 1269 1265 /* Set CT1 gate high to start counting. */ 1270 - outb(GAT_CONFIG(1, GAT_VCC), dev->iobase + PCI230_ZGAT_SCE); 1266 + outb(pci230_gat_config(1, GAT_VCC), 1267 + dev->iobase + PCI230_ZGAT_SCE); 1271 1268 break; 1272 1269 case TRIG_INT: 1273 1270 async->inttrig = pci230_ao_inttrig_scan_begin; ··· 1356 1351 * cmd->scan_begin_arg is sampling period in ns. 1357 1352 * Gate it off for now. 1358 1353 */ 1359 - outb(GAT_CONFIG(1, GAT_GND), dev->iobase + PCI230_ZGAT_SCE); 1354 + outb(pci230_gat_config(1, GAT_GND), 1355 + dev->iobase + PCI230_ZGAT_SCE); 1360 1356 pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3, 1361 1357 cmd->scan_begin_arg, 1362 1358 cmd->flags); ··· 1798 1792 spin_lock_irqsave(&devpriv->ai_stop_spinlock, irqflags); 1799 1793 if (devpriv->ai_cmd_started) { 1800 1794 /* Trigger scan by waggling CT0 gate source. */ 1801 - zgat = GAT_CONFIG(0, GAT_GND); 1795 + zgat = pci230_gat_config(0, GAT_GND); 1802 1796 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 1803 - zgat = GAT_CONFIG(0, GAT_VCC); 1797 + zgat = pci230_gat_config(0, GAT_VCC); 1804 1798 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 1805 1799 } 1806 1800 spin_unlock_irqrestore(&devpriv->ai_stop_spinlock, irqflags); ··· 1932 1926 * Conversion timer CT2 needs to be gated by 1933 1927 * inverted output of monostable CT2. 1934 1928 */ 1935 - zgat = GAT_CONFIG(2, GAT_NOUTNM2); 1929 + zgat = pci230_gat_config(2, GAT_NOUTNM2); 1936 1930 } else { 1937 1931 /* 1938 1932 * Conversion timer CT2 needs to be gated on 1939 1933 * continuously. 1940 1934 */ 1941 - zgat = GAT_CONFIG(2, GAT_VCC); 1935 + zgat = pci230_gat_config(2, GAT_VCC); 1942 1936 } 1943 1937 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 1944 1938 if (cmd->scan_begin_src != TRIG_FOLLOW) { 1945 1939 /* Set monostable CT0 trigger source. */ 1946 1940 switch (cmd->scan_begin_src) { 1947 1941 default: 1948 - zgat = GAT_CONFIG(0, GAT_VCC); 1942 + zgat = pci230_gat_config(0, GAT_VCC); 1949 1943 break; 1950 1944 case TRIG_EXT: 1951 1945 /* ··· 1956 1950 * input in order to use it as an external scan 1957 1951 * trigger. 1958 1952 */ 1959 - zgat = GAT_CONFIG(0, GAT_EXT); 1953 + zgat = pci230_gat_config(0, GAT_EXT); 1960 1954 break; 1961 1955 case TRIG_TIMER: 1962 1956 /* 1963 1957 * Monostable CT0 triggered by rising edge on 1964 1958 * inverted output of CT1 (falling edge on CT1). 1965 1959 */ 1966 - zgat = GAT_CONFIG(0, GAT_NOUTNM2); 1960 + zgat = pci230_gat_config(0, GAT_NOUTNM2); 1967 1961 break; 1968 1962 case TRIG_INT: 1969 1963 /* 1970 1964 * Monostable CT0 is triggered by inttrig 1971 1965 * function waggling the CT0 gate source. 1972 1966 */ 1973 - zgat = GAT_CONFIG(0, GAT_VCC); 1967 + zgat = pci230_gat_config(0, GAT_VCC); 1974 1968 break; 1975 1969 } 1976 1970 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); ··· 1980 1974 * Scan period timer CT1 needs to be 1981 1975 * gated on to start counting. 1982 1976 */ 1983 - zgat = GAT_CONFIG(1, GAT_VCC); 1977 + zgat = pci230_gat_config(1, GAT_VCC); 1984 1978 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 1985 1979 break; 1986 1980 case TRIG_INT: ··· 2222 2216 * Note, counter/timer output 2 can be monitored on the 2223 2217 * connector: PCI230 pin 21, PCI260 pin 18. 2224 2218 */ 2225 - zgat = GAT_CONFIG(2, GAT_GND); 2219 + zgat = pci230_gat_config(2, GAT_GND); 2226 2220 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 2227 2221 /* Set counter/timer 2 to the specified conversion period. */ 2228 2222 pci230_ct_setup_ns_mode(dev, 2, I8254_MODE3, cmd->convert_arg, ··· 2240 2234 * monostable to stop it triggering. The trigger 2241 2235 * source will be changed later. 2242 2236 */ 2243 - zgat = GAT_CONFIG(0, GAT_VCC); 2237 + zgat = pci230_gat_config(0, GAT_VCC); 2244 2238 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 2245 2239 pci230_ct_setup_ns_mode(dev, 0, I8254_MODE1, 2246 2240 ((uint64_t)cmd->convert_arg * ··· 2253 2247 * 2254 2248 * Set up CT1 but gate it off for now. 2255 2249 */ 2256 - zgat = GAT_CONFIG(1, GAT_GND); 2250 + zgat = pci230_gat_config(1, GAT_GND); 2257 2251 outb(zgat, dev->iobase + PCI230_ZGAT_SCE); 2258 2252 pci230_ct_setup_ns_mode(dev, 1, I8254_MODE3, 2259 2253 cmd->scan_begin_arg,