Re: [PATCH 3/6] hwmon: (max6697) Use bit operations where possible

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

 



On Mon, Jul 22, 2024 at 05:52:01PM -0700, Guenter Roeck wrote:
> @@ -32,20 +34,31 @@ static const u8 MAX6697_REG_CRIT[] = {
>  			0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27 };
>  
>  /*
> - * Map device tree / platform data register bit map to chip bit map.
> + * Map device tree / internal register bit map to chip bit map.
>   * Applies to alert register and over-temperature register.
>   */
> +
> +#define MAX6697_EXTERNAL_MASK_DT	GENMASK(7, 1)
> +#define MAX6697_LOCAL_MASK_DT		BIT(0)
> +#define MAX6697_EXTERNAL_MASK_CHIP	GENMASK(6, 0)
> +#define MAX6697_LOCAL_MASK_CHIP		BIT(7)
> +
> +/* alert - local channel is in bit 6 */
>  #define MAX6697_ALERT_MAP_BITS(reg)	((((reg) & 0x7e) >> 1) | \
>  				 (((reg) & 0x01) << 6) | ((reg) & 0x80))
> -#define MAX6697_OVERT_MAP_BITS(reg) (((reg) >> 1) | (((reg) & 0x01) << 7))
> +
> +/* over-temperature - local channel is in bit 7 */
> +#define MAX6697_OVERT_MAP_BITS(reg)	\
> +	(FIELD_PREP(MAX6697_EXTERNAL_MASK_CHIP, FIELD_GET(MAX6697_EXTERNAL_MASK_DT, reg)) | \
> +	 FIELD_PREP(MAX6697_LOCAL_MASK_CHIP, FIELD_GET(MAX6697_LOCAL_MASK_DT, reg)))

How about:
#define MAX6697_OVERT_MAP_BITS(reg)	\
    (FIELD_GET(MAX6697_EXTERNAL_MASK_DT, reg) | \
     FIELD_PREP(MAX6697_LOCAL_MASK_CHIP, reg))




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux