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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux