linux/drivers/acpi/scan.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * scan.c - support for transforming the ACPI namespace into individual objects
 */

#define pr_fmt(fmt)

#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/kernel.h>
#include <linux/acpi.h>
#include <linux/acpi_iort.h>
#include <linux/acpi_viot.h>
#include <linux/iommu.h>
#include <linux/signal.h>
#include <linux/kthread.h>
#include <linux/dmi.h>
#include <linux/dma-map-ops.h>
#include <linux/platform_data/x86/apple.h>
#include <linux/pgtable.h>
#include <linux/crc32.h>
#include <linux/dma-direct.h>

#include "internal.h"
#include "sleep.h"

#define ACPI_BUS_CLASS
#define ACPI_BUS_HID
#define ACPI_BUS_DEVICE_NAME

#define INVALID_ACPI_HANDLE

static const char *dummy_hid =;

static LIST_HEAD(acpi_dep_list);
static DEFINE_MUTEX(acpi_dep_list_lock);
LIST_HEAD();
static DEFINE_MUTEX(acpi_scan_lock);
static LIST_HEAD(acpi_scan_handlers_list);
DEFINE_MUTEX();
LIST_HEAD();
static DEFINE_MUTEX(acpi_hp_context_lock);

/*
 * The UART device described by the SPCR table is the only object which needs
 * special-casing. Everything else is covered by ACPI namespace paths in STAO
 * table.
 */
static u64 spcr_uart_addr;

void acpi_scan_lock_acquire(void)
{}
EXPORT_SYMBOL_GPL();

void acpi_scan_lock_release(void)
{}
EXPORT_SYMBOL_GPL();

void acpi_lock_hp_context(void)
{}

void acpi_unlock_hp_context(void)
{}

void acpi_initialize_hp_context(struct acpi_device *adev,
				struct acpi_hotplug_context *hp,
				acpi_hp_notify notify, acpi_hp_uevent uevent)
{}
EXPORT_SYMBOL_GPL();

int acpi_scan_add_handler(struct acpi_scan_handler *handler)
{}

int acpi_scan_add_handler_with_hotplug(struct acpi_scan_handler *handler,
				       const char *hotplug_profile_name)
{}

bool acpi_scan_is_offline(struct acpi_device *adev, bool uevent)
{}

static acpi_status acpi_bus_offline(acpi_handle handle, u32 lvl, void *data,
				    void **ret_p)
{}

static acpi_status acpi_bus_online(acpi_handle handle, u32 lvl, void *data,
				   void **ret_p)
{}

static int acpi_scan_try_to_offline(struct acpi_device *device)
{}

#define ACPI_SCAN_CHECK_FLAG_STATUS
#define ACPI_SCAN_CHECK_FLAG_EJECT

static int acpi_scan_check_and_detach(struct acpi_device *adev, void *p)
{}

static int acpi_bus_post_eject(struct acpi_device *adev, void *not_used)
{}

static void acpi_scan_check_subtree(struct acpi_device *adev)
{}

static int acpi_scan_hot_remove(struct acpi_device *device)
{}

static int acpi_scan_rescan_bus(struct acpi_device *adev)
{}

static int acpi_scan_device_check(struct acpi_device *adev)
{}

static int acpi_scan_bus_check(struct acpi_device *adev)
{}

static int acpi_generic_hotplug_event(struct acpi_device *adev, u32 type)
{}

void acpi_device_hotplug(struct acpi_device *adev, u32 src)
{}

static void acpi_free_power_resources_lists(struct acpi_device *device)
{}

static void acpi_device_release(struct device *dev)
{}

static void acpi_device_del(struct acpi_device *device)
{}

static BLOCKING_NOTIFIER_HEAD(acpi_reconfig_chain);

static LIST_HEAD(acpi_device_del_list);
static DEFINE_MUTEX(acpi_device_del_lock);

static void acpi_device_del_work_fn(struct work_struct *work_not_used)
{}

/**
 * acpi_scan_drop_device - Drop an ACPI device object.
 * @handle: Handle of an ACPI namespace node, not used.
 * @context: Address of the ACPI device object to drop.
 *
 * This is invoked by acpi_ns_delete_node() during the removal of the ACPI
 * namespace node the device object pointed to by @context is attached to.
 *
 * The unregistration is carried out asynchronously to avoid running
 * acpi_device_del() under the ACPICA's namespace mutex and the list is used to
 * ensure the correct ordering (the device objects must be unregistered in the
 * same order in which the corresponding namespace nodes are deleted).
 */
static void acpi_scan_drop_device(acpi_handle handle, void *context)
{}

static struct acpi_device *handle_to_device(acpi_handle handle,
					    void (*callback)(void *))
{}

