Re: [Q]staging/comedi: Considation of *_find_boardinfo possible?

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

 



On Wed, 2013-01-30 at 00:41 +0100, Peter Hüwe wrote:
> ---> is there a way to consolidate these functions into one function (which 
> can operate on the different types) ?  It's almost a bit like 'templates'.
> Maybe with some gcc extensions or kernel magic functions ?

Nothing wrong with a macro.

Maybe something like:

#define comedi_find_board(array, board_id)		\
({							\
	int i;						\
	typeof array *p = array;			\
	typeof array *rtn = NULL;			\
	for (i = 0; i < ARRAY_SIZE(array); i++, p++) {	\
		if (p->device_id == board_id) {		\
			rtn = p;			\
			break;				\
		}					\
	}						\
	rtn;						\
})


_______________________________________________
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