linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Václav Kubernát" <kubernat@cesnet.cz>
Cc: Jean Delvare <jdelvare@suse.com>,
	Jonathan Corbet <corbet@lwn.net>,
	linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap
Date: Wed, 21 Apr 2021 18:27:38 -0700	[thread overview]
Message-ID: <250c1c16-541a-984f-c720-1a8b6176e97e@roeck-us.net> (raw)
In-Reply-To: <20210413025948.901867-1-kubernat@cesnet.cz>

On 4/12/21 7:59 PM, Václav Kubernát wrote:
> Converting the driver to use regmap makes it more generic. It also makes
> it a lot easier to debug through debugfs.
> 
> Signed-off-by: Václav Kubernát <kubernat@cesnet.cz>
> ---
>  drivers/hwmon/Kconfig    |   1 +
>  drivers/hwmon/max31790.c | 254 ++++++++++++++++++++-------------------
>  2 files changed, 133 insertions(+), 122 deletions(-)
> 
> diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
> index 1ecf697d8d99..9f11d036c316 100644
> --- a/drivers/hwmon/Kconfig
> +++ b/drivers/hwmon/Kconfig
> @@ -1095,6 +1095,7 @@ config SENSORS_MAX6697
>  config SENSORS_MAX31790
>  	tristate "Maxim MAX31790 sensor chip"
>  	depends on I2C
> +	select REGMAP_I2C
>  	help
>  	  If you say yes here you get support for 6-Channel PWM-Output
>  	  Fan RPM Controller.
> diff --git a/drivers/hwmon/max31790.c b/drivers/hwmon/max31790.c
> index 2c6b333a28e9..e3765ce4444a 100644
> --- a/drivers/hwmon/max31790.c
> +++ b/drivers/hwmon/max31790.c
> @@ -12,6 +12,7 @@
>  #include <linux/init.h>
>  #include <linux/jiffies.h>
>  #include <linux/module.h>
> +#include <linux/regmap.h>
>  #include <linux/slab.h>
>  
>  /* MAX31790 registers */
> @@ -46,92 +47,53 @@
>  
>  #define NR_CHANNEL			6
>  
> +#define MAX31790_REG_USER_BYTE_67	0x67
> +
> +#define BULK_TO_U16(msb, lsb)		(((msb) << 8) + (lsb))
> +#define U16_MSB(num)			(((num) & 0xFF00) >> 8)
> +#define U16_LSB(num)			((num) & 0x00FF)
> +
> +static const struct regmap_range max31790_ro_range = {
> +	.range_min = MAX31790_REG_TACH_COUNT(0),
> +	.range_max = MAX31790_REG_PWMOUT(0) - 1,
> +};
> +
> +static const struct regmap_access_table max31790_wr_table = {
> +	.no_ranges = &max31790_ro_range,
> +	.n_no_ranges = 1,
> +};
> +
> +static const struct regmap_range max31790_volatile_ranges[] = {
> +	regmap_reg_range(MAX31790_REG_TACH_COUNT(0), MAX31790_REG_TACH_COUNT(12)),
> +	regmap_reg_range(MAX31790_REG_FAN_FAULT_STATUS2, MAX31790_REG_FAN_FAULT_STATUS1),
> +};
> +
> +static const struct regmap_access_table max31790_volatile_table = {
> +	.no_ranges = max31790_volatile_ranges,
> +	.n_no_ranges = 2,
> +	.n_yes_ranges = 0
> +};

Looks like my reply to this got lost. Other regmap code suggests that
volatile register ranges are identified with yes_ranges, not with no_ranges.
"no" seems to mean "not volatile". Please verify and confirm if the
above code does what you want it to do.

Thanks,
Guenter

  parent reply	other threads:[~2021-04-22  1:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13  2:59 [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
     [not found]   ` <20210419223340.GA229491@roeck-us.net>
2021-04-22  0:26     ` Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-04-13  2:59 ` [PATCH v2 5/5] hwmon: (max31790) Update documentation Václav Kubernát
2021-04-13  3:10 ` [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-04-22  1:27 ` Guenter Roeck [this message]
2021-04-23 10:55   ` Václav Kubernát
2021-04-26 12:46   ` Václav Kubernát
2021-04-26 14:17     ` Guenter Roeck
2021-04-26 14:29       ` Václav Kubernát
2021-04-26 14:35         ` Guenter Roeck
2021-04-26 12:37 ` [PATCH v4 " Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 2/5] hwmon: (max31790) Fix and split pwm*_enable Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 3/5] hwmon: (max31790) Show 0 RPM/fault when input disabled Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 4/5] hwmon: (max31790) Allow setting fan*_div Václav Kubernát
2021-04-26 12:37   ` [PATCH v4 5/5] hwmon: (max31790) Update documentation Václav Kubernát
  -- strict thread matches above, loose matches on Subject: below --
2021-03-16 17:54 [PATCH v2 1/5] hwmon: (max31790) Rework to use regmap Václav Kubernát
2021-03-16 18:11 ` Václav Kubernát
2021-03-17  5:12 ` Dan Carpenter
2021-03-18  9:56   ` Václav Kubernát
     [not found] ` <20210329222704.GA223476@roeck-us.net>
2021-03-30  3:43   ` Václav Kubernát

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=250c1c16-541a-984f-c720-1a8b6176e97e@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=corbet@lwn.net \
    --cc=jdelvare@suse.com \
    --cc=kubernat@cesnet.cz \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).