/**
 * acpi_fetch_acpi_dev - Retrieve ACPI device object.
 * @handle: ACPI handle associated with the requested ACPI device object.
 *
 * Return a pointer to the ACPI device object associated with @handle, if
 * present, or NULL otherwise.
 */
struct acpi_device *acpi_fetch_acpi_dev(acpi_handle handle)
{}
EXPORT_SYMBOL_GPL();

static void get_acpi_device(void *dev)
{}

/**
 * acpi_get_acpi_dev - Retrieve ACPI device object and reference count it.
 * @handle: ACPI handle associated with the requested ACPI device object.
 *
 * Return a pointer to the ACPI device object associated with @handle and bump
 * up that object's reference counter (under the ACPI Namespace lock), if
 * present, or return NULL otherwise.
 *
 * The ACPI device object reference acquired by this function needs to be
 * dropped via acpi_dev_put().
 */
struct acpi_device *acpi_get_acpi_dev(acpi_handle handle)
{}
EXPORT_SYMBOL_GPL();

static struct acpi_device_bus_id *acpi_device_bus_id_match(const char *dev_id)
{}

static int acpi_device_set_name(struct acpi_device *device,
				struct acpi_device_bus_id *acpi_device_bus_id)
{}

int acpi_tie_acpi_dev(struct acpi_device *adev)
{}

static void acpi_store_pld_crc(struct acpi_device *adev)
{}

int acpi_device_add(struct acpi_device *device)
{}

/* --------------------------------------------------------------------------
                                 Device Enumeration
   -------------------------------------------------------------------------- */
static bool acpi_info_matches_ids(struct acpi_device_info *info,
				  const char * const ids[])
{}

/* List of HIDs for which we ignore matching ACPI devices, when checking _DEP lists. */
static const char * const acpi_ignore_dep_ids[] =;

/* List of HIDs for which we honor deps of matching ACPI devs, when checking _DEP lists. */
static const char * const acpi_honor_dep_ids[] =;

static struct acpi_device *acpi_find_parent_acpi_dev(acpi_handle handle)
{}

acpi_status
acpi_bus_get_ejd(acpi_handle handle, acpi_handle *ejd)
{}
EXPORT_SYMBOL_GPL();

static int acpi_bus_extract_wakeup_device_power_package(struct acpi_device *dev)
{}

/* Do not use a button for S5 wakeup */
#define ACPI_AVOID_WAKE_FROM_S5

static bool acpi_wakeup_gpe_init(struct acpi_device *device)
{}

static void acpi_bus_get_wakeup_device_flags(struct acpi_device *device)
{}

static void acpi_bus_init_power_state(struct acpi_device *device, int state)
{}

static void acpi_bus_get_power_flags(struct acpi_device *device)
{}

static void acpi_bus_get_flags(struct acpi_device *device)
{}

static void acpi_device_get_busid(struct acpi_device *device)
{}

/*
 * acpi_ata_match - see if an acpi object is an ATA device
 *
 * If an acpi object has one of the ACPI ATA methods defined,
 * then we can safely call it an ATA device.
 */
bool acpi_ata_match(acpi_handle handle)
{}

/*
 * acpi_bay_match - see if an acpi object is an ejectable driver bay
 *
 * If an acpi object is ejectable and has one of the ACPI ATA methods defined,
 * then we can safely call it an ejectable drive bay
 */
bool acpi_bay_match(acpi_handle handle)
{}

bool acpi_device_is_battery(struct acpi_device *adev)
{}

static bool is_ejectable_bay(struct acpi_device *adev)
{}

/*
 * acpi_dock_match - see if an acpi object has a _DCK method
 */
bool acpi_dock_match(acpi_handle handle)
{}

static acpi_status
acpi_backlight_cap_match(acpi_handle handle, u32 level, void *context,
			  void **return_value)
{}

/* Returns true if the ACPI object is a video device which can be
 * handled by video.ko.
 * The device will get a Linux specific CID added in scan.c to
 * identify the device as an ACPI graphics device
 * Be aware that the graphics device may not be physically present
 * Use acpi_video_get_capabilities() to detect general ACPI video
 * capabilities of present cards
 */
long acpi_is_video_device(acpi_handle handle)
{}
EXPORT_SYMBOL();

const char *acpi_device_hid(struct acpi_device *device)
{}
EXPORT_SYMBOL();

static void acpi_add_id(struct acpi_device_pnp *pnp, const char *dev_id)
{}

/*
 * Old IBM workstations have a DSDT bug wherein the SMBus object
 * lacks the SMBUS01 HID and the methods do not have the necessary "_"
 * prefix.  Work around this.
 */
static bool acpi_ibm_smbus_match(acpi_handle handle)
{}

