Re: [PATCH-V2 3/3] RTC:s35390a: Add update_irq (per Min interrupt)support

From: Andrew Morton
Date: Mon Aug 23 2010 - 19:43:54 EST


On Sat, 21 Aug 2010 18:00:29 +0530
hvaibhav@xxxxxx wrote:

> +static int s35390a_update_irq_enable(struct i2c_client *client,
> + unsigned enabled)
> +{
> + struct s35390a *s35390a = i2c_get_clientdata(client);
> + char buf[1];
> +
> + if (s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf)) < 0)
> + return -EIO;
> +
> + /* This chip returns the bits of each byte in reverse order */
> + buf[0] = bitrev8(buf[0]);
> +
> + buf[0] &= ~S35390A_INT1_MODE_MASK;
> + if (enabled)
> + buf[0] |= S35390A_INT1_MODE_PMIN_STDY;
> + else
> + buf[0] |= S35390A_INT1_MODE_NOINTR;
> +
> + /* This chip expects the bits of each byte in reverse order */
> + buf[0] = bitrev8(buf[0]);

grumble. We bit-reverse it, fiddle a couple of bits and then
bit-reverse it again. Lazy.

Why not leave it bit-reversed and just bit-reverse the constants?
Extra marks are awarded for coming up with a compile-time bitrev8() ;)

> + return s35390a_set_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf));
> +}
--
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/