From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Wolfram Sang <wsa+renesas@sang-engineering.com>
Cc: "open list:GPIO SUBSYSTEM" <linux-gpio@vger.kernel.org>,
linux-renesas-soc@vger.kernel.org,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] gpio: add sloppy logic analyzer using polling
Date: Sun, 19 Sep 2021 23:27:14 +0300 [thread overview]
Message-ID: <CAHp75Vdv=0i05EitMi6JjbjML-jFD_1M0q7ps2KVHcN4UtFU-w@mail.gmail.com> (raw)
In-Reply-To: <20210918083307.3195-2-wsa+renesas@sang-engineering.com>
On Sat, Sep 18, 2021 at 5:22 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
>
> This is a sloppy logic analyzer using GPIOs. It comes with a script to
> isolate a CPU for polling. While this is definitely not a production
> level analyzer, it can be a helpful first view when remote debugging.
> Read the documentation for details.
Thanks for update, my comments below.
...
> + /* upper limit is arbitrary */
Not really. I believe if the upper limit is > PAGE_SIZE, you would get
-ENOMEM with much higher chances. So, I think the comment should be
amended,
> + if (count > 2048 || count & 1)
> + return -EINVAL;
...
> + ret = device_property_read_string_array(dev, "probe-names", gpio_names,
> + priv->descs->ndescs);
> + if (ret >= 0 && ret != priv->descs->ndescs)
> + ret = -ENODATA;
> + if (ret < 0) {
> + dev_err(dev, "error naming the GPIOs: %d\n", ret);
> + return ret;
> + }
Perhaps
return dev_err_probe() ?
And I think it might be split into two conditionals with
distinguishable error messages.
...
> + dev_info(dev, "initialized");
Unneeded noise.
...
> + [ -n "$cur_cpu" ] && fail "CPU$isol_cpu requested but CPU$cur_cpu already isolated"
For the sake of style (handle errors on the error) I would use
[ -z "..." ] || fail ...
...
> + # Move tasks away from isolated CPU
> + for p in $(ps -o pid | tail -n +2); do
> + mask=$(taskset -p "$p") || continue
> + [ "${mask##*: }" != "$oldmask" ] && continue
Perhaps
[ ... = ... ] || continue
to be in alignment with the rest of the similar lines here?
> + taskset -p "$newmask" "$p" || continue
> + done 2>/dev/null >/dev/null
...
> +while true; do
> + case "$1" in
> + -c|--cpu) initcpu="$2"; shift;;
> + -d|--duration-us) duration="$2"; shift;;
> + -h|--help) print_help; exit 0;;
> + -i|--instance) lainstance="$2"; shift;;
> + -k|--kernel-debug-dir) debugdir="$2"; shift;;
> + -n|--num_samples) numsamples="$2"; shift;;
> + -o|--output-dir) outputdir="$2"; shift;;
> + -s|--sample_freq) samplefreq="$2"; shift;;
> + -t|--trigger) triggerdat="$2"; shift;;
> + --) break;;
> + *) fail "error parsing commandline: $*";;
command line
> + esac
> + shift
> +done
...
> +[ "$samplefreq" -eq 0 ] && fail "Invalid sample frequency"
Same as above, use '... || fail ...' approach.
...
> +if [ -n "$lainstance" ]; then
Shouldn't be rather '-d' ?
> + lasysfsdir="$sysfsdir/$lainstance"
> +else
> + lasysfsdir="$(find "$sysfsdir" -mindepth 1 -type d -print -quit)"
> +fi
...
> +[ ! -d "$lacpusetdir" ] && echo "Auto-Isolating CPU1" && init_cpu 1
This ! along with double && is hard to read. Simply
[ -d ... ] || {
...
}
no?
...
> +[ -z "$workcpu" ] && fail "No isolated CPU found"
As above, use ' ... || fail ...' approach.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-09-19 20:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-18 8:33 [PATCH v2 0/1] gpio: add simple logic analyzer using polling Wolfram Sang
2021-09-18 8:33 ` [PATCH v2 1/1] gpio: add sloppy " Wolfram Sang
2021-09-19 20:27 ` Andy Shevchenko [this message]
2021-09-20 8:30 ` Wolfram Sang
2021-09-20 8:45 ` Andy Shevchenko
2021-11-22 12:19 ` Wolfram Sang
2021-11-22 12:33 ` Andy Shevchenko
2021-11-22 15:03 ` Wolfram Sang
2021-09-20 12:15 ` Geert Uytterhoeven
2021-11-22 11:43 ` Wolfram Sang
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='CAHp75Vdv=0i05EitMi6JjbjML-jFD_1M0q7ps2KVHcN4UtFU-w@mail.gmail.com' \
--to=andy.shevchenko@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa+renesas@sang-engineering.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 NNTP newsgroup(s).