From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Nikita Kravets <teackot@gmail.com>,
platform-driver-x86@vger.kernel.org,
Aakash Singh <mail@singhaakash.dev>,
Jose Angel Pastrana <japp0005@red.ujaen.es>
Subject: Re: [PATCH 2/5] platform/x86: msi-ec: Add fw version and release date attributes
Date: Thu, 12 Oct 2023 15:56:52 +0300 (EEST) [thread overview]
Message-ID: <72d7f17d-25a6-dc6-453a-af553ae2349@linux.intel.com> (raw)
In-Reply-To: <c447f107-df52-92d1-fdd3-96b76860621e@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2900 bytes --]
Hi Hans,
You missed the one question I had for you. I put it now conviniently at
the end of the quote block below...
On Thu, 12 Oct 2023, Hans de Goede wrote:
>
> Great to see that you are working on upstreaming more of the
> out-of-tree msi-ec functionality. Thank you for working on this.
>
> On 10/11/23 14:41, Ilpo Järvinen wrote:
> > On Tue, 10 Oct 2023, Nikita Kravets wrote:
> >
> >> Create a root attribute group and add the first platform device
> >> attributes: firmware version and firmware release date. Firmware
> >> version attribute uses an already present ec_get_firmware_version()
> >> function. Both features are present on all supported laptops.
> >>
> >> Cc: Aakash Singh <mail@singhaakash.dev>
> >> Cc: Jose Angel Pastrana <japp0005@red.ujaen.es>
> >> Signed-off-by: Nikita Kravets <teackot@gmail.com>
> >> ---
> >> +static ssize_t fw_release_date_show(struct device *device,
> >> + struct device_attribute *attr, char *buf)
> >> +{
> >> + u8 rdate[MSI_EC_FW_DATE_LENGTH + 1];
> >> + u8 rtime[MSI_EC_FW_TIME_LENGTH + 1];
> >> + int result;
> >> + int year, month, day, hour, minute, second;
> >> +
> >> + memset(rdate, 0, MSI_EC_FW_DATE_LENGTH + 1);
> >
> > sizeof(*rdate) is safer so please use it.
> >
> >> + result = ec_read_seq(MSI_EC_FW_DATE_ADDRESS,
> >> + rdate,
> >> + MSI_EC_FW_DATE_LENGTH);
> >> + if (result < 0)
> >> + return result;
> >> +
> >> + result = sscanf(rdate, "%02d%02d%04d", &month, &day, &year);
> >
> > There fields would naturally be %u and unsigned but see the other comment
> > below before doing this change.
> >
> >> + if (result != 3)
> >> + return -EINVAL;
> >
> > EINVAL should be returned if the input was invalid but here the data
> > itself is not okay so some other errno would be better.
> >
> >> + memset(rtime, 0, MSI_EC_FW_TIME_LENGTH + 1);
> >
> > sizeof() like above.
> >
> >> + result = ec_read_seq(MSI_EC_FW_TIME_ADDRESS,
> >> + rtime,
> >> + MSI_EC_FW_TIME_LENGTH);
> >> + if (result < 0)
> >> + return result;
> >> +
> >> + result = sscanf(rtime, "%02d:%02d:%02d", &hour, &minute, &second);
> >> + if (result != 3)
> >> + return -EINVAL;
> >
> > Ditto.
> >
> >> +
> >> + return sysfs_emit(buf, "%04d/%02d/%02d %02d:%02d:%02d\n", year, month, day,
> >> + hour, minute, second);
> >
> > It would be kind of nice to use %pt formatting here instead of custom
> > datetime format, however, it would either require converting to time64_t
> > or using struct rtc_time. The latter would naturally have the right fields
> > but they're not unsigned so my comment above about %u is not going to work
> > well with it.
> >
> > I'm also a bit unsure whether it's appropriate to use that struct outside
> > of rtc realm. vsprintf.c seems to convert time64_t into rtc_time before
> > printing though.
> >
> > Hans, do you have any idea about the struct rtc_time?
--
i.
next prev parent reply other threads:[~2023-10-12 12:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 17:20 [PATCH 0/5] platform/x86: msi-ec: Add the first platform device attributes Nikita Kravets
2023-10-10 17:20 ` [PATCH 1/5] platform/x86: msi-ec: Register a platform driver Nikita Kravets
2023-10-11 13:00 ` Ilpo Järvinen
2023-10-12 12:30 ` Hans de Goede
2023-10-10 17:20 ` [PATCH 2/5] platform/x86: msi-ec: Add fw version and release date attributes Nikita Kravets
2023-10-11 12:41 ` Ilpo Järvinen
2023-10-12 12:34 ` Hans de Goede
2023-10-12 12:56 ` Ilpo Järvinen [this message]
2023-10-18 14:34 ` Hans de Goede
2025-02-20 12:25 ` N K
2023-10-10 17:20 ` [PATCH 3/5] platform/x86: msi-ec: Filter out unsupported attributes Nikita Kravets
2023-10-11 12:46 ` Ilpo Järvinen
2023-10-10 17:20 ` [PATCH 4/5] platform/x86: msi-ec: Add EC bit operation functions Nikita Kravets
2023-10-11 12:59 ` Ilpo Järvinen
2023-10-12 12:41 ` Hans de Goede
2023-10-10 17:20 ` [PATCH 5/5] platform/x86: msi-ec: Add a cooler boost attribute Nikita Kravets
2023-10-11 12:49 ` Ilpo Järvinen
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=72d7f17d-25a6-dc6-453a-af553ae2349@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=japp0005@red.ujaen.es \
--cc=mail@singhaakash.dev \
--cc=platform-driver-x86@vger.kernel.org \
--cc=teackot@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