The current code provides a helper function em28xx_write_reg_bits() that reads the current state/value of a GPIO register, modifies only the bits specified with the value and bitmask parmaters and writes the new value back to the register. Newer devices (em25xx, em276x/7x/8x) are using separate registers for reading and changing the states of the GPIO ports/lines, for which this helper function cannot be used. Introduce a new function em28xx_write_regs_bits() that uses two register parameters reg_r (register for reading the current value) and reg_w (register for writing the new value). Make em28xx_write_reg_bits() a wrapper function calling this new function with the same value for both registers. Signed-off-by: Frank Schäfer <fschaefer.oss@xxxxxxxxxxxxxx> --- drivers/media/usb/em28xx/em28xx-core.c | 26 +++++++++++++++++++------- drivers/media/usb/em28xx/em28xx.h | 5 +++-- 2 Dateien geändert, 22 Zeilen hinzugefügt(+), 9 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c index fc157af..293dc31 100644 --- a/drivers/media/usb/em28xx/em28xx-core.c +++ b/drivers/media/usb/em28xx/em28xx-core.c @@ -205,23 +205,35 @@ int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val) EXPORT_SYMBOL_GPL(em28xx_write_reg); /* - * em28xx_write_reg_bits() - * sets only some bits (specified by bitmask) of a register, by first reading - * the actual value + * em28xx_write_regs_bits() + * reads value from a register, modifies only the bits specified with the value + * and bitmask parameters and writes the new value two a second register. */ -int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, - u8 bitmask) +int em28xx_write_regs_bits(struct em28xx *dev, u16 reg_r, u16 reg_w, u8 val, + u8 bitmask) { int oldval; u8 newval; - oldval = em28xx_read_reg(dev, reg); + oldval = em28xx_read_reg(dev, reg_r); if (oldval < 0) return oldval; newval = (((u8) oldval) & ~bitmask) | (val & bitmask); - return em28xx_write_regs(dev, reg, &newval, 1); + return em28xx_write_regs(dev, reg_w, &newval, 1); +} +EXPORT_SYMBOL_GPL(em28xx_write_regs_bits); + +/* + * em28xx_write_reg_bits() + * modifies only the bits specified with the value and bitmask parameters of + * a register + */ +int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, + u8 bitmask) +{ + return em28xx_write_regs_bits(dev, reg, reg, val, bitmask); } EXPORT_SYMBOL_GPL(em28xx_write_reg_bits); diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h index e070de0..a817c3d 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -667,8 +667,9 @@ int em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, int len); int em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); int em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); -int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, - u8 bitmask); +int em28xx_write_regs_bits(struct em28xx *dev, u16 reg_r, u16 reg_w, + u8 val, u8 bitmask); +int em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, u8 bitmask); int em28xx_read_ac97(struct em28xx *dev, u8 reg); int em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html