kernel-hacking-2024-linux-s.../drivers/pci/hotplug
Arnd Bergmann 613655fa39 drivers: autoconvert trivial BKL users to private mutex
All these files use the big kernel lock in a trivial
way to serialize their private file operations,
typically resulting from an earlier semi-automatic
pushdown from VFS.

None of these drivers appears to want to lock against
other code, and they all use the BKL as the top-level
lock in their file operations, meaning that there
is no lock-order inversion problem.

Consequently, we can remove the BKL completely,
replacing it with a per-file mutex in every case.
Using a scripted approach means we can avoid
typos.

These drivers do not seem to be under active
maintainance from my brief investigation. Apologies
to those maintainers that I have missed.

file=$1
name=$2
if grep -q lock_kernel ${file} ; then
    if grep -q 'include.*linux.mutex.h' ${file} ; then
            sed -i '/include.*<linux\/smp_lock.h>/d' ${file}
    else
            sed -i 's/include.*<linux\/smp_lock.h>.*$/include <linux\/mutex.h>/g' ${file}
    fi
    sed -i ${file} \
        -e "/^#include.*linux.mutex.h/,$ {
                1,/^\(static\|int\|long\)/ {
                     /^\(static\|int\|long\)/istatic DEFINE_MUTEX(${name}_mutex);

} }"  \
    -e "s/\(un\)*lock_kernel\>[ ]*()/mutex_\1lock(\&${name}_mutex)/g" \
    -e '/[      ]*cycle_kernel_lock();/d'
else
    sed -i -e '/include.*\<smp_lock.h\>/d' ${file}  \
                -e '/cycle_kernel_lock()/d'
fi

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2010-10-05 15:01:04 +02:00
..
acpi_pcihp.c PCI: PCIe: Ask BIOS for control of all native services at once 2010-08-24 13:47:33 -07:00
acpiphp.h
acpiphp_core.c
acpiphp_glue.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
acpiphp_ibm.c sysfs: add struct file* to bin_attr callbacks 2010-05-21 09:37:31 -07:00
cpci_hotplug.h
cpci_hotplug_core.c
cpci_hotplug_pci.c
cpcihp_generic.c
cpcihp_zt5550.c
cpcihp_zt5550.h
cpqphp.h
cpqphp_core.c PCI: hotplug/cpqphp, fix NULL dereference 2010-06-11 13:10:21 -07:00
cpqphp_ctrl.c
cpqphp_nvram.c
cpqphp_nvram.h
cpqphp_pci.c
cpqphp_sysfs.c drivers: autoconvert trivial BKL users to private mutex 2010-10-05 15:01:04 +02:00
fakephp.c PCI: use for_each_pci_dev() 2010-07-30 09:47:22 -07:00
ibmphp.h
ibmphp_core.c
ibmphp_ebda.c PCI hotplug: check ioremap() return value in ibmphp_ebda.c 2010-02-22 16:17:19 -08:00
ibmphp_hpc.c PCI hotplug: fix ibmphp build error 2010-02-22 16:17:18 -08:00
ibmphp_pci.c
ibmphp_res.c
Kconfig
Makefile
pci_hotplug_core.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pciehp.h PCI hotplug: Fix build with CONFIG_ACPI unset 2010-08-25 12:54:03 -07:00
pciehp_acpi.c PCI: PCIe: Ask BIOS for control of all native services at once 2010-08-24 13:47:33 -07:00
pciehp_core.c PCI: PCIe: Ask BIOS for control of all native services at once 2010-08-24 13:47:33 -07:00
pciehp_ctrl.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pciehp_hpc.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
pciehp_pci.c PCI hotplug: pciehp: Fixed return value sign for pciehp_unconfigure_device 2010-07-30 09:29:15 -07:00
pcihp_skeleton.c
pcihp_slot.c
rpadlpar.h
rpadlpar_core.c powerpc/pseries: Flush lazy kernel mappings after unplug operations 2010-04-28 16:23:24 +10:00
rpadlpar_sysfs.c
rpaphp.h
rpaphp_core.c powerpc/pseries: Flush lazy kernel mappings after unplug operations 2010-04-28 16:23:24 +10:00
rpaphp_pci.c
rpaphp_slot.c
sgi_hotplug.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
shpchp.h
shpchp_core.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
shpchp_ctrl.c include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h 2010-03-30 22:02:32 +09:00
shpchp_hpc.c PCI: hotplug/shpchp_hpc: add parenthesis in SLOT_REG_RSVDZ_MASK 2010-07-30 09:29:10 -07:00
shpchp_pci.c PCI hotplug: shpchp: Removed check for hotplug of display devices 2010-07-30 09:29:16 -07:00
shpchp_sysfs.c PCI: add pci_bus_for_each_resource(), remove direct bus->resource[] refs 2010-02-23 09:43:31 -08:00