Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Guenter Roeck <linux@roeck-us.net>
Cc: Hardware Monitoring <linux-hwmon@vger.kernel.org>
Subject: Re: [PATCH 3/6] hwmon: (max6697) Use bit operations where possible
Date: Tue, 23 Jul 2024 05:37:25 +0000	[thread overview]
Message-ID: <Zp9BlV3Hw00QNccD@google.com> (raw)
In-Reply-To: <20240723005204.1356501-4-linux@roeck-us.net>

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))

  reply	other threads:[~2024-07-23  5:37 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23  0:51 [PATCH 0/6] hwmon: (max6697) Cleanup, use regmap and with_info API Guenter Roeck
2024-07-23  0:51 ` [PATCH 1/6] hwmon: (max6697) Reorder include files Guenter Roeck
2024-07-23  5:36   ` Tzung-Bi Shih
2024-07-23 14:16     ` Guenter Roeck
2024-07-23  0:52 ` [PATCH 2/6] hwmon: (max6697) Drop platform data support Guenter Roeck
2024-07-23  5:37   ` Tzung-Bi Shih
2024-07-23 14:20     ` Guenter Roeck
2024-07-23 14:48       ` Guenter Roeck
2024-07-23  0:52 ` [PATCH 3/6] hwmon: (max6697) Use bit operations where possible Guenter Roeck
2024-07-23  5:37   ` Tzung-Bi Shih [this message]
2024-07-23 14:24     ` Guenter Roeck
2024-07-23  0:52 ` [PATCH 4/6] hwmon: (max6697) Convert to use regmap Guenter Roeck
2024-07-23  5:37   ` Tzung-Bi Shih
2024-07-23  0:52 ` [PATCH 5/6] hwmon: (max6697) Convert to with_info hwmon API Guenter Roeck
2024-07-23  5:37   ` Tzung-Bi Shih
2024-07-23  0:52 ` [PATCH 6/6] hwmon: (max6697) Add support for tempX_min and tempX_min_alarm Guenter Roeck
2024-07-23  5:37   ` Tzung-Bi Shih

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zp9BlV3Hw00QNccD@google.com \
    --to=tzungbi@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox