Re: [PATCH] mfd: Convert pcf50633 to use new register map API

From: Lars-Peter Clausen
Date: Mon Aug 08 2011 - 02:39:29 EST



> /* Read a block of up to 32 regs */
> int pcf50633_read_block(struct pcf50633 *pcf, u8 reg,
> int nr_regs, u8 *data)
> {
> - int ret;
> -
> - mutex_lock(&pcf->lock);
> - ret = __pcf50633_read(pcf, reg, nr_regs, data);
> - mutex_unlock(&pcf->lock);
> -
> - return ret;
> + return regmap_raw_read(pcf->regmap, reg, data, nr_regs);
> }
> EXPORT_SYMBOL_GPL(pcf50633_read_block);
>
> @@ -71,21 +42,22 @@ int pcf50633_write_block(struct pcf50633 *pcf , u8 reg,
> {
> int ret;
>
> - mutex_lock(&pcf->lock);
> - ret = __pcf50633_write(pcf, reg, nr_regs, data);
> - mutex_unlock(&pcf->lock);
> + ret = regmap_raw_write(pcf->regmap, reg, data, nr_regs);
> + if (ret != 0)
> + return ret;
>
> - return ret;
> + return nr_regs;
> }
> EXPORT_SYMBOL_GPL(pcf50633_write_block);

We need to return the number of read regs in case of success for read_block
too. (Actually we only need this for read_block, but I guess it is nice to be
consistent here)

- Lars
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/