static bool acpi_object_is_system_bus(acpi_handle handle)
{}

static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
			     int device_type)
{}

void acpi_free_pnp_ids(struct acpi_device_pnp *pnp)
{}

/**
 * acpi_dma_supported - Check DMA support for the specified device.
 * @adev: The pointer to acpi device
 *
 * Return false if DMA is not supported. Otherwise, return true
 */
bool acpi_dma_supported(const struct acpi_device *adev)
{}

/**
 * acpi_get_dma_attr - Check the supported DMA attr for the specified device.
 * @adev: The pointer to acpi device
 *
 * Return enum dev_dma_attr.
 */
enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
{}

/**
 * acpi_dma_get_range() - Get device DMA parameters.
 *
 * @dev: device to configure
 * @map: pointer to DMA ranges result
 *
 * Evaluate DMA regions and return pointer to DMA regions on
 * parsing success; it does not update the passed in values on failure.
 *
 * Return 0 on success, < 0 on failure.
 */
int acpi_dma_get_range(struct device *dev, const struct bus_dma_region **map)
{}

#ifdef CONFIG_IOMMU_API
int acpi_iommu_fwspec_init(struct device *dev, u32 id,
			   struct fwnode_handle *fwnode)
{}

static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
{}

#else /* !CONFIG_IOMMU_API */

int acpi_iommu_fwspec_init(struct device *dev, u32 id,
			   struct fwnode_handle *fwnode)
{
	return -ENODEV;
}

static int acpi_iommu_configure_id(struct device *dev, const u32 *id_in)
{
	return -ENODEV;
}

#endif /* !CONFIG_IOMMU_API */

/**
 * acpi_dma_configure_id - Set-up DMA configuration for the device.
 * @dev: The pointer to the device
 * @attr: device dma attributes
 * @input_id: input device id const value pointer
 */
int acpi_dma_configure_id(struct device *dev, enum dev_dma_attr attr,
			  const u32 *input_id)
{}
EXPORT_SYMBOL_GPL();

static void acpi_init_coherency(struct acpi_device *adev)
{}

static int acpi_check_serial_bus_slave(struct acpi_resource *ares, void *data)
{}

static bool acpi_is_indirect_io_slave(struct acpi_device *device)
{}

static bool acpi_device_enumeration_by_parent(struct acpi_device *device)
{}

void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
			     int type, void (*release)(struct device *))
{}

static void acpi_scan_dep_init(struct acpi_device *adev)
{}

void acpi_device_add_finalize(struct acpi_device *device)
{}

static void acpi_scan_init_status(struct acpi_device *adev)
{}

static int acpi_add_single_object(struct acpi_device **child,
				  acpi_handle handle, int type, bool dep_init)
{}

static acpi_status acpi_get_resource_memory(struct acpi_resource *ares,
					    void *context)
{}

static bool acpi_device_should_be_hidden(acpi_handle handle)
{}

bool acpi_device_is_present(const struct acpi_device *adev)
{}

bool acpi_device_is_enabled(const struct acpi_device *adev)
{}

static bool acpi_scan_handler_matching(struct acpi_scan_handler *handler,
				       const char *idstr,
				       const struct acpi_device_id **matchid)
{}

static struct acpi_scan_handler *acpi_scan_match_handler(const char *idstr,
					const struct acpi_device_id **matchid)
{}

void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val)
{}

int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices)
{}

static void acpi_scan_init_hotplug(struct acpi_device *adev)
{}

u32 __weak arch_acpi_add_auto_dep(acpi_handle handle) {}

static u32 acpi_scan_check_dep(acpi_handle handle)
{}

static acpi_status acpi_scan_check_crs_csi2_cb(acpi_handle handle, u32 a, void *b, void **c)
{}

static acpi_status acpi_bus_check_add(acpi_handle handle, bool first_pass,
				      struct acpi_device **adev_p)
{}

static acpi_status acpi_bus_check_add_1(acpi_handle handle, u32 lvl_not_used,
					void *not_used, void **ret_p)
{}

static acpi_status acpi_bus_check_add_2(acpi_handle handle, u32 lvl_not_used,
					void *not_used, void **ret_p)
{}

static void acpi_default_enumeration(struct acpi_device *device)
{}

static const struct acpi_device_id generic_device_ids[] =;

static int acpi_generic_device_attach(struct acpi_device *adev,
				      const struct acpi_device_id *not_used)
{}

static struct acpi_scan_handler generic_device_handler =;

static int acpi_scan_attach_handler(struct acpi_device *device)
{}

static int acpi_bus_attach(struct acpi_device *device, void *first_pass)
{}

static int acpi_dev_get_next_consumer_dev_cb(struct acpi_dep_data *dep, void *data)
{}

