From: "Krzysztof Wilczyński" <kw@linux.com>
To: Zhenneng Li <lizhenneng@kylinos.cn>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Huacai Chen <chenhuacai@loongson.cn>,
Kai-Heng Feng <kai.heng.feng@canonical.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI/sysfs: add write attribute for boot_vga
Date: Sun, 26 Sep 2021 22:00:45 +0200 [thread overview]
Message-ID: <YVDRbRF5wbcJmTtb@rocinante> (raw)
In-Reply-To: <20210926071539.636644-1-lizhenneng@kylinos.cn>
[+cc Huacai and Kai-Heng as they are working in this area]
Hi,
Thank you for sending the patch over.
I assume this is simply a resend (rather than a v2), as I see no code
changes from the previous version you sent some time ago.
> Add writing attribute for boot_vga sys node,
> so we can config default video display
> output dynamically when there are two video
> cards on a machine.
That's OK, but why are you adding this? What problem does it solve and
what is the intended user here? Might be worth adding a little bit more
details about why this new sysfs attribute is needed.
I also need to ask, as I am not sure myself, whether this is OK to do after
booting during runtime? What do you think Bjorn, Huacai and Kai-Heng?
Also, please correctly capitalise the subject - have a look at previous
commit messages to see how it should look like.
> +static ssize_t boot_vga_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + unsigned long val;
> + struct pci_dev *pdev = to_pci_dev(dev);
> + struct pci_dev *vga_dev = vga_default_device();
> +
> + if (kstrtoul(buf, 0, &val) < 0)
> + return -EINVAL;
> +
> + if (val != 1)
> + return -EINVAL;
Since this is a completely new API have a look at kstrtobool() over
kstrtoul() as the former was created to handle user input more
consistently.
> + if (!capable(CAP_SYS_ADMIN))
> + return -EPERM;
> +
Check for CAP_SYS_ADMIN is a good idea, but it has to take place before you
attempt to accept and parse a input from the user.
Krzysztof
next prev parent reply other threads:[~2021-09-26 20:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-26 7:15 [PATCH] PCI/sysfs: add write attribute for boot_vga Zhenneng Li
2021-09-26 20:00 ` Krzysztof Wilczyński [this message]
2021-09-27 3:06 ` 李真能
2021-09-26 20:20 ` Bjorn Helgaas
2021-09-27 3:45 ` 李真能
2021-09-27 3:57 ` Kai-Heng Feng
2021-09-28 23:37 ` Bjorn Helgaas
2021-09-29 1:45 ` 李真能
-- strict thread matches above, loose matches on Subject: below --
2021-08-31 7:55 Zhenneng Li
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=YVDRbRF5wbcJmTtb@rocinante \
--to=kw@linux.com \
--cc=bhelgaas@google.com \
--cc=chenhuacai@loongson.cn \
--cc=kai.heng.feng@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lizhenneng@kylinos.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.