-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmVmHpsACgkQONu9yGCS aT5uvw//SzcE0GImnHnfeN7iXtpFE9O0fhTxsjZCi8/HTXmGWPtQgWscd9y81bAd EHBVr456GXqd6KuIF+03g/r/FYinwWqK375meLfaybw1vSBP+fZttrEGqz6nTnYD yqOxw2bqgz8Xjp63UeNHD6mifpBvVtuAvzrfO1E2Ie/U1OU2uKdjRRv0iijKNeWN liOYTXaddIkVfZR0z6dVTl0hb5dPWsxNmF77kfVpKz4ALIHJcO13DlUuKtQz6Sb6 0ElmJpuonHuUxHzb8e9LLsFy3IvbBqomSscwcd0tngtdUTzhMYFIZLjg2+WQ9Ovq raMGqvS/bKsoyoTBNKL83QB2NyXQb3vkfL0NgLsq9IwDl+r96mP9ctANYGwSjhND o/4sa/fbMFzeInA8Rzh7i56RCNstOBKApJPhBzWuY0f/6b1BZpvZaONyX3fFksWO dMeYT16GgO4lhQXnG3O6mtDT8eoZ1fLf7ZdGEZ2NktcOzXYelNc4aXJke7qdlIop CVxM+Ur+juj+DJymo59a6baXjEgIROdHq83N3CZwetGviPHneGqgYc0K7ETtA33H sH/0KGYAT8SzzjMlnXB0lpjp68WViJfzzo9Wxdf2aDZbL3SdI14GPKMUeDqqeSyU 8bB2Hb4ItccRFW9RriiE3BPGnLGu7PDTkn5TgXDG/bDX54Cb5DQ= =YPzI -----END PGP SIGNATURE----- Merge 6.1.64 into android14-6.1-lts Changes in 6.1.64 locking/ww_mutex/test: Fix potential workqueue corruption lib/generic-radix-tree.c: Don't overflow in peek() perf/core: Bail out early if the request AUX area is out of bound srcu: Fix srcu_struct node grpmask overflow on 64-bit systems selftests/lkdtm: Disable CONFIG_UBSAN_TRAP in test config clocksource/drivers/timer-imx-gpt: Fix potential memory leak clocksource/drivers/timer-atmel-tcb: Fix initialization on SAM9 hardware smp,csd: Throw an error if a CSD lock is stuck for too long cpu/hotplug: Don't offline the last non-isolated CPU workqueue: Provide one lock class key per work_on_cpu() callsite x86/mm: Drop the 4 MB restriction on minimal NUMA node memory size wifi: plfxlc: fix clang-specific fortify warning wifi: mac80211_hwsim: fix clang-specific fortify warning wifi: mac80211: don't return unset power in ieee80211_get_tx_power() atl1c: Work around the DMA RX overflow issue bpf: Detect IP == ksym.end as part of BPF program wifi: ath9k: fix clang-specific fortify warnings wifi: ath10k: fix clang-specific fortify warning net: annotate data-races around sk->sk_tx_queue_mapping net: annotate data-races around sk->sk_dst_pending_confirm wifi: ath10k: Don't touch the CE interrupt registers after power up vsock: read from socket's error queue bpf: Ensure proper register state printing for cond jumps Bluetooth: btusb: Add date->evt_skb is NULL check Bluetooth: Fix double free in hci_conn_cleanup ACPI: EC: Add quirk for HP 250 G7 Notebook PC tsnep: Fix tsnep_request_irq() format-overflow warning platform/chrome: kunit: initialize lock for fake ec_dev platform/x86: thinkpad_acpi: Add battery quirk for Thinkpad X120e drm/gma500: Fix call trace when psb_gem_mm_init() fails drm/komeda: drop all currently held locks if deadlock happens drm/amdgpu: not to save bo in the case of RAS err_event_athub drm/amdkfd: Fix a race condition of vram buffer unref in svm code drm/amd: Update `update_pcie_parameters` functions to use uint8_t arguments drm/amd/display: use full update for clip size increase of large plane source string.h: add array-wrappers for (v)memdup_user() kernel: kexec: copy user-array safely kernel: watch_queue: copy user-array safely drm_lease.c: copy user-array safely drm: vmwgfx_surface.c: copy user-array safely drm/msm/dp: skip validity check for DP CTS EDID checksum drm/amd: Fix UBSAN array-index-out-of-bounds for SMU7 drm/amd: Fix UBSAN array-index-out-of-bounds for Polaris and Tonga drm/amdgpu: Fix potential null pointer derefernce drm/panel: fix a possible null pointer dereference drm/panel/panel-tpo-tpg110: fix a possible null pointer dereference drm/radeon: fix a possible null pointer dereference drm/amdgpu/vkms: fix a possible null pointer dereference drm/panel: st7703: Pick different reset sequence drm/amdkfd: Fix shift out-of-bounds issue drm/amdgpu: Fix a null pointer access when the smc_rreg pointer is NULL arm64: dts: ls208xa: use a pseudo-bus to constrain usb dma size selftests/efivarfs: create-read: fix a resource leak ASoC: soc-card: Add storage for PCI SSID ASoC: SOF: Pass PCI SSID to machine driver crypto: pcrypt - Fix hungtask for PADATA_RESET ASoC: SOF: ipc4: handle EXCEPTION_CAUGHT notification from firmware RDMA/hfi1: Use FIELD_GET() to extract Link Width scsi: hisi_sas: Set debugfs_dir pointer to NULL after removing debugfs scsi: ibmvfc: Remove BUG_ON in the case of an empty event pool fs/jfs: Add check for negative db_l2nbperpage fs/jfs: Add validity check for db_maxag and db_agpref jfs: fix array-index-out-of-bounds in dbFindLeaf jfs: fix array-index-out-of-bounds in diAlloc HID: lenovo: Detect quirk-free fw on cptkbd and stop applying workaround ARM: 9320/1: fix stack depot IRQ stack filter ALSA: hda: Fix possible null-ptr-deref when assigning a stream PCI: tegra194: Use FIELD_GET()/FIELD_PREP() with Link Width fields PCI: mvebu: Use FIELD_PREP() with Link Width atm: iphase: Do PCI error checks on own line PCI: Do error check on own line to split long "if" conditions scsi: libfc: Fix potential NULL pointer dereference in fc_lport_ptp_setup() PCI: Use FIELD_GET() to extract Link Width PCI: Extract ATS disabling to a helper function PCI: Disable ATS for specific Intel IPU E2000 devices misc: pci_endpoint_test: Add Device ID for R-Car S4-8 PCIe controller PCI: Use FIELD_GET() in Sapphire RX 5600 XT Pulse quirk ASoC: Intel: soc-acpi-cht: Add Lenovo Yoga Tab 3 Pro YT3-X90 quirk crypto: hisilicon/qm - prevent soft lockup in receive loop HID: Add quirk for Dell Pro Wireless Keyboard and Mouse KM5221W exfat: support handle zero-size directory mfd: intel-lpss: Add Intel Lunar Lake-M PCI IDs iio: adc: stm32-adc: harden against NULL pointer deref in stm32_adc_probe() thunderbolt: Apply USB 3.x bandwidth quirk only in software connection manager tty: vcc: Add check for kstrdup() in vcc_probe() usb: dwc3: core: configure TX/RX threshold for DWC3_IP soundwire: dmi-quirks: update HP Omen match f2fs: fix error handling of __get_node_page usb: gadget: f_ncm: Always set current gadget in ncm_bind() 9p/trans_fd: Annotate data-racy writes to file::f_flags 9p: v9fs_listxattr: fix %s null argument warning i3c: mipi-i3c-hci: Fix out of bounds access in hci_dma_irq_handler i2c: fix memleak in i2c_new_client_device() i2c: sun6i-p2wi: Prevent potential division by zero virtio-blk: fix implicit overflow on virtio_max_dma_size i3c: master: mipi-i3c-hci: Fix a kernel panic for accessing DAT_data. media: gspca: cpia1: shift-out-of-bounds in set_flicker media: vivid: avoid integer overflow gfs2: ignore negated quota changes gfs2: fix an oops in gfs2_permission media: cobalt: Use FIELD_GET() to extract Link Width media: ccs: Fix driver quirk struct documentation media: imon: fix access to invalid resource for the second interface drm/amd/display: Avoid NULL dereference of timing generator kgdb: Flush console before entering kgdb on panic i2c: dev: copy userspace array safely ASoC: ti: omap-mcbsp: Fix runtime PM underflow warnings drm/qxl: prevent memory leak ALSA: hda/realtek: Add quirk for ASUS UX7602ZM drm/amdgpu: fix software pci_unplug on some chips pwm: Fix double shift bug mtd: rawnand: tegra: add missing check for platform_get_irq() wifi: iwlwifi: Use FW rate for non-data frames sched/core: Optimize in_task() and in_interrupt() a bit SUNRPC: ECONNRESET might require a rebind mtd: rawnand: intel: check return value of devm_kasprintf() mtd: rawnand: meson: check return value of devm_kasprintf() NFSv4.1: fix handling NFS4ERR_DELAY when testing for session trunking SUNRPC: Add an IS_ERR() check back to where it was NFSv4.1: fix SP4_MACH_CRED protection for pnfs IO SUNRPC: Fix RPC client cleaned up the freed pipefs dentries gfs2: Silence "suspicious RCU usage in gfs2_permission" warning vhost-vdpa: fix use after free in vhost_vdpa_probe() net: set SOCK_RCU_FREE before inserting socket into hashtable ipvlan: add ipvlan_route_v6_outbound() helper tty: Fix uninit-value access in ppp_sync_receive() net: hns3: fix add VLAN fail issue net: hns3: add barrier in vf mailbox reply process net: hns3: fix incorrect capability bit display for copper port net: hns3: fix out-of-bounds access may occur when coalesce info is read via debugfs net: hns3: fix variable may not initialized problem in hns3_init_mac_addr() net: hns3: fix VF reset fail issue net: hns3: fix VF wrong speed and duplex issue tipc: Fix kernel-infoleak due to uninitialized TLV value net: mvneta: fix calls to page_pool_get_stats ppp: limit MRU to 64K xen/events: fix delayed eoi list handling ptp: annotate data-race around q->head and q->tail bonding: stop the device in bond_setup_by_slave() net: ethernet: cortina: Fix max RX frame define net: ethernet: cortina: Handle large frames net: ethernet: cortina: Fix MTU max setting af_unix: fix use-after-free in unix_stream_read_actor() netfilter: nf_conntrack_bridge: initialize err to 0 netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() net: stmmac: fix rx budget limit check net: stmmac: avoid rx queue overrun net/mlx5e: fix double free of encap_header net/mlx5e: fix double free of encap_header in update funcs net/mlx5e: Fix pedit endianness net/mlx5e: Reduce the size of icosq_str net/mlx5e: Check return value of snprintf writing to fw_version buffer net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors macvlan: Don't propagate promisc change to lower dev in passthru tools/power/turbostat: Fix a knl bug tools/power/turbostat: Enable the C-state Pre-wake printing cifs: spnego: add ';' in HOST_KEY_LEN cifs: fix check of rc in function generate_smb3signingkey i915/perf: Fix NULL deref bugs with drm_dbg() calls media: venus: hfi: add checks to perform sanity on queue pointers perf intel-pt: Fix async branch flags powerpc/perf: Fix disabling BHRB and instruction sampling randstruct: Fix gcc-plugin performance mode to stay in group bpf: Fix check_stack_write_fixed_off() to correctly spill imm bpf: Fix precision tracking for BPF_ALU | BPF_TO_BE | BPF_END scsi: mpt3sas: Fix loop logic scsi: megaraid_sas: Increase register read retry rount from 3 to 30 for selected registers scsi: qla2xxx: Fix system crash due to bad pointer access crypto: x86/sha - load modules based on CPU features x86/cpu/hygon: Fix the CPU topology evaluation for real KVM: x86: hyper-v: Don't auto-enable stimer on write from user-space KVM: x86: Ignore MSR_AMD64_TW_CFG access KVM: x86: Clear bit12 of ICR after APIC-write VM-exit audit: don't take task_lock() in audit_exe_compare() code path audit: don't WARN_ON_ONCE(!current->mm) in audit_exe_compare() proc: sysctl: prevent aliased sysctls from getting passed to init tty/sysrq: replace smp_processor_id() with get_cpu() tty: serial: meson: fix hard LOCKUP on crtscts mode hvc/xen: fix console unplug hvc/xen: fix error path in xen_hvc_init() to always register frontend driver hvc/xen: fix event channel handling for secondary consoles PCI/sysfs: Protect driver's D3cold preference from user space mm/damon/sysfs: remove requested targets when online-commit inputs mm/damon/sysfs: update monitoring target regions for online input commit watchdog: move softlockup_panic back to early_param mm/damon/lru_sort: avoid divide-by-zero in hot threshold calculation mm/damon/ops-common: avoid divide-by-zero during region hotness calculation mm/damon: implement a function for max nr_accesses safe calculation mm/damon/sysfs: check error from damon_sysfs_update_target() ACPI: resource: Do IRQ override on TongFang GMxXGxx regmap: Ensure range selector registers are updated after cache sync wifi: ath11k: fix temperature event locking wifi: ath11k: fix dfs radar event locking wifi: ath11k: fix htt pktlog locking wifi: ath11k: fix gtk offload status event locking mmc: meson-gx: Remove setting of CMD_CFG_ERROR genirq/generic_chip: Make irq_remove_generic_chip() irqdomain aware KEYS: trusted: tee: Refactor register SHM usage KEYS: trusted: Rollback init_trusted() consistently PCI: keystone: Don't discard .remove() callback PCI: keystone: Don't discard .probe() callback arm64: Restrict CPU_BIG_ENDIAN to GNU as or LLVM IAS 15.x or newer parisc/pdc: Add width field to struct pdc_model parisc/power: Add power soft-off when running on qemu clk: socfpga: Fix undefined behavior bug in struct stratix10_clock_data clk: qcom: ipq8074: drop the CLK_SET_RATE_PARENT flag from PLL clocks clk: qcom: ipq6018: drop the CLK_SET_RATE_PARENT flag from PLL clocks ksmbd: handle malformed smb1 message ksmbd: fix slab out of bounds write in smb_inherit_dacl() mmc: vub300: fix an error code mmc: sdhci_am654: fix start loop index for TAP value parsing mmc: Add quirk MMC_QUIRK_BROKEN_CACHE_FLUSH for Micron eMMC Q2J54A PCI/ASPM: Fix L1 substate handling in aspm_attr_store_common() PCI: kirin: Don't discard .remove() callback PCI: exynos: Don't discard .remove() callback wifi: wilc1000: use vmm_table as array in wilc struct svcrdma: Drop connection after an RDMA Read error rcu/tree: Defer setting of jiffies during stall reset arm64: dts: qcom: ipq6018: Fix hwlock index for SMEM PM: hibernate: Use __get_safe_page() rather than touching the list PM: hibernate: Clean up sync_read handling in snapshot_write_next() rcu: kmemleak: Ignore kmemleak false positives when RCU-freeing objects btrfs: don't arbitrarily slow down delalloc if we're committing arm64: dts: qcom: ipq8074: Fix hwlock index for SMEM firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit ACPI: FPDT: properly handle invalid FPDT subtables arm64: dts: qcom: ipq6018: Fix tcsr_mutex register size mfd: qcom-spmi-pmic: Fix reference leaks in revid helper mfd: qcom-spmi-pmic: Fix revid implementation ima: annotate iint mutex to avoid lockdep false positive warnings ima: detect changes to the backing overlay file netfilter: nf_tables: remove catchall element in GC sync path netfilter: nf_tables: split async and sync catchall in two functions selftests/resctrl: Remove duplicate feature check from CMT test selftests/resctrl: Move _GNU_SOURCE define into Makefile selftests/resctrl: Reduce failures due to outliers in MBA/MBM tests hid: lenovo: Resend all settings on reset_resume for compact keyboards ASoC: codecs: wsa-macro: fix uninitialized stack variables with name prefix jbd2: fix potential data lost in recovering journal raced with synchronizing fs bdev quota: explicitly forbid quota files from being encrypted kernel/reboot: emergency_restart: Set correct system_state i2c: core: Run atomic i2c xfer when !preemptible tracing: Have the user copy of synthetic event address use correct context driver core: Release all resources during unbind before updating device links mcb: fix error handling for different scenarios when parsing dmaengine: stm32-mdma: correct desc prep when channel running s390/cmma: fix detection of DAT pages mm/cma: use nth_page() in place of direct struct page manipulation mm/memory_hotplug: use pfn math in place of direct struct page manipulation mtd: cfi_cmdset_0001: Byte swap OTP info i3c: master: cdns: Fix reading status register i3c: master: svc: fix race condition in ibi work thread i3c: master: svc: fix wrong data return when IBI happen during start frame i3c: master: svc: fix ibi may not return mandatory data byte i3c: master: svc: fix check wrong status register in irq handler i3c: master: svc: fix SDA keep low when polling IBIWON timeout happen parisc: Prevent booting 64-bit kernels on PA1.x machines parisc/pgtable: Do not drop upper 5 address bits of physical address parisc/power: Fix power soft-off when running on qemu xhci: Enable RPM on controllers that support low-power states fs: add ctime accessors infrastructure smb3: fix creating FIFOs when mounting with "sfu" mount option smb3: fix touch -h of symlink smb3: fix caching of ctime on setxattr smb: client: fix use-after-free bug in cifs_debug_data_proc_show() smb: client: fix potential deadlock when releasing mids cifs: reconnect helper should set reconnect for the right channel cifs: force interface update before a fresh session setup cifs: do not reset chan_max if multichannel is not supported at mount xfs: recovery should not clear di_flushiter unconditionally btrfs: zoned: wait for data BG to be finished on direct IO allocation ALSA: info: Fix potential deadlock at disconnection ALSA: hda/realtek: Enable Mute LED on HP 255 G8 ALSA: hda/realtek - Add Dell ALC295 to pin fall back table ALSA: hda/realtek - Enable internal speaker of ASUS K6500ZC ALSA: hda/realtek: Enable Mute LED on HP 255 G10 ALSA: hda/realtek: Add quirks for HP Laptops pmdomain: bcm: bcm2835-power: check if the ASB register is equal to enable pmdomain: imx: Make imx pgc power domain also set the fwnode cpufreq: stats: Fix buffer overflow detection in trans_stats() clk: visconti: remove unused visconti_pll_provider::regmap clk: visconti: Fix undefined behavior bug in struct visconti_pll_provider Bluetooth: btusb: Add Realtek RTL8852BE support ID 0x0cb8:0xc559 bluetooth: Add device 0bda:887b to device tables bluetooth: Add device 13d3:3571 to device tables Bluetooth: btusb: Add RTW8852BE device 13d3:3570 to device tables Bluetooth: btusb: Add 0bda:b85b for Fn-Link RTL8852BE drm/amd/display: enable dsc_clk even if dsc_pg disabled cxl/region: Validate region mode vs decoder mode cxl/region: Cleanup target list on attach error cxl/region: Move region-position validation to a helper cxl/region: Do not try to cleanup after cxl_region_setup_targets() fails i3c: master: svc: add NACK check after start byte sent i3c: master: svc: fix random hot join failure since timeout error cxl: Unify debug messages when calling devm_cxl_add_port() cxl/mem: Move devm_cxl_add_endpoint() from cxl_core to cxl_mem tools/testing/cxl: Define a fixed volatile configuration to parse cxl/region: Fix x1 root-decoder granularity calculations Revert ncsi: Propagate carrier gain/loss events to the NCSI controller Revert "i2c: pxa: move to generic GPIO recovery" lsm: fix default return value for vm_enough_memory lsm: fix default return value for inode_getsecctx sbsa_gwdt: Calculate timeout with 64-bit math i2c: designware: Disable TX_EMPTY irq while waiting for block length byte s390/ap: fix AP bus crash on early config change callback invocation net: ethtool: Fix documentation of ethtool_sprintf() net: dsa: lan9303: consequently nested-lock physical MDIO net: phylink: initialize carrier state at creation i2c: i801: fix potential race in i801_block_transaction_byte_by_byte f2fs: do not return EFSCORRUPTED, but try to run online repair f2fs: avoid format-overflow warning media: lirc: drop trailing space from scancode transmit media: sharp: fix sharp encoding media: venus: hfi_parser: Add check to keep the number of codecs within range media: venus: hfi: fix the check to handle session buffer requirement media: venus: hfi: add checks to handle capabilities from firmware media: ccs: Correctly initialise try compose rectangle drm/mediatek/dp: fix memory leak on ->get_edid callback audio detection drm/mediatek/dp: fix memory leak on ->get_edid callback error path dm-verity: don't use blocking calls from tasklets nfsd: fix file memleak on client_opens_release LoongArch: Mark __percpu functions as always inline riscv: mm: Update the comment of CONFIG_PAGE_OFFSET riscv: correct pt_level name via pgtable_l5/4_enabled riscv: kprobes: allow writing to x0 mmc: sdhci-pci-gli: A workaround to allow GL9750 to enter ASPM L1.2 mm: fix for negative counter: nr_file_hugepages mm: kmem: drop __GFP_NOFAIL when allocating objcg vectors mptcp: deal with large GSO size mptcp: add validity check for sending RM_ADDR mptcp: fix setsockopt(IP_TOS) subflow locking r8169: fix network lost after resume on DASH systems r8169: add handling DASH when DASH is disabled mmc: sdhci-pci-gli: GL9750: Mask the replay timer timeout of AER media: qcom: camss: Fix pm_domain_on sequence in probe media: qcom: camss: Fix vfe_get() error jump media: qcom: camss: Fix VFE-17x vfe_disable_output() media: qcom: camss: Fix VFE-480 vfe_disable_output() media: qcom: camss: Fix missing vfe_lite clocks check media: qcom: camss: Fix invalid clock enable bit disjunction media: qcom: camss: Fix csid-gen2 for test pattern generator Revert "net: r8169: Disable multicast filter for RTL8168H and RTL8107E" ext4: apply umask if ACL support is disabled ext4: correct offset of gdb backup in non meta_bg group to update_backups ext4: mark buffer new if it is unwritten to avoid stale data exposure ext4: correct return value of ext4_convert_meta_bg ext4: correct the start block of counting reserved clusters ext4: remove gdb backup copy for meta bg in setup_new_flex_group_blocks ext4: add missed brelse in update_backups ext4: properly sync file size update after O_SYNC direct IO drm/amd/pm: Handle non-terminated overdrive commands. drm/i915: Bump GLK CDCLK frequency when driving multiple pipes drm/i915: Fix potential spectre vulnerability drm/amd/pm: Fix error of MACO flag setting code drm/amdgpu/smu13: drop compute workload workaround drm/amdgpu: don't use pci_is_thunderbolt_attached() drm/amdgpu: don't use ATRM for external devices drm/amdgpu: fix error handling in amdgpu_bo_list_get() drm/amdgpu: lower CS errors to debug severity drm/amd/display: fix a NULL pointer dereference in amdgpu_dm_i2c_xfer() drm/amd/display: Enable fast plane updates on DCN3.2 and above drm/amd/display: Change the DMCUB mailbox memory location from FB to inbox powerpc/powernv: Fix fortify source warnings in opal-prd.c tracing: Have trace_event_file have ref counters Input: xpad - add VID for Turtle Beach controllers mmc: sdhci-pci-gli: GL9755: Mask the replay timer timeout of AER cxl/port: Fix NULL pointer access in devm_cxl_add_port() RISC-V: drop error print from riscv_hartid_to_cpuid() Linux 6.1.64 Change-Id: I9284282aeae5d0f9da957a58147efe0114f8e60a Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1375 lines
36 KiB
C
1375 lines
36 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* drivers/base/dd.c - The core device/driver interactions.
|
|
*
|
|
* This file contains the (sometimes tricky) code that controls the
|
|
* interactions between devices and drivers, which primarily includes
|
|
* driver binding and unbinding.
|
|
*
|
|
* All of this code used to exist in drivers/base/bus.c, but was
|
|
* relocated to here in the name of compartmentalization (since it wasn't
|
|
* strictly code just for the 'struct bus_type'.
|
|
*
|
|
* Copyright (c) 2002-5 Patrick Mochel
|
|
* Copyright (c) 2002-3 Open Source Development Labs
|
|
* Copyright (c) 2007-2009 Greg Kroah-Hartman <gregkh@suse.de>
|
|
* Copyright (c) 2007-2009 Novell Inc.
|
|
*/
|
|
|
|
#include <linux/debugfs.h>
|
|
#include <linux/device.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/dma-map-ops.h>
|
|
#include <linux/init.h>
|
|
#include <linux/module.h>
|
|
#include <linux/kthread.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/async.h>
|
|
#include <linux/pm_runtime.h>
|
|
#include <linux/pinctrl/devinfo.h>
|
|
#include <linux/slab.h>
|
|
|
|
#include "base.h"
|
|
#include "power/power.h"
|
|
|
|
/*
|
|
* Deferred Probe infrastructure.
|
|
*
|
|
* Sometimes driver probe order matters, but the kernel doesn't always have
|
|
* dependency information which means some drivers will get probed before a
|
|
* resource it depends on is available. For example, an SDHCI driver may
|
|
* first need a GPIO line from an i2c GPIO controller before it can be
|
|
* initialized. If a required resource is not available yet, a driver can
|
|
* request probing to be deferred by returning -EPROBE_DEFER from its probe hook
|
|
*
|
|
* Deferred probe maintains two lists of devices, a pending list and an active
|
|
* list. A driver returning -EPROBE_DEFER causes the device to be added to the
|
|
* pending list. A successful driver probe will trigger moving all devices
|
|
* from the pending to the active list so that the workqueue will eventually
|
|
* retry them.
|
|
*
|
|
* The deferred_probe_mutex must be held any time the deferred_probe_*_list
|
|
* of the (struct device*)->p->deferred_probe pointers are manipulated
|
|
*/
|
|
static DEFINE_MUTEX(deferred_probe_mutex);
|
|
static LIST_HEAD(deferred_probe_pending_list);
|
|
static LIST_HEAD(deferred_probe_active_list);
|
|
static atomic_t deferred_trigger_count = ATOMIC_INIT(0);
|
|
static bool initcalls_done;
|
|
|
|
/* Save the async probe drivers' name from kernel cmdline */
|
|
#define ASYNC_DRV_NAMES_MAX_LEN 256
|
|
static char async_probe_drv_names[ASYNC_DRV_NAMES_MAX_LEN];
|
|
static bool async_probe_default;
|
|
|
|
/*
|
|
* In some cases, like suspend to RAM or hibernation, It might be reasonable
|
|
* to prohibit probing of devices as it could be unsafe.
|
|
* Once defer_all_probes is true all drivers probes will be forcibly deferred.
|
|
*/
|
|
static bool defer_all_probes;
|
|
|
|
static void __device_set_deferred_probe_reason(const struct device *dev, char *reason)
|
|
{
|
|
kfree(dev->p->deferred_probe_reason);
|
|
dev->p->deferred_probe_reason = reason;
|
|
}
|
|
|
|
/*
|
|
* deferred_probe_work_func() - Retry probing devices in the active list.
|
|
*/
|
|
static void deferred_probe_work_func(struct work_struct *work)
|
|
{
|
|
struct device *dev;
|
|
struct device_private *private;
|
|
/*
|
|
* This block processes every device in the deferred 'active' list.
|
|
* Each device is removed from the active list and passed to
|
|
* bus_probe_device() to re-attempt the probe. The loop continues
|
|
* until every device in the active list is removed and retried.
|
|
*
|
|
* Note: Once the device is removed from the list and the mutex is
|
|
* released, it is possible for the device get freed by another thread
|
|
* and cause a illegal pointer dereference. This code uses
|
|
* get/put_device() to ensure the device structure cannot disappear
|
|
* from under our feet.
|
|
*/
|
|
mutex_lock(&deferred_probe_mutex);
|
|
while (!list_empty(&deferred_probe_active_list)) {
|
|
private = list_first_entry(&deferred_probe_active_list,
|
|
typeof(*dev->p), deferred_probe);
|
|
dev = private->device;
|
|
list_del_init(&private->deferred_probe);
|
|
|
|
get_device(dev);
|
|
|
|
__device_set_deferred_probe_reason(dev, NULL);
|
|
|
|
/*
|
|
* Drop the mutex while probing each device; the probe path may
|
|
* manipulate the deferred list
|
|
*/
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
|
|
/*
|
|
* Force the device to the end of the dpm_list since
|
|
* the PM code assumes that the order we add things to
|
|
* the list is a good order for suspend but deferred
|
|
* probe makes that very unsafe.
|
|
*/
|
|
device_pm_move_to_tail(dev);
|
|
|
|
dev_dbg(dev, "Retrying from deferred list\n");
|
|
bus_probe_device(dev);
|
|
mutex_lock(&deferred_probe_mutex);
|
|
|
|
put_device(dev);
|
|
}
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
}
|
|
static DECLARE_WORK(deferred_probe_work, deferred_probe_work_func);
|
|
|
|
void driver_deferred_probe_add(struct device *dev)
|
|
{
|
|
if (!dev->can_match)
|
|
return;
|
|
|
|
mutex_lock(&deferred_probe_mutex);
|
|
if (list_empty(&dev->p->deferred_probe)) {
|
|
dev_dbg(dev, "Added to deferred list\n");
|
|
list_add_tail(&dev->p->deferred_probe, &deferred_probe_pending_list);
|
|
}
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
}
|
|
|
|
void driver_deferred_probe_del(struct device *dev)
|
|
{
|
|
mutex_lock(&deferred_probe_mutex);
|
|
if (!list_empty(&dev->p->deferred_probe)) {
|
|
dev_dbg(dev, "Removed from deferred list\n");
|
|
list_del_init(&dev->p->deferred_probe);
|
|
__device_set_deferred_probe_reason(dev, NULL);
|
|
}
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
}
|
|
|
|
static bool driver_deferred_probe_enable;
|
|
/**
|
|
* driver_deferred_probe_trigger() - Kick off re-probing deferred devices
|
|
*
|
|
* This functions moves all devices from the pending list to the active
|
|
* list and schedules the deferred probe workqueue to process them. It
|
|
* should be called anytime a driver is successfully bound to a device.
|
|
*
|
|
* Note, there is a race condition in multi-threaded probe. In the case where
|
|
* more than one device is probing at the same time, it is possible for one
|
|
* probe to complete successfully while another is about to defer. If the second
|
|
* depends on the first, then it will get put on the pending list after the
|
|
* trigger event has already occurred and will be stuck there.
|
|
*
|
|
* The atomic 'deferred_trigger_count' is used to determine if a successful
|
|
* trigger has occurred in the midst of probing a driver. If the trigger count
|
|
* changes in the midst of a probe, then deferred processing should be triggered
|
|
* again.
|
|
*/
|
|
void driver_deferred_probe_trigger(void)
|
|
{
|
|
if (!driver_deferred_probe_enable)
|
|
return;
|
|
|
|
/*
|
|
* A successful probe means that all the devices in the pending list
|
|
* should be triggered to be reprobed. Move all the deferred devices
|
|
* into the active list so they can be retried by the workqueue
|
|
*/
|
|
mutex_lock(&deferred_probe_mutex);
|
|
atomic_inc(&deferred_trigger_count);
|
|
list_splice_tail_init(&deferred_probe_pending_list,
|
|
&deferred_probe_active_list);
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
|
|
/*
|
|
* Kick the re-probe thread. It may already be scheduled, but it is
|
|
* safe to kick it again.
|
|
*/
|
|
queue_work(system_unbound_wq, &deferred_probe_work);
|
|
}
|
|
|
|
/**
|
|
* device_block_probing() - Block/defer device's probes
|
|
*
|
|
* It will disable probing of devices and defer their probes instead.
|
|
*/
|
|
void device_block_probing(void)
|
|
{
|
|
defer_all_probes = true;
|
|
/* sync with probes to avoid races. */
|
|
wait_for_device_probe();
|
|
}
|
|
|
|
/**
|
|
* device_unblock_probing() - Unblock/enable device's probes
|
|
*
|
|
* It will restore normal behavior and trigger re-probing of deferred
|
|
* devices.
|
|
*/
|
|
void device_unblock_probing(void)
|
|
{
|
|
defer_all_probes = false;
|
|
driver_deferred_probe_trigger();
|
|
}
|
|
|
|
/**
|
|
* device_set_deferred_probe_reason() - Set defer probe reason message for device
|
|
* @dev: the pointer to the struct device
|
|
* @vaf: the pointer to va_format structure with message
|
|
*/
|
|
void device_set_deferred_probe_reason(const struct device *dev, struct va_format *vaf)
|
|
{
|
|
const char *drv = dev_driver_string(dev);
|
|
char *reason;
|
|
|
|
mutex_lock(&deferred_probe_mutex);
|
|
|
|
reason = kasprintf(GFP_KERNEL, "%s: %pV", drv, vaf);
|
|
__device_set_deferred_probe_reason(dev, reason);
|
|
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
}
|
|
|
|
/*
|
|
* deferred_devs_show() - Show the devices in the deferred probe pending list.
|
|
*/
|
|
static int deferred_devs_show(struct seq_file *s, void *data)
|
|
{
|
|
struct device_private *curr;
|
|
|
|
mutex_lock(&deferred_probe_mutex);
|
|
|
|
list_for_each_entry(curr, &deferred_probe_pending_list, deferred_probe)
|
|
seq_printf(s, "%s\t%s", dev_name(curr->device),
|
|
curr->device->p->deferred_probe_reason ?: "\n");
|
|
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
|
|
return 0;
|
|
}
|
|
DEFINE_SHOW_ATTRIBUTE(deferred_devs);
|
|
|
|
#ifdef CONFIG_MODULES
|
|
int driver_deferred_probe_timeout = 10;
|
|
#else
|
|
int driver_deferred_probe_timeout;
|
|
#endif
|
|
|
|
EXPORT_SYMBOL_GPL(driver_deferred_probe_timeout);
|
|
|
|
static int __init deferred_probe_timeout_setup(char *str)
|
|
{
|
|
int timeout;
|
|
|
|
if (!kstrtoint(str, 10, &timeout))
|
|
driver_deferred_probe_timeout = timeout;
|
|
return 1;
|
|
}
|
|
__setup("deferred_probe_timeout=", deferred_probe_timeout_setup);
|
|
|
|
/**
|
|
* driver_deferred_probe_check_state() - Check deferred probe state
|
|
* @dev: device to check
|
|
*
|
|
* Return:
|
|
* * -ENODEV if initcalls have completed and modules are disabled.
|
|
* * -ETIMEDOUT if the deferred probe timeout was set and has expired
|
|
* and modules are enabled.
|
|
* * -EPROBE_DEFER in other cases.
|
|
*
|
|
* Drivers or subsystems can opt-in to calling this function instead of directly
|
|
* returning -EPROBE_DEFER.
|
|
*/
|
|
int driver_deferred_probe_check_state(struct device *dev)
|
|
{
|
|
if (!IS_ENABLED(CONFIG_MODULES) && initcalls_done) {
|
|
dev_warn(dev, "ignoring dependency for device, assuming no driver\n");
|
|
return -ENODEV;
|
|
}
|
|
|
|
if (!driver_deferred_probe_timeout && initcalls_done) {
|
|
dev_warn(dev, "deferred probe timeout, ignoring dependency\n");
|
|
return -ETIMEDOUT;
|
|
}
|
|
|
|
return -EPROBE_DEFER;
|
|
}
|
|
EXPORT_SYMBOL_GPL(driver_deferred_probe_check_state);
|
|
|
|
static void deferred_probe_timeout_work_func(struct work_struct *work)
|
|
{
|
|
struct device_private *p;
|
|
|
|
fw_devlink_drivers_done();
|
|
|
|
driver_deferred_probe_timeout = 0;
|
|
driver_deferred_probe_trigger();
|
|
flush_work(&deferred_probe_work);
|
|
|
|
mutex_lock(&deferred_probe_mutex);
|
|
list_for_each_entry(p, &deferred_probe_pending_list, deferred_probe)
|
|
dev_info(p->device, "deferred probe pending\n");
|
|
mutex_unlock(&deferred_probe_mutex);
|
|
}
|
|
static DECLARE_DELAYED_WORK(deferred_probe_timeout_work, deferred_probe_timeout_work_func);
|
|
|
|
void deferred_probe_extend_timeout(void)
|
|
{
|
|
/*
|
|
* If the work hasn't been queued yet or if the work expired, don't
|
|
* start a new one.
|
|
*/
|
|
if (cancel_delayed_work(&deferred_probe_timeout_work)) {
|
|
schedule_delayed_work(&deferred_probe_timeout_work,
|
|
driver_deferred_probe_timeout * HZ);
|
|
pr_debug("Extended deferred probe timeout by %d secs\n",
|
|
driver_deferred_probe_timeout);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* deferred_probe_initcall() - Enable probing of deferred devices
|
|
*
|
|
* We don't want to get in the way when the bulk of drivers are getting probed.
|
|
* Instead, this initcall makes sure that deferred probing is delayed until
|
|
* late_initcall time.
|
|
*/
|
|
static int deferred_probe_initcall(void)
|
|
{
|
|
debugfs_create_file("devices_deferred", 0444, NULL, NULL,
|
|
&deferred_devs_fops);
|
|
|
|
driver_deferred_probe_enable = true;
|
|
driver_deferred_probe_trigger();
|
|
/* Sort as many dependencies as possible before exiting initcalls */
|
|
flush_work(&deferred_probe_work);
|
|
initcalls_done = true;
|
|
|
|
if (!IS_ENABLED(CONFIG_MODULES))
|
|
fw_devlink_drivers_done();
|
|
|
|
/*
|
|
* Trigger deferred probe again, this time we won't defer anything
|
|
* that is optional
|
|
*/
|
|
driver_deferred_probe_trigger();
|
|
flush_work(&deferred_probe_work);
|
|
|
|
if (driver_deferred_probe_timeout > 0) {
|
|
schedule_delayed_work(&deferred_probe_timeout_work,
|
|
driver_deferred_probe_timeout * HZ);
|
|
}
|
|
return 0;
|
|
}
|
|
late_initcall(deferred_probe_initcall);
|
|
|
|
static void __exit deferred_probe_exit(void)
|
|
{
|
|
debugfs_lookup_and_remove("devices_deferred", NULL);
|
|
}
|
|
__exitcall(deferred_probe_exit);
|
|
|
|
/**
|
|
* device_is_bound() - Check if device is bound to a driver
|
|
* @dev: device to check
|
|
*
|
|
* Returns true if passed device has already finished probing successfully
|
|
* against a driver.
|
|
*
|
|
* This function must be called with the device lock held.
|
|
*/
|
|
bool device_is_bound(struct device *dev)
|
|
{
|
|
return dev->p && klist_node_attached(&dev->p->knode_driver);
|
|
}
|
|
|
|
static void driver_bound(struct device *dev)
|
|
{
|
|
if (device_is_bound(dev)) {
|
|
pr_warn("%s: device %s already bound\n",
|
|
__func__, kobject_name(&dev->kobj));
|
|
return;
|
|
}
|
|
|
|
pr_debug("driver: '%s': %s: bound to device '%s'\n", dev->driver->name,
|
|
__func__, dev_name(dev));
|
|
|
|
klist_add_tail(&dev->p->knode_driver, &dev->driver->p->klist_devices);
|
|
device_links_driver_bound(dev);
|
|
|
|
device_pm_check_callbacks(dev);
|
|
|
|
/*
|
|
* Make sure the device is no longer in one of the deferred lists and
|
|
* kick off retrying all pending devices
|
|
*/
|
|
driver_deferred_probe_del(dev);
|
|
driver_deferred_probe_trigger();
|
|
|
|
if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_BOUND_DRIVER, dev);
|
|
|
|
kobject_uevent(&dev->kobj, KOBJ_BIND);
|
|
}
|
|
|
|
static ssize_t coredump_store(struct device *dev, struct device_attribute *attr,
|
|
const char *buf, size_t count)
|
|
{
|
|
device_lock(dev);
|
|
dev->driver->coredump(dev);
|
|
device_unlock(dev);
|
|
|
|
return count;
|
|
}
|
|
static DEVICE_ATTR_WO(coredump);
|
|
|
|
static int driver_sysfs_add(struct device *dev)
|
|
{
|
|
int ret;
|
|
|
|
if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_BIND_DRIVER, dev);
|
|
|
|
ret = sysfs_create_link(&dev->driver->p->kobj, &dev->kobj,
|
|
kobject_name(&dev->kobj));
|
|
if (ret)
|
|
goto fail;
|
|
|
|
ret = sysfs_create_link(&dev->kobj, &dev->driver->p->kobj,
|
|
"driver");
|
|
if (ret)
|
|
goto rm_dev;
|
|
|
|
if (!IS_ENABLED(CONFIG_DEV_COREDUMP) || !dev->driver->coredump)
|
|
return 0;
|
|
|
|
ret = device_create_file(dev, &dev_attr_coredump);
|
|
if (!ret)
|
|
return 0;
|
|
|
|
sysfs_remove_link(&dev->kobj, "driver");
|
|
|
|
rm_dev:
|
|
sysfs_remove_link(&dev->driver->p->kobj,
|
|
kobject_name(&dev->kobj));
|
|
|
|
fail:
|
|
return ret;
|
|
}
|
|
|
|
static void driver_sysfs_remove(struct device *dev)
|
|
{
|
|
struct device_driver *drv = dev->driver;
|
|
|
|
if (drv) {
|
|
if (drv->coredump)
|
|
device_remove_file(dev, &dev_attr_coredump);
|
|
sysfs_remove_link(&drv->p->kobj, kobject_name(&dev->kobj));
|
|
sysfs_remove_link(&dev->kobj, "driver");
|
|
}
|
|
}
|
|
|
|
/**
|
|
* device_bind_driver - bind a driver to one device.
|
|
* @dev: device.
|
|
*
|
|
* Allow manual attachment of a driver to a device.
|
|
* Caller must have already set @dev->driver.
|
|
*
|
|
* Note that this does not modify the bus reference count.
|
|
* Please verify that is accounted for before calling this.
|
|
* (It is ok to call with no other effort from a driver's probe() method.)
|
|
*
|
|
* This function must be called with the device lock held.
|
|
*
|
|
* Callers should prefer to use device_driver_attach() instead.
|
|
*/
|
|
int device_bind_driver(struct device *dev)
|
|
{
|
|
int ret;
|
|
|
|
ret = driver_sysfs_add(dev);
|
|
if (!ret) {
|
|
device_links_force_bind(dev);
|
|
driver_bound(dev);
|
|
}
|
|
else if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(device_bind_driver);
|
|
|
|
static atomic_t probe_count = ATOMIC_INIT(0);
|
|
static DECLARE_WAIT_QUEUE_HEAD(probe_waitqueue);
|
|
|
|
static ssize_t state_synced_show(struct device *dev,
|
|
struct device_attribute *attr, char *buf)
|
|
{
|
|
bool val;
|
|
|
|
device_lock(dev);
|
|
val = dev->state_synced;
|
|
device_unlock(dev);
|
|
|
|
return sysfs_emit(buf, "%u\n", val);
|
|
}
|
|
static DEVICE_ATTR_RO(state_synced);
|
|
|
|
static void device_unbind_cleanup(struct device *dev)
|
|
{
|
|
devres_release_all(dev);
|
|
arch_teardown_dma_ops(dev);
|
|
kfree(dev->dma_range_map);
|
|
dev->dma_range_map = NULL;
|
|
dev->driver = NULL;
|
|
dev_set_drvdata(dev, NULL);
|
|
if (dev->pm_domain && dev->pm_domain->dismiss)
|
|
dev->pm_domain->dismiss(dev);
|
|
pm_runtime_reinit(dev);
|
|
dev_pm_set_driver_flags(dev, 0);
|
|
}
|
|
|
|
static void device_remove(struct device *dev)
|
|
{
|
|
device_remove_file(dev, &dev_attr_state_synced);
|
|
device_remove_groups(dev, dev->driver->dev_groups);
|
|
|
|
if (dev->bus && dev->bus->remove)
|
|
dev->bus->remove(dev);
|
|
else if (dev->driver->remove)
|
|
dev->driver->remove(dev);
|
|
}
|
|
|
|
static int call_driver_probe(struct device *dev, struct device_driver *drv)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (dev->bus->probe)
|
|
ret = dev->bus->probe(dev);
|
|
else if (drv->probe)
|
|
ret = drv->probe(dev);
|
|
|
|
switch (ret) {
|
|
case 0:
|
|
break;
|
|
case -EPROBE_DEFER:
|
|
/* Driver requested deferred probing */
|
|
dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name);
|
|
break;
|
|
case -ENODEV:
|
|
case -ENXIO:
|
|
pr_debug("%s: probe of %s rejects match %d\n",
|
|
drv->name, dev_name(dev), ret);
|
|
break;
|
|
default:
|
|
/* driver matched but the probe failed */
|
|
pr_warn("%s: probe of %s failed with error %d\n",
|
|
drv->name, dev_name(dev), ret);
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int really_probe(struct device *dev, struct device_driver *drv)
|
|
{
|
|
bool test_remove = IS_ENABLED(CONFIG_DEBUG_TEST_DRIVER_REMOVE) &&
|
|
!drv->suppress_bind_attrs;
|
|
int ret, link_ret;
|
|
|
|
if (defer_all_probes) {
|
|
/*
|
|
* Value of defer_all_probes can be set only by
|
|
* device_block_probing() which, in turn, will call
|
|
* wait_for_device_probe() right after that to avoid any races.
|
|
*/
|
|
dev_dbg(dev, "Driver %s force probe deferral\n", drv->name);
|
|
return -EPROBE_DEFER;
|
|
}
|
|
|
|
link_ret = device_links_check_suppliers(dev);
|
|
if (link_ret == -EPROBE_DEFER)
|
|
return link_ret;
|
|
|
|
pr_debug("bus: '%s': %s: probing driver %s with device %s\n",
|
|
drv->bus->name, __func__, drv->name, dev_name(dev));
|
|
if (!list_empty(&dev->devres_head)) {
|
|
dev_crit(dev, "Resources present before probing\n");
|
|
ret = -EBUSY;
|
|
goto done;
|
|
}
|
|
|
|
re_probe:
|
|
dev->driver = drv;
|
|
|
|
/* If using pinctrl, bind pins now before probing */
|
|
ret = pinctrl_bind_pins(dev);
|
|
if (ret)
|
|
goto pinctrl_bind_failed;
|
|
|
|
if (dev->bus->dma_configure) {
|
|
ret = dev->bus->dma_configure(dev);
|
|
if (ret)
|
|
goto pinctrl_bind_failed;
|
|
}
|
|
|
|
ret = driver_sysfs_add(dev);
|
|
if (ret) {
|
|
pr_err("%s: driver_sysfs_add(%s) failed\n",
|
|
__func__, dev_name(dev));
|
|
goto sysfs_failed;
|
|
}
|
|
|
|
if (dev->pm_domain && dev->pm_domain->activate) {
|
|
ret = dev->pm_domain->activate(dev);
|
|
if (ret)
|
|
goto probe_failed;
|
|
}
|
|
|
|
ret = call_driver_probe(dev, drv);
|
|
if (ret) {
|
|
/*
|
|
* If fw_devlink_best_effort is active (denoted by -EAGAIN), the
|
|
* device might actually probe properly once some of its missing
|
|
* suppliers have probed. So, treat this as if the driver
|
|
* returned -EPROBE_DEFER.
|
|
*/
|
|
if (link_ret == -EAGAIN)
|
|
ret = -EPROBE_DEFER;
|
|
|
|
/*
|
|
* Return probe errors as positive values so that the callers
|
|
* can distinguish them from other errors.
|
|
*/
|
|
ret = -ret;
|
|
goto probe_failed;
|
|
}
|
|
|
|
ret = device_add_groups(dev, drv->dev_groups);
|
|
if (ret) {
|
|
dev_err(dev, "device_add_groups() failed\n");
|
|
goto dev_groups_failed;
|
|
}
|
|
|
|
if (dev_has_sync_state(dev)) {
|
|
ret = device_create_file(dev, &dev_attr_state_synced);
|
|
if (ret) {
|
|
dev_err(dev, "state_synced sysfs add failed\n");
|
|
goto dev_sysfs_state_synced_failed;
|
|
}
|
|
}
|
|
|
|
if (test_remove) {
|
|
test_remove = false;
|
|
|
|
device_remove(dev);
|
|
driver_sysfs_remove(dev);
|
|
if (dev->bus && dev->bus->dma_cleanup)
|
|
dev->bus->dma_cleanup(dev);
|
|
device_unbind_cleanup(dev);
|
|
|
|
goto re_probe;
|
|
}
|
|
|
|
pinctrl_init_done(dev);
|
|
|
|
if (dev->pm_domain && dev->pm_domain->sync)
|
|
dev->pm_domain->sync(dev);
|
|
|
|
driver_bound(dev);
|
|
pr_debug("bus: '%s': %s: bound device %s to driver %s\n",
|
|
drv->bus->name, __func__, dev_name(dev), drv->name);
|
|
goto done;
|
|
|
|
dev_sysfs_state_synced_failed:
|
|
dev_groups_failed:
|
|
device_remove(dev);
|
|
probe_failed:
|
|
driver_sysfs_remove(dev);
|
|
sysfs_failed:
|
|
if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_DRIVER_NOT_BOUND, dev);
|
|
if (dev->bus && dev->bus->dma_cleanup)
|
|
dev->bus->dma_cleanup(dev);
|
|
pinctrl_bind_failed:
|
|
device_links_no_driver(dev);
|
|
device_unbind_cleanup(dev);
|
|
done:
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* For initcall_debug, show the driver probe time.
|
|
*/
|
|
static int really_probe_debug(struct device *dev, struct device_driver *drv)
|
|
{
|
|
ktime_t calltime, rettime;
|
|
int ret;
|
|
|
|
calltime = ktime_get();
|
|
ret = really_probe(dev, drv);
|
|
rettime = ktime_get();
|
|
/*
|
|
* Don't change this to pr_debug() because that requires
|
|
* CONFIG_DYNAMIC_DEBUG and we want a simple 'initcall_debug' on the
|
|
* kernel commandline to print this all the time at the debug level.
|
|
*/
|
|
printk(KERN_DEBUG "probe of %s returned %d after %lld usecs\n",
|
|
dev_name(dev), ret, ktime_us_delta(rettime, calltime));
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* driver_probe_done
|
|
* Determine if the probe sequence is finished or not.
|
|
*
|
|
* Should somehow figure out how to use a semaphore, not an atomic variable...
|
|
*/
|
|
int driver_probe_done(void)
|
|
{
|
|
int local_probe_count = atomic_read(&probe_count);
|
|
|
|
pr_debug("%s: probe_count = %d\n", __func__, local_probe_count);
|
|
if (local_probe_count)
|
|
return -EBUSY;
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* wait_for_device_probe
|
|
* Wait for device probing to be completed.
|
|
*/
|
|
void wait_for_device_probe(void)
|
|
{
|
|
/* wait for the deferred probe workqueue to finish */
|
|
flush_work(&deferred_probe_work);
|
|
|
|
/* wait for the known devices to complete their probing */
|
|
wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
|
|
async_synchronize_full();
|
|
}
|
|
EXPORT_SYMBOL_GPL(wait_for_device_probe);
|
|
|
|
/**
|
|
* flush_deferred_probe_now
|
|
*
|
|
* This function should be used sparingly. It's meant for when we need to flush
|
|
* the deferred probe list at earlier initcall levels. Really meant only for KVM
|
|
* needs. This function should never be exported because it makes no sense for
|
|
* modules to call this.
|
|
*/
|
|
void flush_deferred_probe_now(void)
|
|
{
|
|
/*
|
|
* Really shouldn't using this if deferred probe has already been
|
|
* enabled
|
|
*/
|
|
if (WARN_ON(driver_deferred_probe_enable))
|
|
return;
|
|
|
|
driver_deferred_probe_enable = true;
|
|
driver_deferred_probe_trigger();
|
|
wait_for_device_probe();
|
|
driver_deferred_probe_enable = false;
|
|
}
|
|
|
|
static int __driver_probe_device(struct device_driver *drv, struct device *dev)
|
|
{
|
|
int ret = 0;
|
|
|
|
if (dev->p->dead || !device_is_registered(dev))
|
|
return -ENODEV;
|
|
if (dev->driver)
|
|
return -EBUSY;
|
|
|
|
dev->can_match = true;
|
|
pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
|
|
drv->bus->name, __func__, dev_name(dev), drv->name);
|
|
|
|
pm_runtime_get_suppliers(dev);
|
|
if (dev->parent)
|
|
pm_runtime_get_sync(dev->parent);
|
|
|
|
pm_runtime_barrier(dev);
|
|
if (initcall_debug)
|
|
ret = really_probe_debug(dev, drv);
|
|
else
|
|
ret = really_probe(dev, drv);
|
|
pm_request_idle(dev);
|
|
|
|
if (dev->parent)
|
|
pm_runtime_put(dev->parent);
|
|
|
|
pm_runtime_put_suppliers(dev);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* driver_probe_device - attempt to bind device & driver together
|
|
* @drv: driver to bind a device to
|
|
* @dev: device to try to bind to the driver
|
|
*
|
|
* This function returns -ENODEV if the device is not registered, -EBUSY if it
|
|
* already has a driver, 0 if the device is bound successfully and a positive
|
|
* (inverted) error code for failures from the ->probe method.
|
|
*
|
|
* This function must be called with @dev lock held. When called for a
|
|
* USB interface, @dev->parent lock must be held as well.
|
|
*
|
|
* If the device has a parent, runtime-resume the parent before driver probing.
|
|
*/
|
|
static int driver_probe_device(struct device_driver *drv, struct device *dev)
|
|
{
|
|
int trigger_count = atomic_read(&deferred_trigger_count);
|
|
int ret;
|
|
|
|
atomic_inc(&probe_count);
|
|
ret = __driver_probe_device(drv, dev);
|
|
if (ret == -EPROBE_DEFER || ret == EPROBE_DEFER) {
|
|
driver_deferred_probe_add(dev);
|
|
|
|
/*
|
|
* Did a trigger occur while probing? Need to re-trigger if yes
|
|
*/
|
|
if (trigger_count != atomic_read(&deferred_trigger_count) &&
|
|
!defer_all_probes)
|
|
driver_deferred_probe_trigger();
|
|
}
|
|
atomic_dec(&probe_count);
|
|
wake_up_all(&probe_waitqueue);
|
|
return ret;
|
|
}
|
|
|
|
static inline bool cmdline_requested_async_probing(const char *drv_name)
|
|
{
|
|
bool async_drv;
|
|
|
|
async_drv = parse_option_str(async_probe_drv_names, drv_name);
|
|
|
|
return (async_probe_default != async_drv);
|
|
}
|
|
|
|
/* The option format is "driver_async_probe=drv_name1,drv_name2,..." */
|
|
static int __init save_async_options(char *buf)
|
|
{
|
|
if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN)
|
|
pr_warn("Too long list of driver names for 'driver_async_probe'!\n");
|
|
|
|
strscpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN);
|
|
async_probe_default = parse_option_str(async_probe_drv_names, "*");
|
|
|
|
return 1;
|
|
}
|
|
__setup("driver_async_probe=", save_async_options);
|
|
|
|
bool driver_allows_async_probing(struct device_driver *drv)
|
|
{
|
|
switch (drv->probe_type) {
|
|
case PROBE_PREFER_ASYNCHRONOUS:
|
|
return true;
|
|
|
|
case PROBE_FORCE_SYNCHRONOUS:
|
|
return false;
|
|
|
|
default:
|
|
if (cmdline_requested_async_probing(drv->name))
|
|
return true;
|
|
|
|
if (module_requested_async_probing(drv->owner))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
struct device_attach_data {
|
|
struct device *dev;
|
|
|
|
/*
|
|
* Indicates whether we are considering asynchronous probing or
|
|
* not. Only initial binding after device or driver registration
|
|
* (including deferral processing) may be done asynchronously, the
|
|
* rest is always synchronous, as we expect it is being done by
|
|
* request from userspace.
|
|
*/
|
|
bool check_async;
|
|
|
|
/*
|
|
* Indicates if we are binding synchronous or asynchronous drivers.
|
|
* When asynchronous probing is enabled we'll execute 2 passes
|
|
* over drivers: first pass doing synchronous probing and second
|
|
* doing asynchronous probing (if synchronous did not succeed -
|
|
* most likely because there was no driver requiring synchronous
|
|
* probing - and we found asynchronous driver during first pass).
|
|
* The 2 passes are done because we can't shoot asynchronous
|
|
* probe for given device and driver from bus_for_each_drv() since
|
|
* driver pointer is not guaranteed to stay valid once
|
|
* bus_for_each_drv() iterates to the next driver on the bus.
|
|
*/
|
|
bool want_async;
|
|
|
|
/*
|
|
* We'll set have_async to 'true' if, while scanning for matching
|
|
* driver, we'll encounter one that requests asynchronous probing.
|
|
*/
|
|
bool have_async;
|
|
};
|
|
|
|
static int __device_attach_driver(struct device_driver *drv, void *_data)
|
|
{
|
|
struct device_attach_data *data = _data;
|
|
struct device *dev = data->dev;
|
|
bool async_allowed;
|
|
int ret;
|
|
|
|
ret = driver_match_device(drv, dev);
|
|
if (ret == 0) {
|
|
/* no match */
|
|
return 0;
|
|
} else if (ret == -EPROBE_DEFER) {
|
|
dev_dbg(dev, "Device match requests probe deferral\n");
|
|
dev->can_match = true;
|
|
driver_deferred_probe_add(dev);
|
|
/*
|
|
* Device can't match with a driver right now, so don't attempt
|
|
* to match or bind with other drivers on the bus.
|
|
*/
|
|
return ret;
|
|
} else if (ret < 0) {
|
|
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
|
return ret;
|
|
} /* ret > 0 means positive match */
|
|
|
|
async_allowed = driver_allows_async_probing(drv);
|
|
|
|
if (async_allowed)
|
|
data->have_async = true;
|
|
|
|
if (data->check_async && async_allowed != data->want_async)
|
|
return 0;
|
|
|
|
/*
|
|
* Ignore errors returned by ->probe so that the next driver can try
|
|
* its luck.
|
|
*/
|
|
ret = driver_probe_device(drv, dev);
|
|
if (ret < 0)
|
|
return ret;
|
|
return ret == 0;
|
|
}
|
|
|
|
static void __device_attach_async_helper(void *_dev, async_cookie_t cookie)
|
|
{
|
|
struct device *dev = _dev;
|
|
struct device_attach_data data = {
|
|
.dev = dev,
|
|
.check_async = true,
|
|
.want_async = true,
|
|
};
|
|
|
|
device_lock(dev);
|
|
|
|
/*
|
|
* Check if device has already been removed or claimed. This may
|
|
* happen with driver loading, device discovery/registration,
|
|
* and deferred probe processing happens all at once with
|
|
* multiple threads.
|
|
*/
|
|
if (dev->p->dead || dev->driver)
|
|
goto out_unlock;
|
|
|
|
if (dev->parent)
|
|
pm_runtime_get_sync(dev->parent);
|
|
|
|
bus_for_each_drv(dev->bus, NULL, &data, __device_attach_driver);
|
|
dev_dbg(dev, "async probe completed\n");
|
|
|
|
pm_request_idle(dev);
|
|
|
|
if (dev->parent)
|
|
pm_runtime_put(dev->parent);
|
|
out_unlock:
|
|
device_unlock(dev);
|
|
|
|
put_device(dev);
|
|
}
|
|
|
|
static int __device_attach(struct device *dev, bool allow_async)
|
|
{
|
|
int ret = 0;
|
|
bool async = false;
|
|
|
|
device_lock(dev);
|
|
if (dev->p->dead) {
|
|
goto out_unlock;
|
|
} else if (dev->driver) {
|
|
if (device_is_bound(dev)) {
|
|
ret = 1;
|
|
goto out_unlock;
|
|
}
|
|
ret = device_bind_driver(dev);
|
|
if (ret == 0)
|
|
ret = 1;
|
|
else {
|
|
dev->driver = NULL;
|
|
ret = 0;
|
|
}
|
|
} else {
|
|
struct device_attach_data data = {
|
|
.dev = dev,
|
|
.check_async = allow_async,
|
|
.want_async = false,
|
|
};
|
|
|
|
if (dev->parent)
|
|
pm_runtime_get_sync(dev->parent);
|
|
|
|
ret = bus_for_each_drv(dev->bus, NULL, &data,
|
|
__device_attach_driver);
|
|
if (!ret && allow_async && data.have_async) {
|
|
/*
|
|
* If we could not find appropriate driver
|
|
* synchronously and we are allowed to do
|
|
* async probes and there are drivers that
|
|
* want to probe asynchronously, we'll
|
|
* try them.
|
|
*/
|
|
dev_dbg(dev, "scheduling asynchronous probe\n");
|
|
get_device(dev);
|
|
async = true;
|
|
} else {
|
|
pm_request_idle(dev);
|
|
}
|
|
|
|
if (dev->parent)
|
|
pm_runtime_put(dev->parent);
|
|
}
|
|
out_unlock:
|
|
device_unlock(dev);
|
|
if (async)
|
|
async_schedule_dev(__device_attach_async_helper, dev);
|
|
return ret;
|
|
}
|
|
|
|
/**
|
|
* device_attach - try to attach device to a driver.
|
|
* @dev: device.
|
|
*
|
|
* Walk the list of drivers that the bus has and call
|
|
* driver_probe_device() for each pair. If a compatible
|
|
* pair is found, break out and return.
|
|
*
|
|
* Returns 1 if the device was bound to a driver;
|
|
* 0 if no matching driver was found;
|
|
* -ENODEV if the device is not registered.
|
|
*
|
|
* When called for a USB interface, @dev->parent lock must be held.
|
|
*/
|
|
int device_attach(struct device *dev)
|
|
{
|
|
return __device_attach(dev, false);
|
|
}
|
|
EXPORT_SYMBOL_GPL(device_attach);
|
|
|
|
void device_initial_probe(struct device *dev)
|
|
{
|
|
__device_attach(dev, true);
|
|
}
|
|
|
|
/*
|
|
* __device_driver_lock - acquire locks needed to manipulate dev->drv
|
|
* @dev: Device we will update driver info for
|
|
* @parent: Parent device. Needed if the bus requires parent lock
|
|
*
|
|
* This function will take the required locks for manipulating dev->drv.
|
|
* Normally this will just be the @dev lock, but when called for a USB
|
|
* interface, @parent lock will be held as well.
|
|
*/
|
|
static void __device_driver_lock(struct device *dev, struct device *parent)
|
|
{
|
|
if (parent && dev->bus->need_parent_lock)
|
|
device_lock(parent);
|
|
device_lock(dev);
|
|
}
|
|
|
|
/*
|
|
* __device_driver_unlock - release locks needed to manipulate dev->drv
|
|
* @dev: Device we will update driver info for
|
|
* @parent: Parent device. Needed if the bus requires parent lock
|
|
*
|
|
* This function will release the required locks for manipulating dev->drv.
|
|
* Normally this will just be the @dev lock, but when called for a
|
|
* USB interface, @parent lock will be released as well.
|
|
*/
|
|
static void __device_driver_unlock(struct device *dev, struct device *parent)
|
|
{
|
|
device_unlock(dev);
|
|
if (parent && dev->bus->need_parent_lock)
|
|
device_unlock(parent);
|
|
}
|
|
|
|
/**
|
|
* device_driver_attach - attach a specific driver to a specific device
|
|
* @drv: Driver to attach
|
|
* @dev: Device to attach it to
|
|
*
|
|
* Manually attach driver to a device. Will acquire both @dev lock and
|
|
* @dev->parent lock if needed. Returns 0 on success, -ERR on failure.
|
|
*/
|
|
int device_driver_attach(struct device_driver *drv, struct device *dev)
|
|
{
|
|
int ret;
|
|
|
|
__device_driver_lock(dev, dev->parent);
|
|
ret = __driver_probe_device(drv, dev);
|
|
__device_driver_unlock(dev, dev->parent);
|
|
|
|
/* also return probe errors as normal negative errnos */
|
|
if (ret > 0)
|
|
ret = -ret;
|
|
if (ret == -EPROBE_DEFER)
|
|
return -EAGAIN;
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL_GPL(device_driver_attach);
|
|
|
|
static void __driver_attach_async_helper(void *_dev, async_cookie_t cookie)
|
|
{
|
|
struct device *dev = _dev;
|
|
struct device_driver *drv;
|
|
int ret;
|
|
|
|
__device_driver_lock(dev, dev->parent);
|
|
drv = dev->p->async_driver;
|
|
dev->p->async_driver = NULL;
|
|
ret = driver_probe_device(drv, dev);
|
|
__device_driver_unlock(dev, dev->parent);
|
|
|
|
dev_dbg(dev, "driver %s async attach completed: %d\n", drv->name, ret);
|
|
|
|
put_device(dev);
|
|
}
|
|
|
|
static int __driver_attach(struct device *dev, void *data)
|
|
{
|
|
struct device_driver *drv = data;
|
|
bool async = false;
|
|
int ret;
|
|
|
|
/*
|
|
* Lock device and try to bind to it. We drop the error
|
|
* here and always return 0, because we need to keep trying
|
|
* to bind to devices and some drivers will return an error
|
|
* simply if it didn't support the device.
|
|
*
|
|
* driver_probe_device() will spit a warning if there
|
|
* is an error.
|
|
*/
|
|
|
|
ret = driver_match_device(drv, dev);
|
|
if (ret == 0) {
|
|
/* no match */
|
|
return 0;
|
|
} else if (ret == -EPROBE_DEFER) {
|
|
dev_dbg(dev, "Device match requests probe deferral\n");
|
|
dev->can_match = true;
|
|
driver_deferred_probe_add(dev);
|
|
/*
|
|
* Driver could not match with device, but may match with
|
|
* another device on the bus.
|
|
*/
|
|
return 0;
|
|
} else if (ret < 0) {
|
|
dev_dbg(dev, "Bus failed to match device: %d\n", ret);
|
|
/*
|
|
* Driver could not match with device, but may match with
|
|
* another device on the bus.
|
|
*/
|
|
return 0;
|
|
} /* ret > 0 means positive match */
|
|
|
|
if (driver_allows_async_probing(drv)) {
|
|
/*
|
|
* Instead of probing the device synchronously we will
|
|
* probe it asynchronously to allow for more parallelism.
|
|
*
|
|
* We only take the device lock here in order to guarantee
|
|
* that the dev->driver and async_driver fields are protected
|
|
*/
|
|
dev_dbg(dev, "probing driver %s asynchronously\n", drv->name);
|
|
device_lock(dev);
|
|
if (!dev->driver && !dev->p->async_driver) {
|
|
get_device(dev);
|
|
dev->p->async_driver = drv;
|
|
async = true;
|
|
}
|
|
device_unlock(dev);
|
|
if (async)
|
|
async_schedule_dev(__driver_attach_async_helper, dev);
|
|
return 0;
|
|
}
|
|
|
|
__device_driver_lock(dev, dev->parent);
|
|
driver_probe_device(drv, dev);
|
|
__device_driver_unlock(dev, dev->parent);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* driver_attach - try to bind driver to devices.
|
|
* @drv: driver.
|
|
*
|
|
* Walk the list of devices that the bus has on it and try to
|
|
* match the driver with each one. If driver_probe_device()
|
|
* returns 0 and the @dev->driver is set, we've found a
|
|
* compatible pair.
|
|
*/
|
|
int driver_attach(struct device_driver *drv)
|
|
{
|
|
return bus_for_each_dev(drv->bus, NULL, drv, __driver_attach);
|
|
}
|
|
EXPORT_SYMBOL_GPL(driver_attach);
|
|
|
|
/*
|
|
* __device_release_driver() must be called with @dev lock held.
|
|
* When called for a USB interface, @dev->parent lock must be held as well.
|
|
*/
|
|
static void __device_release_driver(struct device *dev, struct device *parent)
|
|
{
|
|
struct device_driver *drv;
|
|
|
|
drv = dev->driver;
|
|
if (drv) {
|
|
pm_runtime_get_sync(dev);
|
|
|
|
while (device_links_busy(dev)) {
|
|
__device_driver_unlock(dev, parent);
|
|
|
|
device_links_unbind_consumers(dev);
|
|
|
|
__device_driver_lock(dev, parent);
|
|
/*
|
|
* A concurrent invocation of the same function might
|
|
* have released the driver successfully while this one
|
|
* was waiting, so check for that.
|
|
*/
|
|
if (dev->driver != drv) {
|
|
pm_runtime_put(dev);
|
|
return;
|
|
}
|
|
}
|
|
|
|
driver_sysfs_remove(dev);
|
|
|
|
if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_UNBIND_DRIVER,
|
|
dev);
|
|
|
|
pm_runtime_put_sync(dev);
|
|
|
|
device_remove(dev);
|
|
|
|
if (dev->bus && dev->bus->dma_cleanup)
|
|
dev->bus->dma_cleanup(dev);
|
|
|
|
device_unbind_cleanup(dev);
|
|
device_links_driver_cleanup(dev);
|
|
|
|
klist_remove(&dev->p->knode_driver);
|
|
device_pm_check_callbacks(dev);
|
|
if (dev->bus)
|
|
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
|
|
BUS_NOTIFY_UNBOUND_DRIVER,
|
|
dev);
|
|
|
|
kobject_uevent(&dev->kobj, KOBJ_UNBIND);
|
|
}
|
|
}
|
|
|
|
void device_release_driver_internal(struct device *dev,
|
|
struct device_driver *drv,
|
|
struct device *parent)
|
|
{
|
|
__device_driver_lock(dev, parent);
|
|
|
|
if (!drv || drv == dev->driver)
|
|
__device_release_driver(dev, parent);
|
|
|
|
__device_driver_unlock(dev, parent);
|
|
}
|
|
|
|
/**
|
|
* device_release_driver - manually detach device from driver.
|
|
* @dev: device.
|
|
*
|
|
* Manually detach device from driver.
|
|
* When called for a USB interface, @dev->parent lock must be held.
|
|
*
|
|
* If this function is to be called with @dev->parent lock held, ensure that
|
|
* the device's consumers are unbound in advance or that their locks can be
|
|
* acquired under the @dev->parent lock.
|
|
*/
|
|
void device_release_driver(struct device *dev)
|
|
{
|
|
/*
|
|
* If anyone calls device_release_driver() recursively from
|
|
* within their ->remove callback for the same device, they
|
|
* will deadlock right here.
|
|
*/
|
|
device_release_driver_internal(dev, NULL, NULL);
|
|
}
|
|
EXPORT_SYMBOL_GPL(device_release_driver);
|
|
|
|
/**
|
|
* device_driver_detach - detach driver from a specific device
|
|
* @dev: device to detach driver from
|
|
*
|
|
* Detach driver from device. Will acquire both @dev lock and @dev->parent
|
|
* lock if needed.
|
|
*/
|
|
void device_driver_detach(struct device *dev)
|
|
{
|
|
device_release_driver_internal(dev, NULL, dev->parent);
|
|
}
|
|
|
|
/**
|
|
* driver_detach - detach driver from all devices it controls.
|
|
* @drv: driver.
|
|
*/
|
|
void driver_detach(struct device_driver *drv)
|
|
{
|
|
struct device_private *dev_prv;
|
|
struct device *dev;
|
|
|
|
if (driver_allows_async_probing(drv))
|
|
async_synchronize_full();
|
|
|
|
for (;;) {
|
|
spin_lock(&drv->p->klist_devices.k_lock);
|
|
if (list_empty(&drv->p->klist_devices.k_list)) {
|
|
spin_unlock(&drv->p->klist_devices.k_lock);
|
|
break;
|
|
}
|
|
dev_prv = list_last_entry(&drv->p->klist_devices.k_list,
|
|
struct device_private,
|
|
knode_driver.n_node);
|
|
dev = dev_prv->device;
|
|
get_device(dev);
|
|
spin_unlock(&drv->p->klist_devices.k_lock);
|
|
device_release_driver_internal(dev, drv, dev->parent);
|
|
put_device(dev);
|
|
}
|
|
}
|