Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'driver-core-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
"Here is the set of "big" driver core patches for 4.16-rc1.

The majority of the work here is in the firmware subsystem, with
reworks to try to attempt to make the code easier to handle in the
long run, but no functional change. There's also some tree-wide sysfs
attribute fixups with lots of acks from the various subsystem
maintainers, as well as a handful of other normal fixes and changes.

And finally, some license cleanups for the driver core and sysfs code.

All have been in linux-next for a while with no reported issues"

* tag 'driver-core-4.16-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (48 commits)
device property: Define type of PROPERTY_ENRTY_*() macros
device property: Reuse property_entry_free_data()
device property: Move property_entry_free_data() upper
firmware: Fix up docs referring to FIRMWARE_IN_KERNEL
firmware: Drop FIRMWARE_IN_KERNEL Kconfig option
USB: serial: keyspan: Drop firmware Kconfig options
sysfs: remove DEBUG defines
sysfs: use SPDX identifiers
drivers: base: add coredump driver ops
sysfs: add attribute specification for /sysfs/devices/.../coredump
test_firmware: fix missing unlock on error in config_num_requests_store()
test_firmware: make local symbol test_fw_config static
sysfs: turn WARN() into pr_warn()
firmware: Fix a typo in fallback-mechanisms.rst
treewide: Use DEVICE_ATTR_WO
treewide: Use DEVICE_ATTR_RO
treewide: Use DEVICE_ATTR_RW
sysfs.h: Use octal permissions
component: add debugfs support
bus: simple-pm-bus: convert bool SIMPLE_PM_BUS to tristate
...

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