Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1742754

Re: [PATCH v3 6/8] platform/x86: dell-wmi-smbios: Add a sysfs interface for SMBIOS tokens

From Andy Shevchenko <andy.shevchenko@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH v3 6/8] platform/x86: dell-wmi-smbios: Add a sysfs interface for SMBIOS tokens
Date 2017-10-01 11:00 +0200
Message-ID <uvIgq-8it-11@gated-at.bofh.it> (permalink)
References <uuyj7-40H-7@gated-at.bofh.it> <uuyj7-40H-9@gated-at.bofh.it> <uvfxL-6jP-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Sat, Sep 30, 2017 at 5:10 AM, Darren Hart <dvhart@infradead.org> wrote:
> On Wed, Sep 27, 2017 at 11:02:18PM -0500, Mario Limonciello wrote:
>> Currently userspace tools can access system tokens via the dcdbas
>> kernel module and a SMI call that will cause the platform to execute
>> SMM code.
>>
>> With a goal in mind of deprecating the dcdbas kernel module a different
>> method for accessing these tokens from userspace needs to be created.
>>
>> This is intentionally marked to only be readable as root as it can
>> contain sensitive information about the platform's configuration.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
>> ---
> ...
>> +static ssize_t tokens_show(struct device *dev,
>> +                        struct device_attribute *attr, char *buf)
>> +{
>> +     size_t off = 0;
>> +     int i;
>> +
>> +     for (i = 0; i < da_num_tokens; i++) {
>> +             if (off > PAGE_SIZE)
>> +                     break;
>> +             off += scnprintf(buf+off, PAGE_SIZE-off, "%04x\t%04x\t%04x\n",
>
> Minor Coding Style nit - spaces around binary operators: 3.1) Spaces

Fresh looking to this excerpt gives me an idea that we may actually
predict how many tokens to write beforehand. It makes output also
cleaner in a sense to not disrupt a last token in the middle.

Something like
tokens_to_print = min(da_num_tokens, (PAGE_SIZE  - 1) / 15);
?

-- 
With Best Regards,
Andy Shevchenko

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v3 6/8] platform/x86: dell-wmi-smbios: Add a sysfs interface for SMBIOS tokens Mario Limonciello <mario.limonciello@dell.com> - 2017-09-28 06:10 +0200
  Re: [PATCH v3 6/8] platform/x86: dell-wmi-smbios: Add a sysfs  interface for SMBIOS tokens Darren Hart <dvhart@infradead.org> - 2017-09-30 04:20 +0200
    Re: [PATCH v3 6/8] platform/x86: dell-wmi-smbios: Add a sysfs  interface for SMBIOS tokens Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-10-01 11:00 +0200

csiph-web