struct acpi_scan_clear_dep_work {};

static void acpi_scan_clear_dep_fn(struct work_struct *work)
{}

static bool acpi_scan_clear_dep_queue(struct acpi_device *adev)
{}

static void acpi_scan_delete_dep_data(struct acpi_dep_data *dep)
{}

static int acpi_scan_clear_dep(struct acpi_dep_data *dep, void *data)
{}

/**
 * acpi_walk_dep_device_list - Apply a callback to every entry in acpi_dep_list
 * @handle:	The ACPI handle of the supplier device
 * @callback:	Pointer to the callback function to apply
 * @data:	Pointer to some data to pass to the callback
 *
 * The return value of the callback determines this function's behaviour. If 0
 * is returned we continue to iterate over acpi_dep_list. If a positive value
 * is returned then the loop is broken but this function returns 0. If a
 * negative value is returned by the callback then the loop is broken and that
 * value is returned as the final error.
 */
static int acpi_walk_dep_device_list(acpi_handle handle,
				int (*callback)(struct acpi_dep_data *, void *),
				void *data)
{}

/**
 * acpi_dev_clear_dependencies - Inform consumers that the device is now active
 * @supplier: Pointer to the supplier &struct acpi_device
 *
 * Clear dependencies on the given device.
 */
void acpi_dev_clear_dependencies(struct acpi_device *supplier)
{}
EXPORT_SYMBOL_GPL();

/**
 * acpi_dev_ready_for_enumeration - Check if the ACPI device is ready for enumeration
 * @device: Pointer to the &struct acpi_device to check
 *
 * Check if the device is present and has no unmet dependencies.
 *
 * Return true if the device is ready for enumeratino. Otherwise, return false.
 */
bool acpi_dev_ready_for_enumeration(const struct acpi_device *device)
{}
EXPORT_SYMBOL_GPL();

/**
 * acpi_dev_get_next_consumer_dev - Return the next adev dependent on @supplier
 * @supplier: Pointer to the dependee device
 * @start: Pointer to the current dependent device
 *
 * Returns the next &struct acpi_device which declares itself dependent on
 * @supplier via the _DEP buffer, parsed from the acpi_dep_list.
 *
 * If the returned adev is not passed as @start to this function, the caller is
 * responsible for putting the reference to adev when it is no longer needed.
 */
struct acpi_device *acpi_dev_get_next_consumer_dev(struct acpi_device *supplier,
						   struct acpi_device *start)
{}
EXPORT_SYMBOL_GPL();

static void acpi_scan_postponed_branch(acpi_handle handle)
{}

static void acpi_scan_postponed(void)
{}

/**
 * acpi_bus_scan - Add ACPI device node objects in a given namespace scope.
 * @handle: Root of the namespace scope to scan.
 *
 * Scan a given ACPI tree (probably recently hot-plugged) and create and add
 * found devices.
 *
 * If no devices were found, -ENODEV is returned, but it does not mean that
 * there has been a real error.  There just have been no suitable ACPI objects
 * in the table trunk from which the kernel could create a device and add an
 * appropriate driver.
 *
 * Must be called under acpi_scan_lock.
 */
int acpi_bus_scan(acpi_handle handle)
{}
EXPORT_SYMBOL();

/**
 * acpi_bus_trim - Detach scan handlers and drivers from ACPI device objects.
 * @adev: Root of the ACPI namespace scope to walk.
 *
 * Must be called under acpi_scan_lock.
 */
void acpi_bus_trim(struct acpi_device *adev)
{}
EXPORT_SYMBOL_GPL();

int acpi_bus_register_early_device(int type)
{}
EXPORT_SYMBOL_GPL();

static void acpi_bus_scan_fixed(void)
{}

static void __init acpi_get_spcr_uart_addr(void)
{}

static bool acpi_scan_initialized;

void __init acpi_scan_init(void)
{}

static struct acpi_probe_entry *ape;
static int acpi_probe_count;
static DEFINE_MUTEX(acpi_probe_mutex);

static int __init acpi_match_madt(union acpi_subtable_headers *header,
				  const unsigned long end)
{}

void __weak arch_sort_irqchip_probe(struct acpi_probe_entry *ap_head, int nr) {}

int __init __acpi_probe_device_table(struct acpi_probe_entry *ap_head, int nr)
{}

static void acpi_table_events_fn(struct work_struct *work)
{}

void acpi_scan_table_notify(void)
{}

int acpi_reconfig_notifier_register(struct notifier_block *nb)
{}
EXPORT_SYMBOL();

int acpi_reconfig_notifier_unregister(struct notifier_block *nb)
{}
EXPORT_SYMBOL();