summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-devices-coredump10
-rw-r--r--Documentation/driver-api/firmware/built-in-fw.rst7
-rw-r--r--Documentation/driver-api/firmware/fallback-mechanisms.rst2
-rw-r--r--Documentation/x86/microcode.txt5
-rw-r--r--arch/arc/configs/axs101_defconfig1
-rw-r--r--arch/arc/configs/axs103_defconfig1
-rw-r--r--arch/arc/configs/axs103_smp_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_defconfig1
-rw-r--r--arch/arc/configs/haps_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/hsdk_defconfig1
-rw-r--r--arch/arc/configs/nsim_700_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_defconfig1
-rw-r--r--arch/arc/configs/nsim_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_defconfig1
-rw-r--r--arch/arc/configs/nsimosci_hs_smp_defconfig1
-rw-r--r--arch/arc/configs/tb10x_defconfig1
-rw-r--r--arch/arc/configs/vdk_hs38_defconfig1
-rw-r--r--arch/arc/configs/vdk_hs38_smp_defconfig1
-rw-r--r--arch/arm/configs/cns3420vb_defconfig1
-rw-r--r--arch/arm/configs/magician_defconfig1
-rw-r--r--arch/arm/configs/mini2440_defconfig1
-rw-r--r--arch/arm/configs/mv78xx0_defconfig1
-rw-r--r--arch/arm/configs/mxs_defconfig1
-rw-r--r--arch/arm/configs/orion5x_defconfig1
-rw-r--r--arch/arm/configs/tegra_defconfig1
-rw-r--r--arch/arm/configs/vf610m4_defconfig1
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c4
-rw-r--r--arch/m68k/configs/amiga_defconfig1
-rw-r--r--arch/m68k/configs/apollo_defconfig1
-rw-r--r--arch/m68k/configs/atari_defconfig1
-rw-r--r--arch/m68k/configs/bvme6000_defconfig1
-rw-r--r--arch/m68k/configs/hp300_defconfig1
-rw-r--r--arch/m68k/configs/mac_defconfig1
-rw-r--r--arch/m68k/configs/multi_defconfig1
-rw-r--r--arch/m68k/configs/mvme147_defconfig1
-rw-r--r--arch/m68k/configs/mvme16x_defconfig1
-rw-r--r--arch/m68k/configs/q40_defconfig1
-rw-r--r--arch/m68k/configs/sun3_defconfig1
-rw-r--r--arch/m68k/configs/sun3x_defconfig1
-rw-r--r--arch/mips/configs/ar7_defconfig1
-rw-r--r--arch/mips/configs/ath25_defconfig1
-rw-r--r--arch/mips/configs/ath79_defconfig1
-rw-r--r--arch/mips/configs/pic32mzda_defconfig1
-rw-r--r--arch/mips/configs/qi_lb60_defconfig1
-rw-r--r--arch/mips/configs/rm200_defconfig9
-rw-r--r--arch/mips/configs/rt305x_defconfig1
-rw-r--r--arch/mips/configs/xway_defconfig1
-rw-r--r--arch/mn10300/configs/asb2364_defconfig1
-rw-r--r--arch/powerpc/configs/44x/warp_defconfig1
-rw-r--r--arch/powerpc/configs/c2k_defconfig12
-rw-r--r--arch/powerpc/configs/g5_defconfig12
-rw-r--r--arch/powerpc/configs/maple_defconfig12
-rw-r--r--arch/powerpc/configs/mpc512x_defconfig1
-rw-r--r--arch/powerpc/configs/pmac32_defconfig12
-rw-r--r--arch/powerpc/configs/ppc6xx_defconfig1
-rw-r--r--arch/powerpc/configs/ps3_defconfig1
-rw-r--r--arch/powerpc/configs/wii_defconfig1
-rw-r--r--arch/s390/configs/zfcpdump_defconfig1
-rw-r--r--arch/s390/kernel/smp.c2
-rw-r--r--arch/s390/kernel/topology.c3
-rw-r--r--arch/sh/configs/polaris_defconfig1
-rw-r--r--arch/sh/drivers/push-switch.c2
-rw-r--r--arch/tile/configs/tilegx_defconfig1
-rw-r--r--arch/tile/configs/tilepro_defconfig1
-rw-r--r--arch/tile/kernel/sysfs.c12
-rw-r--r--arch/x86/Kconfig6
-rw-r--r--arch/x86/kernel/cpu/microcode/core.c2
-rw-r--r--drivers/acpi/device_sysfs.c6
-rw-r--r--drivers/base/Kconfig28
-rw-r--r--drivers/base/arch_topology.c8
-rw-r--r--drivers/base/attribute_container.c3
-rw-r--r--drivers/base/bus.c6
-rw-r--r--drivers/base/cacheinfo.c13
-rw-r--r--drivers/base/class.c4
-rw-r--r--drivers/base/component.c83
-rw-r--r--drivers/base/container.c5
-rw-r--r--drivers/base/core.c6
-rw-r--r--drivers/base/cpu.c1
-rw-r--r--drivers/base/dd.c43
-rw-r--r--drivers/base/devcoredump.c17
-rw-r--r--drivers/base/devres.c3
-rw-r--r--drivers/base/dma-contiguous.c6
-rw-r--r--drivers/base/dma-mapping.c3
-rw-r--r--drivers/base/driver.c6
-rw-r--r--drivers/base/firmware.c3
-rw-r--r--drivers/base/firmware_class.c859
-rw-r--r--drivers/base/hypervisor.c3
-rw-r--r--drivers/base/init.c3
-rw-r--r--drivers/base/isa.c1
-rw-r--r--drivers/base/map.c2
-rw-r--r--drivers/base/module.c4
-rw-r--r--drivers/base/pinctrl.c3
-rw-r--r--drivers/base/platform-msi.c13
-rw-r--r--drivers/base/platform.c3
-rw-r--r--drivers/base/property.c73
-rw-r--r--drivers/base/soc.c2
-rw-r--r--drivers/base/syscore.c3
-rw-r--r--drivers/base/test/test_async_driver_probe.c10
-rw-r--r--drivers/base/topology.c17
-rw-r--r--drivers/base/transport_class.c3
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c17
-rw-r--r--drivers/gpu/drm/i915/i915_sysfs.c12
-rw-r--r--drivers/input/touchscreen/elants_i2c.c2
-rw-r--r--drivers/net/ethernet/ibm/ibmvnic.c2
-rw-r--r--drivers/net/wimax/i2400m/sysfs.c3
-rw-r--r--drivers/nvme/host/core.c10
-rw-r--r--drivers/platform/x86/compal-laptop.c18
-rw-r--r--drivers/s390/cio/css.c8
-rw-r--r--drivers/s390/cio/device.c10
-rw-r--r--drivers/s390/crypto/ap_card.c2
-rw-r--r--drivers/scsi/hpsa.c10
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c64
-rw-r--r--drivers/thermal/thermal_sysfs.c17
-rw-r--r--drivers/tty/serial/sh-sci.c2
-rw-r--r--drivers/usb/serial/Kconfig78
-rw-r--r--drivers/video/fbdev/auo_k190x.c4
-rw-r--r--drivers/video/fbdev/w100fb.c4
-rw-r--r--fs/sysfs/dir.c9
-rw-r--r--fs/sysfs/file.c3
-rw-r--r--fs/sysfs/group.c6
-rw-r--r--fs/sysfs/mount.c5
-rw-r--r--fs/sysfs/symlink.c3
-rw-r--r--fs/sysfs/sysfs.h3
-rw-r--r--include/linux/device.h5
-rw-r--r--include/linux/kobject.h3
-rw-r--r--include/linux/kobject_ns.h3
-rw-r--r--include/linux/property.h10
-rw-r--r--include/linux/sysfs.h14
-rw-r--r--lib/kobject.c4
-rw-r--r--lib/kobject_uevent.c3
-rw-r--r--lib/test_firmware.c17
-rw-r--r--lib/test_kmod.c14
-rw-r--r--samples/kobject/kobject-example.c4
-rw-r--r--samples/kobject/kset-example.c4
-rw-r--r--sound/soc/omap/mcbsp.c4
-rw-r--r--sound/soc/soc-core.c2
-rw-r--r--sound/soc/soc-dapm.c2
-rwxr-xr-xtools/testing/selftests/firmware/fw_fallback.sh172
-rwxr-xr-xtools/testing/selftests/firmware/fw_filesystem.sh5
140 files changed, 918 insertions, 1047 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-coredump b/Documentation/ABI/testing/sysfs-devices-coredump
new file mode 100644
index 000000000000..e459368533a4
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-devices-coredump
@@ -0,0 +1,10 @@
1What: /sys/devices/.../coredump
2Date: December 2017
3Contact: Arend van Spriel <aspriel@gmail.com>
4Description:
5 The /sys/devices/.../coredump attribute is only present when the
6 device is bound to a driver, which provides the .coredump()
7 callback. The attribute is write only. Anything written to this
8 file will trigger the .coredump() callback.
9
10 Available when CONFIG_DEV_COREDUMP is enabled.
diff --git a/Documentation/driver-api/firmware/built-in-fw.rst b/Documentation/driver-api/firmware/built-in-fw.rst
index 7300e66857f8..396cdf591ac5 100644
--- a/Documentation/driver-api/firmware/built-in-fw.rst
+++ b/Documentation/driver-api/firmware/built-in-fw.rst
@@ -11,13 +11,8 @@ options:
11 * CONFIG_EXTRA_FIRMWARE 11 * CONFIG_EXTRA_FIRMWARE
12 * CONFIG_EXTRA_FIRMWARE_DIR 12 * CONFIG_EXTRA_FIRMWARE_DIR
13 13
14This should not be confused with CONFIG_FIRMWARE_IN_KERNEL, this is for drivers
15which enables firmware to be built as part of the kernel build process. This
16option, CONFIG_FIRMWARE_IN_KERNEL, will build all firmware for all drivers
17enabled which ship its firmware inside the Linux kernel source tree.
18
19There are a few reasons why you might want to consider building your firmware 14There are a few reasons why you might want to consider building your firmware
20into the kernel with CONFIG_EXTRA_FIRMWARE though: 15into the kernel with CONFIG_EXTRA_FIRMWARE:
21 16
22* Speed 17* Speed
23* Firmware is needed for accessing the boot device, and the user doesn't 18* Firmware is needed for accessing the boot device, and the user doesn't
diff --git a/Documentation/driver-api/firmware/fallback-mechanisms.rst b/Documentation/driver-api/firmware/fallback-mechanisms.rst
index d19354794e67..4055ac76b288 100644
--- a/Documentation/driver-api/firmware/fallback-mechanisms.rst
+++ b/Documentation/driver-api/firmware/fallback-mechanisms.rst
@@ -71,7 +71,7 @@ via fw_create_instance(). This call creates a new struct device named after
71the firmware requested, and establishes it in the device hierarchy by 71the firmware requested, and establishes it in the device hierarchy by
72associating the device used to make the request as the device's parent. 72associating the device used to make the request as the device's parent.
73The sysfs directory's file attributes are defined and controlled through 73The sysfs directory's file attributes are defined and controlled through
74the new device's class (firmare_class) and group (fw_dev_attr_groups). 74the new device's class (firmware_class) and group (fw_dev_attr_groups).
75This is actually where the original firmware_class.c file name comes from, 75This is actually where the original firmware_class.c file name comes from,
76as originally the only firmware loading mechanism available was the 76as originally the only firmware loading mechanism available was the
77mechanism we now use as a fallback mechanism. 77mechanism we now use as a fallback mechanism.
diff --git a/Documentation/x86/microcode.txt b/Documentation/x86/microcode.txt
index f57e1b45e628..79fdb4a8148a 100644
--- a/Documentation/x86/microcode.txt
+++ b/Documentation/x86/microcode.txt
@@ -108,12 +108,11 @@ packages already put them there.
108==================== 108====================
109 109
110The loader supports also loading of a builtin microcode supplied through 110The loader supports also loading of a builtin microcode supplied through
111the regular firmware builtin method CONFIG_FIRMWARE_IN_KERNEL. Only 111the regular builtin firmware method CONFIG_EXTRA_FIRMWARE. Only 64-bit is
11264-bit is currently supported. 112currently supported.
113 113
114Here's an example: 114Here's an example:
115 115
116CONFIG_FIRMWARE_IN_KERNEL=y
117CONFIG_EXTRA_FIRMWARE="intel-ucode/06-3a-09 amd-ucode/microcode_amd_fam15h.bin" 116CONFIG_EXTRA_FIRMWARE="intel-ucode/06-3a-09 amd-ucode/microcode_amd_fam15h.bin"
118CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware" 117CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
119 118
diff --git a/arch/arc/configs/axs101_defconfig b/arch/arc/configs/axs101_defconfig
index ec7c849a5c8e..09f85154c5a4 100644
--- a/arch/arc/configs/axs101_defconfig
+++ b/arch/arc/configs/axs101_defconfig
@@ -44,7 +44,6 @@ CONFIG_IP_PNP_RARP=y
44CONFIG_DEVTMPFS=y 44CONFIG_DEVTMPFS=y
45# CONFIG_STANDALONE is not set 45# CONFIG_STANDALONE is not set
46# CONFIG_PREVENT_FIRMWARE_BUILD is not set 46# CONFIG_PREVENT_FIRMWARE_BUILD is not set
47# CONFIG_FIRMWARE_IN_KERNEL is not set
48CONFIG_SCSI=y 47CONFIG_SCSI=y
49CONFIG_BLK_DEV_SD=y 48CONFIG_BLK_DEV_SD=y
50CONFIG_NETDEVICES=y 49CONFIG_NETDEVICES=y
diff --git a/arch/arc/configs/axs103_defconfig b/arch/arc/configs/axs103_defconfig
index 63d3cf69e0b0..09fed3ef22b6 100644
--- a/arch/arc/configs/axs103_defconfig
+++ b/arch/arc/configs/axs103_defconfig
@@ -44,7 +44,6 @@ CONFIG_IP_PNP_RARP=y
44CONFIG_DEVTMPFS=y 44CONFIG_DEVTMPFS=y
45# CONFIG_STANDALONE is not set 45# CONFIG_STANDALONE is not set
46# CONFIG_PREVENT_FIRMWARE_BUILD is not set 46# CONFIG_PREVENT_FIRMWARE_BUILD is not set
47# CONFIG_FIRMWARE_IN_KERNEL is not set
48CONFIG_BLK_DEV_LOOP=y 47CONFIG_BLK_DEV_LOOP=y
49CONFIG_SCSI=y 48CONFIG_SCSI=y
50CONFIG_BLK_DEV_SD=y 49CONFIG_BLK_DEV_SD=y
diff --git a/arch/arc/configs/axs103_smp_defconfig b/arch/arc/configs/axs103_smp_defconfig
index f613ecac14a7..ea2f6d817d1a 100644
--- a/arch/arc/configs/axs103_smp_defconfig
+++ b/arch/arc/configs/axs103_smp_defconfig
@@ -45,7 +45,6 @@ CONFIG_IP_PNP_RARP=y
45CONFIG_DEVTMPFS=y 45CONFIG_DEVTMPFS=y
46# CONFIG_STANDALONE is not set 46# CONFIG_STANDALONE is not set
47# CONFIG_PREVENT_FIRMWARE_BUILD is not set 47# CONFIG_PREVENT_FIRMWARE_BUILD is not set
48# CONFIG_FIRMWARE_IN_KERNEL is not set
49CONFIG_BLK_DEV_LOOP=y 48CONFIG_BLK_DEV_LOOP=y
50CONFIG_SCSI=y 49CONFIG_SCSI=y
51CONFIG_BLK_DEV_SD=y 50CONFIG_BLK_DEV_SD=y
diff --git a/arch/arc/configs/haps_hs_defconfig b/arch/arc/configs/haps_hs_defconfig
index db04ea4dd2d9..ab231c040efe 100644
--- a/arch/arc/configs/haps_hs_defconfig
+++ b/arch/arc/configs/haps_hs_defconfig
@@ -40,7 +40,6 @@ CONFIG_INET=y
40CONFIG_DEVTMPFS=y 40CONFIG_DEVTMPFS=y
41# CONFIG_STANDALONE is not set 41# CONFIG_STANDALONE is not set
42# CONFIG_PREVENT_FIRMWARE_BUILD is not set 42# CONFIG_PREVENT_FIRMWARE_BUILD is not set
43# CONFIG_FIRMWARE_IN_KERNEL is not set
44# CONFIG_BLK_DEV is not set 43# CONFIG_BLK_DEV is not set
45CONFIG_NETDEVICES=y 44CONFIG_NETDEVICES=y
46# CONFIG_NET_VENDOR_ARC is not set 45# CONFIG_NET_VENDOR_ARC is not set
diff --git a/arch/arc/configs/haps_hs_smp_defconfig b/arch/arc/configs/haps_hs_smp_defconfig
index 3507be2af6fe..cf449cbf440d 100644
--- a/arch/arc/configs/haps_hs_smp_defconfig
+++ b/arch/arc/configs/haps_hs_smp_defconfig
@@ -43,7 +43,6 @@ CONFIG_INET=y
43CONFIG_DEVTMPFS=y 43CONFIG_DEVTMPFS=y
44# CONFIG_STANDALONE is not set 44# CONFIG_STANDALONE is not set
45# CONFIG_PREVENT_FIRMWARE_BUILD is not set 45# CONFIG_PREVENT_FIRMWARE_BUILD is not set
46# CONFIG_FIRMWARE_IN_KERNEL is not set
47# CONFIG_BLK_DEV is not set 46# CONFIG_BLK_DEV is not set
48CONFIG_NETDEVICES=y 47CONFIG_NETDEVICES=y
49# CONFIG_NET_VENDOR_ARC is not set 48# CONFIG_NET_VENDOR_ARC is not set
diff --git a/arch/arc/configs/hsdk_defconfig b/arch/arc/configs/hsdk_defconfig
index ac6b0ed8341e..1b54c72f4296 100644
--- a/arch/arc/configs/hsdk_defconfig
+++ b/arch/arc/configs/hsdk_defconfig
@@ -32,7 +32,6 @@ CONFIG_INET=y
32CONFIG_DEVTMPFS=y 32CONFIG_DEVTMPFS=y
33# CONFIG_STANDALONE is not set 33# CONFIG_STANDALONE is not set
34# CONFIG_PREVENT_FIRMWARE_BUILD is not set 34# CONFIG_PREVENT_FIRMWARE_BUILD is not set
35# CONFIG_FIRMWARE_IN_KERNEL is not set
36CONFIG_SCSI=y 35CONFIG_SCSI=y
37CONFIG_BLK_DEV_SD=y 36CONFIG_BLK_DEV_SD=y
38CONFIG_NETDEVICES=y 37CONFIG_NETDEVICES=y
diff --git a/arch/arc/configs/nsim_700_defconfig b/arch/arc/configs/nsim_700_defconfig
index 6dff83a238b8..31c2c70b34a1 100644
--- a/arch/arc/configs/nsim_700_defconfig
+++ b/arch/arc/configs/nsim_700_defconfig
@@ -36,7 +36,6 @@ CONFIG_INET=y
36CONFIG_DEVTMPFS=y 36CONFIG_DEVTMPFS=y
37# CONFIG_STANDALONE is not set 37# CONFIG_STANDALONE is not set
38# CONFIG_PREVENT_FIRMWARE_BUILD is not set 38# CONFIG_PREVENT_FIRMWARE_BUILD is not set
39# CONFIG_FIRMWARE_IN_KERNEL is not set
40# CONFIG_BLK_DEV is not set 39# CONFIG_BLK_DEV is not set
41CONFIG_NETDEVICES=y 40CONFIG_NETDEVICES=y
42CONFIG_ARC_EMAC=y 41CONFIG_ARC_EMAC=y
diff --git a/arch/arc/configs/nsim_hs_defconfig b/arch/arc/configs/nsim_hs_defconfig
index 31ee51b987e7..a578c721d50f 100644
--- a/arch/arc/configs/nsim_hs_defconfig
+++ b/arch/arc/configs/nsim_hs_defconfig
@@ -40,7 +40,6 @@ CONFIG_INET=y
40CONFIG_DEVTMPFS=y 40CONFIG_DEVTMPFS=y
41# CONFIG_STANDALONE is not set 41# CONFIG_STANDALONE is not set
42# CONFIG_PREVENT_FIRMWARE_BUILD is not set 42# CONFIG_PREVENT_FIRMWARE_BUILD is not set
43# CONFIG_FIRMWARE_IN_KERNEL is not set
44# CONFIG_BLK_DEV is not set 43# CONFIG_BLK_DEV is not set
45# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
46# CONFIG_INPUT_KEYBOARD is not set 45# CONFIG_INPUT_KEYBOARD is not set
diff --git a/arch/arc/configs/nsim_hs_smp_defconfig b/arch/arc/configs/nsim_hs_smp_defconfig
index 8d3b1f67cae4..37d7395f3272 100644
--- a/arch/arc/configs/nsim_hs_smp_defconfig
+++ b/arch/arc/configs/nsim_hs_smp_defconfig
@@ -39,7 +39,6 @@ CONFIG_INET=y
39CONFIG_DEVTMPFS=y 39CONFIG_DEVTMPFS=y
40# CONFIG_STANDALONE is not set 40# CONFIG_STANDALONE is not set
41# CONFIG_PREVENT_FIRMWARE_BUILD is not set 41# CONFIG_PREVENT_FIRMWARE_BUILD is not set
42# CONFIG_FIRMWARE_IN_KERNEL is not set
43# CONFIG_BLK_DEV is not set 42# CONFIG_BLK_DEV is not set
44# CONFIG_INPUT_MOUSEDEV_PSAUX is not set 43# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
45# CONFIG_INPUT_KEYBOARD is not set 44# CONFIG_INPUT_KEYBOARD is not set
diff --git a/arch/arc/configs/nsimosci_defconfig b/arch/arc/configs/nsimosci_defconfig
index 6168ce2ac2ef..1e1470e2a7f0 100644
--- a/arch/arc/configs/nsimosci_defconfig
+++ b/arch/arc/configs/nsimosci_defconfig
@@ -35,7 +35,6 @@ CONFIG_INET=y
35CONFIG_DEVTMPFS=y 35CONFIG_DEVTMPFS=y
36# CONFIG_STANDALONE is not set 36# CONFIG_STANDALONE is not set
37# CONFIG_PREVENT_FIRMWARE_BUILD is not set 37# CONFIG_PREVENT_FIRMWARE_BUILD is not set
38# CONFIG_FIRMWARE_IN_KERNEL is not set
39# CONFIG_BLK_DEV is not set 38# CONFIG_BLK_DEV is not set
40CONFIG_NETDEVICES=y 39CONFIG_NETDEVICES=y
41CONFIG_EZCHIP_NPS_MANAGEMENT_ENET=y 40CONFIG_EZCHIP_NPS_MANAGEMENT_ENET=y
diff --git a/arch/arc/configs/nsimosci_hs_defconfig b/arch/arc/configs/nsimosci_hs_defconfig
index a70bdeb2b3fd..084a6e42685b 100644
--- a/arch/arc/configs/nsimosci_hs_defconfig
+++ b/arch/arc/configs/nsimosci_hs_defconfig
@@ -36,7 +36,6 @@ CONFIG_INET=y
36CONFIG_DEVTMPFS=y 36CONFIG_DEVTMPFS=y
37# CONFIG_STANDALONE is not set 37# CONFIG_STANDALONE is not set
38# CONFIG_PREVENT_FIRMWARE_BUILD is not set 38# CONFIG_PREVENT_FIRMWARE_BUILD is not set
39# CONFIG_FIRMWARE_IN_KERNEL is not set
40# CONFIG_BLK_DEV is not set 39# CONFIG_BLK_DEV is not set
41CONFIG_NETDEVICES=y 40CONFIG_NETDEVICES=y
42CONFIG_EZCHIP_NPS_MANAGEMENT_ENET=y 41CONFIG_EZCHIP_NPS_MANAGEMENT_ENET=y
diff --git a/arch/arc/configs/nsimosci_hs_smp_defconfig b/arch/arc/configs/nsimosci_hs_smp_defconfig
index ef96406c446e..f36d47990415 100644
--- a/arch/arc/configs/nsimosci_hs_smp_defconfig
+++ b/arch/arc/configs/nsimosci_hs_smp_defconfig
@@ -39,7 +39,6 @@ CONFIG_INET=y
39CONFIG_DEVTMPFS=y 39CONFIG_DEVTMPFS=y
40# CONFIG_STANDALONE is not set 40# CONFIG_STANDALONE is not set
41# CONFIG_PREVENT_FIRMWARE_BUILD is not set 41# CONFIG_PREVENT_FIRMWARE_BUILD is not set
42# CONFIG_FIRMWARE_IN_KERNEL is not set
43# CONFIG_BLK_DEV is not set 42# CONFIG_BLK_DEV is not set
44CONFIG_NETDEVICES=y 43CONFIG_NETDEVICES=y
45# CONFIG_NET_VENDOR_ARC is not set 44# CONFIG_NET_VENDOR_ARC is not set
diff --git a/arch/arc/configs/tb10x_defconfig b/arch/arc/configs/tb10x_defconfig
index f30182549395..1aca2e8fd1ba 100644
--- a/arch/arc/configs/tb10x_defconfig
+++ b/arch/arc/configs/tb10x_defconfig
@@ -42,7 +42,6 @@ CONFIG_IP_MULTICAST=y
42# CONFIG_IPV6 is not set 42# CONFIG_IPV6 is not set
43# CONFIG_WIRELESS is not set 43# CONFIG_WIRELESS is not set
44CONFIG_DEVTMPFS=y 44CONFIG_DEVTMPFS=y
45# CONFIG_FIRMWARE_IN_KERNEL is not set
46CONFIG_NETDEVICES=y 45CONFIG_NETDEVICES=y
47# CONFIG_NET_CADENCE is not set 46# CONFIG_NET_CADENCE is not set
48# CONFIG_NET_VENDOR_BROADCOM is not set 47# CONFIG_NET_VENDOR_BROADCOM is not set
diff --git a/arch/arc/configs/vdk_hs38_defconfig b/arch/arc/configs/vdk_hs38_defconfig
index 4fcf4f2503f6..f629493929ea 100644
--- a/arch/arc/configs/vdk_hs38_defconfig
+++ b/arch/arc/configs/vdk_hs38_defconfig
@@ -31,7 +31,6 @@ CONFIG_DEVTMPFS=y
31CONFIG_DEVTMPFS_MOUNT=y 31CONFIG_DEVTMPFS_MOUNT=y
32# CONFIG_STANDALONE is not set 32# CONFIG_STANDALONE is not set
33# CONFIG_PREVENT_FIRMWARE_BUILD is not set 33# CONFIG_PREVENT_FIRMWARE_BUILD is not set
34# CONFIG_FIRMWARE_IN_KERNEL is not set
35CONFIG_MTD=y 34CONFIG_MTD=y
36CONFIG_MTD_CMDLINE_PARTS=y 35CONFIG_MTD_CMDLINE_PARTS=y
37CONFIG_MTD_BLOCK=y 36CONFIG_MTD_BLOCK=y
diff --git a/arch/arc/configs/vdk_hs38_smp_defconfig b/arch/arc/configs/vdk_hs38_smp_defconfig
index 7b71464f6c2f..21f0ca26a05d 100644
--- a/arch/arc/configs/vdk_hs38_smp_defconfig
+++ b/arch/arc/configs/vdk_hs38_smp_defconfig
@@ -34,7 +34,6 @@ CONFIG_DEVTMPFS=y
34CONFIG_DEVTMPFS_MOUNT=y 34CONFIG_DEVTMPFS_MOUNT=y
35# CONFIG_STANDALONE is not set 35# CONFIG_STANDALONE is not set
36# CONFIG_PREVENT_FIRMWARE_BUILD is not set 36# CONFIG_PREVENT_FIRMWARE_BUILD is not set
37# CONFIG_FIRMWARE_IN_KERNEL is not set
38CONFIG_MTD=y 37CONFIG_MTD=y
39CONFIG_MTD_CMDLINE_PARTS=y 38CONFIG_MTD_CMDLINE_PARTS=y
40CONFIG_MTD_BLOCK=y 39CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/cns3420vb_defconfig b/arch/arm/configs/cns3420vb_defconfig
index 63a953d855a6..c6dcd6e4f4e6 100644
--- a/arch/arm/configs/cns3420vb_defconfig
+++ b/arch/arm/configs/cns3420vb_defconfig
@@ -28,7 +28,6 @@ CONFIG_ZBOOT_ROM_TEXT=0x0
28CONFIG_ZBOOT_ROM_BSS=0x0 28CONFIG_ZBOOT_ROM_BSS=0x0
29CONFIG_CMDLINE="console=ttyS0,38400 mem=128M root=/dev/mmcblk0p1 ro rootwait" 29CONFIG_CMDLINE="console=ttyS0,38400 mem=128M root=/dev/mmcblk0p1 ro rootwait"
30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 30CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
31# CONFIG_FIRMWARE_IN_KERNEL is not set
32CONFIG_MTD=y 31CONFIG_MTD=y
33CONFIG_MTD_CMDLINE_PARTS=y 32CONFIG_MTD_CMDLINE_PARTS=y
34CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/magician_defconfig b/arch/arm/configs/magician_defconfig
index ec5674c229a3..de5be2fc7306 100644
--- a/arch/arm/configs/magician_defconfig
+++ b/arch/arm/configs/magician_defconfig
@@ -54,7 +54,6 @@ CONFIG_BT_BNEP_PROTO_FILTER=y
54CONFIG_BT_HIDP=m 54CONFIG_BT_HIDP=m
55CONFIG_BT_HCIBTUSB=m 55CONFIG_BT_HCIBTUSB=m
56CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 56CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
57# CONFIG_FIRMWARE_IN_KERNEL is not set
58CONFIG_MTD=y 57CONFIG_MTD=y
59CONFIG_MTD_CMDLINE_PARTS=y 58CONFIG_MTD_CMDLINE_PARTS=y
60CONFIG_MTD_BLOCK=y 59CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/mini2440_defconfig b/arch/arm/configs/mini2440_defconfig
index cf7dcb2c86e6..88ea02e7ba19 100644
--- a/arch/arm/configs/mini2440_defconfig
+++ b/arch/arm/configs/mini2440_defconfig
@@ -77,7 +77,6 @@ CONFIG_MAC80211=m
77CONFIG_MAC80211_MESH=y 77CONFIG_MAC80211_MESH=y
78CONFIG_MAC80211_LEDS=y 78CONFIG_MAC80211_LEDS=y
79CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 79CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
80# CONFIG_FIRMWARE_IN_KERNEL is not set
81CONFIG_CONNECTOR=m 80CONFIG_CONNECTOR=m
82CONFIG_MTD=y 81CONFIG_MTD=y
83CONFIG_MTD_CMDLINE_PARTS=y 82CONFIG_MTD_CMDLINE_PARTS=y
diff --git a/arch/arm/configs/mv78xx0_defconfig b/arch/arm/configs/mv78xx0_defconfig
index 752e2e74de5b..0448bd8075ac 100644
--- a/arch/arm/configs/mv78xx0_defconfig
+++ b/arch/arm/configs/mv78xx0_defconfig
@@ -37,7 +37,6 @@ CONFIG_IP_PNP_BOOTP=y
37# CONFIG_IPV6 is not set 37# CONFIG_IPV6 is not set
38CONFIG_NET_PKTGEN=m 38CONFIG_NET_PKTGEN=m
39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 39CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
40# CONFIG_FIRMWARE_IN_KERNEL is not set
41CONFIG_MTD=y 40CONFIG_MTD=y
42CONFIG_MTD_CMDLINE_PARTS=y 41CONFIG_MTD_CMDLINE_PARTS=y
43CONFIG_MTD_BLOCK=y 42CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/mxs_defconfig b/arch/arm/configs/mxs_defconfig
index e5822ab01b7d..bbfb6759447b 100644
--- a/arch/arm/configs/mxs_defconfig
+++ b/arch/arm/configs/mxs_defconfig
@@ -46,7 +46,6 @@ CONFIG_CAN_FLEXCAN=m
46# CONFIG_WIRELESS is not set 46# CONFIG_WIRELESS is not set
47CONFIG_DEVTMPFS=y 47CONFIG_DEVTMPFS=y
48CONFIG_DEVTMPFS_MOUNT=y 48CONFIG_DEVTMPFS_MOUNT=y
49# CONFIG_FIRMWARE_IN_KERNEL is not set
50CONFIG_MTD=y 49CONFIG_MTD=y
51CONFIG_MTD_CMDLINE_PARTS=y 50CONFIG_MTD_CMDLINE_PARTS=y
52CONFIG_MTD_BLOCK=y 51CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/orion5x_defconfig b/arch/arm/configs/orion5x_defconfig
index b831baddae02..bf9046331f6e 100644
--- a/arch/arm/configs/orion5x_defconfig
+++ b/arch/arm/configs/orion5x_defconfig
@@ -60,7 +60,6 @@ CONFIG_IP_PNP_BOOTP=y
60CONFIG_NET_DSA=y 60CONFIG_NET_DSA=y
61CONFIG_NET_PKTGEN=m 61CONFIG_NET_PKTGEN=m
62CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 62CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
63# CONFIG_FIRMWARE_IN_KERNEL is not set
64CONFIG_MTD=y 63CONFIG_MTD=y
65CONFIG_MTD_CMDLINE_PARTS=y 64CONFIG_MTD_CMDLINE_PARTS=y
66CONFIG_MTD_BLOCK=y 65CONFIG_MTD_BLOCK=y
diff --git a/arch/arm/configs/tegra_defconfig b/arch/arm/configs/tegra_defconfig
index c819be04187e..c7b99ebf5fcf 100644
--- a/arch/arm/configs/tegra_defconfig
+++ b/arch/arm/configs/tegra_defconfig
@@ -75,7 +75,6 @@ CONFIG_RFKILL_INPUT=y
75CONFIG_RFKILL_GPIO=y 75CONFIG_RFKILL_GPIO=y
76CONFIG_DEVTMPFS=y 76CONFIG_DEVTMPFS=y
77CONFIG_DEVTMPFS_MOUNT=y 77CONFIG_DEVTMPFS_MOUNT=y
78# CONFIG_FIRMWARE_IN_KERNEL is not set
79CONFIG_DMA_CMA=y 78CONFIG_DMA_CMA=y
80CONFIG_CMA_SIZE_MBYTES=64 79CONFIG_CMA_SIZE_MBYTES=64
81CONFIG_TEGRA_GMI=y 80CONFIG_TEGRA_GMI=y
diff --git a/arch/arm/configs/vf610m4_defconfig b/arch/arm/configs/vf610m4_defconfig
index b7ecb83a95b6..a89f035c3b01 100644
--- a/arch/arm/configs/vf610m4_defconfig
+++ b/arch/arm/configs/vf610m4_defconfig
@@ -23,7 +23,6 @@ CONFIG_BINFMT_SHARED_FLAT=y
23# CONFIG_UEVENT_HELPER is not set 23# CONFIG_UEVENT_HELPER is not set
24# CONFIG_STANDALONE is not set 24# CONFIG_STANDALONE is not set
25# CONFIG_PREVENT_FIRMWARE_BUILD is not set 25# CONFIG_PREVENT_FIRMWARE_BUILD is not set
26# CONFIG_FIRMWARE_IN_KERNEL is not set
27# CONFIG_ALLOW_DEV_COREDUMP is not set 26# CONFIG_ALLOW_DEV_COREDUMP is not set
28CONFIG_BLK_DEV_RAM=y 27CONFIG_BLK_DEV_RAM=y
29CONFIG_BLK_DEV_RAM_COUNT=4 28CONFIG_BLK_DEV_RAM_COUNT=4
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 398ba9ba2632..ef9fd9b759cb 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -802,8 +802,8 @@ static ssize_t battery_voltage_show(struct device *dev, struct device_attribute
802 return sprintf(buf, "%d\n", sharpsl_pm.battstat.mainbat_voltage); 802 return sprintf(buf, "%d\n", sharpsl_pm.battstat.mainbat_voltage);
803} 803}
804 804
805static DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL); 805static DEVICE_ATTR_RO(battery_percentage);
806static DEVICE_ATTR(battery_voltage, 0444, battery_voltage_show, NULL); 806static DEVICE_ATTR_RO(battery_voltage);
807 807
808extern void (*apm_get_power_status)(struct apm_power_info *); 808extern void (*apm_get_power_status)(struct apm_power_info *);
809 809
diff --git a/arch/m68k/configs/amiga_defconfig b/arch/m68k/configs/amiga_defconfig
index e0b285e1e75f..52fa7fbdefa2 100644
--- a/arch/m68k/configs/amiga_defconfig
+++ b/arch/m68k/configs/amiga_defconfig
@@ -313,7 +313,6 @@ CONFIG_NET_DEVLINK=m
313# CONFIG_UEVENT_HELPER is not set 313# CONFIG_UEVENT_HELPER is not set
314CONFIG_DEVTMPFS=y 314CONFIG_DEVTMPFS=y
315CONFIG_DEVTMPFS_MOUNT=y 315CONFIG_DEVTMPFS_MOUNT=y
316# CONFIG_FIRMWARE_IN_KERNEL is not set
317CONFIG_TEST_ASYNC_DRIVER_PROBE=m 316CONFIG_TEST_ASYNC_DRIVER_PROBE=m
318CONFIG_CONNECTOR=m 317CONFIG_CONNECTOR=m
319CONFIG_PARPORT=m 318CONFIG_PARPORT=m
diff --git a/arch/m68k/configs/apollo_defconfig b/arch/m68k/configs/apollo_defconfig
index 3281026a3e15..b00fe19e1c04 100644
--- a/arch/m68k/configs/apollo_defconfig
+++ b/arch/m68k/configs/apollo_defconfig
@@ -311,7 +311,6 @@ CONFIG_NET_DEVLINK=m
311# CONFIG_UEVENT_HELPER is not set 311# CONFIG_UEVENT_HELPER is not set
312CONFIG_DEVTMPFS=y 312CONFIG_DEVTMPFS=y
313CONFIG_DEVTMPFS_MOUNT=y 313CONFIG_DEVTMPFS_MOUNT=y
314# CONFIG_FIRMWARE_IN_KERNEL is not set
315CONFIG_TEST_ASYNC_DRIVER_PROBE=m 314CONFIG_TEST_ASYNC_DRIVER_PROBE=m
316CONFIG_CONNECTOR=m 315CONFIG_CONNECTOR=m
317CONFIG_BLK_DEV_LOOP=y 316CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/atari_defconfig b/arch/m68k/configs/atari_defconfig
index e943fad480cf..2871d75b912f 100644
--- a/arch/m68k/configs/atari_defconfig
+++ b/arch/m68k/configs/atari_defconfig
@@ -311,7 +311,6 @@ CONFIG_NET_DEVLINK=m
311# CONFIG_UEVENT_HELPER is not set 311# CONFIG_UEVENT_HELPER is not set
312CONFIG_DEVTMPFS=y 312CONFIG_DEVTMPFS=y
313CONFIG_DEVTMPFS_MOUNT=y 313CONFIG_DEVTMPFS_MOUNT=y
314# CONFIG_FIRMWARE_IN_KERNEL is not set
315CONFIG_TEST_ASYNC_DRIVER_PROBE=m 314CONFIG_TEST_ASYNC_DRIVER_PROBE=m
316CONFIG_CONNECTOR=m 315CONFIG_CONNECTOR=m
317CONFIG_PARPORT=m 316CONFIG_PARPORT=m
diff --git a/arch/m68k/configs/bvme6000_defconfig b/arch/m68k/configs/bvme6000_defconfig
index 700c2310c336..2c90328433bf 100644
--- a/arch/m68k/configs/bvme6000_defconfig
+++ b/arch/m68k/configs/bvme6000_defconfig
@@ -309,7 +309,6 @@ CONFIG_NET_DEVLINK=m
309# CONFIG_UEVENT_HELPER is not set 309# CONFIG_UEVENT_HELPER is not set
310CONFIG_DEVTMPFS=y 310CONFIG_DEVTMPFS=y
311CONFIG_DEVTMPFS_MOUNT=y 311CONFIG_DEVTMPFS_MOUNT=y
312# CONFIG_FIRMWARE_IN_KERNEL is not set
313CONFIG_TEST_ASYNC_DRIVER_PROBE=m 312CONFIG_TEST_ASYNC_DRIVER_PROBE=m
314CONFIG_CONNECTOR=m 313CONFIG_CONNECTOR=m
315CONFIG_BLK_DEV_LOOP=y 314CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/hp300_defconfig b/arch/m68k/configs/hp300_defconfig
index 271d57fa4301..177c91d63826 100644
--- a/arch/m68k/configs/hp300_defconfig
+++ b/arch/m68k/configs/hp300_defconfig
@@ -311,7 +311,6 @@ CONFIG_NET_DEVLINK=m
311# CONFIG_UEVENT_HELPER is not set 311# CONFIG_UEVENT_HELPER is not set
312CONFIG_DEVTMPFS=y 312CONFIG_DEVTMPFS=y
313CONFIG_DEVTMPFS_MOUNT=y 313CONFIG_DEVTMPFS_MOUNT=y
314# CONFIG_FIRMWARE_IN_KERNEL is not set
315CONFIG_TEST_ASYNC_DRIVER_PROBE=m 314CONFIG_TEST_ASYNC_DRIVER_PROBE=m
316CONFIG_CONNECTOR=m 315CONFIG_CONNECTOR=m
317CONFIG_BLK_DEV_LOOP=y 316CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/mac_defconfig b/arch/m68k/configs/mac_defconfig
index 88761b867975..efbcaffa30ed 100644
--- a/arch/m68k/configs/mac_defconfig
+++ b/arch/m68k/configs/mac_defconfig
@@ -313,7 +313,6 @@ CONFIG_NET_DEVLINK=m
313# CONFIG_UEVENT_HELPER is not set 313# CONFIG_UEVENT_HELPER is not set
314CONFIG_DEVTMPFS=y 314CONFIG_DEVTMPFS=y
315CONFIG_DEVTMPFS_MOUNT=y 315CONFIG_DEVTMPFS_MOUNT=y
316# CONFIG_FIRMWARE_IN_KERNEL is not set
317CONFIG_TEST_ASYNC_DRIVER_PROBE=m 316CONFIG_TEST_ASYNC_DRIVER_PROBE=m
318CONFIG_CONNECTOR=m 317CONFIG_CONNECTOR=m
319CONFIG_BLK_DEV_SWIM=m 318CONFIG_BLK_DEV_SWIM=m
diff --git a/arch/m68k/configs/multi_defconfig b/arch/m68k/configs/multi_defconfig
index 7cb35dadf03b..e78a205d266a 100644
--- a/arch/m68k/configs/multi_defconfig
+++ b/arch/m68k/configs/multi_defconfig
@@ -323,7 +323,6 @@ CONFIG_NET_DEVLINK=m
323# CONFIG_UEVENT_HELPER is not set 323# CONFIG_UEVENT_HELPER is not set
324CONFIG_DEVTMPFS=y 324CONFIG_DEVTMPFS=y
325CONFIG_DEVTMPFS_MOUNT=y 325CONFIG_DEVTMPFS_MOUNT=y
326# CONFIG_FIRMWARE_IN_KERNEL is not set
327CONFIG_TEST_ASYNC_DRIVER_PROBE=m 326CONFIG_TEST_ASYNC_DRIVER_PROBE=m
328CONFIG_CONNECTOR=m 327CONFIG_CONNECTOR=m
329CONFIG_PARPORT=m 328CONFIG_PARPORT=m
diff --git a/arch/m68k/configs/mvme147_defconfig b/arch/m68k/configs/mvme147_defconfig
index b139d7b68393..0d42ecacfd7a 100644
--- a/arch/m68k/configs/mvme147_defconfig
+++ b/arch/m68k/configs/mvme147_defconfig
@@ -308,7 +308,6 @@ CONFIG_NET_DEVLINK=m
308# CONFIG_UEVENT_HELPER is not set 308# CONFIG_UEVENT_HELPER is not set
309CONFIG_DEVTMPFS=y 309CONFIG_DEVTMPFS=y
310CONFIG_DEVTMPFS_MOUNT=y 310CONFIG_DEVTMPFS_MOUNT=y
311# CONFIG_FIRMWARE_IN_KERNEL is not set
312CONFIG_TEST_ASYNC_DRIVER_PROBE=m 311CONFIG_TEST_ASYNC_DRIVER_PROBE=m
313CONFIG_CONNECTOR=m 312CONFIG_CONNECTOR=m
314CONFIG_BLK_DEV_LOOP=y 313CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/mvme16x_defconfig b/arch/m68k/configs/mvme16x_defconfig
index 398346138769..8dc609c5b8aa 100644
--- a/arch/m68k/configs/mvme16x_defconfig
+++ b/arch/m68k/configs/mvme16x_defconfig
@@ -309,7 +309,6 @@ CONFIG_NET_DEVLINK=m
309# CONFIG_UEVENT_HELPER is not set 309# CONFIG_UEVENT_HELPER is not set
310CONFIG_DEVTMPFS=y 310CONFIG_DEVTMPFS=y
311CONFIG_DEVTMPFS_MOUNT=y 311CONFIG_DEVTMPFS_MOUNT=y
312# CONFIG_FIRMWARE_IN_KERNEL is not set
313CONFIG_TEST_ASYNC_DRIVER_PROBE=m 312CONFIG_TEST_ASYNC_DRIVER_PROBE=m
314CONFIG_CONNECTOR=m 313CONFIG_CONNECTOR=m
315CONFIG_BLK_DEV_LOOP=y 314CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/q40_defconfig b/arch/m68k/configs/q40_defconfig
index 14c608326f6d..11c96087fc5d 100644
--- a/arch/m68k/configs/q40_defconfig
+++ b/arch/m68k/configs/q40_defconfig
@@ -309,7 +309,6 @@ CONFIG_NET_DEVLINK=m
309# CONFIG_UEVENT_HELPER is not set 309# CONFIG_UEVENT_HELPER is not set
310CONFIG_DEVTMPFS=y 310CONFIG_DEVTMPFS=y
311CONFIG_DEVTMPFS_MOUNT=y 311CONFIG_DEVTMPFS_MOUNT=y
312# CONFIG_FIRMWARE_IN_KERNEL is not set
313CONFIG_TEST_ASYNC_DRIVER_PROBE=m 312CONFIG_TEST_ASYNC_DRIVER_PROBE=m
314CONFIG_CONNECTOR=m 313CONFIG_CONNECTOR=m
315CONFIG_PARPORT=m 314CONFIG_PARPORT=m
diff --git a/arch/m68k/configs/sun3_defconfig b/arch/m68k/configs/sun3_defconfig
index 97dec0bf52f1..ddba205ee1aa 100644
--- a/arch/m68k/configs/sun3_defconfig
+++ b/arch/m68k/configs/sun3_defconfig
@@ -306,7 +306,6 @@ CONFIG_NET_DEVLINK=m
306# CONFIG_UEVENT_HELPER is not set 306# CONFIG_UEVENT_HELPER is not set
307CONFIG_DEVTMPFS=y 307CONFIG_DEVTMPFS=y
308CONFIG_DEVTMPFS_MOUNT=y 308CONFIG_DEVTMPFS_MOUNT=y
309# CONFIG_FIRMWARE_IN_KERNEL is not set
310CONFIG_TEST_ASYNC_DRIVER_PROBE=m 309CONFIG_TEST_ASYNC_DRIVER_PROBE=m
311CONFIG_CONNECTOR=m 310CONFIG_CONNECTOR=m
312CONFIG_BLK_DEV_LOOP=y 311CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/m68k/configs/sun3x_defconfig b/arch/m68k/configs/sun3x_defconfig
index 56df28d6d91d..88d09a14c684 100644
--- a/arch/m68k/configs/sun3x_defconfig
+++ b/arch/m68k/configs/sun3x_defconfig
@@ -306,7 +306,6 @@ CONFIG_NET_DEVLINK=m
306# CONFIG_UEVENT_HELPER is not set 306# CONFIG_UEVENT_HELPER is not set
307CONFIG_DEVTMPFS=y 307CONFIG_DEVTMPFS=y
308CONFIG_DEVTMPFS_MOUNT=y 308CONFIG_DEVTMPFS_MOUNT=y
309# CONFIG_FIRMWARE_IN_KERNEL is not set
310CONFIG_TEST_ASYNC_DRIVER_PROBE=m 309CONFIG_TEST_ASYNC_DRIVER_PROBE=m
311CONFIG_CONNECTOR=m 310CONFIG_CONNECTOR=m
312CONFIG_BLK_DEV_LOOP=y 311CONFIG_BLK_DEV_LOOP=y
diff --git a/arch/mips/configs/ar7_defconfig b/arch/mips/configs/ar7_defconfig
index 92fca3c42eac..5651f4d8f45c 100644
--- a/arch/mips/configs/ar7_defconfig
+++ b/arch/mips/configs/ar7_defconfig
@@ -82,7 +82,6 @@ CONFIG_MAC80211=m
82CONFIG_MAC80211_RC_PID=y 82CONFIG_MAC80211_RC_PID=y
83CONFIG_MAC80211_RC_DEFAULT_PID=y 83CONFIG_MAC80211_RC_DEFAULT_PID=y
84CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 84CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
85# CONFIG_FIRMWARE_IN_KERNEL is not set
86CONFIG_MTD=y 85CONFIG_MTD=y
87CONFIG_MTD_BLOCK=y 86CONFIG_MTD_BLOCK=y
88CONFIG_MTD_CFI=y 87CONFIG_MTD_CFI=y
diff --git a/arch/mips/configs/ath25_defconfig b/arch/mips/configs/ath25_defconfig
index 2c829950be17..b8d48038e74f 100644
--- a/arch/mips/configs/ath25_defconfig
+++ b/arch/mips/configs/ath25_defconfig
@@ -38,7 +38,6 @@ CONFIG_CFG80211=m
38CONFIG_MAC80211=m 38CONFIG_MAC80211=m
39CONFIG_MAC80211_DEBUGFS=y 39CONFIG_MAC80211_DEBUGFS=y
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41# CONFIG_FIRMWARE_IN_KERNEL is not set
42CONFIG_MTD=y 41CONFIG_MTD=y
43CONFIG_MTD_REDBOOT_PARTS=y 42CONFIG_MTD_REDBOOT_PARTS=y
44CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2 43CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2
diff --git a/arch/mips/configs/ath79_defconfig b/arch/mips/configs/ath79_defconfig
index 25ed914933e5..951c4231bdb8 100644
--- a/arch/mips/configs/ath79_defconfig
+++ b/arch/mips/configs/ath79_defconfig
@@ -39,7 +39,6 @@ CONFIG_CFG80211=m
39CONFIG_MAC80211=m 39CONFIG_MAC80211=m
40CONFIG_MAC80211_DEBUGFS=y 40CONFIG_MAC80211_DEBUGFS=y
41CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 41CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
42# CONFIG_FIRMWARE_IN_KERNEL is not set
43CONFIG_MTD=y 42CONFIG_MTD=y
44CONFIG_MTD_REDBOOT_PARTS=y 43CONFIG_MTD_REDBOOT_PARTS=y
45CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2 44CONFIG_MTD_REDBOOT_DIRECTORY_BLOCK=-2
diff --git a/arch/mips/configs/pic32mzda_defconfig b/arch/mips/configs/pic32mzda_defconfig
index 52192c632ae8..41190c2036e6 100644
--- a/arch/mips/configs/pic32mzda_defconfig
+++ b/arch/mips/configs/pic32mzda_defconfig
@@ -26,7 +26,6 @@ CONFIG_BINFMT_MISC=m
26# CONFIG_SUSPEND is not set 26# CONFIG_SUSPEND is not set
27CONFIG_DEVTMPFS=y 27CONFIG_DEVTMPFS=y
28CONFIG_DEVTMPFS_MOUNT=y 28CONFIG_DEVTMPFS_MOUNT=y
29# CONFIG_FIRMWARE_IN_KERNEL is not set
30# CONFIG_ALLOW_DEV_COREDUMP is not set 29# CONFIG_ALLOW_DEV_COREDUMP is not set
31CONFIG_BLK_DEV_LOOP=m 30CONFIG_BLK_DEV_LOOP=m
32CONFIG_SCSI=y 31CONFIG_SCSI=y
diff --git a/arch/mips/configs/qi_lb60_defconfig b/arch/mips/configs/qi_lb60_defconfig
index 3f1333517405..3b02ff9a7c64 100644
--- a/arch/mips/configs/qi_lb60_defconfig
+++ b/arch/mips/configs/qi_lb60_defconfig
@@ -42,7 +42,6 @@ CONFIG_TCP_CONG_WESTWOOD=y
42# CONFIG_TCP_CONG_HTCP is not set 42# CONFIG_TCP_CONG_HTCP is not set
43# CONFIG_IPV6 is not set 43# CONFIG_IPV6 is not set
44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
45# CONFIG_FIRMWARE_IN_KERNEL is not set
46CONFIG_MTD=y 45CONFIG_MTD=y
47CONFIG_MTD_BLOCK=y 46CONFIG_MTD_BLOCK=y
48CONFIG_MTD_NAND=y 47CONFIG_MTD_NAND=y
diff --git a/arch/mips/configs/rm200_defconfig b/arch/mips/configs/rm200_defconfig
index 99679e514042..5f71aa598b06 100644
--- a/arch/mips/configs/rm200_defconfig
+++ b/arch/mips/configs/rm200_defconfig
@@ -325,15 +325,6 @@ CONFIG_USB_SERIAL_EDGEPORT=m
325CONFIG_USB_SERIAL_EDGEPORT_TI=m 325CONFIG_USB_SERIAL_EDGEPORT_TI=m
326CONFIG_USB_SERIAL_KEYSPAN_PDA=m 326CONFIG_USB_SERIAL_KEYSPAN_PDA=m
327CONFIG_USB_SERIAL_KEYSPAN=m 327CONFIG_USB_SERIAL_KEYSPAN=m
328CONFIG_USB_SERIAL_KEYSPAN_MPR=y
329CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
330CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
331CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
332CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
333CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
334CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
335CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
336CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
337CONFIG_USB_SERIAL_KLSI=m 328CONFIG_USB_SERIAL_KLSI=m
338CONFIG_USB_SERIAL_KOBIL_SCT=m 329CONFIG_USB_SERIAL_KOBIL_SCT=m
339CONFIG_USB_SERIAL_MCT_U232=m 330CONFIG_USB_SERIAL_MCT_U232=m
diff --git a/arch/mips/configs/rt305x_defconfig b/arch/mips/configs/rt305x_defconfig
index c695b7b1c4ae..dbe6a4639d05 100644
--- a/arch/mips/configs/rt305x_defconfig
+++ b/arch/mips/configs/rt305x_defconfig
@@ -76,7 +76,6 @@ CONFIG_VLAN_8021Q=y
76CONFIG_NET_SCHED=y 76CONFIG_NET_SCHED=y
77CONFIG_HAMRADIO=y 77CONFIG_HAMRADIO=y
78CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 78CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
79# CONFIG_FIRMWARE_IN_KERNEL is not set
80CONFIG_MTD=y 79CONFIG_MTD=y
81CONFIG_MTD_CMDLINE_PARTS=y 80CONFIG_MTD_CMDLINE_PARTS=y
82CONFIG_MTD_BLOCK=y 81CONFIG_MTD_BLOCK=y
diff --git a/arch/mips/configs/xway_defconfig b/arch/mips/configs/xway_defconfig
index 4365108bef77..fa750d501c11 100644
--- a/arch/mips/configs/xway_defconfig
+++ b/arch/mips/configs/xway_defconfig
@@ -75,7 +75,6 @@ CONFIG_VLAN_8021Q=y
75CONFIG_NET_SCHED=y 75CONFIG_NET_SCHED=y
76CONFIG_HAMRADIO=y 76CONFIG_HAMRADIO=y
77CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 77CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
78# CONFIG_FIRMWARE_IN_KERNEL is not set
79CONFIG_MTD=y 78CONFIG_MTD=y
80CONFIG_MTD_CMDLINE_PARTS=y 79CONFIG_MTD_CMDLINE_PARTS=y
81CONFIG_MTD_BLOCK=y 80CONFIG_MTD_BLOCK=y
diff --git a/arch/mn10300/configs/asb2364_defconfig b/arch/mn10300/configs/asb2364_defconfig
index b1d80cee97ee..a84c3153f22a 100644
--- a/arch/mn10300/configs/asb2364_defconfig
+++ b/arch/mn10300/configs/asb2364_defconfig
@@ -44,7 +44,6 @@ CONFIG_IPV6=y
44# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set 44# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
45# CONFIG_INET6_XFRM_MODE_TUNNEL is not set 45# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
46# CONFIG_INET6_XFRM_MODE_BEET is not set 46# CONFIG_INET6_XFRM_MODE_BEET is not set
47# CONFIG_FIRMWARE_IN_KERNEL is not set
48CONFIG_CONNECTOR=y 47CONFIG_CONNECTOR=y
49CONFIG_MTD=y 48CONFIG_MTD=y
50CONFIG_MTD_DEBUG=y 49CONFIG_MTD_DEBUG=y
diff --git a/arch/powerpc/configs/44x/warp_defconfig b/arch/powerpc/configs/44x/warp_defconfig
index b5c866073efd..6c02f53271cd 100644
--- a/arch/powerpc/configs/44x/warp_defconfig
+++ b/arch/powerpc/configs/44x/warp_defconfig
@@ -28,7 +28,6 @@ CONFIG_NETFILTER=y
28CONFIG_VLAN_8021Q=y 28CONFIG_VLAN_8021Q=y
29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 29CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
30# CONFIG_STANDALONE is not set 30# CONFIG_STANDALONE is not set
31# CONFIG_FIRMWARE_IN_KERNEL is not set
32CONFIG_MTD=y 31CONFIG_MTD=y
33CONFIG_MTD_CMDLINE_PARTS=y 32CONFIG_MTD_CMDLINE_PARTS=y
34CONFIG_MTD_BLOCK=y 33CONFIG_MTD_BLOCK=y
diff --git a/arch/powerpc/configs/c2k_defconfig b/arch/powerpc/configs/c2k_defconfig
index f1552af9eecc..4bb832a41d55 100644
--- a/arch/powerpc/configs/c2k_defconfig
+++ b/arch/powerpc/configs/c2k_defconfig
@@ -272,18 +272,6 @@ CONFIG_USB_SERIAL_EDGEPORT=m
272CONFIG_USB_SERIAL_EDGEPORT_TI=m 272CONFIG_USB_SERIAL_EDGEPORT_TI=m
273CONFIG_USB_SERIAL_KEYSPAN_PDA=m 273CONFIG_USB_SERIAL_KEYSPAN_PDA=m
274CONFIG_USB_SERIAL_KEYSPAN=m 274CONFIG_USB_SERIAL_KEYSPAN=m
275CONFIG_USB_SERIAL_KEYSPAN_MPR=y
276CONFIG_USB_SERIAL_KEYSPAN_USA28=y
277CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
278CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
279CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
280CONFIG_USB_SERIAL_KEYSPAN_USA19=y
281CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
282CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
283CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
284CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
285CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
286CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
287CONFIG_USB_SERIAL_KLSI=m 275CONFIG_USB_SERIAL_KLSI=m
288CONFIG_USB_SERIAL_KOBIL_SCT=m 276CONFIG_USB_SERIAL_KOBIL_SCT=m
289CONFIG_USB_SERIAL_MCT_U232=m 277CONFIG_USB_SERIAL_MCT_U232=m
diff --git a/arch/powerpc/configs/g5_defconfig b/arch/powerpc/configs/g5_defconfig
index 063817fee61c..67c39f4acede 100644
--- a/arch/powerpc/configs/g5_defconfig
+++ b/arch/powerpc/configs/g5_defconfig
@@ -189,18 +189,6 @@ CONFIG_USB_SERIAL_GARMIN=m
189CONFIG_USB_SERIAL_IPW=m 189CONFIG_USB_SERIAL_IPW=m
190CONFIG_USB_SERIAL_KEYSPAN_PDA=m 190CONFIG_USB_SERIAL_KEYSPAN_PDA=m
191CONFIG_USB_SERIAL_KEYSPAN=m 191CONFIG_USB_SERIAL_KEYSPAN=m
192CONFIG_USB_SERIAL_KEYSPAN_MPR=y
193CONFIG_USB_SERIAL_KEYSPAN_USA28=y
194CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
195CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
196CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
197CONFIG_USB_SERIAL_KEYSPAN_USA19=y
198CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
199CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
200CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
201CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
202CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
203CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
204CONFIG_USB_SERIAL_KLSI=m 192CONFIG_USB_SERIAL_KLSI=m
205CONFIG_USB_SERIAL_KOBIL_SCT=m 193CONFIG_USB_SERIAL_KOBIL_SCT=m
206CONFIG_USB_SERIAL_MCT_U232=m 194CONFIG_USB_SERIAL_MCT_U232=m
diff --git a/arch/powerpc/configs/maple_defconfig b/arch/powerpc/configs/maple_defconfig
index 078cdb427fc9..59e47ec85336 100644
--- a/arch/powerpc/configs/maple_defconfig
+++ b/arch/powerpc/configs/maple_defconfig
@@ -82,18 +82,6 @@ CONFIG_USB_SERIAL_CYPRESS_M8=m
82CONFIG_USB_SERIAL_GARMIN=m 82CONFIG_USB_SERIAL_GARMIN=m
83CONFIG_USB_SERIAL_IPW=m 83CONFIG_USB_SERIAL_IPW=m
84CONFIG_USB_SERIAL_KEYSPAN=y 84CONFIG_USB_SERIAL_KEYSPAN=y
85CONFIG_USB_SERIAL_KEYSPAN_MPR=y
86CONFIG_USB_SERIAL_KEYSPAN_USA28=y
87CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
88CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
89CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
90CONFIG_USB_SERIAL_KEYSPAN_USA19=y
91CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
92CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
93CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
94CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
95CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
96CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
97CONFIG_USB_SERIAL_TI=m 85CONFIG_USB_SERIAL_TI=m
98CONFIG_EXT2_FS=y 86CONFIG_EXT2_FS=y
99CONFIG_EXT4_FS=y 87CONFIG_EXT4_FS=y
diff --git a/arch/powerpc/configs/mpc512x_defconfig b/arch/powerpc/configs/mpc512x_defconfig
index 10be5773ad5d..c2b1c4404683 100644
--- a/arch/powerpc/configs/mpc512x_defconfig
+++ b/arch/powerpc/configs/mpc512x_defconfig
@@ -39,7 +39,6 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
39CONFIG_DEVTMPFS=y 39CONFIG_DEVTMPFS=y
40CONFIG_DEVTMPFS_MOUNT=y 40CONFIG_DEVTMPFS_MOUNT=y
41# CONFIG_PREVENT_FIRMWARE_BUILD is not set 41# CONFIG_PREVENT_FIRMWARE_BUILD is not set
42# CONFIG_FIRMWARE_IN_KERNEL is not set
43CONFIG_MTD=y 42CONFIG_MTD=y
44CONFIG_MTD_CMDLINE_PARTS=y 43CONFIG_MTD_CMDLINE_PARTS=y
45CONFIG_MTD_BLOCK=y 44CONFIG_MTD_BLOCK=y
diff --git a/arch/powerpc/configs/pmac32_defconfig b/arch/powerpc/configs/pmac32_defconfig
index 1aab9a62a681..62948d198d7f 100644
--- a/arch/powerpc/configs/pmac32_defconfig
+++ b/arch/powerpc/configs/pmac32_defconfig
@@ -264,18 +264,6 @@ CONFIG_USB_SERIAL_VISOR=m
264CONFIG_USB_SERIAL_IPAQ=m 264CONFIG_USB_SERIAL_IPAQ=m
265CONFIG_USB_SERIAL_KEYSPAN_PDA=m 265CONFIG_USB_SERIAL_KEYSPAN_PDA=m
266CONFIG_USB_SERIAL_KEYSPAN=m 266CONFIG_USB_SERIAL_KEYSPAN=m
267CONFIG_USB_SERIAL_KEYSPAN_MPR=y
268CONFIG_USB_SERIAL_KEYSPAN_USA28=y
269CONFIG_USB_SERIAL_KEYSPAN_USA28X=y
270CONFIG_USB_SERIAL_KEYSPAN_USA28XA=y
271CONFIG_USB_SERIAL_KEYSPAN_USA28XB=y
272CONFIG_USB_SERIAL_KEYSPAN_USA19=y
273CONFIG_USB_SERIAL_KEYSPAN_USA18X=y
274CONFIG_USB_SERIAL_KEYSPAN_USA19W=y
275CONFIG_USB_SERIAL_KEYSPAN_USA19QW=y
276CONFIG_USB_SERIAL_KEYSPAN_USA19QI=y
277CONFIG_USB_SERIAL_KEYSPAN_USA49W=y
278CONFIG_USB_SERIAL_KEYSPAN_USA49WLC=y
279CONFIG_USB_APPLEDISPLAY=m 267CONFIG_USB_APPLEDISPLAY=m
280CONFIG_LEDS_TRIGGER_DEFAULT_ON=y 268CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
281CONFIG_EXT2_FS=y 269CONFIG_EXT2_FS=y
diff --git a/arch/powerpc/configs/ppc6xx_defconfig b/arch/powerpc/configs/ppc6xx_defconfig
index da0e8d535eb8..7ee736f20774 100644
--- a/arch/powerpc/configs/ppc6xx_defconfig
+++ b/arch/powerpc/configs/ppc6xx_defconfig
@@ -347,7 +347,6 @@ CONFIG_MAC80211_DEBUGFS=y
347CONFIG_NET_9P=m 347CONFIG_NET_9P=m
348CONFIG_NET_9P_VIRTIO=m 348CONFIG_NET_9P_VIRTIO=m
349CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 349CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
350# CONFIG_FIRMWARE_IN_KERNEL is not set
351CONFIG_DEBUG_DEVRES=y 350CONFIG_DEBUG_DEVRES=y
352CONFIG_CONNECTOR=y 351CONFIG_CONNECTOR=y
353CONFIG_PARPORT=m 352CONFIG_PARPORT=m
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index 2efa025bf483..187e2f7c12c8 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -64,7 +64,6 @@ CONFIG_CFG80211_WEXT=y
64CONFIG_MAC80211=m 64CONFIG_MAC80211=m
65# CONFIG_MAC80211_RC_MINSTREL is not set 65# CONFIG_MAC80211_RC_MINSTREL is not set
66CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 66CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
67# CONFIG_FIRMWARE_IN_KERNEL is not set
68CONFIG_BLK_DEV_LOOP=y 67CONFIG_BLK_DEV_LOOP=y
69CONFIG_BLK_DEV_RAM=y 68CONFIG_BLK_DEV_RAM=y
70CONFIG_BLK_DEV_RAM_SIZE=65535 69CONFIG_BLK_DEV_RAM_SIZE=65535
diff --git a/arch/powerpc/configs/wii_defconfig b/arch/powerpc/configs/wii_defconfig
index 9c7400a19e9d..0b0f78823a1b 100644
--- a/arch/powerpc/configs/wii_defconfig
+++ b/arch/powerpc/configs/wii_defconfig
@@ -43,7 +43,6 @@ CONFIG_CFG80211=y
43CONFIG_MAC80211=y 43CONFIG_MAC80211=y
44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 44CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
45# CONFIG_STANDALONE is not set 45# CONFIG_STANDALONE is not set
46# CONFIG_FIRMWARE_IN_KERNEL is not set
47CONFIG_BLK_DEV_LOOP=y 46CONFIG_BLK_DEV_LOOP=y
48CONFIG_BLK_DEV_RAM=y 47CONFIG_BLK_DEV_RAM=y
49CONFIG_BLK_DEV_RAM_COUNT=2 48CONFIG_BLK_DEV_RAM_COUNT=2
diff --git a/arch/s390/configs/zfcpdump_defconfig b/arch/s390/configs/zfcpdump_defconfig
index 04e042edbab7..7dc7f58c4287 100644
--- a/arch/s390/configs/zfcpdump_defconfig
+++ b/arch/s390/configs/zfcpdump_defconfig
@@ -26,7 +26,6 @@ CONFIG_NET=y
26# CONFIG_IUCV is not set 26# CONFIG_IUCV is not set
27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 27CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
28CONFIG_DEVTMPFS=y 28CONFIG_DEVTMPFS=y
29# CONFIG_FIRMWARE_IN_KERNEL is not set
30CONFIG_BLK_DEV_RAM=y 29CONFIG_BLK_DEV_RAM=y
31# CONFIG_BLK_DEV_XPRAM is not set 30# CONFIG_BLK_DEV_XPRAM is not set
32# CONFIG_DCSSBLK is not set 31# CONFIG_DCSSBLK is not set
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index b8c1a85bcf2d..a919b2f0141d 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1151,7 +1151,7 @@ static ssize_t __ref rescan_store(struct device *dev,
1151 rc = smp_rescan_cpus(); 1151 rc = smp_rescan_cpus();
1152 return rc ? rc : count; 1152 return rc ? rc : count;
1153} 1153}
1154static DEVICE_ATTR(rescan, 0200, NULL, rescan_store); 1154static DEVICE_ATTR_WO(rescan);
1155#endif /* CONFIG_HOTPLUG_CPU */ 1155#endif /* CONFIG_HOTPLUG_CPU */
1156 1156
1157static int __init s390_smp_init(void) 1157static int __init s390_smp_init(void)
diff --git a/arch/s390/kernel/topology.c b/arch/s390/kernel/topology.c
index 4d5b65e527b5..4b6e0397f66d 100644
--- a/arch/s390/kernel/topology.c
+++ b/arch/s390/kernel/topology.c
@@ -404,8 +404,7 @@ out:
404 put_online_cpus(); 404 put_online_cpus();
405 return rc ? rc : count; 405 return rc ? rc : count;
406} 406}
407static DEVICE_ATTR(dispatching, 0644, dispatching_show, 407static DEVICE_ATTR_RW(dispatching);
408 dispatching_store);
409 408
410static ssize_t cpu_polarization_show(struct device *dev, 409static ssize_t cpu_polarization_show(struct device *dev,
411 struct device_attribute *attr, char *buf) 410 struct device_attribute *attr, char *buf)
diff --git a/arch/sh/configs/polaris_defconfig b/arch/sh/configs/polaris_defconfig
index 0a432b5f50e7..87641b7d6c4e 100644
--- a/arch/sh/configs/polaris_defconfig
+++ b/arch/sh/configs/polaris_defconfig
@@ -38,7 +38,6 @@ CONFIG_IP_MULTICAST=y
38# CONFIG_INET_XFRM_MODE_BEET is not set 38# CONFIG_INET_XFRM_MODE_BEET is not set
39# CONFIG_IPV6 is not set 39# CONFIG_IPV6 is not set
40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 40CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
41# CONFIG_FIRMWARE_IN_KERNEL is not set
42CONFIG_MTD=y 41CONFIG_MTD=y
43CONFIG_MTD_CMDLINE_PARTS=y 42CONFIG_MTD_CMDLINE_PARTS=y
44CONFIG_MTD_BLOCK=y 43CONFIG_MTD_BLOCK=y
diff --git a/arch/sh/drivers/push-switch.c b/arch/sh/drivers/push-switch.c
index a17181160233..762bc5619910 100644
--- a/arch/sh/drivers/push-switch.c
+++ b/arch/sh/drivers/push-switch.c
@@ -24,7 +24,7 @@ static ssize_t switch_show(struct device *dev,
24 struct push_switch_platform_info *psw_info = dev->platform_data; 24 struct push_switch_platform_info *psw_info = dev->platform_data;
25 return sprintf(buf, "%s\n", psw_info->name); 25 return sprintf(buf, "%s\n", psw_info->name);
26} 26}
27static DEVICE_ATTR(switch, S_IRUGO, switch_show, NULL); 27static DEVICE_ATTR_RO(switch);
28 28
29static void switch_timer(struct timer_list *t) 29static void switch_timer(struct timer_list *t)
30{ 30{
diff --git a/arch/tile/configs/tilegx_defconfig b/arch/tile/configs/tilegx_defconfig
index 9f94435cc44f..357a4c271ad4 100644
--- a/arch/tile/configs/tilegx_defconfig
+++ b/arch/tile/configs/tilegx_defconfig
@@ -159,7 +159,6 @@ CONFIG_DNS_RESOLVER=y
159CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 159CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
160CONFIG_DEVTMPFS=y 160CONFIG_DEVTMPFS=y
161CONFIG_DEVTMPFS_MOUNT=y 161CONFIG_DEVTMPFS_MOUNT=y
162# CONFIG_FIRMWARE_IN_KERNEL is not set
163CONFIG_CONNECTOR=y 162CONFIG_CONNECTOR=y
164CONFIG_BLK_DEV_LOOP=y 163CONFIG_BLK_DEV_LOOP=y
165CONFIG_BLK_DEV_CRYPTOLOOP=m 164CONFIG_BLK_DEV_CRYPTOLOOP=m
diff --git a/arch/tile/configs/tilepro_defconfig b/arch/tile/configs/tilepro_defconfig
index 1c5bd4f8ffca..da2858755fa1 100644
--- a/arch/tile/configs/tilepro_defconfig
+++ b/arch/tile/configs/tilepro_defconfig
@@ -289,7 +289,6 @@ CONFIG_DNS_RESOLVER=y
289CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug" 289CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
290CONFIG_DEVTMPFS=y 290CONFIG_DEVTMPFS=y
291CONFIG_DEVTMPFS_MOUNT=y 291CONFIG_DEVTMPFS_MOUNT=y
292# CONFIG_FIRMWARE_IN_KERNEL is not set
293CONFIG_CONNECTOR=y 292CONFIG_CONNECTOR=y
294CONFIG_BLK_DEV_LOOP=y 293CONFIG_BLK_DEV_LOOP=y
295CONFIG_BLK_DEV_CRYPTOLOOP=m 294CONFIG_BLK_DEV_CRYPTOLOOP=m
diff --git a/arch/tile/kernel/sysfs.c b/arch/tile/kernel/sysfs.c
index 825867c53853..b09456a3d77a 100644
--- a/arch/tile/kernel/sysfs.c
+++ b/arch/tile/kernel/sysfs.c
@@ -38,7 +38,7 @@ static ssize_t chip_width_show(struct device *dev,
38{ 38{
39 return sprintf(page, "%u\n", smp_width); 39 return sprintf(page, "%u\n", smp_width);
40} 40}
41static DEVICE_ATTR(chip_width, 0444, chip_width_show, NULL); 41static DEVICE_ATTR_RO(chip_width);
42 42
43static ssize_t chip_height_show(struct device *dev, 43static ssize_t chip_height_show(struct device *dev,
44 struct device_attribute *attr, 44 struct device_attribute *attr,
@@ -46,7 +46,7 @@ static ssize_t chip_height_show(struct device *dev,
46{ 46{
47 return sprintf(page, "%u\n", smp_height); 47 return sprintf(page, "%u\n", smp_height);
48} 48}
49static DEVICE_ATTR(chip_height, 0444, chip_height_show, NULL); 49static DEVICE_ATTR_RO(chip_height);
50 50
51static ssize_t chip_serial_show(struct device *dev, 51static ssize_t chip_serial_show(struct device *dev,
52 struct device_attribute *attr, 52 struct device_attribute *attr,
@@ -54,7 +54,7 @@ static ssize_t chip_serial_show(struct device *dev,
54{ 54{
55 return get_hv_confstr(page, HV_CONFSTR_CHIP_SERIAL_NUM); 55 return get_hv_confstr(page, HV_CONFSTR_CHIP_SERIAL_NUM);
56} 56}
57static DEVICE_ATTR(chip_serial, 0444, chip_serial_show, NULL); 57static DEVICE_ATTR_RO(chip_serial);
58 58
59static ssize_t chip_revision_show(struct device *dev, 59static ssize_t chip_revision_show(struct device *dev,
60 struct device_attribute *attr, 60 struct device_attribute *attr,
@@ -62,7 +62,7 @@ static ssize_t chip_revision_show(struct device *dev,
62{ 62{
63 return get_hv_confstr(page, HV_CONFSTR_CHIP_REV); 63 return get_hv_confstr(page, HV_CONFSTR_CHIP_REV);
64} 64}
65static DEVICE_ATTR(chip_revision, 0444, chip_revision_show, NULL); 65static DEVICE_ATTR_RO(chip_revision);
66 66
67 67
68static ssize_t type_show(struct device *dev, 68static ssize_t type_show(struct device *dev,
@@ -71,7 +71,7 @@ static ssize_t type_show(struct device *dev,
71{ 71{
72 return sprintf(page, "tilera\n"); 72 return sprintf(page, "tilera\n");
73} 73}
74static DEVICE_ATTR(type, 0444, type_show, NULL); 74static DEVICE_ATTR_RO(type);
75 75
76#define HV_CONF_ATTR(name, conf) \ 76#define HV_CONF_ATTR(name, conf) \
77 static ssize_t name ## _show(struct device *dev, \ 77 static ssize_t name ## _show(struct device *dev, \
@@ -184,7 +184,7 @@ static ssize_t hv_stats_store(struct device *dev,
184 return n < 0 ? n : count; 184 return n < 0 ? n : count;
185} 185}
186 186
187static DEVICE_ATTR(hv_stats, 0644, hv_stats_show, hv_stats_store); 187static DEVICE_ATTR_RW(hv_stats);
188 188
189static int hv_stats_device_add(struct device *dev, struct subsys_interface *sif) 189static int hv_stats_device_add(struct device *dev, struct subsys_interface *sif)
190{ 190{
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index d416fd9fdb3b..72d5149bcaa1 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -1265,9 +1265,9 @@ config MICROCODE
1265 CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the 1265 CONFIG_BLK_DEV_INITRD in order for the loader to be able to scan the
1266 initrd for microcode blobs. 1266 initrd for microcode blobs.
1267 1267
1268 In addition, you can build-in the microcode into the kernel. For that you 1268 In addition, you can build the microcode into the kernel. For that you
1269 need to enable FIRMWARE_IN_KERNEL and add the vendor-supplied microcode 1269 need to add the vendor-supplied microcode to the CONFIG_EXTRA_FIRMWARE
1270 to the CONFIG_EXTRA_FIRMWARE config option. 1270 config option.
1271 1271
1272config MICROCODE_INTEL 1272config MICROCODE_INTEL
1273 bool "Intel microcode loading support" 1273 bool "Intel microcode loading support"
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index e4fc595cd6ea..319dd65f98a2 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
560 return sprintf(buf, "0x%x\n", uci->cpu_sig.pf); 560 return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
561} 561}
562 562
563static DEVICE_ATTR(reload, 0200, NULL, reload_store); 563static DEVICE_ATTR_WO(reload);
564static DEVICE_ATTR(version, 0400, version_show, NULL); 564static DEVICE_ATTR(version, 0400, version_show, NULL);
565static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL); 565static DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
566 566
diff --git a/drivers/acpi/device_sysfs.c b/drivers/acpi/device_sysfs.c
index a041689e5701..545e91420cde 100644
--- a/drivers/acpi/device_sysfs.c
+++ b/drivers/acpi/device_sysfs.c
@@ -357,7 +357,7 @@ static ssize_t real_power_state_show(struct device *dev,
357 return sprintf(buf, "%s\n", acpi_power_state_string(state)); 357 return sprintf(buf, "%s\n", acpi_power_state_string(state));
358} 358}
359 359
360static DEVICE_ATTR(real_power_state, 0444, real_power_state_show, NULL); 360static DEVICE_ATTR_RO(real_power_state);
361 361
362static ssize_t power_state_show(struct device *dev, 362static ssize_t power_state_show(struct device *dev,
363 struct device_attribute *attr, char *buf) 363 struct device_attribute *attr, char *buf)
@@ -367,7 +367,7 @@ static ssize_t power_state_show(struct device *dev,
367 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state)); 367 return sprintf(buf, "%s\n", acpi_power_state_string(adev->power.state));
368} 368}
369 369
370static DEVICE_ATTR(power_state, 0444, power_state_show, NULL); 370static DEVICE_ATTR_RO(power_state);
371 371
372static ssize_t 372static ssize_t
373acpi_eject_store(struct device *d, struct device_attribute *attr, 373acpi_eject_store(struct device *d, struct device_attribute *attr,
@@ -462,7 +462,7 @@ static ssize_t description_show(struct device *dev,
462 462
463 return result; 463 return result;
464} 464}
465static DEVICE_ATTR(description, 0444, description_show, NULL); 465static DEVICE_ATTR_RO(description);
466 466
467static ssize_t 467static ssize_t
468acpi_device_sun_show(struct device *dev, struct device_attribute *attr, 468acpi_device_sun_show(struct device *dev, struct device_attribute *attr,
diff --git a/drivers/base/Kconfig b/drivers/base/Kconfig
index 2415ad9f6dd4..784ff0003c1b 100644
--- a/drivers/base/Kconfig
+++ b/drivers/base/Kconfig
@@ -86,10 +86,9 @@ config FW_LOADER
86 require userspace firmware loading support, but a module built 86 require userspace firmware loading support, but a module built
87 out-of-tree does. 87 out-of-tree does.
88 88
89config FIRMWARE_IN_KERNEL 89config EXTRA_FIRMWARE
90 bool "Include in-kernel firmware blobs in kernel binary" 90 string "External firmware blobs to build into the kernel binary"
91 depends on FW_LOADER 91 depends on FW_LOADER
92 default y
93 help 92 help
94 Various drivers in the kernel source tree may require firmware, 93 Various drivers in the kernel source tree may require firmware,
95 which is generally available in your distribution's linux-firmware 94 which is generally available in your distribution's linux-firmware
@@ -99,23 +98,6 @@ config FIRMWARE_IN_KERNEL
99 /lib/firmware/ on your system, so they can be loaded by userspace 98 /lib/firmware/ on your system, so they can be loaded by userspace
100 helpers on request. 99 helpers on request.
101 100
102 Enabling this option will build each required firmware blob
103 specified by EXTRA_FIRMWARE into the kernel directly, where
104 request_firmware() will find them without having to call out to
105 userspace. This may be useful if your root file system requires a
106 device that uses such firmware and you do not wish to use an
107 initrd.
108
109 This single option controls the inclusion of firmware for
110 every driver that uses request_firmware(), which avoids a
111 proliferation of 'Include firmware for xxx device' options.
112
113 Say 'N' and let firmware be loaded from userspace.
114
115config EXTRA_FIRMWARE
116 string "External firmware blobs to build into the kernel binary"
117 depends on FW_LOADER
118 help
119 This option allows firmware to be built into the kernel for the case 101 This option allows firmware to be built into the kernel for the case
120 where the user either cannot or doesn't want to provide it from 102 where the user either cannot or doesn't want to provide it from
121 userspace at runtime (for example, when the firmware in question is 103 userspace at runtime (for example, when the firmware in question is
@@ -126,11 +108,11 @@ config EXTRA_FIRMWARE
126 firmware files -- the same names that appear in MODULE_FIRMWARE() 108 firmware files -- the same names that appear in MODULE_FIRMWARE()
127 and request_firmware() in the source. These files should exist under 109 and request_firmware() in the source. These files should exist under
128 the directory specified by the EXTRA_FIRMWARE_DIR option, which is 110 the directory specified by the EXTRA_FIRMWARE_DIR option, which is
129 by default the firmware subdirectory of the kernel source tree. 111 /lib/firmware by default.
130 112
131 For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy 113 For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy
132 the usb8388.bin file into the firmware directory, and build the kernel. 114 the usb8388.bin file into /lib/firmware, and build the kernel. Then
133 Then any request_firmware("usb8388.bin") will be satisfied internally 115 any request_firmware("usb8388.bin") will be satisfied internally
134 without needing to call out to userspace. 116 without needing to call out to userspace.
135 117
136 WARNING: If you include additional firmware files into your binary 118 WARNING: If you include additional firmware files into your binary
diff --git a/drivers/base/arch_topology.c b/drivers/base/arch_topology.c
index 4de87b0b53c8..52ec5174bcb1 100644
--- a/drivers/base/arch_topology.c
+++ b/drivers/base/arch_topology.c
@@ -1,15 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Arch specific cpu topology information 3 * Arch specific cpu topology information
3 * 4 *
4 * Copyright (C) 2016, ARM Ltd. 5 * Copyright (C) 2016, ARM Ltd.
5 * Written by: Juri Lelli, ARM Ltd. 6 * Written by: Juri Lelli, ARM Ltd.
6 *
7 * This file is subject to the terms and conditions of the GNU General Public
8 * License. See the file "COPYING" in the main directory of this archive
9 * for more details.
10 *
11 * Released under the GPLv2 only.
12 * SPDX-License-Identifier: GPL-2.0
13 */ 7 */
14 8
15#include <linux/acpi.h> 9#include <linux/acpi.h>
diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
index 95e3ef82f3b7..20736aaa0e69 100644
--- a/drivers/base/attribute_container.c
+++ b/drivers/base/attribute_container.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * attribute_container.c - implementation of a simple container for classes 3 * attribute_container.c - implementation of a simple container for classes
3 * 4 *
4 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> 5 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
5 * 6 *
6 * This file is licensed under GPLv2
7 *
8 * The basic idea here is to enable a device to be attached to an 7 * The basic idea here is to enable a device to be attached to an
9 * aritrary numer of classes without having to allocate storage for them. 8 * aritrary numer of classes without having to allocate storage for them.
10 * Instead, the contained classes select the devices they need to attach 9 * Instead, the contained classes select the devices they need to attach
diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 22a64fd3309b..ef6183306b40 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * bus.c - bus driver management 3 * bus.c - bus driver management
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (c) 2007 Novell Inc. 8 * Copyright (c) 2007 Novell Inc.
8 *
9 * This file is released under the GPLv2
10 *
11 */ 9 */
12 10
13#include <linux/async.h> 11#include <linux/async.h>
@@ -309,7 +307,7 @@ int bus_for_each_dev(struct bus_type *bus, struct device *start,
309 307
310 klist_iter_init_node(&bus->p->klist_devices, &i, 308 klist_iter_init_node(&bus->p->klist_devices, &i,
311 (start ? &start->p->knode_bus : NULL)); 309 (start ? &start->p->knode_bus : NULL));
312 while ((dev = next_device(&i)) && !error) 310 while (!error && (dev = next_device(&i)))
313 error = fn(dev, data); 311 error = fn(dev, data);
314 klist_iter_exit(&i); 312 klist_iter_exit(&i);
315 return error; 313 return error;
diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c
index 07532d83be0b..edf726267282 100644
--- a/drivers/base/cacheinfo.c
+++ b/drivers/base/cacheinfo.c
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * cacheinfo support - processor cache information via sysfs 3 * cacheinfo support - processor cache information via sysfs
3 * 4 *
4 * Based on arch/x86/kernel/cpu/intel_cacheinfo.c 5 * Based on arch/x86/kernel/cpu/intel_cacheinfo.c
5 * Author: Sudeep Holla <sudeep.holla@arm.com> 6 * Author: Sudeep Holla <sudeep.holla@arm.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
12 * kind, whether express or implied; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 8#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20 9
diff --git a/drivers/base/class.c b/drivers/base/class.c
index 52eb8e644acd..54def4e02f00 100644
--- a/drivers/base/class.c
+++ b/drivers/base/class.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * class.c - basic device class management 3 * class.c - basic device class management
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2003-2004 Greg Kroah-Hartman 7 * Copyright (c) 2003-2004 Greg Kroah-Hartman
7 * Copyright (c) 2003-2004 IBM Corp. 8 * Copyright (c) 2003-2004 IBM Corp.
8 *
9 * This file is released under the GPLv2
10 *
11 */ 9 */
12 10
13#include <linux/device.h> 11#include <linux/device.h>
diff --git a/drivers/base/component.c b/drivers/base/component.c
index 89b032f2ffd2..8946dfee4768 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -1,10 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Componentized device handling. 3 * Componentized device handling.
3 * 4 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This is work in progress. We gather up the component devices into a list, 5 * This is work in progress. We gather up the component devices into a list,
9 * and bind them when instructed. At the moment, we're specific to the DRM 6 * and bind them when instructed. At the moment, we're specific to the DRM
10 * subsystem, and only handles one master device, but this doesn't have to be 7 * subsystem, and only handles one master device, but this doesn't have to be
@@ -17,6 +14,7 @@
17#include <linux/module.h> 14#include <linux/module.h>
18#include <linux/mutex.h> 15#include <linux/mutex.h>
19#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/debugfs.h>
20 18
21struct component; 19struct component;
22 20
@@ -41,6 +39,7 @@ struct master {
41 const struct component_master_ops *ops; 39 const struct component_master_ops *ops;
42 struct device *dev; 40 struct device *dev;
43 struct component_match *match; 41 struct component_match *match;
42 struct dentry *dentry;
44}; 43};
45 44
46struct component { 45struct component {
@@ -56,6 +55,80 @@ static DEFINE_MUTEX(component_mutex);
56static LIST_HEAD(component_list); 55static LIST_HEAD(component_list);
57static LIST_HEAD(masters); 56static LIST_HEAD(masters);
58 57
58#ifdef CONFIG_DEBUG_FS
59
60static struct dentry *component_debugfs_dir;
61
62static int component_devices_show(struct seq_file *s, void *data)
63{
64 struct master *m = s->private;
65 struct component_match *match = m->match;
66 size_t i;
67
68 mutex_lock(&component_mutex);
69 seq_printf(s, "%-40s %20s\n", "master name", "status");
70 seq_puts(s, "-------------------------------------------------------------\n");
71 seq_printf(s, "%-40s %20s\n\n",
72 dev_name(m->dev), m->bound ? "bound" : "not bound");
73
74 seq_printf(s, "%-40s %20s\n", "device name", "status");
75 seq_puts(s, "-------------------------------------------------------------\n");
76 for (i = 0; i < match->num; i++) {
77 struct device *d = (struct device *)match->compare[i].data;
78
79 seq_printf(s, "%-40s %20s\n", dev_name(d),
80 match->compare[i].component ?
81 "registered" : "not registered");
82 }
83 mutex_unlock(&component_mutex);
84
85 return 0;
86}
87
88static int component_devices_open(struct inode *inode, struct file *file)
89{
90 return single_open(file, component_devices_show, inode->i_private);
91}
92
93static const struct file_operations component_devices_fops = {
94 .open = component_devices_open,
95 .read = seq_read,
96 .llseek = seq_lseek,
97 .release = single_release,
98};
99
100static int __init component_debug_init(void)
101{
102 component_debugfs_dir = debugfs_create_dir("device_component", NULL);
103
104 return 0;
105}
106
107core_initcall(component_debug_init);
108
109static void component_master_debugfs_add(struct master *m)
110{
111 m->dentry = debugfs_create_file(dev_name(m->dev), 0444,
112 component_debugfs_dir,
113 m, &component_devices_fops);
114}
115
116static void component_master_debugfs_del(struct master *m)
117{
118 debugfs_remove(m->dentry);
119 m->dentry = NULL;
120}
121
122#else
123
124static void component_master_debugfs_add(struct master *m)
125{ }
126
127static void component_master_debugfs_del(struct master *m)
128{ }
129
130#endif
131
59static struct master *__master_find(struct device *dev, 132static struct master *__master_find(struct device *dev,
60 const struct component_master_ops *ops) 133 const struct component_master_ops *ops)
61{ 134{
@@ -290,6 +363,7 @@ static void free_master(struct master *master)
290 struct component_match *match = master->match; 363 struct component_match *match = master->match;
291 int i; 364 int i;
292 365
366 component_master_debugfs_del(master);
293 list_del(&master->node); 367 list_del(&master->node);
294 368
295 if (match) { 369 if (match) {
@@ -323,6 +397,7 @@ int component_master_add_with_match(struct device *dev,
323 master->ops = ops; 397 master->ops = ops;
324 master->match = match; 398 master->match = match;
325 399
400 component_master_debugfs_add(master);
326 /* Add to the list of available masters. */ 401 /* Add to the list of available masters. */
327 mutex_lock(&component_mutex); 402 mutex_lock(&component_mutex);
328 list_add(&master->node, &masters); 403 list_add(&master->node, &masters);
diff --git a/drivers/base/container.c b/drivers/base/container.c
index ecbfbe2e908f..1ba42d2d3532 100644
--- a/drivers/base/container.c
+++ b/drivers/base/container.c
@@ -1,12 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * System bus type for containers. 3 * System bus type for containers.
3 * 4 *
4 * Copyright (C) 2013, Intel Corporation 5 * Copyright (C) 2013, Intel Corporation
5 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 6 * Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */ 7 */
11 8
12#include <linux/container.h> 9#include <linux/container.h>
diff --git a/drivers/base/core.c b/drivers/base/core.c
index 110230d86527..61515ef91184 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/base/core.c - core driver model code (device registration, etc) 3 * drivers/base/core.c - core driver model code (device registration, etc)
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2006 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (c) 2006 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (c) 2006 Novell, Inc. 8 * Copyright (c) 2006 Novell, Inc.
8 *
9 * This file is released under the GPLv2
10 *
11 */ 9 */
12 10
13#include <linux/device.h> 11#include <linux/device.h>
@@ -2116,7 +2114,7 @@ int device_for_each_child(struct device *parent, void *data,
2116 return 0; 2114 return 0;
2117 2115
2118 klist_iter_init(&parent->p->klist_children, &i); 2116 klist_iter_init(&parent->p->klist_children, &i);
2119 while ((child = next_device(&i)) && !error) 2117 while (!error && (child = next_device(&i)))
2120 error = fn(child, data); 2118 error = fn(child, data);
2121 klist_iter_exit(&i); 2119 klist_iter_exit(&i);
2122 return error; 2120 return error;
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index d99038487a0d..d21a2d913107 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * CPU subsystem support 3 * CPU subsystem support
3 */ 4 */
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 2c964f56dafe..de6fd092bf2f 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/base/dd.c - The core device/driver interactions. 3 * drivers/base/dd.c - The core device/driver interactions.
3 * 4 *
@@ -13,8 +14,6 @@
13 * Copyright (c) 2002-3 Open Source Development Labs 14 * Copyright (c) 2002-3 Open Source Development Labs
14 * Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de> 15 * Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de>
15 * Copyright (c) 2007-2009 Novell Inc. 16 * Copyright (c) 2007-2009 Novell Inc.
16 *
17 * This file is released under the GPLv2
18 */ 17 */
19 18
20#include <linux/device.h> 19#include <linux/device.h>
@@ -289,6 +288,18 @@ static void driver_bound(struct device *dev)
289 kobject_uevent(&dev->kobj, KOBJ_BIND); 288 kobject_uevent(&dev->kobj, KOBJ_BIND);
290} 289}
291 290
291static ssize_t coredump_store(struct device *dev, struct device_attribute *attr,
292 const char *buf, size_t count)
293{
294 device_lock(dev);
295 if (dev->driver->coredump)
296 dev->driver->coredump(dev);
297 device_unlock(dev);
298
299 return count;
300}
301static DEVICE_ATTR_WO(coredump);
302
292static int driver_sysfs_add(struct device *dev) 303static int driver_sysfs_add(struct device *dev)
293{ 304{
294 int ret; 305 int ret;
@@ -298,14 +309,26 @@ static int driver_sysfs_add(struct device *dev)
298 BUS_NOTIFY_BIND_DRIVER, dev); 309 BUS_NOTIFY_BIND_DRIVER, dev);
299 310
300 ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj, 311 ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj,
312 kobject_name(&dev->kobj));
313 if (ret)
314 goto fail;
315
316 ret = sysfs_create_link(&dev->kobj, &dev->driver->p->kobj,
317 "driver");
318 if (ret)
319 goto rm_dev;
320
321 if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump ||
322 !device_create_file(dev, &dev_attr_coredump))
323 return 0;
324
325 sysfs_remove_link(&dev->kobj, "driver");
326
327rm_dev:
328 sysfs_remove_link(&dev->driver->p->kobj,
301 kobject_name(&dev->kobj)); 329 kobject_name(&dev->kobj));
302 if (ret == 0) { 330
303 ret = sysfs_create_link(&dev->kobj, &dev->driver->p->kobj, 331fail:
304 "driver");
305 if (ret)
306 sysfs_remove_link(&dev->driver->p->kobj,
307 kobject_name(&dev->kobj));
308 }
309 return ret; 332 return ret;
310} 333}
311 334
@@ -314,6 +337,8 @@ static void driver_sysfs_remove(struct device *dev)
314 struct device_driver *drv = dev->driver; 337 struct device_driver *drv = dev->driver;
315 338
316 if (drv) { 339 if (drv) {
340 if (drv->coredump)
341 device_remove_file(dev, &dev_attr_coredump);
317 sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj)); 342 sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj));
318 sysfs_remove_link(&dev->kobj, "driver"); 343 sysfs_remove_link(&dev->kobj, "driver");
319 } 344 }
diff --git a/drivers/base/devcoredump.c b/drivers/base/devcoredump.c
index 7be310f7db73..f1a3353f3494 100644
--- a/drivers/base/devcoredump.c
+++ b/drivers/base/devcoredump.c
@@ -1,23 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * This file is provided under the GPLv2 license.
3 *
4 * GPL LICENSE SUMMARY
5 *
6 * Copyright(c) 2014 Intel Mobile Communications GmbH 3 * Copyright(c) 2014 Intel Mobile Communications GmbH
7 * Copyright(c) 2015 Intel Deutschland GmbH 4 * Copyright(c) 2015 Intel Deutschland GmbH
8 * 5 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * The full GNU General Public License is included in this distribution
19 * in the file called COPYING.
20 *
21 * Contact Information: 6 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com> 7 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 8 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
diff --git a/drivers/base/devres.c b/drivers/base/devres.c
index 71d577025285..95b67281cd2a 100644
--- a/drivers/base/devres.c
+++ b/drivers/base/devres.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/base/devres.c - device resource management 3 * drivers/base/devres.c - device resource management
3 * 4 *
4 * Copyright (c) 2006 SUSE Linux Products GmbH 5 * Copyright (c) 2006 SUSE Linux Products GmbH
5 * Copyright (c) 2006 Tejun Heo <teheo@suse.de> 6 * Copyright (c) 2006 Tejun Heo <teheo@suse.de>
6 *
7 * This file is released under the GPLv2.
8 */ 7 */
9 8
10#include <linux/device.h> 9#include <linux/device.h>
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index ea9726e71468..d987dcd1bd56 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -1,14 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * Contiguous Memory Allocator for DMA mapping framework 3 * Contiguous Memory Allocator for DMA mapping framework
3 * Copyright (c) 2010-2011 by Samsung Electronics. 4 * Copyright (c) 2010-2011 by Samsung Electronics.
4 * Written by: 5 * Written by:
5 * Marek Szyprowski <m.szyprowski@samsung.com> 6 * Marek Szyprowski <m.szyprowski@samsung.com>
6 * Michal Nazarewicz <mina86@mina86.com> 7 * Michal Nazarewicz <mina86@mina86.com>
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License or (at your optional) any later version of the license.
12 */ 8 */
13 9
14#define pr_fmt(fmt) "cma: " fmt 10#define pr_fmt(fmt) "cma: " fmt
diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c
index e584eddef0a7..3b118353ea17 100644
--- a/drivers/base/dma-mapping.c
+++ b/drivers/base/dma-mapping.c
@@ -1,10 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * drivers/base/dma-mapping.c - arch-independent dma-mapping routines 3 * drivers/base/dma-mapping.c - arch-independent dma-mapping routines
3 * 4 *
4 * Copyright (c) 2006 SUSE Linux Products GmbH 5 * Copyright (c) 2006 SUSE Linux Products GmbH
5 * Copyright (c) 2006 Tejun Heo <teheo@suse.de> 6 * Copyright (c) 2006 Tejun Heo <teheo@suse.de>
6 *
7 * This file is released under the GPLv2.
8 */ 7 */
9 8
10#include <linux/acpi.h> 9#include <linux/acpi.h>
diff --git a/drivers/base/driver.c b/drivers/base/driver.c
index 4eabfe28d2b3..ba912558a510 100644
--- a/drivers/base/driver.c
+++ b/drivers/base/driver.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * driver.c - centralized device driver management 3 * driver.c - centralized device driver management
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (c) 2007 Novell Inc. 8 * Copyright (c) 2007 Novell Inc.
8 *
9 * This file is released under the GPLv2
10 *
11 */ 9 */
12 10
13#include <linux/device.h> 11#include <linux/device.h>
@@ -52,7 +50,7 @@ int driver_for_each_device(struct device_driver *drv, struct device *start,
52 50
53 klist_iter_init_node(&drv->p->klist_devices, &i, 51 klist_iter_init_node(&drv->p->klist_devices, &i,
54 start ? &start->p->knode_driver : NULL); 52 start ? &start->p->knode_driver : NULL);
55 while ((dev = next_device(&i)) && !error) 53 while (!error && (dev = next_device(&i)))
56 error = fn(dev, data); 54 error = fn(dev, data);
57 klist_iter_exit(&i); 55 klist_iter_exit(&i);
58 return error; 56 return error;
diff --git a/drivers/base/firmware.c b/drivers/base/firmware.c
index 113815556809..8dff940e0db9 100644
--- a/drivers/base/firmware.c
+++ b/drivers/base/firmware.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * firmware.c - firmware subsystem hoohaw. 3 * firmware.c - firmware subsystem hoohaw.
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de> 7 * Copyright (c) 2007 Greg Kroah-Hartman <gregkh@suse.de>
7 * Copyright (c) 2007 Novell Inc. 8 * Copyright (c) 2007 Novell Inc.
8 *
9 * This file is released under the GPLv2
10 */ 9 */
11#include <linux/kobject.h> 10#include <linux/kobject.h>
12#include <linux/module.h> 11#include <linux/module.h>
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4b57cf5bc81d..7dd36ace6152 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * firmware_class.c - Multi purpose firmware loading support 3 * firmware_class.c - Multi purpose firmware loading support
3 * 4 *
@@ -41,6 +42,96 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
41MODULE_DESCRIPTION("Multi purpose firmware loading support"); 42MODULE_DESCRIPTION("Multi purpose firmware loading support");
42MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL");
43 44
45enum fw_status {
46 FW_STATUS_UNKNOWN,
47 FW_STATUS_LOADING,
48 FW_STATUS_DONE,
49 FW_STATUS_ABORTED,
50};
51
52/*
53 * Concurrent request_firmware() for the same firmware need to be
54 * serialized. struct fw_state is simple state machine which hold the
55 * state of the firmware loading.
56 */
57struct fw_state {
58 struct completion completion;
59 enum fw_status status;
60};
61
62/* firmware behavior options */
63#define FW_OPT_UEVENT (1U << 0)
64#define FW_OPT_NOWAIT (1U << 1)
65#define FW_OPT_USERHELPER (1U << 2)
66#define FW_OPT_NO_WARN (1U << 3)
67#define FW_OPT_NOCACHE (1U << 4)
68#define FW_OPT_NOFALLBACK (1U << 5)
69
70struct firmware_cache {
71 /* firmware_buf instance will be added into the below list */
72 spinlock_t lock;
73 struct list_head head;
74 int state;
75
76#ifdef CONFIG_PM_SLEEP
77 /*
78 * Names of firmware images which have been cached successfully
79 * will be added into the below list so that device uncache
80 * helper can trace which firmware images have been cached
81 * before.
82 */
83 spinlock_t name_lock;
84 struct list_head fw_names;
85
86 struct delayed_work work;
87
88 struct notifier_block pm_notify;
89#endif
90};
91
92struct fw_priv {
93 struct kref ref;
94 struct list_head list;
95 struct firmware_cache *fwc;
96 struct fw_state fw_st;
97 void *data;
98 size_t size;
99 size_t allocated_size;
100#ifdef CONFIG_FW_LOADER_USER_HELPER
101 bool is_paged_buf;
102 bool need_uevent;
103 struct page **pages;
104 int nr_pages;
105 int page_array_size;
106 struct list_head pending_list;
107#endif
108 const char *fw_name;
109};
110
111struct fw_cache_entry {
112 struct list_head list;
113 const char *name;
114};
115
116struct fw_name_devm {
117 unsigned long magic;
118 const char *name;
119};
120
121static inline struct fw_priv *to_fw_priv(struct kref *ref)
122{
123 return container_of(ref, struct fw_priv, ref);
124}
125
126#define FW_LOADER_NO_CACHE 0
127#define FW_LOADER_START_CACHE 1
128
129/* fw_lock could be moved to 'struct fw_sysfs' but since it is just
130 * guarding for corner cases a global lock should be OK */
131static DEFINE_MUTEX(fw_lock);
132
133static struct firmware_cache fw_cache;
134
44/* Builtin firmware support */ 135/* Builtin firmware support */
45 136
46#ifdef CONFIG_FW_LOADER 137#ifdef CONFIG_FW_LOADER
@@ -48,6 +139,14 @@ MODULE_LICENSE("GPL");
48extern struct builtin_fw __start_builtin_fw[]; 139extern struct builtin_fw __start_builtin_fw[];
49extern struct builtin_fw __end_builtin_fw[]; 140extern struct builtin_fw __end_builtin_fw[];
50 141
142static void fw_copy_to_prealloc_buf(struct firmware *fw,
143 void *buf, size_t size)
144{
145 if (!buf || size < fw->size)
146 return;
147 memcpy(buf, fw->data, fw->size);
148}
149
51static bool fw_get_builtin_firmware(struct firmware *fw, const char *name, 150static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
52 void *buf, size_t size) 151 void *buf, size_t size)
53{ 152{
@@ -57,9 +156,8 @@ static bool fw_get_builtin_firmware(struct firmware *fw, const char *name,
57 if (strcmp(name, b_fw->name) == 0) { 156 if (strcmp(name, b_fw->name) == 0) {
58 fw->size = b_fw->size; 157 fw->size = b_fw->size;
59 fw->data = b_fw->data; 158 fw->data = b_fw->data;
159 fw_copy_to_prealloc_buf(fw, buf, size);
60 160
61 if (buf && fw->size <= size)
62 memcpy(buf, fw->data, fw->size);
63 return true; 161 return true;
64 } 162 }
65 } 163 }
@@ -93,13 +191,6 @@ static inline bool fw_is_builtin_firmware(const struct firmware *fw)
93} 191}
94#endif 192#endif
95 193
96enum fw_status {
97 FW_STATUS_UNKNOWN,
98 FW_STATUS_LOADING,
99 FW_STATUS_DONE,
100 FW_STATUS_ABORTED,
101};
102
103static int loading_timeout = 60; /* In seconds */ 194static int loading_timeout = 60; /* In seconds */
104 195
105static inline long firmware_loading_timeout(void) 196static inline long firmware_loading_timeout(void)
@@ -107,29 +198,17 @@ static inline long firmware_loading_timeout(void)
107 return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET; 198 return loading_timeout > 0 ? loading_timeout * HZ : MAX_JIFFY_OFFSET;
108} 199}
109 200
110/* 201static void fw_state_init(struct fw_priv *fw_priv)
111 * Concurrent request_firmware() for the same firmware need to be
112 * serialized. struct fw_state is simple state machine which hold the
113 * state of the firmware loading.
114 */
115struct fw_state {
116 struct completion completion;
117 enum fw_status status;
118};
119
120static void fw_state_init(struct fw_state *fw_st)
121{ 202{
203 struct fw_state *fw_st = &fw_priv->fw_st;
204
122 init_completion(&fw_st->completion); 205 init_completion(&fw_st->completion);
123 fw_st->status = FW_STATUS_UNKNOWN; 206 fw_st->status = FW_STATUS_UNKNOWN;
124} 207}
125 208
126static inline bool __fw_state_is_done(enum fw_status status) 209static int __fw_state_wait_common(struct fw_priv *fw_priv, long timeout)
127{
128 return status == FW_STATUS_DONE || status == FW_STATUS_ABORTED;
129}
130
131static int __fw_state_wait_common(struct fw_state *fw_st, long timeout)
132{ 210{
211 struct fw_state *fw_st = &fw_priv->fw_st;
133 long ret; 212 long ret;
134 213
135 ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout); 214 ret = wait_for_completion_killable_timeout(&fw_st->completion, timeout);
@@ -141,226 +220,172 @@ static int __fw_state_wait_common(struct fw_state *fw_st, long timeout)
141 return ret < 0 ? ret : 0; 220 return ret < 0 ? ret : 0;
142} 221}
143 222
144static void __fw_state_set(struct fw_state *fw_st, 223static void __fw_state_set(struct fw_priv *fw_priv,
145 enum fw_status status) 224 enum fw_status status)
146{ 225{
226 struct fw_state *fw_st = &fw_priv->fw_st;
227
147 WRITE_ONCE(fw_st->status, status); 228 WRITE_ONCE(fw_st->status, status);
148 229
149 if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED) 230 if (status == FW_STATUS_DONE || status == FW_STATUS_ABORTED)
150 complete_all(&fw_st->completion); 231 complete_all(&fw_st->completion);
151} 232}
152 233
153#define fw_state_start(fw_st) \ 234static inline void fw_state_start(struct fw_priv *fw_priv)
154 __fw_state_set(fw_st, FW_STATUS_LOADING)
155#define fw_state_done(fw_st) \
156 __fw_state_set(fw_st, FW_STATUS_DONE)
157#define fw_state_aborted(fw_st) \
158 __fw_state_set(fw_st, FW_STATUS_ABORTED)
159#define fw_state_wait(fw_st) \
160 __fw_state_wait_common(fw_st, MAX_SCHEDULE_TIMEOUT)
161
162static int __fw_state_check(struct fw_state *fw_st, enum fw_status status)
163{ 235{
164 return fw_st->status == status; 236 __fw_state_set(fw_priv, FW_STATUS_LOADING);
165} 237}
166 238
167#define fw_state_is_aborted(fw_st) \ 239static inline void fw_state_done(struct fw_priv *fw_priv)
168 __fw_state_check(fw_st, FW_STATUS_ABORTED) 240{
169 241 __fw_state_set(fw_priv, FW_STATUS_DONE);
170#ifdef CONFIG_FW_LOADER_USER_HELPER 242}
171
172#define fw_state_aborted(fw_st) \
173 __fw_state_set(fw_st, FW_STATUS_ABORTED)
174#define fw_state_is_done(fw_st) \
175 __fw_state_check(fw_st, FW_STATUS_DONE)
176#define fw_state_is_loading(fw_st) \
177 __fw_state_check(fw_st, FW_STATUS_LOADING)
178#define fw_state_wait_timeout(fw_st, timeout) \
179 __fw_state_wait_common(fw_st, timeout)
180
181#endif /* CONFIG_FW_LOADER_USER_HELPER */
182 243
183/* firmware behavior options */ 244static inline void fw_state_aborted(struct fw_priv *fw_priv)
184#define FW_OPT_UEVENT (1U << 0) 245{
185#define FW_OPT_NOWAIT (1U << 1) 246 __fw_state_set(fw_priv, FW_STATUS_ABORTED);
186#ifdef CONFIG_FW_LOADER_USER_HELPER 247}
187#define FW_OPT_USERHELPER (1U << 2)
188#else
189#define FW_OPT_USERHELPER 0
190#endif
191#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
192#define FW_OPT_FALLBACK FW_OPT_USERHELPER
193#else
194#define FW_OPT_FALLBACK 0
195#endif
196#define FW_OPT_NO_WARN (1U << 3)
197#define FW_OPT_NOCACHE (1U << 4)
198 248
199struct firmware_cache { 249static inline int fw_state_wait(struct fw_priv *fw_priv)
200 /* firmware_buf instance will be added into the below list */ 250{
201 spinlock_t lock; 251 return __fw_state_wait_common(fw_priv, MAX_SCHEDULE_TIMEOUT);
202 struct list_head head; 252}
203 int state;
204 253
205#ifdef CONFIG_PM_SLEEP 254static bool __fw_state_check(struct fw_priv *fw_priv,
206 /* 255 enum fw_status status)
207 * Names of firmware images which have been cached successfully 256{
208 * will be added into the below list so that device uncache 257 struct fw_state *fw_st = &fw_priv->fw_st;
209 * helper can trace which firmware images have been cached
210 * before.
211 */
212 spinlock_t name_lock;
213 struct list_head fw_names;
214 258
215 struct delayed_work work; 259 return fw_st->status == status;
260}
216 261
217 struct notifier_block pm_notify; 262static inline bool fw_state_is_aborted(struct fw_priv *fw_priv)
218#endif 263{
219}; 264 return __fw_state_check(fw_priv, FW_STATUS_ABORTED);
265}
220 266
221struct firmware_buf {
222 struct kref ref;
223 struct list_head list;
224 struct firmware_cache *fwc;
225 struct fw_state fw_st;
226 void *data;
227 size_t size;
228 size_t allocated_size;
229#ifdef CONFIG_FW_LOADER_USER_HELPER 267#ifdef CONFIG_FW_LOADER_USER_HELPER
230 bool is_paged_buf;
231 bool need_uevent;
232 struct page **pages;
233 int nr_pages;
234 int page_array_size;
235 struct list_head pending_list;
236#endif
237 const char *fw_id;
238};
239 268
240struct fw_cache_entry { 269static inline bool fw_sysfs_done(struct fw_priv *fw_priv)
241 struct list_head list; 270{
242 const char *name; 271 return __fw_state_check(fw_priv, FW_STATUS_DONE);
243}; 272}
244 273
245struct fw_name_devm { 274static inline bool fw_sysfs_loading(struct fw_priv *fw_priv)
246 unsigned long magic; 275{
247 const char *name; 276 return __fw_state_check(fw_priv, FW_STATUS_LOADING);
248}; 277}
249 278
250#define to_fwbuf(d) container_of(d, struct firmware_buf, ref) 279static inline int fw_sysfs_wait_timeout(struct fw_priv *fw_priv, long timeout)
280{
281 return __fw_state_wait_common(fw_priv, timeout);
282}
251 283
252#define FW_LOADER_NO_CACHE 0 284#endif /* CONFIG_FW_LOADER_USER_HELPER */
253#define FW_LOADER_START_CACHE 1
254 285
255static int fw_cache_piggyback_on_request(const char *name); 286static int fw_cache_piggyback_on_request(const char *name);
256 287
257/* fw_lock could be moved to 'struct firmware_priv' but since it is just 288static struct fw_priv *__allocate_fw_priv(const char *fw_name,
258 * guarding for corner cases a global lock should be OK */ 289 struct firmware_cache *fwc,
259static DEFINE_MUTEX(fw_lock); 290 void *dbuf, size_t size)
260
261static struct firmware_cache fw_cache;
262
263static struct firmware_buf *__allocate_fw_buf(const char *fw_name,
264 struct firmware_cache *fwc,
265 void *dbuf, size_t size)
266{ 291{
267 struct firmware_buf *buf; 292 struct fw_priv *fw_priv;
268 293
269 buf = kzalloc(sizeof(*buf), GFP_ATOMIC); 294 fw_priv = kzalloc(sizeof(*fw_priv), GFP_ATOMIC);
270 if (!buf) 295 if (!fw_priv)
271 return NULL; 296 return NULL;
272 297
273 buf->fw_id = kstrdup_const(fw_name, GFP_ATOMIC); 298 fw_priv->fw_name = kstrdup_const(fw_name, GFP_ATOMIC);
274 if (!buf->fw_id) { 299 if (!fw_priv->fw_name) {
275 kfree(buf); 300 kfree(fw_priv);
276 return NULL; 301 return NULL;
277 } 302 }
278 303
279 kref_init(&buf->ref); 304 kref_init(&fw_priv->ref);
280 buf->fwc = fwc; 305 fw_priv->fwc = fwc;
281 buf->data = dbuf; 306 fw_priv->data = dbuf;
282 buf->allocated_size = size; 307 fw_priv->allocated_size = size;
283 fw_state_init(&buf->fw_st); 308 fw_state_init(fw_priv);
284#ifdef CONFIG_FW_LOADER_USER_HELPER 309#ifdef CONFIG_FW_LOADER_USER_HELPER
285 INIT_LIST_HEAD(&buf->pending_list); 310 INIT_LIST_HEAD(&fw_priv->pending_list);
286#endif 311#endif
287 312
288 pr_debug("%s: fw-%s buf=%p\n", __func__, fw_name, buf); 313 pr_debug("%s: fw-%s fw_priv=%p\n", __func__, fw_name, fw_priv);
289 314
290 return buf; 315 return fw_priv;
291} 316}
292 317
293static struct firmware_buf *__fw_lookup_buf(const char *fw_name) 318static struct fw_priv *__lookup_fw_priv(const char *fw_name)
294{ 319{
295 struct firmware_buf *tmp; 320 struct fw_priv *tmp;
296 struct firmware_cache *fwc = &fw_cache; 321 struct firmware_cache *fwc = &fw_cache;
297 322
298 list_for_each_entry(tmp, &fwc->head, list) 323 list_for_each_entry(tmp, &fwc->head, list)
299 if (!strcmp(tmp->fw_id, fw_name)) 324 if (!strcmp(tmp->fw_name, fw_name))
300 return tmp; 325 return tmp;
301 return NULL; 326 return NULL;
302} 327}
303 328
304/* Returns 1 for batching firmware requests with the same name */ 329/* Returns 1 for batching firmware requests with the same name */
305static int fw_lookup_and_allocate_buf(const char *fw_name, 330static int alloc_lookup_fw_priv(const char *fw_name,
306 struct firmware_cache *fwc, 331 struct firmware_cache *fwc,
307 struct firmware_buf **buf, void *dbuf, 332 struct fw_priv **fw_priv, void *dbuf,
308 size_t size) 333 size_t size)
309{ 334{
310 struct firmware_buf *tmp; 335 struct fw_priv *tmp;
311 336
312 spin_lock(&fwc->lock); 337 spin_lock(&fwc->lock);
313 tmp = __fw_lookup_buf(fw_name); 338 tmp = __lookup_fw_priv(fw_name);
314 if (tmp) { 339 if (tmp) {
315 kref_get(&tmp->ref); 340 kref_get(&tmp->ref);
316 spin_unlock(&fwc->lock); 341 spin_unlock(&fwc->lock);
317 *buf = tmp; 342 *fw_priv = tmp;
318 pr_debug("batched request - sharing the same struct firmware_buf and lookup for multiple requests\n"); 343 pr_debug("batched request - sharing the same struct fw_priv and lookup for multiple requests\n");
319 return 1; 344 return 1;
320 } 345 }
321 tmp = __allocate_fw_buf(fw_name, fwc, dbuf, size); 346 tmp = __allocate_fw_priv(fw_name, fwc, dbuf, size);
322 if (tmp) 347 if (tmp)
323 list_add(&tmp->list, &fwc->head); 348 list_add(&tmp->list, &fwc->head);
324 spin_unlock(&fwc->lock); 349 spin_unlock(&fwc->lock);
325 350
326 *buf = tmp; 351 *fw_priv = tmp;
327 352
328 return tmp ? 0 : -ENOMEM; 353 return tmp ? 0 : -ENOMEM;
329} 354}
330 355
331static void __fw_free_buf(struct kref *ref) 356static void __free_fw_priv(struct kref *ref)
332 __releases(&fwc->lock) 357 __releases(&fwc->lock)
333{ 358{
334 struct firmware_buf *buf = to_fwbuf(ref); 359 struct fw_priv *fw_priv = to_fw_priv(ref);
335 struct firmware_cache *fwc = buf->fwc; 360 struct firmware_cache *fwc = fw_priv->fwc;
336 361
337 pr_debug("%s: fw-%s buf=%p data=%p size=%u\n", 362 pr_debug("%s: fw-%s fw_priv=%p data=%p size=%u\n",
338 __func__, buf->fw_id, buf, buf->data, 363 __func__, fw_priv->fw_name, fw_priv, fw_priv->data,
339 (unsigned int)buf->size); 364 (unsigned int)fw_priv->size);
340 365
341 list_del(&buf->list); 366 list_del(&fw_priv->list);
342 spin_unlock(&fwc->lock); 367 spin_unlock(&fwc->lock);
343 368
344#ifdef CONFIG_FW_LOADER_USER_HELPER 369#ifdef CONFIG_FW_LOADER_USER_HELPER
345 if (buf->is_paged_buf) { 370 if (fw_priv->is_paged_buf) {
346 int i; 371 int i;
347 vunmap(buf->data); 372 vunmap(fw_priv->data);
348 for (i = 0; i < buf->nr_pages; i++) 373 for (i = 0; i < fw_priv->nr_pages; i++)
349 __free_page(buf->pages[i]); 374 __free_page(fw_priv->pages[i]);
350 vfree(buf->pages); 375 vfree(fw_priv->pages);
351 } else 376 } else
352#endif 377#endif
353 if (!buf->allocated_size) 378 if (!fw_priv->allocated_size)
354 vfree(buf->data); 379 vfree(fw_priv->data);
355 kfree_const(buf->fw_id); 380 kfree_const(fw_priv->fw_name);
356 kfree(buf); 381 kfree(fw_priv);
357} 382}
358 383
359static void fw_free_buf(struct firmware_buf *buf) 384static void free_fw_priv(struct fw_priv *fw_priv)
360{ 385{
361 struct firmware_cache *fwc = buf->fwc; 386 struct firmware_cache *fwc = fw_priv->fwc;
362 spin_lock(&fwc->lock); 387 spin_lock(&fwc->lock);
363 if (!kref_put(&buf->ref, __fw_free_buf)) 388 if (!kref_put(&fw_priv->ref, __free_fw_priv))
364 spin_unlock(&fwc->lock); 389 spin_unlock(&fwc->lock);
365} 390}
366 391
@@ -383,7 +408,7 @@ module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
383MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path"); 408MODULE_PARM_DESC(path, "customized firmware image search path with a higher priority than default path");
384 409
385static int 410static int
386fw_get_filesystem_firmware(struct device *device, struct firmware_buf *buf) 411fw_get_filesystem_firmware(struct device *device, struct fw_priv *fw_priv)
387{ 412{
388 loff_t size; 413 loff_t size;
389 int i, len; 414 int i, len;
@@ -393,9 +418,9 @@ fw_get_filesystem_firmware(struct device *device, struct firmware_buf *buf)
393 size_t msize = INT_MAX; 418 size_t msize = INT_MAX;
394 419
395 /* Already populated data member means we're loading into a buffer */ 420 /* Already populated data member means we're loading into a buffer */
396 if (buf->data) { 421 if (fw_priv->data) {
397 id = READING_FIRMWARE_PREALLOC_BUFFER; 422 id = READING_FIRMWARE_PREALLOC_BUFFER;
398 msize = buf->allocated_size; 423 msize = fw_priv->allocated_size;
399 } 424 }
400 425
401 path = __getname(); 426 path = __getname();
@@ -408,15 +433,15 @@ fw_get_filesystem_firmware(struct device *device, struct firmware_buf *buf)
408 continue; 433 continue;
409 434
410 len = snprintf(path, PATH_MAX, "%s/%s", 435 len = snprintf(path, PATH_MAX, "%s/%s",
411 fw_path[i], buf->fw_id); 436 fw_path[i], fw_priv->fw_name);
412 if (len >= PATH_MAX) { 437 if (len >= PATH_MAX) {
413 rc = -ENAMETOOLONG; 438 rc = -ENAMETOOLONG;
414 break; 439 break;
415 } 440 }
416 441
417 buf->size = 0; 442 fw_priv->size = 0;
418 rc = kernel_read_file_from_path(path, &buf->data, &size, msize, 443 rc = kernel_read_file_from_path(path, &fw_priv->data, &size,
419 id); 444 msize, id);
420 if (rc) { 445 if (rc) {
421 if (rc == -ENOENT) 446 if (rc == -ENOENT)
422 dev_dbg(device, "loading %s failed with error %d\n", 447 dev_dbg(device, "loading %s failed with error %d\n",
@@ -426,9 +451,9 @@ fw_get_filesystem_firmware(struct device *device, struct firmware_buf *buf)
426 path, rc); 451 path, rc);
427 continue; 452 continue;
428 } 453 }
429 dev_dbg(device, "direct-loading %s\n", buf->fw_id); 454 dev_dbg(device, "direct-loading %s\n", fw_priv->fw_name);
430 buf->size = size; 455 fw_priv->size = size;
431 fw_state_done(&buf->fw_st); 456 fw_state_done(fw_priv);
432 break; 457 break;
433 } 458 }
434 __putname(path); 459 __putname(path);
@@ -444,22 +469,22 @@ static void firmware_free_data(const struct firmware *fw)
444 vfree(fw->data); 469 vfree(fw->data);
445 return; 470 return;
446 } 471 }
447 fw_free_buf(fw->priv); 472 free_fw_priv(fw->priv);
448} 473}
449 474
450/* store the pages buffer info firmware from buf */ 475/* store the pages buffer info firmware from buf */
451static void fw_set_page_data(struct firmware_buf *buf, struct firmware *fw) 476static void fw_set_page_data(struct fw_priv *fw_priv, struct firmware *fw)
452{ 477{
453 fw->priv = buf; 478 fw->priv = fw_priv;
454#ifdef CONFIG_FW_LOADER_USER_HELPER 479#ifdef CONFIG_FW_LOADER_USER_HELPER
455 fw->pages = buf->pages; 480 fw->pages = fw_priv->pages;
456#endif 481#endif
457 fw->size = buf->size; 482 fw->size = fw_priv->size;
458 fw->data = buf->data; 483 fw->data = fw_priv->data;
459 484
460 pr_debug("%s: fw-%s buf=%p data=%p size=%u\n", 485 pr_debug("%s: fw-%s fw_priv=%p data=%p size=%u\n",
461 __func__, buf->fw_id, buf, buf->data, 486 __func__, fw_priv->fw_name, fw_priv, fw_priv->data,
462 (unsigned int)buf->size); 487 (unsigned int)fw_priv->size);
463} 488}
464 489
465#ifdef CONFIG_PM_SLEEP 490#ifdef CONFIG_PM_SLEEP
@@ -523,13 +548,13 @@ static int fw_add_devm_name(struct device *dev, const char *name)
523} 548}
524#endif 549#endif
525 550
526static int assign_firmware_buf(struct firmware *fw, struct device *device, 551static int assign_fw(struct firmware *fw, struct device *device,
527 unsigned int opt_flags) 552 unsigned int opt_flags)
528{ 553{
529 struct firmware_buf *buf = fw->priv; 554 struct fw_priv *fw_priv = fw->priv;
530 555
531 mutex_lock(&fw_lock); 556 mutex_lock(&fw_lock);
532 if (!buf->size || fw_state_is_aborted(&buf->fw_st)) { 557 if (!fw_priv->size || fw_state_is_aborted(fw_priv)) {
533 mutex_unlock(&fw_lock); 558 mutex_unlock(&fw_lock);
534 return -ENOENT; 559 return -ENOENT;
535 } 560 }
@@ -544,20 +569,20 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
544 /* don't cache firmware handled without uevent */ 569 /* don't cache firmware handled without uevent */
545 if (device && (opt_flags & FW_OPT_UEVENT) && 570 if (device && (opt_flags & FW_OPT_UEVENT) &&
546 !(opt_flags & FW_OPT_NOCACHE)) 571 !(opt_flags & FW_OPT_NOCACHE))
547 fw_add_devm_name(device, buf->fw_id); 572 fw_add_devm_name(device, fw_priv->fw_name);
548 573
549 /* 574 /*
550 * After caching firmware image is started, let it piggyback 575 * After caching firmware image is started, let it piggyback
551 * on request firmware. 576 * on request firmware.
552 */ 577 */
553 if (!(opt_flags & FW_OPT_NOCACHE) && 578 if (!(opt_flags & FW_OPT_NOCACHE) &&
554 buf->fwc->state == FW_LOADER_START_CACHE) { 579 fw_priv->fwc->state == FW_LOADER_START_CACHE) {
555 if (fw_cache_piggyback_on_request(buf->fw_id)) 580 if (fw_cache_piggyback_on_request(fw_priv->fw_name))
556 kref_get(&buf->ref); 581 kref_get(&fw_priv->ref);
557 } 582 }
558 583
559 /* pass the pages buffer to driver at the last minute */ 584 /* pass the pages buffer to driver at the last minute */
560 fw_set_page_data(buf, fw); 585 fw_set_page_data(fw_priv, fw);
561 mutex_unlock(&fw_lock); 586 mutex_unlock(&fw_lock);
562 return 0; 587 return 0;
563} 588}
@@ -566,49 +591,50 @@ static int assign_firmware_buf(struct firmware *fw, struct device *device,
566 * user-mode helper code 591 * user-mode helper code
567 */ 592 */
568#ifdef CONFIG_FW_LOADER_USER_HELPER 593#ifdef CONFIG_FW_LOADER_USER_HELPER
569struct firmware_priv { 594struct fw_sysfs {
570 bool nowait; 595 bool nowait;
571 struct device dev; 596 struct device dev;
572 struct firmware_buf *buf; 597 struct fw_priv *fw_priv;
573 struct firmware *fw; 598 struct firmware *fw;
574}; 599};
575 600
576static struct firmware_priv *to_firmware_priv(struct device *dev) 601static struct fw_sysfs *to_fw_sysfs(struct device *dev)
577{ 602{
578 return container_of(dev, struct firmware_priv, dev); 603 return container_of(dev, struct fw_sysfs, dev);
579} 604}
580 605
581static void __fw_load_abort(struct firmware_buf *buf) 606static void __fw_load_abort(struct fw_priv *fw_priv)
582{ 607{
583 /* 608 /*
584 * There is a small window in which user can write to 'loading' 609 * There is a small window in which user can write to 'loading'
585 * between loading done and disappearance of 'loading' 610 * between loading done and disappearance of 'loading'
586 */ 611 */
587 if (fw_state_is_done(&buf->fw_st)) 612 if (fw_sysfs_done(fw_priv))
588 return; 613 return;
589 614
590 list_del_init(&buf->pending_list); 615 list_del_init(&fw_priv->pending_list);
591 fw_state_aborted(&buf->fw_st); 616 fw_state_aborted(fw_priv);
592} 617}
593 618
594static void fw_load_abort(struct firmware_priv *fw_priv) 619static void fw_load_abort(struct fw_sysfs *fw_sysfs)
595{ 620{
596 struct firmware_buf *buf = fw_priv->buf; 621 struct fw_priv *fw_priv = fw_sysfs->fw_priv;
597 622
598 __fw_load_abort(buf); 623 __fw_load_abort(fw_priv);
599} 624}
600 625
601static LIST_HEAD(pending_fw_head); 626static LIST_HEAD(pending_fw_head);
602 627
603static void kill_pending_fw_fallback_reqs(bool only_kill_custom) 628static void kill_pending_fw_fallback_reqs(bool only_kill_custom)
604{ 629{
605 struct firmware_buf *buf; 630 struct fw_priv *fw_priv;
606 struct firmware_buf *next; 631 struct fw_priv *next;
607 632
608 mutex_lock(&fw_lock); 633 mutex_lock(&fw_lock);
609 list_for_each_entry_safe(buf, next, &pending_fw_head, pending_list) { 634 list_for_each_entry_safe(fw_priv, next, &pending_fw_head,
610 if (!buf->need_uevent || !only_kill_custom) 635 pending_list) {
611 __fw_load_abort(buf); 636 if (!fw_priv->need_uevent || !only_kill_custom)
637 __fw_load_abort(fw_priv);
612 } 638 }
613 mutex_unlock(&fw_lock); 639 mutex_unlock(&fw_lock);
614} 640}
@@ -651,18 +677,18 @@ ATTRIBUTE_GROUPS(firmware_class);
651 677
652static void fw_dev_release(struct device *dev) 678static void fw_dev_release(struct device *dev)
653{ 679{
654 struct firmware_priv *fw_priv = to_firmware_priv(dev); 680 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
655 681
656 kfree(fw_priv); 682 kfree(fw_sysfs);
657} 683}
658 684
659static int do_firmware_uevent(struct firmware_priv *fw_priv, struct kobj_uevent_env *env) 685static int do_firmware_uevent(struct fw_sysfs *fw_sysfs, struct kobj_uevent_env *env)
660{ 686{
661 if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->buf->fw_id)) 687 if (add_uevent_var(env, "FIRMWARE=%s", fw_sysfs->fw_priv->fw_name))
662 return -ENOMEM; 688 return -ENOMEM;
663 if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) 689 if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout))
664 return -ENOMEM; 690 return -ENOMEM;
665 if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait)) 691 if (add_uevent_var(env, "ASYNC=%d", fw_sysfs->nowait))
666 return -ENOMEM; 692 return -ENOMEM;
667 693
668 return 0; 694 return 0;
@@ -670,12 +696,12 @@ static int do_firmware_uevent(struct firmware_priv *fw_priv, struct kobj_uevent_
670 696
671static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) 697static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env)
672{ 698{
673 struct firmware_priv *fw_priv = to_firmware_priv(dev); 699 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
674 int err = 0; 700 int err = 0;
675 701
676 mutex_lock(&fw_lock); 702 mutex_lock(&fw_lock);
677 if (fw_priv->buf) 703 if (fw_sysfs->fw_priv)
678 err = do_firmware_uevent(fw_priv, env); 704 err = do_firmware_uevent(fw_sysfs, env);
679 mutex_unlock(&fw_lock); 705 mutex_unlock(&fw_lock);
680 return err; 706 return err;
681} 707}
@@ -687,15 +713,25 @@ static struct class firmware_class = {
687 .dev_release = fw_dev_release, 713 .dev_release = fw_dev_release,
688}; 714};
689 715
716static inline int register_sysfs_loader(void)
717{
718 return class_register(&firmware_class);
719}
720
721static inline void unregister_sysfs_loader(void)
722{
723 class_unregister(&firmware_class);
724}
725
690static ssize_t firmware_loading_show(struct device *dev, 726static ssize_t firmware_loading_show(struct device *dev,
691 struct device_attribute *attr, char *buf) 727 struct device_attribute *attr, char *buf)
692{ 728{
693 struct firmware_priv *fw_priv = to_firmware_priv(dev); 729 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
694 int loading = 0; 730 int loading = 0;
695 731
696 mutex_lock(&fw_lock); 732 mutex_lock(&fw_lock);
697 if (fw_priv->buf) 733 if (fw_sysfs->fw_priv)
698 loading = fw_state_is_loading(&fw_priv->buf->fw_st); 734 loading = fw_sysfs_loading(fw_sysfs->fw_priv);
699 mutex_unlock(&fw_lock); 735 mutex_unlock(&fw_lock);
700 736
701 return sprintf(buf, "%d\n", loading); 737 return sprintf(buf, "%d\n", loading);
@@ -707,14 +743,15 @@ static ssize_t firmware_loading_show(struct device *dev,
707#endif 743#endif
708 744
709/* one pages buffer should be mapped/unmapped only once */ 745/* one pages buffer should be mapped/unmapped only once */
710static int fw_map_pages_buf(struct firmware_buf *buf) 746static int map_fw_priv_pages(struct fw_priv *fw_priv)
711{ 747{
712 if (!buf->is_paged_buf) 748 if (!fw_priv->is_paged_buf)
713 return 0; 749 return 0;
714 750
715 vunmap(buf->data); 751 vunmap(fw_priv->data);
716 buf->data = vmap(buf->pages, buf->nr_pages, 0, PAGE_KERNEL_RO); 752 fw_priv->data = vmap(fw_priv->pages, fw_priv->nr_pages, 0,
717 if (!buf->data) 753 PAGE_KERNEL_RO);
754 if (!fw_priv->data)
718 return -ENOMEM; 755 return -ENOMEM;
719 return 0; 756 return 0;
720} 757}
@@ -736,32 +773,32 @@ static ssize_t firmware_loading_store(struct device *dev,
736 struct device_attribute *attr, 773 struct device_attribute *attr,
737 const char *buf, size_t count) 774 const char *buf, size_t count)
738{ 775{
739 struct firmware_priv *fw_priv = to_firmware_priv(dev); 776 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
740 struct firmware_buf *fw_buf; 777 struct fw_priv *fw_priv;
741 ssize_t written = count; 778 ssize_t written = count;
742 int loading = simple_strtol(buf, NULL, 10); 779 int loading = simple_strtol(buf, NULL, 10);
743 int i; 780 int i;
744 781
745 mutex_lock(&fw_lock); 782 mutex_lock(&fw_lock);
746 fw_buf = fw_priv->buf; 783 fw_priv = fw_sysfs->fw_priv;
747 if (fw_state_is_aborted(&fw_buf->fw_st)) 784 if (fw_state_is_aborted(fw_priv))
748 goto out; 785 goto out;
749 786
750 switch (loading) { 787 switch (loading) {
751 case 1: 788 case 1:
752 /* discarding any previous partial load */ 789 /* discarding any previous partial load */
753 if (!fw_state_is_done(&fw_buf->fw_st)) { 790 if (!fw_sysfs_done(fw_priv)) {
754 for (i = 0; i < fw_buf->nr_pages; i++) 791 for (i = 0; i < fw_priv->nr_pages; i++)
755 __free_page(fw_buf->pages[i]); 792 __free_page(fw_priv->pages[i]);
756 vfree(fw_buf->pages); 793 vfree(fw_priv->pages);
757 fw_buf->pages = NULL; 794 fw_priv->pages = NULL;
758 fw_buf->page_array_size = 0; 795 fw_priv->page_array_size = 0;
759 fw_buf->nr_pages = 0; 796 fw_priv->nr_pages = 0;
760 fw_state_start(&fw_buf->fw_st); 797 fw_state_start(fw_priv);
761 } 798 }
762 break; 799 break;
763 case 0: 800 case 0:
764 if (fw_state_is_loading(&fw_buf->fw_st)) { 801 if (fw_sysfs_loading(fw_priv)) {
765 int rc; 802 int rc;
766 803
767 /* 804 /*
@@ -770,25 +807,25 @@ static ssize_t firmware_loading_store(struct device *dev,
770 * see the mapped 'buf->data' once the loading 807 * see the mapped 'buf->data' once the loading
771 * is completed. 808 * is completed.
772 * */ 809 * */
773 rc = fw_map_pages_buf(fw_buf); 810 rc = map_fw_priv_pages(fw_priv);
774 if (rc) 811 if (rc)
775 dev_err(dev, "%s: map pages failed\n", 812 dev_err(dev, "%s: map pages failed\n",
776 __func__); 813 __func__);
777 else 814 else
778 rc = security_kernel_post_read_file(NULL, 815 rc = security_kernel_post_read_file(NULL,
779 fw_buf->data, fw_buf->size, 816 fw_priv->data, fw_priv->size,
780 READING_FIRMWARE); 817 READING_FIRMWARE);
781 818
782 /* 819 /*
783 * Same logic as fw_load_abort, only the DONE bit 820 * Same logic as fw_load_abort, only the DONE bit
784 * is ignored and we set ABORT only on failure. 821 * is ignored and we set ABORT only on failure.
785 */ 822 */
786 list_del_init(&fw_buf->pending_list); 823 list_del_init(&fw_priv->pending_list);
787 if (rc) { 824 if (rc) {
788 fw_state_aborted(&fw_buf->fw_st); 825 fw_state_aborted(fw_priv);
789 written = rc; 826 written = rc;
790 } else { 827 } else {
791 fw_state_done(&fw_buf->fw_st); 828 fw_state_done(fw_priv);
792 } 829 }
793 break; 830 break;
794 } 831 }
@@ -797,7 +834,7 @@ static ssize_t firmware_loading_store(struct device *dev,
797 dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading); 834 dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading);
798 /* fallthrough */ 835 /* fallthrough */
799 case -1: 836 case -1:
800 fw_load_abort(fw_priv); 837 fw_load_abort(fw_sysfs);
801 break; 838 break;
802 } 839 }
803out: 840out:
@@ -807,16 +844,16 @@ out:
807 844
808static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); 845static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store);
809 846
810static void firmware_rw_buf(struct firmware_buf *buf, char *buffer, 847static void firmware_rw_data(struct fw_priv *fw_priv, char *buffer,
811 loff_t offset, size_t count, bool read) 848 loff_t offset, size_t count, bool read)
812{ 849{
813 if (read) 850 if (read)
814 memcpy(buffer, buf->data + offset, count); 851 memcpy(buffer, fw_priv->data + offset, count);
815 else 852 else
816 memcpy(buf->data + offset, buffer, count); 853 memcpy(fw_priv->data + offset, buffer, count);
817} 854}
818 855
819static void firmware_rw(struct firmware_buf *buf, char *buffer, 856static void firmware_rw(struct fw_priv *fw_priv, char *buffer,
820 loff_t offset, size_t count, bool read) 857 loff_t offset, size_t count, bool read)
821{ 858{
822 while (count) { 859 while (count) {
@@ -825,14 +862,14 @@ static void firmware_rw(struct firmware_buf *buf, char *buffer,
825 int page_ofs = offset & (PAGE_SIZE-1); 862 int page_ofs = offset & (PAGE_SIZE-1);
826 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count); 863 int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count);
827 864
828 page_data = kmap(buf->pages[page_nr]); 865 page_data = kmap(fw_priv->pages[page_nr]);
829 866
830 if (read) 867 if (read)
831 memcpy(buffer, page_data + page_ofs, page_cnt); 868 memcpy(buffer, page_data + page_ofs, page_cnt);
832 else 869 else
833 memcpy(page_data + page_ofs, buffer, page_cnt); 870 memcpy(page_data + page_ofs, buffer, page_cnt);
834 871
835 kunmap(buf->pages[page_nr]); 872 kunmap(fw_priv->pages[page_nr]);
836 buffer += page_cnt; 873 buffer += page_cnt;
837 offset += page_cnt; 874 offset += page_cnt;
838 count -= page_cnt; 875 count -= page_cnt;
@@ -844,69 +881,69 @@ static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj,
844 char *buffer, loff_t offset, size_t count) 881 char *buffer, loff_t offset, size_t count)
845{ 882{
846 struct device *dev = kobj_to_dev(kobj); 883 struct device *dev = kobj_to_dev(kobj);
847 struct firmware_priv *fw_priv = to_firmware_priv(dev); 884 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
848 struct firmware_buf *buf; 885 struct fw_priv *fw_priv;
849 ssize_t ret_count; 886 ssize_t ret_count;
850 887
851 mutex_lock(&fw_lock); 888 mutex_lock(&fw_lock);
852 buf = fw_priv->buf; 889 fw_priv = fw_sysfs->fw_priv;
853 if (!buf || fw_state_is_done(&buf->fw_st)) { 890 if (!fw_priv || fw_sysfs_done(fw_priv)) {
854 ret_count = -ENODEV; 891 ret_count = -ENODEV;
855 goto out; 892 goto out;
856 } 893 }
857 if (offset > buf->size) { 894 if (offset > fw_priv->size) {
858 ret_count = 0; 895 ret_count = 0;
859 goto out; 896 goto out;
860 } 897 }
861 if (count > buf->size - offset) 898 if (count > fw_priv->size - offset)
862 count = buf->size - offset; 899 count = fw_priv->size - offset;
863 900
864 ret_count = count; 901 ret_count = count;
865 902
866 if (buf->data) 903 if (fw_priv->data)
867 firmware_rw_buf(buf, buffer, offset, count, true); 904 firmware_rw_data(fw_priv, buffer, offset, count, true);
868 else 905 else
869 firmware_rw(buf, buffer, offset, count, true); 906 firmware_rw(fw_priv, buffer, offset, count, true);
870 907
871out: 908out:
872 mutex_unlock(&fw_lock); 909 mutex_unlock(&fw_lock);
873 return ret_count; 910 return ret_count;
874} 911}
875 912
876static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) 913static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
877{ 914{
878 struct firmware_buf *buf = fw_priv->buf; 915 struct fw_priv *fw_priv= fw_sysfs->fw_priv;
879 int pages_needed = PAGE_ALIGN(min_size) >> PAGE_SHIFT; 916 int pages_needed = PAGE_ALIGN(min_size) >> PAGE_SHIFT;
880 917
881 /* If the array of pages is too small, grow it... */ 918 /* If the array of pages is too small, grow it... */
882 if (buf->page_array_size < pages_needed) { 919 if (fw_priv->page_array_size < pages_needed) {
883 int new_array_size = max(pages_needed, 920 int new_array_size = max(pages_needed,
884 buf->page_array_size * 2); 921 fw_priv->page_array_size * 2);
885 struct page **new_pages; 922 struct page **new_pages;
886 923
887 new_pages = vmalloc(new_array_size * sizeof(void *)); 924 new_pages = vmalloc(new_array_size * sizeof(void *));
888 if (!new_pages) { 925 if (!new_pages) {
889 fw_load_abort(fw_priv); 926 fw_load_abort(fw_sysfs);
890 return -ENOMEM; 927 return -ENOMEM;
891 } 928 }
892 memcpy(new_pages, buf->pages, 929 memcpy(new_pages, fw_priv->pages,
893 buf->page_array_size * sizeof(void *)); 930 fw_priv->page_array_size * sizeof(void *));
894 memset(&new_pages[buf->page_array_size], 0, sizeof(void *) * 931 memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) *
895 (new_array_size - buf->page_array_size)); 932 (new_array_size - fw_priv->page_array_size));
896 vfree(buf->pages); 933 vfree(fw_priv->pages);
897 buf->pages = new_pages; 934 fw_priv->pages = new_pages;
898 buf->page_array_size = new_array_size; 935 fw_priv->page_array_size = new_array_size;
899 } 936 }
900 937
901 while (buf->nr_pages < pages_needed) { 938 while (fw_priv->nr_pages < pages_needed) {
902 buf->pages[buf->nr_pages] = 939 fw_priv->pages[fw_priv->nr_pages] =
903 alloc_page(GFP_KERNEL | __GFP_HIGHMEM); 940 alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
904 941
905 if (!buf->pages[buf->nr_pages]) { 942 if (!fw_priv->pages[fw_priv->nr_pages]) {
906 fw_load_abort(fw_priv); 943 fw_load_abort(fw_sysfs);
907 return -ENOMEM; 944 return -ENOMEM;
908 } 945 }
909 buf->nr_pages++; 946 fw_priv->nr_pages++;
910 } 947 }
911 return 0; 948 return 0;
912} 949}
@@ -928,37 +965,37 @@ static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj,
928 char *buffer, loff_t offset, size_t count) 965 char *buffer, loff_t offset, size_t count)
929{ 966{
930 struct device *dev = kobj_to_dev(kobj); 967 struct device *dev = kobj_to_dev(kobj);
931 struct firmware_priv *fw_priv = to_firmware_priv(dev); 968 struct fw_sysfs *fw_sysfs = to_fw_sysfs(dev);
932 struct firmware_buf *buf; 969 struct fw_priv *fw_priv;
933 ssize_t retval; 970 ssize_t retval;
934 971
935 if (!capable(CAP_SYS_RAWIO)) 972 if (!capable(CAP_SYS_RAWIO))
936 return -EPERM; 973 return -EPERM;
937 974
938 mutex_lock(&fw_lock); 975 mutex_lock(&fw_lock);
939 buf = fw_priv->buf; 976 fw_priv = fw_sysfs->fw_priv;
940 if (!buf || fw_state_is_done(&buf->fw_st)) { 977 if (!fw_priv || fw_sysfs_done(fw_priv)) {
941 retval = -ENODEV; 978 retval = -ENODEV;
942 goto out; 979 goto out;
943 } 980 }
944 981
945 if (buf->data) { 982 if (fw_priv->data) {
946 if (offset + count > buf->allocated_size) { 983 if (offset + count > fw_priv->allocated_size) {
947 retval = -ENOMEM; 984 retval = -ENOMEM;
948 goto out; 985 goto out;
949 } 986 }
950 firmware_rw_buf(buf, buffer, offset, count, false); 987 firmware_rw_data(fw_priv, buffer, offset, count, false);
951 retval = count; 988 retval = count;
952 } else { 989 } else {
953 retval = fw_realloc_buffer(fw_priv, offset + count); 990 retval = fw_realloc_pages(fw_sysfs, offset + count);
954 if (retval) 991 if (retval)
955 goto out; 992 goto out;
956 993
957 retval = count; 994 retval = count;
958 firmware_rw(buf, buffer, offset, count, false); 995 firmware_rw(fw_priv, buffer, offset, count, false);
959 } 996 }
960 997
961 buf->size = max_t(size_t, offset + count, buf->size); 998 fw_priv->size = max_t(size_t, offset + count, fw_priv->size);
962out: 999out:
963 mutex_unlock(&fw_lock); 1000 mutex_unlock(&fw_lock);
964 return retval; 1001 return retval;
@@ -991,22 +1028,22 @@ static const struct attribute_group *fw_dev_attr_groups[] = {
991 NULL 1028 NULL
992}; 1029};
993 1030
994static struct firmware_priv * 1031static struct fw_sysfs *
995fw_create_instance(struct firmware *firmware, const char *fw_name, 1032fw_create_instance(struct firmware *firmware, const char *fw_name,
996 struct device *device, unsigned int opt_flags) 1033 struct device *device, unsigned int opt_flags)
997{ 1034{
998 struct firmware_priv *fw_priv; 1035 struct fw_sysfs *fw_sysfs;
999 struct device *f_dev; 1036 struct device *f_dev;
1000 1037
1001 fw_priv = kzalloc(sizeof(*fw_priv), GFP_KERNEL); 1038 fw_sysfs = kzalloc(sizeof(*fw_sysfs), GFP_KERNEL);
1002 if (!fw_priv) { 1039 if (!fw_sysfs) {
1003 fw_priv = ERR_PTR(-ENOMEM); 1040 fw_sysfs = ERR_PTR(-ENOMEM);
1004 goto exit; 1041 goto exit;
1005 } 1042 }
1006 1043
1007 fw_priv->nowait = !!(opt_flags & FW_OPT_NOWAIT); 1044 fw_sysfs->nowait = !!(opt_flags & FW_OPT_NOWAIT);
1008 fw_priv->fw = firmware; 1045 fw_sysfs->fw = firmware;
1009 f_dev = &fw_priv->dev; 1046 f_dev = &fw_sysfs->dev;
1010 1047
1011 device_initialize(f_dev); 1048 device_initialize(f_dev);
1012 dev_set_name(f_dev, "%s", fw_name); 1049 dev_set_name(f_dev, "%s", fw_name);
@@ -1014,20 +1051,20 @@ fw_create_instance(struct firmware *firmware, const char *fw_name,
1014 f_dev->class = &firmware_class; 1051 f_dev->class = &firmware_class;
1015 f_dev->groups = fw_dev_attr_groups; 1052 f_dev->groups = fw_dev_attr_groups;
1016exit: 1053exit:
1017 return fw_priv; 1054 return fw_sysfs;
1018} 1055}
1019 1056
1020/* load a firmware via user helper */ 1057/* load a firmware via user helper */
1021static int _request_firmware_load(struct firmware_priv *fw_priv, 1058static int _request_firmware_load(struct fw_sysfs *fw_sysfs,
1022 unsigned int opt_flags, long timeout) 1059 unsigned int opt_flags, long timeout)
1023{ 1060{
1024 int retval = 0; 1061 int retval = 0;
1025 struct device *f_dev = &fw_priv->dev; 1062 struct device *f_dev = &fw_sysfs->dev;
1026 struct firmware_buf *buf = fw_priv->buf; 1063 struct fw_priv *fw_priv = fw_sysfs->fw_priv;
1027 1064
1028 /* fall back on userspace loading */ 1065 /* fall back on userspace loading */
1029 if (!buf->data) 1066 if (!fw_priv->data)
1030 buf->is_paged_buf = true; 1067 fw_priv->is_paged_buf = true;
1031 1068
1032 dev_set_uevent_suppress(f_dev, true); 1069 dev_set_uevent_suppress(f_dev, true);
1033 1070
@@ -1038,31 +1075,31 @@ static int _request_firmware_load(struct firmware_priv *fw_priv,
1038 } 1075 }
1039 1076
1040 mutex_lock(&fw_lock); 1077 mutex_lock(&fw_lock);
1041 list_add(&buf->pending_list, &pending_fw_head); 1078 list_add(&fw_priv->pending_list, &pending_fw_head);
1042 mutex_unlock(&fw_lock); 1079 mutex_unlock(&fw_lock);
1043 1080
1044 if (opt_flags & FW_OPT_UEVENT) { 1081 if (opt_flags & FW_OPT_UEVENT) {
1045 buf->need_uevent = true; 1082 fw_priv->need_uevent = true;
1046 dev_set_uevent_suppress(f_dev, false); 1083 dev_set_uevent_suppress(f_dev, false);
1047 dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id); 1084 dev_dbg(f_dev, "firmware: requesting %s\n", fw_priv->fw_name);
1048 kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); 1085 kobject_uevent(&fw_sysfs->dev.kobj, KOBJ_ADD);
1049 } else { 1086 } else {
1050 timeout = MAX_JIFFY_OFFSET; 1087 timeout = MAX_JIFFY_OFFSET;
1051 } 1088 }
1052 1089
1053 retval = fw_state_wait_timeout(&buf->fw_st, timeout); 1090 retval = fw_sysfs_wait_timeout(fw_priv, timeout);
1054 if (retval < 0) { 1091 if (retval < 0) {
1055 mutex_lock(&fw_lock); 1092 mutex_lock(&fw_lock);
1056 fw_load_abort(fw_priv); 1093 fw_load_abort(fw_sysfs);
1057 mutex_unlock(&fw_lock); 1094 mutex_unlock(&fw_lock);
1058 } 1095 }
1059 1096
1060 if (fw_state_is_aborted(&buf->fw_st)) { 1097 if (fw_state_is_aborted(fw_priv)) {
1061 if (retval == -ERESTARTSYS) 1098 if (retval == -ERESTARTSYS)
1062 retval = -EINTR; 1099 retval = -EINTR;
1063 else 1100 else
1064 retval = -EAGAIN; 1101 retval = -EAGAIN;
1065 } else if (buf->is_paged_buf && !buf->data) 1102 } else if (fw_priv->is_paged_buf && !fw_priv->data)
1066 retval = -ENOMEM; 1103 retval = -ENOMEM;
1067 1104
1068 device_del(f_dev); 1105 device_del(f_dev);
@@ -1075,7 +1112,7 @@ static int fw_load_from_user_helper(struct firmware *firmware,
1075 const char *name, struct device *device, 1112 const char *name, struct device *device,
1076 unsigned int opt_flags) 1113 unsigned int opt_flags)
1077{ 1114{
1078 struct firmware_priv *fw_priv; 1115 struct fw_sysfs *fw_sysfs;
1079 long timeout; 1116 long timeout;
1080 int ret; 1117 int ret;
1081 1118
@@ -1096,17 +1133,17 @@ static int fw_load_from_user_helper(struct firmware *firmware,
1096 } 1133 }
1097 } 1134 }
1098 1135
1099 fw_priv = fw_create_instance(firmware, name, device, opt_flags); 1136 fw_sysfs = fw_create_instance(firmware, name, device, opt_flags);
1100 if (IS_ERR(fw_priv)) { 1137 if (IS_ERR(fw_sysfs)) {
1101 ret = PTR_ERR(fw_priv); 1138 ret = PTR_ERR(fw_sysfs);
1102 goto out_unlock; 1139 goto out_unlock;
1103 } 1140 }
1104 1141
1105 fw_priv->buf = firmware->priv; 1142 fw_sysfs->fw_priv = firmware->priv;
1106 ret = _request_firmware_load(fw_priv, opt_flags, timeout); 1143 ret = _request_firmware_load(fw_sysfs, opt_flags, timeout);
1107 1144
1108 if (!ret) 1145 if (!ret)
1109 ret = assign_firmware_buf(firmware, device, opt_flags); 1146 ret = assign_fw(firmware, device, opt_flags);
1110 1147
1111out_unlock: 1148out_unlock:
1112 usermodehelper_read_unlock(); 1149 usermodehelper_read_unlock();
@@ -1114,16 +1151,60 @@ out_unlock:
1114 return ret; 1151 return ret;
1115} 1152}
1116 1153
1154#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
1155static bool fw_force_sysfs_fallback(unsigned int opt_flags)
1156{
1157 return true;
1158}
1159#else
1160static bool fw_force_sysfs_fallback(unsigned int opt_flags)
1161{
1162 if (!(opt_flags & FW_OPT_USERHELPER))
1163 return false;
1164 return true;
1165}
1166#endif
1167
1168static bool fw_run_sysfs_fallback(unsigned int opt_flags)
1169{
1170 if ((opt_flags & FW_OPT_NOFALLBACK))
1171 return false;
1172
1173 return fw_force_sysfs_fallback(opt_flags);
1174}
1175
1176static int fw_sysfs_fallback(struct firmware *fw, const char *name,
1177 struct device *device,
1178 unsigned int opt_flags,
1179 int ret)
1180{
1181 if (!fw_run_sysfs_fallback(opt_flags))
1182 return ret;
1183
1184 dev_warn(device, "Falling back to user helper\n");
1185 return fw_load_from_user_helper(fw, name, device, opt_flags);
1186}
1117#else /* CONFIG_FW_LOADER_USER_HELPER */ 1187#else /* CONFIG_FW_LOADER_USER_HELPER */
1118static inline int 1188static int fw_sysfs_fallback(struct firmware *fw, const char *name,
1119fw_load_from_user_helper(struct firmware *firmware, const char *name, 1189 struct device *device,
1120 struct device *device, unsigned int opt_flags) 1190 unsigned int opt_flags,
1191 int ret)
1121{ 1192{
1122 return -ENOENT; 1193 /* Keep carrying over the same error */
1194 return ret;
1123} 1195}
1124 1196
1125static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } 1197static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
1126 1198
1199static inline int register_sysfs_loader(void)
1200{
1201 return 0;
1202}
1203
1204static inline void unregister_sysfs_loader(void)
1205{
1206}
1207
1127#endif /* CONFIG_FW_LOADER_USER_HELPER */ 1208#endif /* CONFIG_FW_LOADER_USER_HELPER */
1128 1209
1129/* prepare firmware and firmware_buf structs; 1210/* prepare firmware and firmware_buf structs;
@@ -1135,7 +1216,7 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
1135 struct device *device, void *dbuf, size_t size) 1216 struct device *device, void *dbuf, size_t size)
1136{ 1217{
1137 struct firmware *firmware; 1218 struct firmware *firmware;
1138 struct firmware_buf *buf; 1219 struct fw_priv *fw_priv;
1139 int ret; 1220 int ret;
1140 1221
1141 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); 1222 *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL);
@@ -1150,18 +1231,18 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
1150 return 0; /* assigned */ 1231 return 0; /* assigned */
1151 } 1232 }
1152 1233
1153 ret = fw_lookup_and_allocate_buf(name, &fw_cache, &buf, dbuf, size); 1234 ret = alloc_lookup_fw_priv(name, &fw_cache, &fw_priv, dbuf, size);
1154 1235
1155 /* 1236 /*
1156 * bind with 'buf' now to avoid warning in failure path 1237 * bind with 'priv' now to avoid warning in failure path
1157 * of requesting firmware. 1238 * of requesting firmware.
1158 */ 1239 */
1159 firmware->priv = buf; 1240 firmware->priv = fw_priv;
1160 1241
1161 if (ret > 0) { 1242 if (ret > 0) {
1162 ret = fw_state_wait(&buf->fw_st); 1243 ret = fw_state_wait(fw_priv);
1163 if (!ret) { 1244 if (!ret) {
1164 fw_set_page_data(buf, firmware); 1245 fw_set_page_data(fw_priv, firmware);
1165 return 0; /* assigned */ 1246 return 0; /* assigned */
1166 } 1247 }
1167 } 1248 }
@@ -1177,20 +1258,20 @@ _request_firmware_prepare(struct firmware **firmware_p, const char *name,
1177 * released until the last user calls release_firmware(). 1258 * released until the last user calls release_firmware().
1178 * 1259 *
1179 * Failed batched requests are possible as well, in such cases we just share 1260 * Failed batched requests are possible as well, in such cases we just share
1180 * the struct firmware_buf and won't release it until all requests are woken 1261 * the struct fw_priv and won't release it until all requests are woken
1181 * and have gone through this same path. 1262 * and have gone through this same path.
1182 */ 1263 */
1183static void fw_abort_batch_reqs(struct firmware *fw) 1264static void fw_abort_batch_reqs(struct firmware *fw)
1184{ 1265{
1185 struct firmware_buf *buf; 1266 struct fw_priv *fw_priv;
1186 1267
1187 /* Loaded directly? */ 1268 /* Loaded directly? */
1188 if (!fw || !fw->priv) 1269 if (!fw || !fw->priv)
1189 return; 1270 return;
1190 1271
1191 buf = fw->priv; 1272 fw_priv = fw->priv;
1192 if (!fw_state_is_aborted(&buf->fw_st)) 1273 if (!fw_state_is_aborted(fw_priv))
1193 fw_state_aborted(&buf->fw_st); 1274 fw_state_aborted(fw_priv);
1194} 1275}
1195 1276
1196/* called from request_firmware() and request_firmware_work_func() */ 1277/* called from request_firmware() and request_firmware_work_func() */
@@ -1220,13 +1301,9 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
1220 dev_warn(device, 1301 dev_warn(device,
1221 "Direct firmware load for %s failed with error %d\n", 1302 "Direct firmware load for %s failed with error %d\n",
1222 name, ret); 1303 name, ret);
1223 if (opt_flags & FW_OPT_USERHELPER) { 1304 ret = fw_sysfs_fallback(fw, name, device, opt_flags, ret);
1224 dev_warn(device, "Falling back to user helper\n");
1225 ret = fw_load_from_user_helper(fw, name, device,
1226 opt_flags);
1227 }
1228 } else 1305 } else
1229 ret = assign_firmware_buf(fw, device, opt_flags); 1306 ret = assign_fw(fw, device, opt_flags);
1230 1307
1231 out: 1308 out:
1232 if (ret < 0) { 1309 if (ret < 0) {
@@ -1268,7 +1345,7 @@ request_firmware(const struct firmware **firmware_p, const char *name,
1268 /* Need to pin this module until return */ 1345 /* Need to pin this module until return */
1269 __module_get(THIS_MODULE); 1346 __module_get(THIS_MODULE);
1270 ret = _request_firmware(firmware_p, name, device, NULL, 0, 1347 ret = _request_firmware(firmware_p, name, device, NULL, 0,
1271 FW_OPT_UEVENT | FW_OPT_FALLBACK); 1348 FW_OPT_UEVENT);
1272 module_put(THIS_MODULE); 1349 module_put(THIS_MODULE);
1273 return ret; 1350 return ret;
1274} 1351}
@@ -1292,7 +1369,8 @@ int request_firmware_direct(const struct firmware **firmware_p,
1292 1369
1293 __module_get(THIS_MODULE); 1370 __module_get(THIS_MODULE);
1294 ret = _request_firmware(firmware_p, name, device, NULL, 0, 1371 ret = _request_firmware(firmware_p, name, device, NULL, 0,
1295 FW_OPT_UEVENT | FW_OPT_NO_WARN); 1372 FW_OPT_UEVENT | FW_OPT_NO_WARN |
1373 FW_OPT_NOFALLBACK);
1296 module_put(THIS_MODULE); 1374 module_put(THIS_MODULE);
1297 return ret; 1375 return ret;
1298} 1376}
@@ -1321,8 +1399,7 @@ request_firmware_into_buf(const struct firmware **firmware_p, const char *name,
1321 1399
1322 __module_get(THIS_MODULE); 1400 __module_get(THIS_MODULE);
1323 ret = _request_firmware(firmware_p, name, device, buf, size, 1401 ret = _request_firmware(firmware_p, name, device, buf, size,
1324 FW_OPT_UEVENT | FW_OPT_FALLBACK | 1402 FW_OPT_UEVENT | FW_OPT_NOCACHE);
1325 FW_OPT_NOCACHE);
1326 module_put(THIS_MODULE); 1403 module_put(THIS_MODULE);
1327 return ret; 1404 return ret;
1328} 1405}
@@ -1414,7 +1491,7 @@ request_firmware_nowait(
1414 fw_work->device = device; 1491 fw_work->device = device;
1415 fw_work->context = context; 1492 fw_work->context = context;
1416 fw_work->cont = cont; 1493 fw_work->cont = cont;
1417 fw_work->opt_flags = FW_OPT_NOWAIT | FW_OPT_FALLBACK | 1494 fw_work->opt_flags = FW_OPT_NOWAIT |
1418 (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER); 1495 (uevent ? FW_OPT_UEVENT : FW_OPT_USERHELPER);
1419 1496
1420 if (!try_module_get(module)) { 1497 if (!try_module_get(module)) {
@@ -1463,13 +1540,13 @@ static int cache_firmware(const char *fw_name)
1463 return ret; 1540 return ret;
1464} 1541}
1465 1542
1466static struct firmware_buf *fw_lookup_buf(const char *fw_name) 1543static struct fw_priv *lookup_fw_priv(const char *fw_name)
1467{ 1544{
1468 struct firmware_buf *tmp; 1545 struct fw_priv *tmp;
1469 struct firmware_cache *fwc = &fw_cache; 1546 struct firmware_cache *fwc = &fw_cache;
1470 1547
1471 spin_lock(&fwc->lock); 1548 spin_lock(&fwc->lock);
1472 tmp = __fw_lookup_buf(fw_name); 1549 tmp = __lookup_fw_priv(fw_name);
1473 spin_unlock(&fwc->lock); 1550 spin_unlock(&fwc->lock);
1474 1551
1475 return tmp; 1552 return tmp;
@@ -1488,7 +1565,7 @@ static struct firmware_buf *fw_lookup_buf(const char *fw_name)
1488 */ 1565 */
1489static int uncache_firmware(const char *fw_name) 1566static int uncache_firmware(const char *fw_name)
1490{ 1567{
1491 struct firmware_buf *buf; 1568 struct fw_priv *fw_priv;
1492 struct firmware fw; 1569 struct firmware fw;
1493 1570
1494 pr_debug("%s: %s\n", __func__, fw_name); 1571 pr_debug("%s: %s\n", __func__, fw_name);
@@ -1496,9 +1573,9 @@ static int uncache_firmware(const char *fw_name)
1496 if (fw_get_builtin_firmware(&fw, fw_name, NULL, 0)) 1573 if (fw_get_builtin_firmware(&fw, fw_name, NULL, 0))
1497 return 0; 1574 return 0;
1498 1575
1499 buf = fw_lookup_buf(fw_name); 1576 fw_priv = lookup_fw_priv(fw_name);
1500 if (buf) { 1577 if (fw_priv) {
1501 fw_free_buf(buf); 1578 free_fw_priv(fw_priv);
1502 return 0; 1579 return 0;
1503 } 1580 }
1504 1581
@@ -1767,20 +1844,11 @@ static int fw_suspend(void)
1767static struct syscore_ops fw_syscore_ops = { 1844static struct syscore_ops fw_syscore_ops = {
1768 .suspend = fw_suspend, 1845 .suspend = fw_suspend,
1769}; 1846};
1770#else
1771static int fw_cache_piggyback_on_request(const char *name)
1772{
1773 return 0;
1774}
1775#endif
1776 1847
1777static void __init fw_cache_init(void) 1848static int __init register_fw_pm_ops(void)
1778{ 1849{
1779 spin_lock_init(&fw_cache.lock); 1850 int ret;
1780 INIT_LIST_HEAD(&fw_cache.head);
1781 fw_cache.state = FW_LOADER_NO_CACHE;
1782 1851
1783#ifdef CONFIG_PM_SLEEP
1784 spin_lock_init(&fw_cache.name_lock); 1852 spin_lock_init(&fw_cache.name_lock);
1785 INIT_LIST_HEAD(&fw_cache.fw_names); 1853 INIT_LIST_HEAD(&fw_cache.fw_names);
1786 1854
@@ -1788,10 +1856,39 @@ static void __init fw_cache_init(void)
1788 device_uncache_fw_images_work); 1856 device_uncache_fw_images_work);
1789 1857
1790 fw_cache.pm_notify.notifier_call = fw_pm_notify; 1858 fw_cache.pm_notify.notifier_call = fw_pm_notify;
1791 register_pm_notifier(&fw_cache.pm_notify); 1859 ret = register_pm_notifier(&fw_cache.pm_notify);
1860 if (ret)
1861 return ret;
1792 1862
1793 register_syscore_ops(&fw_syscore_ops); 1863 register_syscore_ops(&fw_syscore_ops);
1864
1865 return ret;
1866}
1867
1868static inline void unregister_fw_pm_ops(void)
1869{
1870 unregister_syscore_ops(&fw_syscore_ops);
1871 unregister_pm_notifier(&fw_cache.pm_notify);
1872}
1873#else
1874static int fw_cache_piggyback_on_request(const char *name)
1875{
1876 return 0;
1877}
1878static inline int register_fw_pm_ops(void)
1879{
1880 return 0;
1881}
1882static inline void unregister_fw_pm_ops(void)
1883{
1884}
1794#endif 1885#endif
1886
1887static void __init fw_cache_init(void)
1888{
1889 spin_lock_init(&fw_cache.lock);
1890 INIT_LIST_HEAD(&fw_cache.head);
1891 fw_cache.state = FW_LOADER_NO_CACHE;
1795} 1892}
1796 1893
1797static int fw_shutdown_notify(struct notifier_block *unused1, 1894static int fw_shutdown_notify(struct notifier_block *unused1,
@@ -1812,25 +1909,31 @@ static struct notifier_block fw_shutdown_nb = {
1812 1909
1813static int __init firmware_class_init(void) 1910static int __init firmware_class_init(void)
1814{ 1911{
1912 int ret;
1913
1914 /* No need to unfold these on exit */
1815 fw_cache_init(); 1915 fw_cache_init();
1816 register_reboot_notifier(&fw_shutdown_nb); 1916
1817#ifdef CONFIG_FW_LOADER_USER_HELPER 1917 ret = register_fw_pm_ops();
1818 return class_register(&firmware_class); 1918 if (ret)
1819#else 1919 return ret;
1820 return 0; 1920
1821#endif 1921 ret = register_reboot_notifier(&fw_shutdown_nb);
1922 if (ret)
1923 goto out;
1924
1925 return register_sysfs_loader();
1926
1927out:
1928 unregister_fw_pm_ops();
1929 return ret;
1822} 1930}
1823 1931
1824static void __exit firmware_class_exit(void) 1932static void __exit firmware_class_exit(void)
1825{ 1933{
1826#ifdef CONFIG_PM_SLEEP 1934 unregister_fw_pm_ops();
1827 unregister_syscore_ops(&fw_syscore_ops);
1828 unregister_pm_notifier(&fw_cache.pm_notify);
1829#endif
1830 unregister_reboot_notifier(&fw_shutdown_nb); 1935 unregister_reboot_notifier(&fw_shutdown_nb);
1831#ifdef CONFIG_FW_LOADER_USER_HELPER 1936 unregister_sysfs_loader();
1832 class_unregister(&firmware_class);
1833#endif
1834} 1937}
1835 1938
1836fs_initcall(firmware_class_init); 1939fs_initcall(firmware_class_init);
diff --git a/drivers/base/hypervisor.c b/drivers/base/hypervisor.c
index 4f8b741f4615..1ce59b4b53ce 100644
--- a/drivers/base/hypervisor.c
+++ b/drivers/base/hypervisor.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * hypervisor.c - /sys/hypervisor subsystem. 3 * hypervisor.c - /sys/hypervisor subsystem.
3 * 4 *
4 * Copyright (C) IBM Corp. 2006 5 * Copyright (C) IBM Corp. 2006
5 * Copyright (C) 2007 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (C) 2007 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (C) 2007 Novell Inc. 7 * Copyright (C) 2007 Novell Inc.
7 *
8 * This file is released under the GPLv2
9 */ 8 */
10 9
11#include <linux/kobject.h> 10#include <linux/kobject.h>
diff --git a/drivers/base/init.c b/drivers/base/init.c
index 48c0e220acc0..dd85b05a6a16 100644
--- a/drivers/base/init.c
+++ b/drivers/base/init.c
@@ -1,8 +1,7 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (c) 2002-3 Patrick Mochel 3 * Copyright (c) 2002-3 Patrick Mochel
3 * Copyright (c) 2002-3 Open Source Development Labs 4 * Copyright (c) 2002-3 Open Source Development Labs
4 *
5 * This file is released under the GPLv2
6 */ 5 */
7 6
8#include <linux/device.h> 7#include <linux/device.h>
diff --git a/drivers/base/isa.c b/drivers/base/isa.c
index 372d10af2600..2772f5d1948a 100644
--- a/drivers/base/isa.c
+++ b/drivers/base/isa.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * ISA bus. 3 * ISA bus.
3 */ 4 */
diff --git a/drivers/base/map.c b/drivers/base/map.c
index c1d38234d725..5650ab2b247a 100644
--- a/drivers/base/map.c
+++ b/drivers/base/map.c
@@ -1,8 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * linux/drivers/base/map.c 3 * linux/drivers/base/map.c
3 * 4 *
4 * (C) Copyright Al Viro 2002,2003 5 * (C) Copyright Al Viro 2002,2003
5 * Released under GPL v2.
6 * 6 *
7 * NOTE: data structure needs to be changed. It works, but for large dev_t 7 * NOTE: data structure needs to be changed. It works, but for large dev_t
8 * it will be too slow. It is isolated, though, so these changes will be 8 * it will be too slow. It is isolated, though, so these changes will be
diff --git a/drivers/base/module.c b/drivers/base/module.c
index 2a215780eda2..46ad4d636731 100644
--- a/drivers/base/module.c
+++ b/drivers/base/module.c
@@ -1,8 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * module.c - module sysfs fun for drivers 3 * module.c - module sysfs fun for drivers
3 *
4 * This file is released under the GPLv2
5 *
6 */ 4 */
7#include <linux/device.h> 5#include <linux/device.h>
8#include <linux/module.h> 6#include <linux/module.h>
diff --git a/drivers/base/pinctrl.c b/drivers/base/pinctrl.c
index eb929dd6ef1e..c22864458511 100644
--- a/drivers/base/pinctrl.c
+++ b/drivers/base/pinctrl.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Driver core interface to the pinctrl subsystem. 3 * Driver core interface to the pinctrl subsystem.
3 * 4 *
@@ -6,8 +7,6 @@
6 * Based on bits of regulator core, gpio core and clk core 7 * Based on bits of regulator core, gpio core and clk core
7 * 8 *
8 * Author: Linus Walleij <linus.walleij@linaro.org> 9 * Author: Linus Walleij <linus.walleij@linaro.org>
9 *
10 * License terms: GNU General Public License (GPL) version 2
11 */ 10 */
12 11
13#include <linux/device.h> 12#include <linux/device.h>
diff --git a/drivers/base/platform-msi.c b/drivers/base/platform-msi.c
index e5473525e7b2..8e22073aeeed 100644
--- a/drivers/base/platform-msi.c
+++ b/drivers/base/platform-msi.c
@@ -1,20 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * MSI framework for platform devices 3 * MSI framework for platform devices
3 * 4 *
4 * Copyright (C) 2015 ARM Limited, All Rights Reserved. 5 * Copyright (C) 2015 ARM Limited, All Rights Reserved.
5 * Author: Marc Zyngier <marc.zyngier@arm.com> 6 * Author: Marc Zyngier <marc.zyngier@arm.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */ 7 */
19 8
20#include <linux/device.h> 9#include <linux/device.h>
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index c203fb90c1a0..f1bf7b38d91c 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * platform.c - platform 'pseudo' bus for legacy devices 3 * platform.c - platform 'pseudo' bus for legacy devices
3 * 4 *
4 * Copyright (c) 2002-3 Patrick Mochel 5 * Copyright (c) 2002-3 Patrick Mochel
5 * Copyright (c) 2002-3 Open Source Development Labs 6 * Copyright (c) 2002-3 Open Source Development Labs
6 * 7 *
7 * This file is released under the GPLv2
8 *
9 * Please see Documentation/driver-model/platform.txt for more 8 * Please see Documentation/driver-model/platform.txt for more
10 * information. 9 * information.
11 */ 10 */
diff --git a/drivers/base/property.c b/drivers/base/property.c
index 96aa71c93daf..302236281d83 100644
--- a/drivers/base/property.c
+++ b/drivers/base/property.c
@@ -1,13 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * property.c - Unified device property interface. 3 * property.c - Unified device property interface.
3 * 4 *
4 * Copyright (C) 2014, Intel Corporation 5 * Copyright (C) 2014, Intel Corporation
5 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com> 6 * Authors: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
6 * Mika Westerberg <mika.westerberg@linux.intel.com> 7 * Mika Westerberg <mika.westerberg@linux.intel.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */ 8 */
12 9
13#include <linux/acpi.h> 10#include <linux/acpi.h>
@@ -699,6 +696,23 @@ int fwnode_property_get_reference_args(const struct fwnode_handle *fwnode,
699} 696}
700EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args); 697EXPORT_SYMBOL_GPL(fwnode_property_get_reference_args);
701 698
699static void property_entry_free_data(const struct property_entry *p)
700{
701 size_t i, nval;
702
703 if (p->is_array) {
704 if (p->is_string && p->pointer.str) {
705 nval = p->length / sizeof(const char *);
706 for (i = 0; i < nval; i++)
707 kfree(p->pointer.str[i]);
708 }
709 kfree(p->pointer.raw_data);
710 } else if (p->is_string) {
711 kfree(p->value.str);
712 }
713 kfree(p->name);
714}
715
702static int property_copy_string_array(struct property_entry *dst, 716static int property_copy_string_array(struct property_entry *dst,
703 const struct property_entry *src) 717 const struct property_entry *src)
704{ 718{
@@ -729,34 +743,24 @@ static int property_entry_copy_data(struct property_entry *dst,
729{ 743{
730 int error; 744 int error;
731 745
732 dst->name = kstrdup(src->name, GFP_KERNEL);
733 if (!dst->name)
734 return -ENOMEM;
735
736 if (src->is_array) { 746 if (src->is_array) {
737 if (!src->length) { 747 if (!src->length)
738 error = -ENODATA; 748 return -ENODATA;
739 goto out_free_name;
740 }
741 749
742 if (src->is_string) { 750 if (src->is_string) {
743 error = property_copy_string_array(dst, src); 751 error = property_copy_string_array(dst, src);
744 if (error) 752 if (error)
745 goto out_free_name; 753 return error;
746 } else { 754 } else {
747 dst->pointer.raw_data = kmemdup(src->pointer.raw_data, 755 dst->pointer.raw_data = kmemdup(src->pointer.raw_data,
748 src->length, GFP_KERNEL); 756 src->length, GFP_KERNEL);
749 if (!dst->pointer.raw_data) { 757 if (!dst->pointer.raw_data)
750 error = -ENOMEM; 758 return -ENOMEM;
751 goto out_free_name;
752 }
753 } 759 }
754 } else if (src->is_string) { 760 } else if (src->is_string) {
755 dst->value.str = kstrdup(src->value.str, GFP_KERNEL); 761 dst->value.str = kstrdup(src->value.str, GFP_KERNEL);
756 if (!dst->value.str && src->value.str) { 762 if (!dst->value.str && src->value.str)
757 error = -ENOMEM; 763 return -ENOMEM;
758 goto out_free_name;
759 }
760 } else { 764 } else {
761 dst->value.raw_data = src->value.raw_data; 765 dst->value.raw_data = src->value.raw_data;
762 } 766 }
@@ -765,28 +769,15 @@ static int property_entry_copy_data(struct property_entry *dst,
765 dst->is_array = src->is_array; 769 dst->is_array = src->is_array;
766 dst->is_string = src->is_string; 770 dst->is_string = src->is_string;
767 771
768 return 0; 772 dst->name = kstrdup(src->name, GFP_KERNEL);
769 773 if (!dst->name)
770out_free_name: 774 goto out_free_data;
771 kfree(dst->name);
772 return error;
773}
774 775
775static void property_entry_free_data(const struct property_entry *p) 776 return 0;
776{
777 size_t i, nval;
778 777
779 if (p->is_array) { 778out_free_data:
780 if (p->is_string && p->pointer.str) { 779 property_entry_free_data(dst);
781 nval = p->length / sizeof(const char *); 780 return -ENOMEM;
782 for (i = 0; i < nval; i++)
783 kfree(p->pointer.str[i]);
784 }
785 kfree(p->pointer.raw_data);
786 } else if (p->is_string) {
787 kfree(p->value.str);
788 }
789 kfree(p->name);
790} 781}
791 782
792/** 783/**
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 909dedae4c4e..4e80f48ad5d6 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -1,8 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) ST-Ericsson SA 2011 3 * Copyright (C) ST-Ericsson SA 2011
3 * 4 *
4 * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson. 5 * Author: Lee Jones <lee.jones@linaro.org> for ST-Ericsson.
5 * License terms: GNU General Public License (GPL), version 2
6 */ 6 */
7 7
8#include <linux/sysfs.h> 8#include <linux/sysfs.h>
diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
index 8d98a329f6ea..6e076f359dcc 100644
--- a/drivers/base/syscore.c
+++ b/drivers/base/syscore.c
@@ -1,9 +1,8 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * syscore.c - Execution of system core operations. 3 * syscore.c - Execution of system core operations.
3 * 4 *
4 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc. 5 * Copyright (C) 2011 Rafael J. Wysocki <rjw@sisk.pl>, Novell Inc.
5 *
6 * This file is released under the GPLv2.
7 */ 6 */
8 7
9#include <linux/syscore_ops.h> 8#include <linux/syscore_ops.h>
diff --git a/drivers/base/test/test_async_driver_probe.c b/drivers/base/test/test_async_driver_probe.c
index a3355d66bc12..e7f145d662f0 100644
--- a/drivers/base/test/test_async_driver_probe.c
+++ b/drivers/base/test/test_async_driver_probe.c
@@ -1,14 +1,6 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Copyright (C) 2014 Google, Inc. 3 * Copyright (C) 2014 Google, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */ 4 */
13 5
14#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt 6#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index d936fcf9f1fb..5fd9f167ecc1 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0+
1/* 2/*
2 * driver/base/topology.c - Populate sysfs with cpu topology information 3 * driver/base/topology.c - Populate sysfs with cpu topology information
3 * 4 *
@@ -6,22 +7,6 @@
6 * Copyright (C) 2006, Intel Corp. 7 * Copyright (C) 2006, Intel Corp.
7 * 8 *
8 * All rights reserved. 9 * All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
18 * NON INFRINGEMENT. See the GNU General Public License for more
19 * details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 *
25 */ 10 */
26#include <linux/mm.h> 11#include <linux/mm.h>
27#include <linux/cpu.h> 12#include <linux/cpu.h>
diff --git a/drivers/base/transport_class.c b/drivers/base/transport_class.c
index f6c453c3816e..5ed86ded6e6b 100644
--- a/drivers/base/transport_class.c
+++ b/drivers/base/transport_class.c
@@ -1,11 +1,10 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * transport_class.c - implementation of generic transport classes 3 * transport_class.c - implementation of generic transport classes
3 * using attribute_containers 4 * using attribute_containers
4 * 5 *
5 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com> 6 * Copyright (c) 2005 - James Bottomley <James.Bottomley@steeleye.com>
6 * 7 *
7 * This file is licensed under GPLv2
8 *
9 * The basic idea here is to allow any "device controller" (which 8 * The basic idea here is to allow any "device controller" (which
10 * would most often be a Host Bus Adapter to use the services of one 9 * would most often be a Host Bus Adapter to use the services of one
11 * or more tranport classes for performing transport specific 10 * or more tranport classes for performing transport specific
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 01fbffb3168e..e0b0d7e2d976 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2588,7 +2588,7 @@ static ssize_t device_id_show(struct device *dev,
2588 2588
2589 return snprintf(buf, 10, "%u\n", id.device_id); 2589 return snprintf(buf, 10, "%u\n", id.device_id);
2590} 2590}
2591static DEVICE_ATTR(device_id, S_IRUGO, device_id_show, NULL); 2591static DEVICE_ATTR_RO(device_id);
2592 2592
2593static ssize_t provides_device_sdrs_show(struct device *dev, 2593static ssize_t provides_device_sdrs_show(struct device *dev,
2594 struct device_attribute *attr, 2594 struct device_attribute *attr,
@@ -2604,8 +2604,7 @@ static ssize_t provides_device_sdrs_show(struct device *dev,
2604 2604
2605 return snprintf(buf, 10, "%u\n", (id.device_revision & 0x80) >> 7); 2605 return snprintf(buf, 10, "%u\n", (id.device_revision & 0x80) >> 7);
2606} 2606}
2607static DEVICE_ATTR(provides_device_sdrs, S_IRUGO, provides_device_sdrs_show, 2607static DEVICE_ATTR_RO(provides_device_sdrs);
2608 NULL);
2609 2608
2610static ssize_t revision_show(struct device *dev, struct device_attribute *attr, 2609static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
2611 char *buf) 2610 char *buf)
@@ -2620,7 +2619,7 @@ static ssize_t revision_show(struct device *dev, struct device_attribute *attr,
2620 2619
2621 return snprintf(buf, 20, "%u\n", id.device_revision & 0x0F); 2620 return snprintf(buf, 20, "%u\n", id.device_revision & 0x0F);
2622} 2621}
2623static DEVICE_ATTR(revision, S_IRUGO, revision_show, NULL); 2622static DEVICE_ATTR_RO(revision);
2624 2623
2625static ssize_t firmware_revision_show(struct device *dev, 2624static ssize_t firmware_revision_show(struct device *dev,
2626 struct device_attribute *attr, 2625 struct device_attribute *attr,
@@ -2637,7 +2636,7 @@ static ssize_t firmware_revision_show(struct device *dev,
2637 return snprintf(buf, 20, "%u.%x\n", id.firmware_revision_1, 2636 return snprintf(buf, 20, "%u.%x\n", id.firmware_revision_1,
2638 id.firmware_revision_2); 2637 id.firmware_revision_2);
2639} 2638}
2640static DEVICE_ATTR(firmware_revision, S_IRUGO, firmware_revision_show, NULL); 2639static DEVICE_ATTR_RO(firmware_revision);
2641 2640
2642static ssize_t ipmi_version_show(struct device *dev, 2641static ssize_t ipmi_version_show(struct device *dev,
2643 struct device_attribute *attr, 2642 struct device_attribute *attr,
@@ -2655,7 +2654,7 @@ static ssize_t ipmi_version_show(struct device *dev,
2655 ipmi_version_major(&id), 2654 ipmi_version_major(&id),
2656 ipmi_version_minor(&id)); 2655 ipmi_version_minor(&id));
2657} 2656}
2658static DEVICE_ATTR(ipmi_version, S_IRUGO, ipmi_version_show, NULL); 2657static DEVICE_ATTR_RO(ipmi_version);
2659 2658
2660static ssize_t add_dev_support_show(struct device *dev, 2659static ssize_t add_dev_support_show(struct device *dev,
2661 struct device_attribute *attr, 2660 struct device_attribute *attr,
@@ -2688,7 +2687,7 @@ static ssize_t manufacturer_id_show(struct device *dev,
2688 2687
2689 return snprintf(buf, 20, "0x%6.6x\n", id.manufacturer_id); 2688 return snprintf(buf, 20, "0x%6.6x\n", id.manufacturer_id);
2690} 2689}
2691static DEVICE_ATTR(manufacturer_id, S_IRUGO, manufacturer_id_show, NULL); 2690static DEVICE_ATTR_RO(manufacturer_id);
2692 2691
2693static ssize_t product_id_show(struct device *dev, 2692static ssize_t product_id_show(struct device *dev,
2694 struct device_attribute *attr, 2693 struct device_attribute *attr,
@@ -2704,7 +2703,7 @@ static ssize_t product_id_show(struct device *dev,
2704 2703
2705 return snprintf(buf, 10, "0x%4.4x\n", id.product_id); 2704 return snprintf(buf, 10, "0x%4.4x\n", id.product_id);
2706} 2705}
2707static DEVICE_ATTR(product_id, S_IRUGO, product_id_show, NULL); 2706static DEVICE_ATTR_RO(product_id);
2708 2707
2709static ssize_t aux_firmware_rev_show(struct device *dev, 2708static ssize_t aux_firmware_rev_show(struct device *dev,
2710 struct device_attribute *attr, 2709 struct device_attribute *attr,
@@ -2742,7 +2741,7 @@ static ssize_t guid_show(struct device *dev, struct device_attribute *attr,
2742 2741
2743 return snprintf(buf, 38, "%pUl\n", guid.b); 2742 return snprintf(buf, 38, "%pUl\n", guid.b);
2744} 2743}
2745static DEVICE_ATTR(guid, S_IRUGO, guid_show, NULL); 2744static DEVICE_ATTR_RO(guid);
2746 2745
2747static struct attribute *bmc_dev_attrs[] = { 2746static struct attribute *bmc_dev_attrs[] = {
2748 &dev_attr_device_id.attr, 2747 &dev_attr_device_id.attr,
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index 791759f632e1..fb46ce3bd5f2 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -434,13 +434,13 @@ static ssize_t gt_min_freq_mhz_store(struct device *kdev,
434 return ret ?: count; 434 return ret ?: count;
435} 435}
436 436
437static DEVICE_ATTR(gt_act_freq_mhz, S_IRUGO, gt_act_freq_mhz_show, NULL); 437static DEVICE_ATTR_RO(gt_act_freq_mhz);
438static DEVICE_ATTR(gt_cur_freq_mhz, S_IRUGO, gt_cur_freq_mhz_show, NULL); 438static DEVICE_ATTR_RO(gt_cur_freq_mhz);
439static DEVICE_ATTR(gt_boost_freq_mhz, S_IRUGO | S_IWUSR, gt_boost_freq_mhz_show, gt_boost_freq_mhz_store); 439static DEVICE_ATTR_RW(gt_boost_freq_mhz);
440static DEVICE_ATTR(gt_max_freq_mhz, S_IRUGO | S_IWUSR, gt_max_freq_mhz_show, gt_max_freq_mhz_store); 440static DEVICE_ATTR_RW(gt_max_freq_mhz);
441static DEVICE_ATTR(gt_min_freq_mhz, S_IRUGO | S_IWUSR, gt_min_freq_mhz_show, gt_min_freq_mhz_store); 441static DEVICE_ATTR_RW(gt_min_freq_mhz);
442 442
443static DEVICE_ATTR(vlv_rpe_freq_mhz, S_IRUGO, vlv_rpe_freq_mhz_show, NULL); 443static DEVICE_ATTR_RO(vlv_rpe_freq_mhz);
444 444
445static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf); 445static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr, char *buf);
446static DEVICE_ATTR(gt_RP0_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL); 446static DEVICE_ATTR(gt_RP0_freq_mhz, S_IRUGO, gt_rp_mhz_show, NULL);
diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c
index a458e5ec9e41..819213e88f32 100644
--- a/drivers/input/touchscreen/elants_i2c.c
+++ b/drivers/input/touchscreen/elants_i2c.c
@@ -1000,7 +1000,7 @@ static ssize_t show_iap_mode(struct device *dev,
1000 "Normal" : "Recovery"); 1000 "Normal" : "Recovery");
1001} 1001}
1002 1002
1003static DEVICE_ATTR(calibrate, S_IWUSR, NULL, calibrate_store); 1003static DEVICE_ATTR_WO(calibrate);
1004static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL); 1004static DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
1005static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw); 1005static DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
1006 1006
diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 8c3058d5d191..56d6f1a4205a 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -4479,7 +4479,7 @@ static ssize_t failover_store(struct device *dev, struct device_attribute *attr,
4479 return count; 4479 return count;
4480} 4480}
4481 4481
4482static DEVICE_ATTR(failover, 0200, NULL, failover_store); 4482static DEVICE_ATTR_WO(failover);
4483 4483
4484static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev) 4484static unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
4485{ 4485{
diff --git a/drivers/net/wimax/i2400m/sysfs.c b/drivers/net/wimax/i2400m/sysfs.c
index 1237109f251a..8c67df11105c 100644
--- a/drivers/net/wimax/i2400m/sysfs.c
+++ b/drivers/net/wimax/i2400m/sysfs.c
@@ -65,8 +65,7 @@ error_bad_value:
65} 65}
66 66
67static 67static
68DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR, 68DEVICE_ATTR_WO(i2400m_idle_timeout);
69 NULL, i2400m_idle_timeout_store);
70 69
71static 70static
72struct attribute *i2400m_dev_attrs[] = { 71struct attribute *i2400m_dev_attrs[] = {
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index e8104871cbbf..f431c32774f3 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2554,14 +2554,14 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
2554 serial_len, subsys->serial, model_len, subsys->model, 2554 serial_len, subsys->serial, model_len, subsys->model,
2555 head->ns_id); 2555 head->ns_id);
2556} 2556}
2557static DEVICE_ATTR(wwid, S_IRUGO, wwid_show, NULL); 2557static DEVICE_ATTR_RO(wwid);
2558 2558
2559static ssize_t nguid_show(struct device *dev, struct device_attribute *attr, 2559static ssize_t nguid_show(struct device *dev, struct device_attribute *attr,
2560 char *buf) 2560 char *buf)
2561{ 2561{
2562 return sprintf(buf, "%pU\n", dev_to_ns_head(dev)->ids.nguid); 2562 return sprintf(buf, "%pU\n", dev_to_ns_head(dev)->ids.nguid);
2563} 2563}
2564static DEVICE_ATTR(nguid, S_IRUGO, nguid_show, NULL); 2564static DEVICE_ATTR_RO(nguid);
2565 2565
2566static ssize_t uuid_show(struct device *dev, struct device_attribute *attr, 2566static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
2567 char *buf) 2567 char *buf)
@@ -2578,21 +2578,21 @@ static ssize_t uuid_show(struct device *dev, struct device_attribute *attr,
2578 } 2578 }
2579 return sprintf(buf, "%pU\n", &ids->uuid); 2579 return sprintf(buf, "%pU\n", &ids->uuid);
2580} 2580}
2581static DEVICE_ATTR(uuid, S_IRUGO, uuid_show, NULL); 2581static DEVICE_ATTR_RO(uuid);
2582 2582
2583static ssize_t eui_show(struct device *dev, struct device_attribute *attr, 2583static ssize_t eui_show(struct device *dev, struct device_attribute *attr,
2584 char *buf) 2584 char *buf)
2585{ 2585{
2586 return sprintf(buf, "%8ph\n", dev_to_ns_head(dev)->ids.eui64); 2586 return sprintf(buf, "%8ph\n", dev_to_ns_head(dev)->ids.eui64);
2587} 2587}
2588static DEVICE_ATTR(eui, S_IRUGO, eui_show, NULL); 2588static DEVICE_ATTR_RO(eui);
2589 2589
2590static ssize_t nsid_show(struct device *dev, struct device_attribute *attr, 2590static ssize_t nsid_show(struct device *dev, struct device_attribute *attr,
2591 char *buf) 2591 char *buf)
2592{ 2592{
2593 return sprintf(buf, "%d\n", dev_to_ns_head(dev)->ns_id); 2593 return sprintf(buf, "%d\n", dev_to_ns_head(dev)->ns_id);
2594} 2594}
2595static DEVICE_ATTR(nsid, S_IRUGO, nsid_show, NULL); 2595static DEVICE_ATTR_RO(nsid);
2596 2596
2597static struct attribute *nvme_ns_id_attrs[] = { 2597static struct attribute *nvme_ns_id_attrs[] = {
2598 &dev_attr_wwid.attr, 2598 &dev_attr_wwid.attr,
diff --git a/drivers/platform/x86/compal-laptop.c b/drivers/platform/x86/compal-laptop.c
index 6bcb750e1865..4f9bc72f0584 100644
--- a/drivers/platform/x86/compal-laptop.c
+++ b/drivers/platform/x86/compal-laptop.c
@@ -679,18 +679,12 @@ static int bat_writeable_property(struct power_supply *psy,
679/* ============== */ 679/* ============== */
680/* Driver Globals */ 680/* Driver Globals */
681/* ============== */ 681/* ============== */
682static DEVICE_ATTR(wake_up_pme, 682static DEVICE_ATTR_RW(wake_up_pme);
683 0644, wake_up_pme_show, wake_up_pme_store); 683static DEVICE_ATTR_RW(wake_up_modem);
684static DEVICE_ATTR(wake_up_modem, 684static DEVICE_ATTR_RW(wake_up_lan);
685 0644, wake_up_modem_show, wake_up_modem_store); 685static DEVICE_ATTR_RW(wake_up_wlan);
686static DEVICE_ATTR(wake_up_lan, 686static DEVICE_ATTR_RW(wake_up_key);
687 0644, wake_up_lan_show, wake_up_lan_store); 687static DEVICE_ATTR_RW(wake_up_mouse);
688static DEVICE_ATTR(wake_up_wlan,
689 0644, wake_up_wlan_show, wake_up_wlan_store);
690static DEVICE_ATTR(wake_up_key,
691 0644, wake_up_key_show, wake_up_key_store);
692static DEVICE_ATTR(wake_up_mouse,
693 0644, wake_up_mouse_show, wake_up_mouse_store);
694 688
695static DEVICE_ATTR(fan1_input, S_IRUGO, fan_show, NULL); 689static DEVICE_ATTR(fan1_input, S_IRUGO, fan_show, NULL);
696static DEVICE_ATTR(temp1_input, S_IRUGO, temp_cpu, NULL); 690static DEVICE_ATTR(temp1_input, S_IRUGO, temp_cpu, NULL);
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 0f11dce6e224..9263a0fb3858 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -268,7 +268,7 @@ static ssize_t type_show(struct device *dev, struct device_attribute *attr,
268 return sprintf(buf, "%01x\n", sch->st); 268 return sprintf(buf, "%01x\n", sch->st);
269} 269}
270 270
271static DEVICE_ATTR(type, 0444, type_show, NULL); 271static DEVICE_ATTR_RO(type);
272 272
273static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, 273static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
274 char *buf) 274 char *buf)
@@ -278,7 +278,7 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
278 return sprintf(buf, "css:t%01X\n", sch->st); 278 return sprintf(buf, "css:t%01X\n", sch->st);
279} 279}
280 280
281static DEVICE_ATTR(modalias, 0444, modalias_show, NULL); 281static DEVICE_ATTR_RO(modalias);
282 282
283static struct attribute *subch_attrs[] = { 283static struct attribute *subch_attrs[] = {
284 &dev_attr_type.attr, 284 &dev_attr_type.attr,
@@ -315,7 +315,7 @@ static ssize_t chpids_show(struct device *dev,
315 ret += sprintf(buf + ret, "\n"); 315 ret += sprintf(buf + ret, "\n");
316 return ret; 316 return ret;
317} 317}
318static DEVICE_ATTR(chpids, 0444, chpids_show, NULL); 318static DEVICE_ATTR_RO(chpids);
319 319
320static ssize_t pimpampom_show(struct device *dev, 320static ssize_t pimpampom_show(struct device *dev,
321 struct device_attribute *attr, 321 struct device_attribute *attr,
@@ -327,7 +327,7 @@ static ssize_t pimpampom_show(struct device *dev,
327 return sprintf(buf, "%02x %02x %02x\n", 327 return sprintf(buf, "%02x %02x %02x\n",
328 pmcw->pim, pmcw->pam, pmcw->pom); 328 pmcw->pim, pmcw->pam, pmcw->pom);
329} 329}
330static DEVICE_ATTR(pimpampom, 0444, pimpampom_show, NULL); 330static DEVICE_ATTR_RO(pimpampom);
331 331
332static struct attribute *io_subchannel_type_attrs[] = { 332static struct attribute *io_subchannel_type_attrs[] = {
333 &dev_attr_chpids.attr, 333 &dev_attr_chpids.attr,
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 75a245f38e2e..f50ea035aa9b 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -597,13 +597,13 @@ static ssize_t vpm_show(struct device *dev, struct device_attribute *attr,
597 return sprintf(buf, "%02x\n", sch->vpm); 597 return sprintf(buf, "%02x\n", sch->vpm);
598} 598}
599 599
600static DEVICE_ATTR(devtype, 0444, devtype_show, NULL); 600static DEVICE_ATTR_RO(devtype);
601static DEVICE_ATTR(cutype, 0444, cutype_show, NULL); 601static DEVICE_ATTR_RO(cutype);
602static DEVICE_ATTR(modalias, 0444, modalias_show, NULL); 602static DEVICE_ATTR_RO(modalias);
603static DEVICE_ATTR(online, 0644, online_show, online_store); 603static DEVICE_ATTR_RW(online);
604static DEVICE_ATTR(availability, 0444, available_show, NULL); 604static DEVICE_ATTR(availability, 0444, available_show, NULL);
605static DEVICE_ATTR(logging, 0200, NULL, initiate_logging); 605static DEVICE_ATTR(logging, 0200, NULL, initiate_logging);
606static DEVICE_ATTR(vpm, 0444, vpm_show, NULL); 606static DEVICE_ATTR_RO(vpm);
607 607
608static struct attribute *io_subchannel_attrs[] = { 608static struct attribute *io_subchannel_attrs[] = {
609 &dev_attr_logging.attr, 609 &dev_attr_logging.attr,
diff --git a/drivers/s390/crypto/ap_card.c b/drivers/s390/crypto/ap_card.c
index 97a8cf578116..2c726df210f6 100644
--- a/drivers/s390/crypto/ap_card.c
+++ b/drivers/s390/crypto/ap_card.c
@@ -57,7 +57,7 @@ static ssize_t ap_functions_show(struct device *dev,
57 return snprintf(buf, PAGE_SIZE, "0x%08X\n", ac->functions); 57 return snprintf(buf, PAGE_SIZE, "0x%08X\n", ac->functions);
58} 58}
59 59
60static DEVICE_ATTR(ap_functions, 0444, ap_functions_show, NULL); 60static DEVICE_ATTR_RO(ap_functions);
61 61
62static ssize_t ap_req_count_show(struct device *dev, 62static ssize_t ap_req_count_show(struct device *dev,
63 struct device_attribute *attr, 63 struct device_attribute *attr,
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index 87b260e403ec..5293e6827ce5 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -901,14 +901,14 @@ static ssize_t host_show_legacy_board(struct device *dev,
901 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0); 901 return snprintf(buf, 20, "%d\n", h->legacy_board ? 1 : 0);
902} 902}
903 903
904static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL); 904static DEVICE_ATTR_RO(raid_level);
905static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL); 905static DEVICE_ATTR_RO(lunid);
906static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL); 906static DEVICE_ATTR_RO(unique_id);
907static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan); 907static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan);
908static DEVICE_ATTR(sas_address, S_IRUGO, sas_address_show, NULL); 908static DEVICE_ATTR_RO(sas_address);
909static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO, 909static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO,
910 host_show_hp_ssd_smart_path_enabled, NULL); 910 host_show_hp_ssd_smart_path_enabled, NULL);
911static DEVICE_ATTR(path_info, S_IRUGO, path_info_show, NULL); 911static DEVICE_ATTR_RO(path_info);
912static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH, 912static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH,
913 host_show_hp_ssd_smart_path_status, 913 host_show_hp_ssd_smart_path_status,
914 host_store_hp_ssd_smart_path_status); 914 host_store_hp_ssd_smart_path_status);
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index d188fb565a32..ac77081e6e9e 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -2294,8 +2294,8 @@ static DEVICE_ATTR(num_discovered_ports, S_IRUGO,
2294 lpfc_num_discovered_ports_show, NULL); 2294 lpfc_num_discovered_ports_show, NULL);
2295static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL); 2295static DEVICE_ATTR(menlo_mgmt_mode, S_IRUGO, lpfc_mlomgmt_show, NULL);
2296static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL); 2296static DEVICE_ATTR(nport_evt_cnt, S_IRUGO, lpfc_nport_evt_cnt_show, NULL);
2297static DEVICE_ATTR(lpfc_drvr_version, S_IRUGO, lpfc_drvr_version_show, NULL); 2297static DEVICE_ATTR_RO(lpfc_drvr_version);
2298static DEVICE_ATTR(lpfc_enable_fip, S_IRUGO, lpfc_enable_fip_show, NULL); 2298static DEVICE_ATTR_RO(lpfc_enable_fip);
2299static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR, 2299static DEVICE_ATTR(board_mode, S_IRUGO | S_IWUSR,
2300 lpfc_board_mode_show, lpfc_board_mode_store); 2300 lpfc_board_mode_show, lpfc_board_mode_store);
2301static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset); 2301static DEVICE_ATTR(issue_reset, S_IWUSR, NULL, lpfc_issue_reset);
@@ -2306,12 +2306,11 @@ static DEVICE_ATTR(used_rpi, S_IRUGO, lpfc_used_rpi_show, NULL);
2306static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL); 2306static DEVICE_ATTR(max_xri, S_IRUGO, lpfc_max_xri_show, NULL);
2307static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL); 2307static DEVICE_ATTR(used_xri, S_IRUGO, lpfc_used_xri_show, NULL);
2308static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL); 2308static DEVICE_ATTR(npiv_info, S_IRUGO, lpfc_npiv_info_show, NULL);
2309static DEVICE_ATTR(lpfc_temp_sensor, S_IRUGO, lpfc_temp_sensor_show, NULL); 2309static DEVICE_ATTR_RO(lpfc_temp_sensor);
2310static DEVICE_ATTR(lpfc_fips_level, S_IRUGO, lpfc_fips_level_show, NULL); 2310static DEVICE_ATTR_RO(lpfc_fips_level);
2311static DEVICE_ATTR(lpfc_fips_rev, S_IRUGO, lpfc_fips_rev_show, NULL); 2311static DEVICE_ATTR_RO(lpfc_fips_rev);
2312static DEVICE_ATTR(lpfc_dss, S_IRUGO, lpfc_dss_show, NULL); 2312static DEVICE_ATTR_RO(lpfc_dss);
2313static DEVICE_ATTR(lpfc_sriov_hw_max_virtfn, S_IRUGO, 2313static DEVICE_ATTR_RO(lpfc_sriov_hw_max_virtfn);
2314 lpfc_sriov_hw_max_virtfn_show, NULL);
2315static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL); 2314static DEVICE_ATTR(protocol, S_IRUGO, lpfc_sli4_protocol_show, NULL);
2316static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show, 2315static DEVICE_ATTR(lpfc_xlane_supported, S_IRUGO, lpfc_oas_supported_show,
2317 NULL); 2316 NULL);
@@ -2419,8 +2418,7 @@ lpfc_soft_wwn_enable_store(struct device *dev, struct device_attribute *attr,
2419 2418
2420 return count; 2419 return count;
2421} 2420}
2422static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL, 2421static DEVICE_ATTR_WO(lpfc_soft_wwn_enable);
2423 lpfc_soft_wwn_enable_store);
2424 2422
2425/** 2423/**
2426 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter 2424 * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the adapter
@@ -2519,8 +2517,7 @@ lpfc_soft_wwpn_store(struct device *dev, struct device_attribute *attr,
2519 "reinit adapter - %d\n", stat2); 2517 "reinit adapter - %d\n", stat2);
2520 return (stat1 || stat2) ? -EIO : count; 2518 return (stat1 || stat2) ? -EIO : count;
2521} 2519}
2522static DEVICE_ATTR(lpfc_soft_wwpn, S_IRUGO | S_IWUSR, 2520static DEVICE_ATTR_RW(lpfc_soft_wwpn);
2523 lpfc_soft_wwpn_show, lpfc_soft_wwpn_store);
2524 2521
2525/** 2522/**
2526 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter 2523 * lpfc_soft_wwnn_show - Return the cfg soft ww node name for the adapter
@@ -2583,8 +2580,7 @@ lpfc_soft_wwnn_store(struct device *dev, struct device_attribute *attr,
2583 2580
2584 return count; 2581 return count;
2585} 2582}
2586static DEVICE_ATTR(lpfc_soft_wwnn, S_IRUGO | S_IWUSR, 2583static DEVICE_ATTR_RW(lpfc_soft_wwnn);
2587 lpfc_soft_wwnn_show, lpfc_soft_wwnn_store);
2588 2584
2589/** 2585/**
2590 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for 2586 * lpfc_oas_tgt_show - Return wwpn of target whose luns maybe enabled for
@@ -3102,8 +3098,7 @@ MODULE_PARM_DESC(lpfc_poll, "FCP ring polling mode control:"
3102 " 1 - poll with interrupts enabled" 3098 " 1 - poll with interrupts enabled"
3103 " 3 - poll and disable FCP ring interrupts"); 3099 " 3 - poll and disable FCP ring interrupts");
3104 3100
3105static DEVICE_ATTR(lpfc_poll, S_IRUGO | S_IWUSR, 3101static DEVICE_ATTR_RW(lpfc_poll);
3106 lpfc_poll_show, lpfc_poll_store);
3107 3102
3108int lpfc_no_hba_reset_cnt; 3103int lpfc_no_hba_reset_cnt;
3109unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = { 3104unsigned long lpfc_no_hba_reset[MAX_HBAS_NO_RESET] = {
@@ -3336,8 +3331,7 @@ lpfc_nodev_tmo_set(struct lpfc_vport *vport, int val)
3336 3331
3337lpfc_vport_param_store(nodev_tmo) 3332lpfc_vport_param_store(nodev_tmo)
3338 3333
3339static DEVICE_ATTR(lpfc_nodev_tmo, S_IRUGO | S_IWUSR, 3334static DEVICE_ATTR_RW(lpfc_nodev_tmo);
3340 lpfc_nodev_tmo_show, lpfc_nodev_tmo_store);
3341 3335
3342/* 3336/*
3343# lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that 3337# lpfc_devloss_tmo: If set, it will hold all I/O errors on devices that
@@ -3386,8 +3380,7 @@ lpfc_devloss_tmo_set(struct lpfc_vport *vport, int val)
3386} 3380}
3387 3381
3388lpfc_vport_param_store(devloss_tmo) 3382lpfc_vport_param_store(devloss_tmo)
3389static DEVICE_ATTR(lpfc_devloss_tmo, S_IRUGO | S_IWUSR, 3383static DEVICE_ATTR_RW(lpfc_devloss_tmo);
3390 lpfc_devloss_tmo_show, lpfc_devloss_tmo_store);
3391 3384
3392/* 3385/*
3393 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it 3386 * lpfc_suppress_rsp: Enable suppress rsp feature is firmware supports it
@@ -3580,8 +3573,7 @@ lpfc_restrict_login_set(struct lpfc_vport *vport, int val)
3580 return 0; 3573 return 0;
3581} 3574}
3582lpfc_vport_param_store(restrict_login); 3575lpfc_vport_param_store(restrict_login);
3583static DEVICE_ATTR(lpfc_restrict_login, S_IRUGO | S_IWUSR, 3576static DEVICE_ATTR_RW(lpfc_restrict_login);
3584 lpfc_restrict_login_show, lpfc_restrict_login_store);
3585 3577
3586/* 3578/*
3587# Some disk devices have a "select ID" or "select Target" capability. 3579# Some disk devices have a "select ID" or "select Target" capability.
@@ -3695,8 +3687,7 @@ lpfc_topology_store(struct device *dev, struct device_attribute *attr,
3695} 3687}
3696 3688
3697lpfc_param_show(topology) 3689lpfc_param_show(topology)
3698static DEVICE_ATTR(lpfc_topology, S_IRUGO | S_IWUSR, 3690static DEVICE_ATTR_RW(lpfc_topology);
3699 lpfc_topology_show, lpfc_topology_store);
3700 3691
3701/** 3692/**
3702 * lpfc_static_vport_show: Read callback function for 3693 * lpfc_static_vport_show: Read callback function for
@@ -3726,8 +3717,7 @@ lpfc_static_vport_show(struct device *dev, struct device_attribute *attr,
3726/* 3717/*
3727 * Sysfs attribute to control the statistical data collection. 3718 * Sysfs attribute to control the statistical data collection.
3728 */ 3719 */
3729static DEVICE_ATTR(lpfc_static_vport, S_IRUGO, 3720static DEVICE_ATTR_RO(lpfc_static_vport);
3730 lpfc_static_vport_show, NULL);
3731 3721
3732/** 3722/**
3733 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file 3723 * lpfc_stat_data_ctrl_store - write call back for lpfc_stat_data_ctrl sysfs file
@@ -3954,8 +3944,7 @@ lpfc_stat_data_ctrl_show(struct device *dev, struct device_attribute *attr,
3954/* 3944/*
3955 * Sysfs attribute to control the statistical data collection. 3945 * Sysfs attribute to control the statistical data collection.
3956 */ 3946 */
3957static DEVICE_ATTR(lpfc_stat_data_ctrl, S_IRUGO | S_IWUSR, 3947static DEVICE_ATTR_RW(lpfc_stat_data_ctrl);
3958 lpfc_stat_data_ctrl_show, lpfc_stat_data_ctrl_store);
3959 3948
3960/* 3949/*
3961 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data. 3950 * lpfc_drvr_stat_data: sysfs attr to get driver statistical data.
@@ -4194,8 +4183,7 @@ lpfc_link_speed_init(struct lpfc_hba *phba, int val)
4194 return -EINVAL; 4183 return -EINVAL;
4195} 4184}
4196 4185
4197static DEVICE_ATTR(lpfc_link_speed, S_IRUGO | S_IWUSR, 4186static DEVICE_ATTR_RW(lpfc_link_speed);
4198 lpfc_link_speed_show, lpfc_link_speed_store);
4199 4187
4200/* 4188/*
4201# lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER) 4189# lpfc_aer_support: Support PCIe device Advanced Error Reporting (AER)
@@ -4288,8 +4276,7 @@ lpfc_aer_support_store(struct device *dev, struct device_attribute *attr,
4288 return rc; 4276 return rc;
4289} 4277}
4290 4278
4291static DEVICE_ATTR(lpfc_aer_support, S_IRUGO | S_IWUSR, 4279static DEVICE_ATTR_RW(lpfc_aer_support);
4292 lpfc_aer_support_show, lpfc_aer_support_store);
4293 4280
4294/** 4281/**
4295 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device 4282 * lpfc_aer_cleanup_state - Clean up aer state to the aer enabled device
@@ -4436,8 +4423,7 @@ LPFC_ATTR(sriov_nr_virtfn, LPFC_DEF_VFN_PER_PFN, 0, LPFC_MAX_VFN_PER_PFN,
4436 "Enable PCIe device SR-IOV virtual fn"); 4423 "Enable PCIe device SR-IOV virtual fn");
4437 4424
4438lpfc_param_show(sriov_nr_virtfn) 4425lpfc_param_show(sriov_nr_virtfn)
4439static DEVICE_ATTR(lpfc_sriov_nr_virtfn, S_IRUGO | S_IWUSR, 4426static DEVICE_ATTR_RW(lpfc_sriov_nr_virtfn);
4440 lpfc_sriov_nr_virtfn_show, lpfc_sriov_nr_virtfn_store);
4441 4427
4442/** 4428/**
4443 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade 4429 * lpfc_request_firmware_store - Request for Linux generic firmware upgrade
@@ -4611,8 +4597,7 @@ lpfc_fcp_imax_init(struct lpfc_hba *phba, int val)
4611 return 0; 4597 return 0;
4612} 4598}
4613 4599
4614static DEVICE_ATTR(lpfc_fcp_imax, S_IRUGO | S_IWUSR, 4600static DEVICE_ATTR_RW(lpfc_fcp_imax);
4615 lpfc_fcp_imax_show, lpfc_fcp_imax_store);
4616 4601
4617/* 4602/*
4618 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support. 4603 * lpfc_auto_imax: Controls Auto-interrupt coalescing values support.
@@ -4772,8 +4757,7 @@ lpfc_fcp_cpu_map_init(struct lpfc_hba *phba, int val)
4772 return 0; 4757 return 0;
4773} 4758}
4774 4759
4775static DEVICE_ATTR(lpfc_fcp_cpu_map, S_IRUGO | S_IWUSR, 4760static DEVICE_ATTR_RW(lpfc_fcp_cpu_map);
4776 lpfc_fcp_cpu_map_show, lpfc_fcp_cpu_map_store);
4777 4761
4778/* 4762/*
4779# lpfc_fcp_class: Determines FC class to use for the FCP protocol. 4763# lpfc_fcp_class: Determines FC class to use for the FCP protocol.
@@ -4859,9 +4843,7 @@ lpfc_max_scsicmpl_time_set(struct lpfc_vport *vport, int val)
4859 return 0; 4843 return 0;
4860} 4844}
4861lpfc_vport_param_store(max_scsicmpl_time); 4845lpfc_vport_param_store(max_scsicmpl_time);
4862static DEVICE_ATTR(lpfc_max_scsicmpl_time, S_IRUGO | S_IWUSR, 4846static DEVICE_ATTR_RW(lpfc_max_scsicmpl_time);
4863 lpfc_max_scsicmpl_time_show,
4864 lpfc_max_scsicmpl_time_store);
4865 4847
4866/* 4848/*
4867# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value 4849# lpfc_ack0: Use ACK0, instead of ACK1 for class 2 acknowledgement. Value
diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c
index fb80c96d8f73..ba81c9080f6e 100644
--- a/drivers/thermal/thermal_sysfs.c
+++ b/drivers/thermal/thermal_sysfs.c
@@ -317,7 +317,7 @@ emul_temp_store(struct device *dev, struct device_attribute *attr,
317 317
318 return ret ? ret : count; 318 return ret ? ret : count;
319} 319}
320static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store); 320static DEVICE_ATTR_WO(emul_temp);
321#endif 321#endif
322 322
323static ssize_t 323static ssize_t
@@ -396,16 +396,15 @@ create_s32_tzp_attr(offset);
396 * All the attributes created for tzp (create_s32_tzp_attr) also are always 396 * All the attributes created for tzp (create_s32_tzp_attr) also are always
397 * present on the sysfs interface. 397 * present on the sysfs interface.
398 */ 398 */
399static DEVICE_ATTR(type, 0444, type_show, NULL); 399static DEVICE_ATTR_RO(type);
400static DEVICE_ATTR(temp, 0444, temp_show, NULL); 400static DEVICE_ATTR_RO(temp);
401static DEVICE_ATTR(policy, S_IRUGO | S_IWUSR, policy_show, policy_store); 401static DEVICE_ATTR_RW(policy);
402static DEVICE_ATTR(available_policies, S_IRUGO, available_policies_show, NULL); 402static DEVICE_ATTR_RO(available_policies);
403static DEVICE_ATTR(sustainable_power, S_IWUSR | S_IRUGO, sustainable_power_show, 403static DEVICE_ATTR_RW(sustainable_power);
404 sustainable_power_store);
405 404
406/* These thermal zone device attributes are created based on conditions */ 405/* These thermal zone device attributes are created based on conditions */
407static DEVICE_ATTR(mode, 0644, mode_show, mode_store); 406static DEVICE_ATTR_RW(mode);
408static DEVICE_ATTR(passive, S_IRUGO | S_IWUSR, passive_show, passive_store); 407static DEVICE_ATTR_RW(passive);
409 408
410/* These attributes are unconditionally added to a thermal zone */ 409/* These attributes are unconditionally added to a thermal zone */
411static struct attribute *thermal_zone_dev_attrs[] = { 410static struct attribute *thermal_zone_dev_attrs[] = {
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index d9f399c4e90c..7257c078e155 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1144,7 +1144,7 @@ static ssize_t rx_fifo_timeout_store(struct device *dev,
1144 return count; 1144 return count;
1145} 1145}
1146 1146
1147static DEVICE_ATTR(rx_fifo_timeout, 0644, rx_fifo_timeout_show, rx_fifo_timeout_store); 1147static DEVICE_ATTR_RW(rx_fifo_timeout);
1148 1148
1149 1149
1150#ifdef CONFIG_SERIAL_SH_SCI_DMA 1150#ifdef CONFIG_SERIAL_SH_SCI_DMA
diff --git a/drivers/usb/serial/Kconfig b/drivers/usb/serial/Kconfig
index c66b93664d54..a646820f5a78 100644
--- a/drivers/usb/serial/Kconfig
+++ b/drivers/usb/serial/Kconfig
@@ -323,84 +323,6 @@ config USB_SERIAL_KEYSPAN
323 To compile this driver as a module, choose M here: the 323 To compile this driver as a module, choose M here: the
324 module will be called keyspan. 324 module will be called keyspan.
325 325
326config USB_SERIAL_KEYSPAN_MPR
327 bool "USB Keyspan MPR Firmware"
328 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
329 help
330 Say Y here to include firmware for the Keyspan MPR converter.
331
332config USB_SERIAL_KEYSPAN_USA28
333 bool "USB Keyspan USA-28 Firmware"
334 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
335 help
336 Say Y here to include firmware for the USA-28 converter.
337
338config USB_SERIAL_KEYSPAN_USA28X
339 bool "USB Keyspan USA-28X Firmware"
340 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
341 help
342 Say Y here to include firmware for the USA-28X converter.
343 Be sure you have a USA-28X, there are also 28XA and 28XB
344 models, the label underneath has the actual part number.
345
346config USB_SERIAL_KEYSPAN_USA28XA
347 bool "USB Keyspan USA-28XA Firmware"
348 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
349 help
350 Say Y here to include firmware for the USA-28XA converter.
351 Be sure you have a USA-28XA, there are also 28X and 28XB
352 models, the label underneath has the actual part number.
353
354config USB_SERIAL_KEYSPAN_USA28XB
355 bool "USB Keyspan USA-28XB Firmware"
356 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
357 help
358 Say Y here to include firmware for the USA-28XB converter.
359 Be sure you have a USA-28XB, there are also 28X and 28XA
360 models, the label underneath has the actual part number.
361
362config USB_SERIAL_KEYSPAN_USA19
363 bool "USB Keyspan USA-19 Firmware"
364 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
365 help
366 Say Y here to include firmware for the USA-19 converter.
367
368config USB_SERIAL_KEYSPAN_USA18X
369 bool "USB Keyspan USA-18X Firmware"
370 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
371 help
372 Say Y here to include firmware for the USA-18X converter.
373
374config USB_SERIAL_KEYSPAN_USA19W
375 bool "USB Keyspan USA-19W Firmware"
376 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
377 help
378 Say Y here to include firmware for the USA-19W converter.
379
380config USB_SERIAL_KEYSPAN_USA19QW
381 bool "USB Keyspan USA-19QW Firmware"
382 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
383 help
384 Say Y here to include firmware for the USA-19QW converter.
385
386config USB_SERIAL_KEYSPAN_USA19QI
387 bool "USB Keyspan USA-19QI Firmware"
388 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
389 help
390 Say Y here to include firmware for the USA-19QI converter.
391
392config USB_SERIAL_KEYSPAN_USA49W
393 bool "USB Keyspan USA-49W Firmware"
394 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
395 help
396 Say Y here to include firmware for the USA-49W converter.
397
398config USB_SERIAL_KEYSPAN_USA49WLC
399 bool "USB Keyspan USA-49WLC Firmware"
400 depends on USB_SERIAL_KEYSPAN && FIRMWARE_IN_KERNEL
401 help
402 Say Y here to include firmware for the USA-49WLC converter.
403
404config USB_SERIAL_KLSI 326config USB_SERIAL_KLSI
405 tristate "USB KL5KUSB105 (Palmconnect) Driver" 327 tristate "USB KL5KUSB105 (Palmconnect) Driver"
406 ---help--- 328 ---help---
diff --git a/drivers/video/fbdev/auo_k190x.c b/drivers/video/fbdev/auo_k190x.c
index 0d06038324e0..1e383c547633 100644
--- a/drivers/video/fbdev/auo_k190x.c
+++ b/drivers/video/fbdev/auo_k190x.c
@@ -708,8 +708,8 @@ static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
708 return sprintf(buf, "%d\n", temp); 708 return sprintf(buf, "%d\n", temp);
709} 709}
710 710
711static DEVICE_ATTR(update_mode, 0644, update_mode_show, update_mode_store); 711static DEVICE_ATTR_RW(update_mode);
712static DEVICE_ATTR(flash, 0644, flash_show, flash_store); 712static DEVICE_ATTR_RW(flash);
713static DEVICE_ATTR(temp, 0644, temp_show, NULL); 713static DEVICE_ATTR(temp, 0644, temp_show, NULL);
714 714
715static struct attribute *auok190x_attributes[] = { 715static struct attribute *auok190x_attributes[] = {
diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
index d570e19a2864..035ff6e02894 100644
--- a/drivers/video/fbdev/w100fb.c
+++ b/drivers/video/fbdev/w100fb.c
@@ -110,7 +110,7 @@ static ssize_t flip_store(struct device *dev, struct device_attribute *attr, con
110 return count; 110 return count;
111} 111}
112 112
113static DEVICE_ATTR(flip, 0644, flip_show, flip_store); 113static DEVICE_ATTR_RW(flip);
114 114
115static ssize_t w100fb_reg_read(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 115static ssize_t w100fb_reg_read(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
116{ 116{
@@ -166,7 +166,7 @@ static ssize_t fastpllclk_store(struct device *dev, struct device_attribute *att
166 return count; 166 return count;
167} 167}
168 168
169static DEVICE_ATTR(fastpllclk, 0644, fastpllclk_show, fastpllclk_store); 169static DEVICE_ATTR_RW(fastpllclk);
170 170
171/* 171/*
172 * Some touchscreens need hsync information from the video driver to 172 * Some touchscreens need hsync information from the video driver to
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 2b67bda2021b..58eba92a0e41 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/sysfs/dir.c - sysfs core and dir operation implementation 3 * fs/sysfs/dir.c - sysfs core and dir operation implementation
3 * 4 *
@@ -5,12 +6,10 @@
5 * Copyright (c) 2007 SUSE Linux Products GmbH 6 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007 Tejun Heo <teheo@suse.de> 7 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7 * 8 *
8 * This file is released under the GPLv2.
9 *
10 * Please see Documentation/filesystems/sysfs.txt for more information. 9 * Please see Documentation/filesystems/sysfs.txt for more information.
11 */ 10 */
12 11
13#undef DEBUG 12#define pr_fmt(fmt) "sysfs: " fmt
14 13
15#include <linux/fs.h> 14#include <linux/fs.h>
16#include <linux/kobject.h> 15#include <linux/kobject.h>
@@ -27,8 +26,8 @@ void sysfs_warn_dup(struct kernfs_node *parent, const char *name)
27 if (buf) 26 if (buf)
28 kernfs_path(parent, buf, PATH_MAX); 27 kernfs_path(parent, buf, PATH_MAX);
29 28
30 WARN(1, KERN_WARNING "sysfs: cannot create duplicate filename '%s/%s'\n", 29 pr_warn("cannot create duplicate filename '%s/%s'\n", buf, name);
31 buf, name); 30 dump_stack();
32 31
33 kfree(buf); 32 kfree(buf);
34} 33}
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index 39c75a86c67f..39da8e86f10a 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/sysfs/file.c - sysfs regular (text) file implementation 3 * fs/sysfs/file.c - sysfs regular (text) file implementation
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (c) 2007 SUSE Linux Products GmbH 6 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007 Tejun Heo <teheo@suse.de> 7 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7 * 8 *
8 * This file is released under the GPLv2.
9 *
10 * Please see Documentation/filesystems/sysfs.txt for more information. 9 * Please see Documentation/filesystems/sysfs.txt for more information.
11 */ 10 */
12 11
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index ac2de0ed69ad..4802ec0e1e3a 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/sysfs/group.c - Operations for adding/removing multiple files at once. 3 * fs/sysfs/group.c - Operations for adding/removing multiple files at once.
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2003 Open Source Development Lab 6 * Copyright (c) 2003 Open Source Development Lab
6 * Copyright (c) 2013 Greg Kroah-Hartman 7 * Copyright (c) 2013 Greg Kroah-Hartman
7 * Copyright (c) 2013 The Linux Foundation 8 * Copyright (c) 2013 The Linux Foundation
8 *
9 * This file is released undert the GPL v2.
10 *
11 */ 9 */
12 10
13#include <linux/kobject.h> 11#include <linux/kobject.h>
@@ -406,6 +404,6 @@ int __compat_only_sysfs_link_entry_to_kobj(struct kobject *kobj,
406 404
407 kernfs_put(entry); 405 kernfs_put(entry);
408 kernfs_put(target); 406 kernfs_put(target);
409 return IS_ERR(link) ? PTR_ERR(link) : 0; 407 return PTR_ERR_OR_ZERO(link);
410} 408}
411EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj); 409EXPORT_SYMBOL_GPL(__compat_only_sysfs_link_entry_to_kobj);
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index fb49510c5dcf..b428d317ae92 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/sysfs/symlink.c - operations for initializing and mounting sysfs 3 * fs/sysfs/symlink.c - operations for initializing and mounting sysfs
3 * 4 *
@@ -5,13 +6,9 @@
5 * Copyright (c) 2007 SUSE Linux Products GmbH 6 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007 Tejun Heo <teheo@suse.de> 7 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7 * 8 *
8 * This file is released under the GPLv2.
9 *
10 * Please see Documentation/filesystems/sysfs.txt for more information. 9 * Please see Documentation/filesystems/sysfs.txt for more information.
11 */ 10 */
12 11
13#define DEBUG
14
15#include <linux/fs.h> 12#include <linux/fs.h>
16#include <linux/magic.h> 13#include <linux/magic.h>
17#include <linux/mount.h> 14#include <linux/mount.h>
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index aecb15f84557..8664db25a9a6 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * fs/sysfs/symlink.c - sysfs symlink implementation 3 * fs/sysfs/symlink.c - sysfs symlink implementation
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (c) 2007 SUSE Linux Products GmbH 6 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007 Tejun Heo <teheo@suse.de> 7 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7 * 8 *
8 * This file is released under the GPLv2.
9 *
10 * Please see Documentation/filesystems/sysfs.txt for more information. 9 * Please see Documentation/filesystems/sysfs.txt for more information.
11 */ 10 */
12 11
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 0e2f1cccb812..d098e015fcc9 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -1,11 +1,10 @@
1/* SPDX-License-Identifier: GPL-2.0 */
1/* 2/*
2 * fs/sysfs/sysfs.h - sysfs internal header file 3 * fs/sysfs/sysfs.h - sysfs internal header file
3 * 4 *
4 * Copyright (c) 2001-3 Patrick Mochel 5 * Copyright (c) 2001-3 Patrick Mochel
5 * Copyright (c) 2007 SUSE Linux Products GmbH 6 * Copyright (c) 2007 SUSE Linux Products GmbH
6 * Copyright (c) 2007 Tejun Heo <teheo@suse.de> 7 * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
7 *
8 * This file is released under the GPLv2.
9 */ 8 */
10 9
11#ifndef __SYSFS_INTERNAL_H 10#ifndef __SYSFS_INTERNAL_H
diff --git a/include/linux/device.h b/include/linux/device.h
index 46ac622e5c6f..f649fc0c2571 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * device.h - generic, centralized driver model 3 * device.h - generic, centralized driver model
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de> 6 * Copyright (c) 2004-2009 Greg Kroah-Hartman <gregkh@suse.de>
6 * Copyright (c) 2008-2009 Novell Inc. 7 * Copyright (c) 2008-2009 Novell Inc.
7 * 8 *
8 * This file is released under the GPLv2
9 *
10 * See Documentation/driver-model/ for more information. 9 * See Documentation/driver-model/ for more information.
11 */ 10 */
12 11
@@ -288,6 +287,7 @@ struct device_driver {
288 const struct attribute_group **groups; 287 const struct attribute_group **groups;
289 288
290 const struct dev_pm_ops *pm; 289 const struct dev_pm_ops *pm;
290 int (*coredump) (struct device *dev);
291 291
292 struct driver_private *p; 292 struct driver_private *p;
293}; 293};
@@ -301,7 +301,6 @@ extern struct device_driver *driver_find(const char *name,
301extern int driver_probe_done(void); 301extern int driver_probe_done(void);
302extern void wait_for_device_probe(void); 302extern void wait_for_device_probe(void);
303 303
304
305/* sysfs interface for exporting driver attributes */ 304/* sysfs interface for exporting driver attributes */
306 305
307struct driver_attribute { 306struct driver_attribute {
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
index e0a6205caa71..7f6f93c3df9c 100644
--- a/include/linux/kobject.h
+++ b/include/linux/kobject.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * kobject.h - generic kernel object infrastructure. 3 * kobject.h - generic kernel object infrastructure.
3 * 4 *
@@ -6,8 +7,6 @@
6 * Copyright (c) 2006-2008 Greg Kroah-Hartman <greg@kroah.com> 7 * Copyright (c) 2006-2008 Greg Kroah-Hartman <greg@kroah.com>
7 * Copyright (c) 2006-2008 Novell Inc. 8 * Copyright (c) 2006-2008 Novell Inc.
8 * 9 *
9 * This file is released under the GPLv2.
10 *
11 * Please read Documentation/kobject.txt before using the kobject 10 * Please read Documentation/kobject.txt before using the kobject
12 * interface, ESPECIALLY the parts about reference counts and object 11 * interface, ESPECIALLY the parts about reference counts and object
13 * destructors. 12 * destructors.
diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
index df32d2508290..069aa2ebef90 100644
--- a/include/linux/kobject_ns.h
+++ b/include/linux/kobject_ns.h
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* Kernel object name space definitions 2/* Kernel object name space definitions
2 * 3 *
3 * Copyright (c) 2002-2003 Patrick Mochel 4 * Copyright (c) 2002-2003 Patrick Mochel
@@ -7,8 +8,6 @@
7 * 8 *
8 * Split from kobject.h by David Howells (dhowells@redhat.com) 9 * Split from kobject.h by David Howells (dhowells@redhat.com)
9 * 10 *
10 * This file is released under the GPLv2.
11 *
12 * Please read Documentation/kobject.txt before using the kobject 11 * Please read Documentation/kobject.txt before using the kobject
13 * interface, ESPECIALLY the parts about reference counts and object 12 * interface, ESPECIALLY the parts about reference counts and object
14 * destructors. 13 * destructors.
diff --git a/include/linux/property.h b/include/linux/property.h
index 1106bc62dd8c..769d372c1edf 100644
--- a/include/linux/property.h
+++ b/include/linux/property.h
@@ -214,7 +214,7 @@ struct property_entry {
214 */ 214 */
215 215
216#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _val_) \ 216#define PROPERTY_ENTRY_INTEGER_ARRAY(_name_, _type_, _val_) \
217{ \ 217(struct property_entry) { \
218 .name = _name_, \ 218 .name = _name_, \
219 .length = ARRAY_SIZE(_val_) * sizeof(_type_), \ 219 .length = ARRAY_SIZE(_val_) * sizeof(_type_), \
220 .is_array = true, \ 220 .is_array = true, \
@@ -232,7 +232,7 @@ struct property_entry {
232 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, _val_) 232 PROPERTY_ENTRY_INTEGER_ARRAY(_name_, u64, _val_)
233 233
234#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \ 234#define PROPERTY_ENTRY_STRING_ARRAY(_name_, _val_) \
235{ \ 235(struct property_entry) { \
236 .name = _name_, \ 236 .name = _name_, \
237 .length = ARRAY_SIZE(_val_) * sizeof(const char *), \ 237 .length = ARRAY_SIZE(_val_) * sizeof(const char *), \
238 .is_array = true, \ 238 .is_array = true, \
@@ -241,7 +241,7 @@ struct property_entry {
241} 241}
242 242
243#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _val_) \ 243#define PROPERTY_ENTRY_INTEGER(_name_, _type_, _val_) \
244{ \ 244(struct property_entry) { \
245 .name = _name_, \ 245 .name = _name_, \
246 .length = sizeof(_type_), \ 246 .length = sizeof(_type_), \
247 .is_string = false, \ 247 .is_string = false, \
@@ -258,7 +258,7 @@ struct property_entry {
258 PROPERTY_ENTRY_INTEGER(_name_, u64, _val_) 258 PROPERTY_ENTRY_INTEGER(_name_, u64, _val_)
259 259
260#define PROPERTY_ENTRY_STRING(_name_, _val_) \ 260#define PROPERTY_ENTRY_STRING(_name_, _val_) \
261{ \ 261(struct property_entry) { \
262 .name = _name_, \ 262 .name = _name_, \
263 .length = sizeof(_val_), \ 263 .length = sizeof(_val_), \
264 .is_string = true, \ 264 .is_string = true, \
@@ -266,7 +266,7 @@ struct property_entry {
266} 266}
267 267
268#define PROPERTY_ENTRY_BOOL(_name_) \ 268#define PROPERTY_ENTRY_BOOL(_name_) \
269{ \ 269(struct property_entry) { \
270 .name = _name_, \ 270 .name = _name_, \
271} 271}
272 272
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index 40839c02d28c..b8bfdc173ec0 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -113,7 +113,7 @@ struct attribute_group {
113} 113}
114 114
115#define __ATTR_RO(_name) { \ 115#define __ATTR_RO(_name) { \
116 .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ 116 .attr = { .name = __stringify(_name), .mode = 0444 }, \
117 .show = _name##_show, \ 117 .show = _name##_show, \
118} 118}
119 119
@@ -124,12 +124,11 @@ struct attribute_group {
124} 124}
125 125
126#define __ATTR_WO(_name) { \ 126#define __ATTR_WO(_name) { \
127 .attr = { .name = __stringify(_name), .mode = S_IWUSR }, \ 127 .attr = { .name = __stringify(_name), .mode = 0200 }, \
128 .store = _name##_store, \ 128 .store = _name##_store, \
129} 129}
130 130
131#define __ATTR_RW(_name) __ATTR(_name, (S_IWUSR | S_IRUGO), \ 131#define __ATTR_RW(_name) __ATTR(_name, 0644, _name##_show, _name##_store)
132 _name##_show, _name##_store)
133 132
134#define __ATTR_NULL { .attr = { .name = NULL } } 133#define __ATTR_NULL { .attr = { .name = NULL } }
135 134
@@ -192,14 +191,13 @@ struct bin_attribute {
192} 191}
193 192
194#define __BIN_ATTR_RO(_name, _size) { \ 193#define __BIN_ATTR_RO(_name, _size) { \
195 .attr = { .name = __stringify(_name), .mode = S_IRUGO }, \ 194 .attr = { .name = __stringify(_name), .mode = 0444 }, \
196 .read = _name##_read, \ 195 .read = _name##_read, \
197 .size = _size, \ 196 .size = _size, \
198} 197}
199 198
200#define __BIN_ATTR_RW(_name, _size) __BIN_ATTR(_name, \ 199#define __BIN_ATTR_RW(_name, _size) \
201 (S_IWUSR | S_IRUGO), _name##_read, \ 200 __BIN_ATTR(_name, 0644, _name##_read, _name##_write, _size)
202 _name##_write, _size)
203 201
204#define __BIN_ATTR_NULL __ATTR_NULL 202#define __BIN_ATTR_NULL __ATTR_NULL
205 203
diff --git a/lib/kobject.c b/lib/kobject.c
index 06b849eee0ca..afd5a3fc6123 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * kobject.c - library routines for handling generic kernel objects 3 * kobject.c - library routines for handling generic kernel objects
3 * 4 *
@@ -5,9 +6,6 @@
5 * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com> 6 * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com>
6 * Copyright (c) 2006-2007 Novell Inc. 7 * Copyright (c) 2006-2007 Novell Inc.
7 * 8 *
8 * This file is released under the GPLv2.
9 *
10 *
11 * Please see the file Documentation/kobject.txt for critical information 9 * Please see the file Documentation/kobject.txt for critical information
12 * about using the kobject interface. 10 * about using the kobject interface.
13 */ 11 */
diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
index 2615074d3de5..9fe6ec8fda28 100644
--- a/lib/kobject_uevent.c
+++ b/lib/kobject_uevent.c
@@ -1,3 +1,4 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * kernel userspace event delivery 3 * kernel userspace event delivery
3 * 4 *
@@ -5,8 +6,6 @@
5 * Copyright (C) 2004 Novell, Inc. All rights reserved. 6 * Copyright (C) 2004 Novell, Inc. All rights reserved.
6 * Copyright (C) 2004 IBM, Inc. All rights reserved. 7 * Copyright (C) 2004 IBM, Inc. All rights reserved.
7 * 8 *
8 * Licensed under the GNU GPL v2.
9 *
10 * Authors: 9 * Authors:
11 * Robert Love <rml@novell.com> 10 * Robert Love <rml@novell.com>
12 * Kay Sievers <kay.sievers@vrfy.org> 11 * Kay Sievers <kay.sievers@vrfy.org>
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 64a4c76cba2b..078a61480573 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -96,7 +96,7 @@ struct test_config {
96 struct device *device); 96 struct device *device);
97}; 97};
98 98
99struct test_config *test_fw_config; 99static struct test_config *test_fw_config;
100 100
101static ssize_t test_fw_misc_read(struct file *f, char __user *buf, 101static ssize_t test_fw_misc_read(struct file *f, char __user *buf,
102 size_t size, loff_t *offset) 102 size_t size, loff_t *offset)
@@ -359,7 +359,7 @@ static ssize_t config_name_show(struct device *dev,
359{ 359{
360 return config_test_show_str(buf, test_fw_config->name); 360 return config_test_show_str(buf, test_fw_config->name);
361} 361}
362static DEVICE_ATTR(config_name, 0644, config_name_show, config_name_store); 362static DEVICE_ATTR_RW(config_name);
363 363
364static ssize_t config_num_requests_store(struct device *dev, 364static ssize_t config_num_requests_store(struct device *dev,
365 struct device_attribute *attr, 365 struct device_attribute *attr,
@@ -371,6 +371,7 @@ static ssize_t config_num_requests_store(struct device *dev,
371 if (test_fw_config->reqs) { 371 if (test_fw_config->reqs) {
372 pr_err("Must call release_all_firmware prior to changing config\n"); 372 pr_err("Must call release_all_firmware prior to changing config\n");
373 rc = -EINVAL; 373 rc = -EINVAL;
374 mutex_unlock(&test_fw_mutex);
374 goto out; 375 goto out;
375 } 376 }
376 mutex_unlock(&test_fw_mutex); 377 mutex_unlock(&test_fw_mutex);
@@ -388,8 +389,7 @@ static ssize_t config_num_requests_show(struct device *dev,
388{ 389{
389 return test_dev_config_show_u8(buf, test_fw_config->num_requests); 390 return test_dev_config_show_u8(buf, test_fw_config->num_requests);
390} 391}
391static DEVICE_ATTR(config_num_requests, 0644, config_num_requests_show, 392static DEVICE_ATTR_RW(config_num_requests);
392 config_num_requests_store);
393 393
394static ssize_t config_sync_direct_store(struct device *dev, 394static ssize_t config_sync_direct_store(struct device *dev,
395 struct device_attribute *attr, 395 struct device_attribute *attr,
@@ -411,8 +411,7 @@ static ssize_t config_sync_direct_show(struct device *dev,
411{ 411{
412 return test_dev_config_show_bool(buf, test_fw_config->sync_direct); 412 return test_dev_config_show_bool(buf, test_fw_config->sync_direct);
413} 413}
414static DEVICE_ATTR(config_sync_direct, 0644, config_sync_direct_show, 414static DEVICE_ATTR_RW(config_sync_direct);
415 config_sync_direct_store);
416 415
417static ssize_t config_send_uevent_store(struct device *dev, 416static ssize_t config_send_uevent_store(struct device *dev,
418 struct device_attribute *attr, 417 struct device_attribute *attr,
@@ -428,8 +427,7 @@ static ssize_t config_send_uevent_show(struct device *dev,
428{ 427{
429 return test_dev_config_show_bool(buf, test_fw_config->send_uevent); 428 return test_dev_config_show_bool(buf, test_fw_config->send_uevent);
430} 429}
431static DEVICE_ATTR(config_send_uevent, 0644, config_send_uevent_show, 430static DEVICE_ATTR_RW(config_send_uevent);
432 config_send_uevent_store);
433 431
434static ssize_t config_read_fw_idx_store(struct device *dev, 432static ssize_t config_read_fw_idx_store(struct device *dev,
435 struct device_attribute *attr, 433 struct device_attribute *attr,
@@ -445,8 +443,7 @@ static ssize_t config_read_fw_idx_show(struct device *dev,
445{ 443{
446 return test_dev_config_show_u8(buf, test_fw_config->read_fw_idx); 444 return test_dev_config_show_u8(buf, test_fw_config->read_fw_idx);
447} 445}
448static DEVICE_ATTR(config_read_fw_idx, 0644, config_read_fw_idx_show, 446static DEVICE_ATTR_RW(config_read_fw_idx);
449 config_read_fw_idx_store);
450 447
451 448
452static ssize_t trigger_request_store(struct device *dev, 449static ssize_t trigger_request_store(struct device *dev,
diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 337f408b4de6..e372b97eee13 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -694,8 +694,7 @@ static ssize_t config_test_driver_show(struct device *dev,
694 return config_test_show_str(&test_dev->config_mutex, buf, 694 return config_test_show_str(&test_dev->config_mutex, buf,
695 config->test_driver); 695 config->test_driver);
696} 696}
697static DEVICE_ATTR(config_test_driver, 0644, config_test_driver_show, 697static DEVICE_ATTR_RW(config_test_driver);
698 config_test_driver_store);
699 698
700static ssize_t config_test_fs_store(struct device *dev, 699static ssize_t config_test_fs_store(struct device *dev,
701 struct device_attribute *attr, 700 struct device_attribute *attr,
@@ -726,8 +725,7 @@ static ssize_t config_test_fs_show(struct device *dev,
726 return config_test_show_str(&test_dev->config_mutex, buf, 725 return config_test_show_str(&test_dev->config_mutex, buf,
727 config->test_fs); 726 config->test_fs);
728} 727}
729static DEVICE_ATTR(config_test_fs, 0644, config_test_fs_show, 728static DEVICE_ATTR_RW(config_test_fs);
730 config_test_fs_store);
731 729
732static int trigger_config_run_type(struct kmod_test_device *test_dev, 730static int trigger_config_run_type(struct kmod_test_device *test_dev,
733 enum kmod_test_case test_case, 731 enum kmod_test_case test_case,
@@ -1012,8 +1010,7 @@ static ssize_t config_num_threads_show(struct device *dev,
1012 1010
1013 return test_dev_config_show_int(test_dev, buf, config->num_threads); 1011 return test_dev_config_show_int(test_dev, buf, config->num_threads);
1014} 1012}
1015static DEVICE_ATTR(config_num_threads, 0644, config_num_threads_show, 1013static DEVICE_ATTR_RW(config_num_threads);
1016 config_num_threads_store);
1017 1014
1018static ssize_t config_test_case_store(struct device *dev, 1015static ssize_t config_test_case_store(struct device *dev,
1019 struct device_attribute *attr, 1016 struct device_attribute *attr,
@@ -1037,8 +1034,7 @@ static ssize_t config_test_case_show(struct device *dev,
1037 1034
1038 return test_dev_config_show_uint(test_dev, buf, config->test_case); 1035 return test_dev_config_show_uint(test_dev, buf, config->test_case);
1039} 1036}
1040static DEVICE_ATTR(config_test_case, 0644, config_test_case_show, 1037static DEVICE_ATTR_RW(config_test_case);
1041 config_test_case_store);
1042 1038
1043static ssize_t test_result_show(struct device *dev, 1039static ssize_t test_result_show(struct device *dev,
1044 struct device_attribute *attr, 1040 struct device_attribute *attr,
@@ -1049,7 +1045,7 @@ static ssize_t test_result_show(struct device *dev,
1049 1045
1050 return test_dev_config_show_int(test_dev, buf, config->test_result); 1046 return test_dev_config_show_int(test_dev, buf, config->test_result);
1051} 1047}
1052static DEVICE_ATTR(test_result, 0644, test_result_show, test_result_store); 1048static DEVICE_ATTR_RW(test_result);
1053 1049
1054#define TEST_KMOD_DEV_ATTR(name) &dev_attr_##name.attr 1050#define TEST_KMOD_DEV_ATTR(name) &dev_attr_##name.attr
1055 1051
diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c
index 2e0740f06cd7..9e383fdbaa00 100644
--- a/samples/kobject/kobject-example.c
+++ b/samples/kobject/kobject-example.c
@@ -1,11 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Sample kobject implementation 3 * Sample kobject implementation
3 * 4 *
4 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2007 Novell Inc. 6 * Copyright (C) 2007 Novell Inc.
6 *
7 * Released under the GPL version 2 only.
8 *
9 */ 7 */
10#include <linux/kobject.h> 8#include <linux/kobject.h>
11#include <linux/string.h> 9#include <linux/string.h>
diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c
index a55bff52bde3..401328fd687d 100644
--- a/samples/kobject/kset-example.c
+++ b/samples/kobject/kset-example.c
@@ -1,11 +1,9 @@
1// SPDX-License-Identifier: GPL-2.0
1/* 2/*
2 * Sample kset and ktype implementation 3 * Sample kset and ktype implementation
3 * 4 *
4 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com> 5 * Copyright (C) 2004-2007 Greg Kroah-Hartman <greg@kroah.com>
5 * Copyright (C) 2007 Novell Inc. 6 * Copyright (C) 2007 Novell Inc.
6 *
7 * Released under the GPL version 2 only.
8 *
9 */ 7 */
10#include <linux/kobject.h> 8#include <linux/kobject.h>
11#include <linux/string.h> 9#include <linux/string.h>
diff --git a/sound/soc/omap/mcbsp.c b/sound/soc/omap/mcbsp.c
index 7a54e3083203..79d4dc785e5c 100644
--- a/sound/soc/omap/mcbsp.c
+++ b/sound/soc/omap/mcbsp.c
@@ -854,7 +854,7 @@ unlock:
854 return size; 854 return size;
855} 855}
856 856
857static DEVICE_ATTR(dma_op_mode, 0644, dma_op_mode_show, dma_op_mode_store); 857static DEVICE_ATTR_RW(dma_op_mode);
858 858
859static const struct attribute *additional_attrs[] = { 859static const struct attribute *additional_attrs[] = {
860 &dev_attr_max_tx_thres.attr, 860 &dev_attr_max_tx_thres.attr,
@@ -923,7 +923,7 @@ out:
923 return size; 923 return size;
924} 924}
925 925
926static DEVICE_ATTR(st_taps, 0644, st_taps_show, st_taps_store); 926static DEVICE_ATTR_RW(st_taps);
927 927
928static const struct attribute *sidetone_attrs[] = { 928static const struct attribute *sidetone_attrs[] = {
929 &dev_attr_st_taps.attr, 929 &dev_attr_st_taps.attr,
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index e91879569a0f..88efc84f3e7b 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -173,7 +173,7 @@ static ssize_t codec_reg_show(struct device *dev,
173 return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0); 173 return soc_codec_reg_show(rtd->codec, buf, PAGE_SIZE, 0);
174} 174}
175 175
176static DEVICE_ATTR(codec_reg, 0444, codec_reg_show, NULL); 176static DEVICE_ATTR_RO(codec_reg);
177 177
178static ssize_t pmdown_time_show(struct device *dev, 178static ssize_t pmdown_time_show(struct device *dev,
179 struct device_attribute *attr, char *buf) 179 struct device_attribute *attr, char *buf)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index a10b21cfc31e..d1977ced895f 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -2364,7 +2364,7 @@ static ssize_t dapm_widget_show(struct device *dev,
2364 return count; 2364 return count;
2365} 2365}
2366 2366
2367static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); 2367static DEVICE_ATTR_RO(dapm_widget);
2368 2368
2369struct attribute *soc_dapm_dev_attrs[] = { 2369struct attribute *soc_dapm_dev_attrs[] = {
2370 &dev_attr_dapm_widget.attr, 2370 &dev_attr_dapm_widget.attr,
diff --git a/tools/testing/selftests/firmware/fw_fallback.sh b/tools/testing/selftests/firmware/fw_fallback.sh
index 34a42c68ebfb..722cad91df74 100755
--- a/tools/testing/selftests/firmware/fw_fallback.sh
+++ b/tools/testing/selftests/firmware/fw_fallback.sh
@@ -175,96 +175,118 @@ trap "test_finish" EXIT
175echo "ABCD0123" >"$FW" 175echo "ABCD0123" >"$FW"
176NAME=$(basename "$FW") 176NAME=$(basename "$FW")
177 177
178DEVPATH="$DIR"/"nope-$NAME"/loading 178test_syfs_timeout()
179 179{
180# Test failure when doing nothing (timeout works). 180 DEVPATH="$DIR"/"nope-$NAME"/loading
181echo -n 2 >/sys/class/firmware/timeout 181
182echo -n "nope-$NAME" >"$DIR"/trigger_request 2>/dev/null & 182 # Test failure when doing nothing (timeout works).
183 183 echo -n 2 >/sys/class/firmware/timeout
184# Give the kernel some time to load the loading file, must be less 184 echo -n "nope-$NAME" >"$DIR"/trigger_request 2>/dev/null &
185# than the timeout above. 185
186sleep 1 186 # Give the kernel some time to load the loading file, must be less
187if [ ! -f $DEVPATH ]; then 187 # than the timeout above.
188 echo "$0: fallback mechanism immediately cancelled" 188 sleep 1
189 echo "" 189 if [ ! -f $DEVPATH ]; then
190 echo "The file never appeared: $DEVPATH" 190 echo "$0: fallback mechanism immediately cancelled"
191 echo "" 191 echo ""
192 echo "This might be a distribution udev rule setup by your distribution" 192 echo "The file never appeared: $DEVPATH"
193 echo "to immediately cancel all fallback requests, this must be" 193 echo ""
194 echo "removed before running these tests. To confirm look for" 194 echo "This might be a distribution udev rule setup by your distribution"
195 echo "a firmware rule like /lib/udev/rules.d/50-firmware.rules" 195 echo "to immediately cancel all fallback requests, this must be"
196 echo "and see if you have something like this:" 196 echo "removed before running these tests. To confirm look for"
197 echo "" 197 echo "a firmware rule like /lib/udev/rules.d/50-firmware.rules"
198 echo "SUBSYSTEM==\"firmware\", ACTION==\"add\", ATTR{loading}=\"-1\"" 198 echo "and see if you have something like this:"
199 echo "" 199 echo ""
200 echo "If you do remove this file or comment out this line before" 200 echo "SUBSYSTEM==\"firmware\", ACTION==\"add\", ATTR{loading}=\"-1\""
201 echo "proceeding with these tests." 201 echo ""
202 exit 1 202 echo "If you do remove this file or comment out this line before"
203fi 203 echo "proceeding with these tests."
204 204 exit 1
205if diff -q "$FW" /dev/test_firmware >/dev/null ; then 205 fi
206 echo "$0: firmware was not expected to match" >&2
207 exit 1
208else
209 echo "$0: timeout works"
210fi
211
212# Put timeout high enough for us to do work but not so long that failures
213# slow down this test too much.
214echo 4 >/sys/class/firmware/timeout
215 206
216# Load this script instead of the desired firmware. 207 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
217load_fw "$NAME" "$0" 208 echo "$0: firmware was not expected to match" >&2
218if diff -q "$FW" /dev/test_firmware >/dev/null ; then 209 exit 1
219 echo "$0: firmware was not expected to match" >&2 210 else
220 exit 1 211 echo "$0: timeout works"
221else 212 fi
222 echo "$0: firmware comparison works" 213}
223fi
224 214
225# Do a proper load, which should work correctly. 215run_sysfs_main_tests()
226load_fw "$NAME" "$FW" 216{
227if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then 217 test_syfs_timeout
228 echo "$0: firmware was not loaded" >&2 218 # Put timeout high enough for us to do work but not so long that failures
229 exit 1 219 # slow down this test too much.
230else 220 echo 4 >/sys/class/firmware/timeout
231 echo "$0: fallback mechanism works"
232fi
233 221
234load_fw_cancel "nope-$NAME" "$FW" 222 # Load this script instead of the desired firmware.
235if diff -q "$FW" /dev/test_firmware >/dev/null ; then 223 load_fw "$NAME" "$0"
236 echo "$0: firmware was expected to be cancelled" >&2 224 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
237 exit 1 225 echo "$0: firmware was not expected to match" >&2
238else 226 exit 1
239 echo "$0: cancelling fallback mechanism works" 227 else
240fi 228 echo "$0: firmware comparison works"
229 fi
241 230
242if load_fw_custom "$NAME" "$FW" ; then 231 # Do a proper load, which should work correctly.
232 load_fw "$NAME" "$FW"
243 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then 233 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
244 echo "$0: firmware was not loaded" >&2 234 echo "$0: firmware was not loaded" >&2
245 exit 1 235 exit 1
246 else 236 else
247 echo "$0: custom fallback loading mechanism works" 237 echo "$0: fallback mechanism works"
248 fi 238 fi
249fi
250 239
251if load_fw_custom_cancel "nope-$NAME" "$FW" ; then 240 load_fw_cancel "nope-$NAME" "$FW"
252 if diff -q "$FW" /dev/test_firmware >/dev/null ; then 241 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
253 echo "$0: firmware was expected to be cancelled" >&2 242 echo "$0: firmware was expected to be cancelled" >&2
254 exit 1 243 exit 1
255 else 244 else
256 echo "$0: cancelling custom fallback mechanism works" 245 echo "$0: cancelling fallback mechanism works"
257 fi 246 fi
258fi
259 247
260set +e 248 set +e
261load_fw_fallback_with_child "nope-signal-$NAME" "$FW" 249 load_fw_fallback_with_child "nope-signal-$NAME" "$FW"
262if [ "$?" -eq 0 ]; then 250 if [ "$?" -eq 0 ]; then
263 echo "$0: SIGCHLD on sync ignored as expected" >&2 251 echo "$0: SIGCHLD on sync ignored as expected" >&2
264else 252 else
265 echo "$0: error - sync firmware request cancelled due to SIGCHLD" >&2 253 echo "$0: error - sync firmware request cancelled due to SIGCHLD" >&2
266 exit 1 254 exit 1
267fi 255 fi
268set -e 256 set -e
257}
258
259run_sysfs_custom_load_tests()
260{
261 if load_fw_custom "$NAME" "$FW" ; then
262 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
263 echo "$0: firmware was not loaded" >&2
264 exit 1
265 else
266 echo "$0: custom fallback loading mechanism works"
267 fi
268 fi
269
270 if load_fw_custom "$NAME" "$FW" ; then
271 if ! diff -q "$FW" /dev/test_firmware >/dev/null ; then
272 echo "$0: firmware was not loaded" >&2
273 exit 1
274 else
275 echo "$0: custom fallback loading mechanism works"
276 fi
277 fi
278
279 if load_fw_custom_cancel "nope-$NAME" "$FW" ; then
280 if diff -q "$FW" /dev/test_firmware >/dev/null ; then
281 echo "$0: firmware was expected to be cancelled" >&2
282 exit 1
283 else
284 echo "$0: cancelling custom fallback mechanism works"
285 fi
286 fi
287}
288
289run_sysfs_main_tests
290run_sysfs_custom_load_tests
269 291
270exit 0 292exit 0
diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh
index b1f20fef36c7..f9508e1a4058 100755
--- a/tools/testing/selftests/firmware/fw_filesystem.sh
+++ b/tools/testing/selftests/firmware/fw_filesystem.sh
@@ -45,7 +45,10 @@ test_finish()
45 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then 45 if [ "$HAS_FW_LOADER_USER_HELPER" = "yes" ]; then
46 echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout 46 echo "$OLD_TIMEOUT" >/sys/class/firmware/timeout
47 fi 47 fi
48 echo -n "$OLD_PATH" >/sys/module/firmware_class/parameters/path 48 if [ "$OLD_FWPATH" = "" ]; then
49 OLD_FWPATH=" "
50 fi
51 echo -n "$OLD_FWPATH" >/sys/module/firmware_class/parameters/path
49 rm -f "$FW" 52 rm -f "$FW"
50 rmdir "$FWPATH" 53 rmdir "$FWPATH"
51} 54}