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

media: v4l: cci: Add macros to obtain register width and address

Add CCI_REG_WIDTH() macro to obtain register width in bits and similarly,
CCI_REG_WIDTH_BYTES() to obtain it in bytes.

Also add CCI_REG_ADDR() macro to obtain the address of a register.

Use both macros in v4l2-cci.c, too.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>

authored by

Sakari Ailus and committed by
Hans Verkuil
cd93cc24 94ed0098

+9 -4
+4 -4
drivers/media/v4l2-core/v4l2-cci.c
··· 25 25 if (err && *err) 26 26 return *err; 27 27 28 - len = FIELD_GET(CCI_REG_WIDTH_MASK, reg); 29 - reg = FIELD_GET(CCI_REG_ADDR_MASK, reg); 28 + len = CCI_REG_WIDTH_BYTES(reg); 29 + reg = CCI_REG_ADDR(reg); 30 30 31 31 ret = regmap_bulk_read(map, reg, buf, len); 32 32 if (ret) { ··· 75 75 if (err && *err) 76 76 return *err; 77 77 78 - len = FIELD_GET(CCI_REG_WIDTH_MASK, reg); 79 - reg = FIELD_GET(CCI_REG_ADDR_MASK, reg); 78 + len = CCI_REG_WIDTH_BYTES(reg); 79 + reg = CCI_REG_ADDR(reg); 80 80 81 81 switch (len) { 82 82 case 1:
+5
include/media/v4l2-cci.h
··· 7 7 #ifndef _V4L2_CCI_H 8 8 #define _V4L2_CCI_H 9 9 10 + #include <linux/bitfield.h> 10 11 #include <linux/bits.h> 11 12 #include <linux/types.h> 12 13 ··· 39 38 */ 40 39 #define CCI_REG_PRIVATE_SHIFT 28U 41 40 #define CCI_REG_PRIVATE_MASK GENMASK(31U, CCI_REG_PRIVATE_SHIFT) 41 + 42 + #define CCI_REG_WIDTH_BYTES(x) FIELD_GET(CCI_REG_WIDTH_MASK, x) 43 + #define CCI_REG_WIDTH(x) (CCI_REG_WIDTH_BYTES(x) << 3) 44 + #define CCI_REG_ADDR(x) FIELD_GET(CCI_REG_ADDR_MASK, x) 42 45 43 46 #define CCI_REG8(x) ((1 << CCI_REG_WIDTH_SHIFT) | (x)) 44 47 #define CCI_REG16(x) ((2 << CCI_REG_WIDTH_SHIFT) | (x))