diff mbox series

[1/2] iio: accel: kionix-kx022a: Fix the setting of regmap_config rd_table and wr_table

Message ID 0003ce97298da5afd9cfeab8ae8f93f50542fe8c.1674996464.git.mehdi.djait.k@gmail.com (mailing list archive)
State Rejected
Headers show
Series iio: accel: kionix-kx022a: Minor fixes | expand

Commit Message

Mehdi Djait Jan. 29, 2023, 1:37 p.m. UTC
rd_table points to a regmap_access_table with valid ranges for read access
and should be set to &kx022a_ro_regs which points to the read_only regs.
The same for wr_table.

Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
---
 drivers/iio/accel/kionix-kx022a.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Matti Vaittinen Jan. 30, 2023, 7:37 a.m. UTC | #1
Hi Mehdi,

Thank you for the patch.

On 1/29/23 15:37, Mehdi Djait wrote:
> rd_table points to a regmap_access_table with valid ranges for read access
> and should be set to &kx022a_ro_regs which points to the read_only regs.
> The same for wr_table.
> 
> Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
> ---
>   drivers/iio/accel/kionix-kx022a.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
> index f866859855cd..1d3af42ec0e1 100644
> --- a/drivers/iio/accel/kionix-kx022a.c
> +++ b/drivers/iio/accel/kionix-kx022a.c
> @@ -142,8 +142,8 @@ const struct regmap_config kx022a_regmap = {
>   	.reg_bits = 8,
>   	.val_bits = 8,
>   	.volatile_table = &kx022a_volatile_regs,
> -	.rd_table = &kx022a_wo_regs,
> -	.wr_table = &kx022a_ro_regs,
> +	.rd_table = &kx022a_ro_regs,
> +	.wr_table = &kx022a_wo_regs,

Have you tested this? If I interpret the code correctly, the current 
code (before this patch) adds read-only registers - Eg, registers which 
are not writable - to wr_table no-range. I think it is correct way. Same 
for write-only registers - eg, registers which are not readable - are 
stored in rd-table no-range. Do you think I am misunderstanding something?

>   	.rd_noinc_table = &kx022a_nir_regs,
>   	.precious_table = &kx022a_precious_regs,
>   	.max_register = KX022A_MAX_REGISTER,

Best Regards
	-- Matti
Mehdi Djait Jan. 31, 2023, 7:32 p.m. UTC | #2
Hi Matti,

On Mon, Jan 30, 2023 at 09:37:12AM +0200, Matti Vaittinen wrote:
> Hi Mehdi,
> 
> Thank you for the patch.
> 
> On 1/29/23 15:37, Mehdi Djait wrote:
> > rd_table points to a regmap_access_table with valid ranges for read access
> > and should be set to &kx022a_ro_regs which points to the read_only regs.
> > The same for wr_table.
> > 
> > Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
> > ---
> >   drivers/iio/accel/kionix-kx022a.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
> > index f866859855cd..1d3af42ec0e1 100644
> > --- a/drivers/iio/accel/kionix-kx022a.c
> > +++ b/drivers/iio/accel/kionix-kx022a.c
> > @@ -142,8 +142,8 @@ const struct regmap_config kx022a_regmap = {
> >   	.reg_bits = 8,
> >   	.val_bits = 8,
> >   	.volatile_table = &kx022a_volatile_regs,
> > -	.rd_table = &kx022a_wo_regs,
> > -	.wr_table = &kx022a_ro_regs,
> > +	.rd_table = &kx022a_ro_regs,
> > +	.wr_table = &kx022a_wo_regs,
> 
> Have you tested this? If I interpret the code correctly, the current code
> (before this patch) adds read-only registers - Eg, registers which are not
> writable - to wr_table no-range. I think it is correct way. Same for
> write-only registers - eg, registers which are not readable - are stored in
> rd-table no-range. Do you think I am misunderstanding something?
> 

I am the person totally misunderstanding everything here (which is
expected). I was confused by the assignment of write_only_regs to
readable_table and read_only_regs to writeable_table, it's not an excuse I
should have verified more before sending a patch.

--
Best Regards,
Mehdi Djait

> >   	.rd_noinc_table = &kx022a_nir_regs,
> >   	.precious_table = &kx022a_precious_regs,
> >   	.max_register = KX022A_MAX_REGISTER,
> 
> Best Regards
> 	-- Matti
> 
> -- 
> Matti Vaittinen
> Linux kernel developer at ROHM Semiconductors
> Oulu Finland
> 
> ~~ When things go utterly wrong vim users can always type :help! ~~
>
diff mbox series

Patch

diff --git a/drivers/iio/accel/kionix-kx022a.c b/drivers/iio/accel/kionix-kx022a.c
index f866859855cd..1d3af42ec0e1 100644
--- a/drivers/iio/accel/kionix-kx022a.c
+++ b/drivers/iio/accel/kionix-kx022a.c
@@ -142,8 +142,8 @@  const struct regmap_config kx022a_regmap = {
 	.reg_bits = 8,
 	.val_bits = 8,
 	.volatile_table = &kx022a_volatile_regs,
-	.rd_table = &kx022a_wo_regs,
-	.wr_table = &kx022a_ro_regs,
+	.rd_table = &kx022a_ro_regs,
+	.wr_table = &kx022a_wo_regs,
 	.rd_noinc_table = &kx022a_nir_regs,
 	.precious_table = &kx022a_precious_regs,
 	.max_register = KX022A_MAX_REGISTER,