Re: [PATCH 2/3] staging: comedi: amplc_dio200: add helper macros to check bus type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2012-08-15 11:48, Dan Carpenter wrote:
On Wed, Aug 15, 2012 at 11:16:20AM +0100, Ian Abbott wrote:
On 2012-08-15 08:14, Dan Carpenter wrote:
On Tue, Aug 14, 2012 at 04:31:28PM +0100, Ian Abbott wrote:
+#define IS_ISA_BOARD(board)	(DO_ISA && (board)->bustype == isa_bustype)
+#define IS_PCI_BOARD(board)	(DO_PCI && (board)->bustype == pci_bustype)

It would be better to make this an inline function.

#if IS_ENABLED(CONFIG_COMEDI_AMPLC_DIO200_ISA)

static inline bool is_isa_board(const struct dio200_board *board)
{
	return board->bustype == isa_bustype;
}

#else

static inline bool is_isa_board(const struct dio200_board *board)
{
	return 0;
}

#endif

I prefer the macro as it seems "easier" for the compiler to
recognize it as a constant in the case where DO_ISA expands to 0.

If we were just discussing this one function then, sure, we're not
going to complain about small style issues, but it's the whole file.
It's just riddled with #ifdefs.  It can't be moved out of staging
until it is written according the same coding style as the rest of
the kernel.

The remaining #ifdefs are only used to fill in the list of supported boards, the static "layout" data referenced by the supported boards (the #ifdefs could be removed from the layout array with a moderate expansion of module size), and to optionally make it a PCI driver. Currently, the driver does not link any PCI functions if it is not configured to support PCI boards, even if CONFIG_PCI is enabled (as long as the compiler can optimize out the code that calls those functions).

I don't really want to hide the MODULE_DEVICE_TABLE(), module_comedi_pci_driver() and module_comedi_driver() macro calls in some other macros buried in some private header file, and I also want to avoid compiler warnings about unused static functions and variables.

--
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux