Re: fixup PCI device booleans in sysfs

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

 



On Sunday, November 30, 2008 5:10 pm Trent Piepho wrote:
> From d962157b2b36f2c54d147a296921553b4aefcf7b Mon Sep 17 00:00:00 2001
> From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>
> Date: Sun, 30 Nov 2008 16:51:29 -0800
> Subject: [PATCH] PCI: Make settable sysfs attributes more consistent
>
> PCI devices have three settable boolean attributes, enable,
> broken_parity_status, and msi_bus.
>
> The store functions for these would silently interpret "0x01" as false,
> "1llogical" as true, and "true" would be (silently!) ignored and do
> nothing.
>
> This is inconsistent with typical sysfs handling of settable attributes,
> and just plain doesn't make much sense.
>
> So, use strict_strtoul(), which was created for this purpose.  The store
> functions will treat a value of 0 as false, non-zero as true, and return
> -EINVAL for a parse failure.
>
> Additionally, is_enabled_store() and msi_bus_store() return -EPERM if
> CAP_SYS_ADMIN is lacking, rather than silently doing nothing.  This is more
> typical behavior for sysfs attributes that need a capability.
>
> And msi_bus_store() will only print the "forced subordinate bus ..."
> warning if the MSI flag was actually forced to a different value.
>
> Signed-off-by: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

Nice, I dug this out of the big fakephp flame thread.  Looks like a good fix; 
there are probably other sysfs interfaces in the kernel that need similar 
treatment.  This one is in my linux-next branch now.  Hope there aren't many 
scripts out there depending on the broken behavior! :)

Thanks,
-- 
Jesse Barnes, Intel Open Source Technology Center

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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