Linux-IIO Archive mirror
 help / color / mirror / Atom feed
From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Chenyuan Yang <chenyuan0y@gmail.com>
Cc: jic23@kernel.org, lars@metafoo.de, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org, Zijie Zhao <zzjas98@gmail.com>
Subject: Re: [drivers/iio] Question about `iio_gts_build_avail_time_table`
Date: Wed, 13 Mar 2024 10:08:50 +0200	[thread overview]
Message-ID: <9724f90c-111f-40e7-9787-c62787cef96e@gmail.com> (raw)
In-Reply-To: <CALGdzuoA4ANBurXyP+00hFPmPznixcMTgrYNp1P4VwvpFb_GtA@mail.gmail.com>

Hi Chenyuan,

On 3/12/24 18:53, Chenyuan Yang wrote:
> Hi Matti,
> 
> I have a question about the "The idea of the check which has been
> removed was to assign the value in
> the array in first free spot if it is bigger than the last value".

Can you please avoid top-posting when discussing on the Linux lists. You 
can find more information from:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html

part of which may be crucial in order to get your changes applied if you 
haven't already familiarized yourself with the kernel development processes.


> 
> -               if (times[idx] < new) {
> -                       times[idx++] = new;
> -                       continue;
> -               }
> +               times[idx] = new;
> 
> It appears that the comparison should perhaps be made with `idx-1`
> rather than `idx`, given that `idx` represents the current number of
> copied values in times, whereas `idx-1` points to the last value.
> Could I have your thoughts on this?

Yes. I implemented the old code wrong as you pointed out.

You may want to take the GTS Kunit test cases:
https://lore.kernel.org/all/6b839dd533fd93b75c2e6f6a8f2286233d4901fb.1704881096.git.mazziesaccount@gmail.com/
which, I think, are already merged in IIO testing branch.

You can test the sorting when you change the order of the times in the 
test case:

+static const struct iio_itime_sel_mul gts_test_itimes[] = {
+	GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8),
+	GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4),
+	GAIN_SCALE_ITIME_US(100 * 1000, TEST_TSEL_100, 2),
+	GAIN_SCALE_ITIME_US(50 * 1000, TEST_TSEL_50, 1),
+#define TIMEGAIN_MAX 8
+};

for example to

+static const struct iio_itime_sel_mul gts_test_itimes[] = {
+	GAIN_SCALE_ITIME_US(400 * 1000, TEST_TSEL_400, 8),
+	GAIN_SCALE_ITIME_US(50 * 1000, TEST_TSEL_50, 1),
+	GAIN_SCALE_ITIME_US(200 * 1000, TEST_TSEL_200, 4),
+	GAIN_SCALE_ITIME_US(100 * 1000, TEST_TSEL_100, 2),
+#define TIMEGAIN_MAX 8
+};

Yours,
	-- Matti

-- 
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~


      reply	other threads:[~2024-03-13  8:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-11 19:48 [drivers/iio] Question about `iio_gts_build_avail_time_table` Chenyuan Yang
2024-03-12 11:16 ` Matti Vaittinen
2024-03-12 16:53   ` Chenyuan Yang
2024-03-13  8:08     ` Matti Vaittinen [this message]

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=9724f90c-111f-40e7-9787-c62787cef96e@gmail.com \
    --to=mazziesaccount@gmail.com \
    --cc=chenyuan0y@gmail.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zzjas98@gmail.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).