[PATCH 08/11] staging: comedi: jr3_pci: check sizes at compile time

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

 



The driver currently checks the size of `struct jr3_sensor` is correct
when a device is attached, returning an error if it is wrong.  Replace
that with a compile-time check.  We don't care too much about the size
of `struct jr3_sensor` as it is embedded in the larger `struct
jr3_block` and is followed by a lot of padding.  We should care more
that the size of `struct jr3_block` is correct, as it describes the
overall register layout of a block, and there is an array of such blocks
(one per subdevice).  Check its size at compile-time using the
`BUILD_BUG_ON()` macro.

Signed-off-by: Ian Abbott <abbotti@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/jr3_pci.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/staging/comedi/drivers/jr3_pci.c b/drivers/staging/comedi/drivers/jr3_pci.c
index 8399493e7472..c0ae92217932 100644
--- a/drivers/staging/comedi/drivers/jr3_pci.c
+++ b/drivers/staging/comedi/drivers/jr3_pci.c
@@ -688,12 +688,7 @@ static int jr3_pci_auto_attach(struct comedi_device *dev,
 	int ret;
 	int i;
 
-	if (sizeof(struct jr3_sensor) != 0xc00) {
-		dev_err(dev->class_dev,
-			"sizeof(struct jr3_sensor) = %x [expected %x]\n",
-			(unsigned int)sizeof(struct jr3_sensor), 0xc00);
-		return -EINVAL;
-	}
+	BUILD_BUG_ON(sizeof(struct jr3_block) != 0x80000);
 
 	if (context < ARRAY_SIZE(jr3_pci_boards))
 		board = &jr3_pci_boards[context];
-- 
2.11.0

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-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