Re: [PATCH] PCI/sysfs: add write attribute for boot_vga

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[+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



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux