public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: Nikhil Gautam <nikhilgtr@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, dlechner@baylibre.com, anshulusr@gmail.com
Subject: Re: [PATCH] iio: dac: mcp4821: add configurable gain support
Date: Wed, 25 Mar 2026 12:21:39 +0530	[thread overview]
Message-ID: <acOF-wN2Diwm_W2E@nik> (raw)
In-Reply-To: <20260321180707.73a7ad60@jic23-huawei>

On Sat, Mar 21, 2026 at 06:07:07PM +0000, Jonathan Cameron wrote:
> On Thu, 19 Mar 2026 22:22:16 +0530
> Nikhil Gautam <nikhilgtr@gmail.com> wrote:
> 

Hi Jonathan,

Thank you for the detailed review, that’s very helpful.

> > +#include <linux/iio/iio.h>
> > +#include <linux/iio/types.h>
> >  #include <linux/module.h>
> >  #include <linux/mod_devicetable.h>
> >  #include <linux/spi/spi.h>
> > -
> > -#include <linux/iio/iio.h>
> > -#include <linux/iio/types.h>
> > -
> Hi Nikhil,
> 
> Don't do code recorganization in a patch doing anything else.
> Also, it's fairly common convention to have subsystem specific headers
> in a block at the end for a driver in that subsystem.
> >  #include <linux/unaligned.h>
> This is the oddity.  Was a result of a mass change from
> asm/unaligned.h to this that didn't include reordering headers.
> 
> Given you are touching the driver anyway, it's fine to move that up to
> under spi.h, but should still be a seperate patch.
> 
Understood. I agree this wasn’t appropriate to mix with functional changes.
I’ll drop the header reordering from this patch, and if needed,
will send a separate cleanup patch that moves linux/unaligned.h to a more sensible location.

> 
> >  
> >  #define MCP4821_ACTIVE_MODE BIT(12)
> >  #define MCP4802_SECOND_CHAN BIT(15)
> > +#define MCP4821_GAIN_ENABLE BIT(13)
> 
> Put this in order. So above MCP4802_SECOND_CHAN
> >  
Agreed. I’ll reorder the defines so the gain bit is placed logically alongside the other command bits,
before MCP4802_SECOND_CHAN. 

> > -#define MCP4821_CHAN(channel_id, resolution)                          \
> > -	{                                                             \
> > -		.type = IIO_VOLTAGE, .output = 1, .indexed = 1,       \
> > -		.channel = (channel_id),                              \
> > -		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),         \
> > -		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
> > -		.scan_type = {                                        \
> > -			.realbits = (resolution),                     \
> > -			.shift = 12 - (resolution),                   \
> > -		},                                                    \
> > +#define MCP4821_CHAN(channel_id, resolution)					\
> > +	{															\
> > +		.type = IIO_VOLTAGE, .output = 1, .indexed = 1,			\
> > +		.channel = (channel_id),								\
> > +		.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),			\
> > +		.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) |	\
> > +			BIT(IIO_CHAN_INFO_CALIBSCALE),						\
> > +	    .info_mask_shared_by_type_available =					\
> > +			BIT(IIO_CHAN_INFO_CALIBSCALE),						\
> > +		.scan_type = {											\
> > +			.realbits = (resolution),							\
> > +			.shift = 12 - (resolution),							\
> > +		},														\
> >  	}
> No idea what went wrong formatting wise here, but that needs to go back to normal!
>
Yes, that was accidental and slipped through during editing. I’ll restore the original formatting style

> Why is it calibscale as opposed to scale?  A x2 multiplier presumably affects the
> scale userspace should apply? calibbscale is for adjusting due to minor device differences
> not this sort of major range adjustment.
>
Thanks for the clarification. You’re right exposing the gain selection via calibscale was incorrect.
The GA bit changes the voltage‑per‑LSB and therefore the scale userspace should apply.
I will switch this to use selectable IIO_CHAN_INFO_SCALE values with scale_available, and remove all use of calibscale.

> > +
> >  	default:
> > -		return -EINVAL;
> > +		break;
> >  	}
> > +	return -EINVAL;
> 
> Why?  Original code was at least as good if not better.
>
Agreed. The original structure was clearer.
I’ll move the EINVAL returns back into the default case and avoid the extra break.

> >  }
> >  
> > +	default:
> > +		break;
> >  	}
> > +	return -EINVAL;
> Move that up into the default. 
> 
Sure, will move that up.

I’ll post a revised version addressing all of the above.

Thanks again for the review.

Best regards,
Nikhil

  reply	other threads:[~2026-03-25  6:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-19 16:52 [PATCH] iio: dac: mcp4821: add configurable gain support Nikhil Gautam
2026-03-21 18:07 ` Jonathan Cameron
2026-03-25  6:51   ` Nikhil Gautam [this message]
2026-03-26  7:12   ` [PATCH v2] " Nikhil Gautam
2026-03-26 20:38     ` Jonathan Cameron
2026-03-27  5:55       ` Nikhil Gautam
2026-03-27  6:18         ` [PATCH v3] " Nikhil Gautam

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=acOF-wN2Diwm_W2E@nik \
    --to=nikhilgtr@gmail.com \
    --cc=anshulusr@gmail.com \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@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