Re: [PATCH v6 5/5] firmware: qcom_scm: Add multiple download mode support

Andy Shevchenko
2023-05-27T07:23:18Z

On Sat, May 27, 2023 at 2:32 AM Bjorn Andersson <andersson@kernel.org> wrote:
> On Sat, May 27, 2023 at 01:14:50AM +0300, andy.shevchenko@gmail.com wrote:
> > Wed, Mar 29, 2023 at 01:16:52PM +0530, Mukesh Ojha kirjoitti:

...

> > > if (download_mode == QCOM_DOWNLOAD_FULLDUMP)
> > > len = sysfs_emit(buffer, "full\n");
> > > + else if (download_mode == QCOM_DOWNLOAD_MINIDUMP)
> > > + len = sysfs_emit(buffer, "mini\n");
> > > + else if (download_mode == QCOM_DOWNLOAD_BOTHDUMP)
> >
> > > + len = sysfs_emit(buffer, "full,mini\n");
> >
> > Why not "both" ?

> "both" isn't very future proof (and I think we've had additional
> variations in the past already), so I asked for this form.

Okay, so this should be the bit flags and we should parse a list of
the values. In that case I may agree with the approach.

> > if (mode >= ARRAY_SIZE(...))
> > return sysfs_emit("Oh heh!\n");
> >
> > return sysfs_emit("%s\n", array[mode]);

...

> > > + if (sysfs_streq(val, "full,mini") || sysfs_streq(val, "mini,full")) {
> > > + download_mode = QCOM_DOWNLOAD_BOTHDUMP;
> >
> > It's way too hard, esp. taking into account that once user enters wrong order,
> > user can't simply validate this by reading value back.
> >
> > Use "both" and that's it.
> >
> > > + } else if (sysfs_streq(val, "full")) {
> > > download_mode = QCOM_DOWNLOAD_FULLDUMP;
> > > + } else if (sysfs_streq(val, "mini")) {
> > > + download_mode = QCOM_DOWNLOAD_MINIDUMP;

As per above.

--
With Best Regards,
Andy Shevchenko