Linux-IIO Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] iio: humidity: hts221: move register definitions to sensor structs
@ 2019-12-02 10:23 Lorenzo Bianconi
  2019-12-07 10:39 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-12-02 10:23 UTC (permalink / raw)
  To: jic23; +Cc: lorenzo.bianconi, linux-iio

Move some register definitions to hts221_avg_list, hts221_avg_list and
hts221_channels since they are used only there and simplify driver code

Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 drivers/iio/humidity/hts221_core.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
index 4922444771c6..9003671f14fb 100644
--- a/drivers/iio/humidity/hts221_core.c
+++ b/drivers/iio/humidity/hts221_core.c
@@ -24,13 +24,6 @@
 #define HTS221_REG_CNTRL1_ADDR		0x20
 #define HTS221_REG_CNTRL2_ADDR		0x21
 
-#define HTS221_REG_AVG_ADDR		0x10
-#define HTS221_REG_H_OUT_L		0x28
-#define HTS221_REG_T_OUT_L		0x2a
-
-#define HTS221_HUMIDITY_AVG_MASK	0x07
-#define HTS221_TEMP_AVG_MASK		0x38
-
 #define HTS221_ODR_MASK			0x03
 #define HTS221_BDU_MASK			BIT(2)
 #define HTS221_ENABLE_MASK		BIT(7)
