Linux IIO development
 help / color / mirror / Atom feed
From: William Breathitt Gray <william.gray@linaro.org>
To: Biju Das <biju.das.jz@bp.renesas.com>
Cc: "linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Chris Paterson <Chris.Paterson2@renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
	"linux-renesas-soc@vger.kernel.org" 
	<linux-renesas-soc@vger.kernel.org>
Subject: Re: [PATCH v6 4/5] counter: Add Renesas RZ/G2L MTU3a counter driver
Date: Tue, 15 Nov 2022 21:12:51 -0500	[thread overview]
Message-ID: <Y3RHI/Ed1xHpzmCW@fedora> (raw)
In-Reply-To: <OS0PR01MB59228EEA7D3ECFCA83B0679386049@OS0PR01MB5922.jpnprd01.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 3179 bytes --]

On Tue, Nov 15, 2022 at 10:38:32AM +0000, Biju Das wrote:
> Hi William Breathitt Gray,
> 
> Thanks for the feedback.
> 
> > -----Original Message-----
> > From: William Breathitt Gray <william.gray@linaro.org>
> > Sent: 15 November 2022 04:53
> > To: Biju Das <biju.das.jz@bp.renesas.com>
> > Cc: linux-iio@vger.kernel.org; Geert Uytterhoeven
> > <geert+renesas@glider.be>; Chris Paterson
> > <Chris.Paterson2@renesas.com>; Prabhakar Mahadev Lad
> > <prabhakar.mahadev-lad.rj@bp.renesas.com>; linux-renesas-
> > soc@vger.kernel.org
> > Subject: Re: [PATCH v6 4/5] counter: Add Renesas RZ/G2L MTU3a counter
> > driver
> > 
> > On Mon, Nov 14, 2022 at 05:52:11PM +0000, Biju Das wrote:
> > > > > > +static int rz_mtu3_initialize_counter(struct counter_device
> > > > > > +*counter, int id) {
> > > > > > +	struct rz_mtu3_cnt *const priv = counter_priv(counter);
> > > > > > +	struct rz_mtu3_channel *ch1 = priv->ch;
> > > > > > +	struct rz_mtu3_channel *ch2 = ch1 + 1;
> > > > >
> > > > > No need to complicate this, just use priv->ch[0], priv->ch[1],
> > and
> > > > > priv->ch[id]. Same advice applies to the other functions as
> > well.
> > > >
> > > > I get below error when I use array susbscripts. "*ch1 = priv-
> > >ch[0];"
> > >
> > > > drivers/counter/rz-mtu3-cnt.c:291:32: error: incompatible types
> > when
> > > > initialising type 'struct rz_mtu3_channel *' using type 'struct
> > > > rz_mtu3_channel'
> > > >   291 |  struct rz_mtu3_channel *ch1 = priv->ch[0];
> > > >
> > >
> > > I could use "*ch1 = &priv->ch[0];" please let me know is it ok?
> > >
> > > Cheers,
> > > Biju
> > 
> > Hi Biju,
> > 
> > I meant to use the array subscripts inline (e.g. priv-
> > >ch[id].function).
> > However, I can see the benefit of using the ch1 and ch2 local
> > variables, so perhaps something like this would be clearer to read:
> > 
> >     struct rz_mtu3_chanel *const ch = priv->ch;
> >     struct rz_mtu3_chanel *const ch1 = &ch[0];
> >     struct rz_mtu3_chanel *const ch2 = &ch[1];
> >     ...
> >     case RZ_MTU3_16_BIT_MTU1_CH:
> >     case RZ_MTU3_16_BIT_MTU2_CH:
> >             if (ch[id].function != RZ_MTU3_NORMAL) {
> >     ...
> 
> 
> OK, I have added below inline function which simplifies the code
> in each function. Is it ok?
> 
> For eg:
> 
> +static inline struct rz_mtu3_channel *
> +rz_mtu3_get_ch(struct counter_device *counter, int id)
> +{
> +       struct rz_mtu3_cnt *const priv = counter_priv(counter);
> +       const size_t ch_id = RZ_MTU3_GET_HW_CH(id);
> +
> +       return &priv->ch[ch_id];
> +}
> 
> 
> @@ -154,11 +163,10 @@ static int rz_mtu3_count_function_read(struct counter_device *counter,
>                                        struct counter_count *count,
>                                        enum counter_function *function)
>  {
> -       struct rz_mtu3_cnt *const priv = counter_priv(counter);
> -       const size_t ch_id = RZ_MTU3_GET_HW_CH(count->id);
> +       struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
> 
> 
> Cheers,
> Biju

Sure, I think that function will be okay to use.

William Breathitt Gray

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2022-11-16  2:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221113171545.282457-1-biju.das.jz@bp.renesas.com>
2022-11-13 17:15 ` [PATCH v6 3/5] Documentation: ABI: sysfs-bus-counter: add external_input_phase_clock_select & long_word_access_ctrl_mode items Biju Das
2022-11-13 17:15 ` [PATCH v6 4/5] counter: Add Renesas RZ/G2L MTU3a counter driver Biju Das
2022-11-14  3:47   ` William Breathitt Gray
2022-11-14 13:53     ` William Breathitt Gray
2022-11-14 16:27       ` Biju Das
2022-11-14 15:24     ` Biju Das
2022-11-14 17:52       ` Biju Das
2022-11-15  4:53         ` William Breathitt Gray
2022-11-15 10:38           ` Biju Das
2022-11-16  2:12             ` William Breathitt Gray [this message]
2022-11-16  3:27       ` William Breathitt Gray

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=Y3RHI/Ed1xHpzmCW@fedora \
    --to=william.gray@linaro.org \
    --cc=Chris.Paterson2@renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=geert+renesas@glider.be \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /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