lkml.org 
[lkml]   [2006]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Add a "enable" sysfs attribute to the pci devices to allow userspace (Xorg) to enable devices without doing foul direct access
Arjan van de Ven <arjan@linux.intel.com> wrote:
>
> +static ssize_t
> +is_enabled_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct pci_dev *pdev = to_pci_dev(dev);

whitespace broke

> + if (!pdev)
> + return 1;

Can this happen?

> + /* this can crash the machine when done on the "wrong" device */
> + if (!capable(CAP_SYS_ADMIN))
> + return 1;

Don't the file's permissions suffice?

> + if (*buf == '0')
> + pci_disable_device(pdev);
> +
> + if (*buf == '1')
> + pci_enable_device(pdev);
> +
> + return 1;

return count;

> +}
> +
>
> struct device_attribute pci_dev_attrs[] = {
> __ATTR_RO(resource),
> @@ -101,6 +124,7 @@ struct device_attribute pci_dev_attrs[]
> __ATTR_RO(irq),
> __ATTR_RO(local_cpus),
> __ATTR_RO(modalias),
> + __ATTR(enable, 0600, is_enabled_show, is_enabled_store),
> __ATTR_NULL,
> };
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-04-29 10:55    [W:0.102 / U:1.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site