Re: [PATCH] regulator: anatop: add is_enabled interface

From: Mark Brown
Date: Mon Dec 16 2013 - 13:58:21 EST


On Mon, Dec 16, 2013 at 04:20:27PM -0500, Anson Huang wrote:

> +{
> + struct anatop_regulator *anatop_reg = rdev_get_drvdata(reg);
> + u32 val;
> +
> + if (!anatop_reg->control_reg)
> + return -ENOTSUPP;

In what situation would this happen and why would the operation be
provided in those situations?

> + regmap_read(anatop_reg->anatop, anatop_reg->control_reg, &val);
> +
> + return (val >> anatop_reg->vol_bit_shift) &
> + ((1 << anatop_reg->vol_bit_width) - 1) ? 1 : 0;
> +}

This isn't terribly legible but it looks like it's trying to read to see
if a non-zero voltage has been written. If that's the case it looks
like enable and disable operations should be supported since presumably
the register can be written as well.

Please try to avoid the ternery operator, especially in cases like this
where it's not adding anything.

Attachment: signature.asc
Description: Digital signature