@@ -66,8 +59,8 @@ static const struct hts221_odr hts221_odr_table[] = {
 
 static const struct hts221_avg hts221_avg_list[] = {
 	{
-		.addr = HTS221_REG_AVG_ADDR,
-		.mask = HTS221_HUMIDITY_AVG_MASK,
+		.addr = 0x10,
+		.mask = 0x07,
 		.avg_avl = {
 			4, /* 0.4 %RH */
 			8, /* 0.3 %RH */
@@ -80,8 +73,8 @@ static const struct hts221_avg hts221_avg_list[] = {
 		},
 	},
 	{
-		.addr = HTS221_REG_AVG_ADDR,
-		.mask = HTS221_TEMP_AVG_MASK,
+		.addr = 0x10,
+		.mask = 0x38,
 		.avg_avl = {
 			2, /* 0.08 degC */
 			4, /* 0.05 degC */
@@ -98,7 +91,7 @@ static const struct hts221_avg hts221_avg_list[] = {
 static const struct iio_chan_spec hts221_channels[] = {
 	{
 		.type = IIO_HUMIDITYRELATIVE,
-		.address = HTS221_REG_H_OUT_L,
+		.address = 0x28,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
 				      BIT(IIO_CHAN_INFO_OFFSET) |
 				      BIT(IIO_CHAN_INFO_SCALE) |
@@ -114,7 +107,7 @@ static const struct iio_chan_spec hts221_channels[] = {
 	},
 	{
 		.type = IIO_TEMP,
-		.address = HTS221_REG_T_OUT_L,
+		.address = 0x2a,
 		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
 				      BIT(IIO_CHAN_INFO_OFFSET) |
 				      BIT(IIO_CHAN_INFO_SCALE) |
-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: humidity: hts221: move register definitions to sensor structs
  2019-12-02 10:23 [PATCH] iio: humidity: hts221: move register definitions to sensor structs Lorenzo Bianconi
@ 2019-12-07 10:39 ` Jonathan Cameron
  2019-12-07 12:47   ` Lorenzo Bianconi
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2019-12-07 10:39 UTC (permalink / raw)
  To: Lorenzo Bianconi; +Cc: lorenzo.bianconi, linux-iio

On Mon,  2 Dec 2019 12:23:28 +0200
Lorenzo Bianconi <lorenzo@kernel.org> wrote:

> Move some register definitions to hts221_avg_list, hts221_avg_list and
> hts221_channels since they are used only there and simplify driver code
> 
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
You could potentially switch this to GENMASK for the masks, but that can
be a follow up patch if you want to do so.

Applied to the togreg branch of iio.git and pushed out as testing for
the autobuilders to play with it.

Thanks,

Jonathan

> ---
>  drivers/iio/humidity/hts221_core.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> index 4922444771c6..9003671f14fb 100644
> --- a/drivers/iio/humidity/hts221_core.c
> +++ b/drivers/iio/humidity/hts221_core.c
> @@ -24,13 +24,6 @@
>  #define HTS221_REG_CNTRL1_ADDR		0x20
>  #define HTS221_REG_CNTRL2_ADDR		0x21
>  
> -#define HTS221_REG_AVG_ADDR		0x10
> -#define HTS221_REG_H_OUT_L		0x28
> -#define HTS221_REG_T_OUT_L		0x2a
> -
> -#define HTS221_HUMIDITY_AVG_MASK	0x07
> -#define HTS221_TEMP_AVG_MASK		0x38
> -
>  #define HTS221_ODR_MASK			0x03
>  #define HTS221_BDU_MASK			BIT(2)
>  #define HTS221_ENABLE_MASK		BIT(7)
> @@ -66,8 +59,8 @@ static const struct hts221_odr hts221_odr_table[] = {
>  
>  static const struct hts221_avg hts221_avg_list[] = {
>  	{
> -		.addr = HTS221_REG_AVG_ADDR,
> -		.mask = HTS221_HUMIDITY_AVG_MASK,
> +		.addr = 0x10,
> +		.mask = 0x07,
>  		.avg_avl = {
>  			4, /* 0.4 %RH */
>  			8, /* 0.3 %RH */
> @@ -80,8 +73,8 @@ static const struct hts221_avg hts221_avg_list[] = {
>  		},
>  	},
>  	{
> -		.addr = HTS221_REG_AVG_ADDR,
> -		.mask = HTS221_TEMP_AVG_MASK,
> +		.addr = 0x10,
> +		.mask = 0x38,
>  		.avg_avl = {
>  			2, /* 0.08 degC */
>  			4, /* 0.05 degC */
> @@ -98,7 +91,7 @@ static const struct hts221_avg hts221_avg_list[] = {
>  static const struct iio_chan_spec hts221_channels[] = {
>  	{
>  		.type = IIO_HUMIDITYRELATIVE,
> -		.address = HTS221_REG_H_OUT_L,
> +		.address = 0x28,
>  		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>  				      BIT(IIO_CHAN_INFO_OFFSET) |
>  				      BIT(IIO_CHAN_INFO_SCALE) |
> @@ -114,7 +107,7 @@ static const struct iio_chan_spec hts221_channels[] = {
>  	},
>  	{
>  		.type = IIO_TEMP,
> -		.address = HTS221_REG_T_OUT_L,
> +		.address = 0x2a,
>  		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
>  				      BIT(IIO_CHAN_INFO_OFFSET) |
>  				      BIT(IIO_CHAN_INFO_SCALE) |


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: humidity: hts221: move register definitions to sensor structs
  2019-12-07 10:39 ` Jonathan Cameron
@ 2019-12-07 12:47   ` Lorenzo Bianconi
  0 siblings, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2019-12-07 12:47 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Lorenzo Bianconi, linux-iio

>
> On Mon,  2 Dec 2019 12:23:28 +0200
> Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> > Move some register definitions to hts221_avg_list, hts221_avg_list and
> > hts221_channels since they are used only there and simplify driver code
> >
> > Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> You could potentially switch this to GENMASK for the masks, but that can
> be a follow up patch if you want to do so.

Hi Jonathan,

ack, fine. I will post a patch.

Regards,
Lorenzo

>
> Applied to the togreg branch of iio.git and pushed out as testing for
> the autobuilders to play with it.
>
> Thanks,
>
> Jonathan
>
> > ---
> >  drivers/iio/humidity/hts221_core.c | 19 ++++++-------------
> >  1 file changed, 6 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/iio/humidity/hts221_core.c b/drivers/iio/humidity/hts221_core.c
> > index 4922444771c6..9003671f14fb 100644
> > --- a/drivers/iio/humidity/hts221_core.c
> > +++ b/drivers/iio/humidity/hts221_core.c
> > @@ -24,13 +24,6 @@
> >  #define HTS221_REG_CNTRL1_ADDR               0x20
> >  #define HTS221_REG_CNTRL2_ADDR               0x21
> >
> > -#define HTS221_REG_AVG_ADDR          0x10
> > -#define HTS221_REG_H_OUT_L           0x28
> > -#define HTS221_REG_T_OUT_L           0x2a
> > -
> > -#define HTS221_HUMIDITY_AVG_MASK     0x07
> > -#define HTS221_TEMP_AVG_MASK         0x38
> > -
> >  #define HTS221_ODR_MASK                      0x03
> >  #define HTS221_BDU_MASK                      BIT(2)
> >  #define HTS221_ENABLE_MASK           BIT(7)
> > @@ -66,8 +59,8 @@ static const struct hts221_odr hts221_odr_table[] = {
> >
> >  static const struct hts221_avg hts221_avg_list[] = {
> >       {
> > -             .addr = HTS221_REG_AVG_ADDR,
> > -             .mask = HTS221_HUMIDITY_AVG_MASK,
> > +             .addr = 0x10,
> > +             .mask = 0x07,
> >               .avg_avl = {
> >                       4, /* 0.4 %RH */
> >                       8, /* 0.3 %RH */
> > @@ -80,8 +73,8 @@ static const struct hts221_avg hts221_avg_list[] = {
> >               },
> >       },
> >       {
> > -             .addr = HTS221_REG_AVG_ADDR,
> > -             .mask = HTS221_TEMP_AVG_MASK,
> > +             .addr = 0x10,
> > +             .mask = 0x38,
> >               .avg_avl = {
> >                       2, /* 0.08 degC */
> >                       4, /* 0.05 degC */
> > @@ -98,7 +91,7 @@ static const struct hts221_avg hts221_avg_list[] = {
> >  static const struct iio_chan_spec hts221_channels[] = {
> >       {
> >               .type = IIO_HUMIDITYRELATIVE,
> > -             .address = HTS221_REG_H_OUT_L,
> > +             .address = 0x28,
> >               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> >                                     BIT(IIO_CHAN_INFO_OFFSET) |
> >                                     BIT(IIO_CHAN_INFO_SCALE) |
> > @@ -114,7 +107,7 @@ static const struct iio_chan_spec hts221_channels[] = {
> >       },
> >       {
> >               .type = IIO_TEMP,
> > -             .address = HTS221_REG_T_OUT_L,
> > +             .address = 0x2a,
> >               .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
> >                                     BIT(IIO_CHAN_INFO_OFFSET) |
> >                                     BIT(IIO_CHAN_INFO_SCALE) |
>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 10:23 [PATCH] iio: humidity: hts221: move register definitions to sensor structs Lorenzo Bianconi
2019-12-07 10:39 ` Jonathan Cameron
2019-12-07 12:47   ` Lorenzo Bianconi

Linux-IIO Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-iio/0 linux-iio/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-iio linux-iio/ https://lore.kernel.org/linux-iio \
		linux-iio@vger.kernel.org
	public-inbox-index linux-iio

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-iio


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git