Merge branch 'acpi-driver'

Merge changes related to ACPI support in device drivers for 7.4:

 - Switch over the users of acpi_get_first_physical_node(), that
   was inherently racy and therefore not really safe to use, to use
   its replacement acpi_bus_get_primary_device(), and eliminate the
   former (Rafael Wysocki)

 - Add !CONFIG_ACPI stubs for acpi_find_child_device() and
   acpi_device_uid() (Mario Limonciello and Robin Murphy)

* acpi-driver:
  ACPI: bus: Drop acpi_get_first_physical_node()
  efi/dev-path-parser: Switch to use acpi_bus_get_primary_device()
  ALSA: hda: tas2781: Switch to use acpi_bus_get_primary_device()
  ALSA: hda: cs35l41: Switch to use acpi_bus_get_primary_device()
  iommu/arm-smmu-v3: Switch to use acpi_bus_get_primary_device()
  ACPI: Add stub for acpi_find_child_device()
  ACPI: bus: Provide !ACPI stub for acpi_device_uid()
  ALSA: hda: aw88399: Switch to use acpi_bus_get_primary_device()
  ASoC: loongson: Switch to use acpi_bus_get_primary_device()
  ASoC: intel: boards: Switch to use acpi_bus_get_primary_device()
  ASoC: amd: acp3x-es83xx: Switch to use acpi_bus_get_primary_device()
  ASoC: amd: acp-es8336: Switch to use acpi_bus_get_primary_device()
  thunderbolt: Switch to use acpi_bus_get_primary_device()
  platform/x86: apple-gmux: Switch to use acpi_bus_get_primary_device()
  platform/x86: x86-android-tablets: Use acpi_bus_get_primary_device()
  platform/x86: serdev_helpers: Switch to use acpi_bus_get_primary_device()
  platform/x86: yogabook: Switch to use acpi_bus_get_primary_device()
  ACPI: amba: Switch to use acpi_bus_get_primary_device()
  ACPI: bus: Use acpi/acpi_bus.h without CONFIG_ACPI
This commit is contained in:
Rafael J. Wysocki 2026-10-19 13:32:55 +02:00
commit 8669f2b6c9
24 changed files with 58 additions and 64 deletions

View File

@ -87,11 +87,12 @@ static int amba_handler_attach(struct acpi_device *adev,
* the amba device we are about to create.
*/
if (parent)
dev->dev.parent = acpi_get_first_physical_node(parent);
dev->dev.parent = acpi_bus_get_primary_device(parent);
device_set_node(&dev->dev, acpi_fwnode_handle(adev));
ret = amba_device_add(dev, &iomem_resource);
put_device(dev->dev.parent);
if (ret) {
dev_err(&adev->dev, "%s(): amba_device_add() failed (%d)\n",
__func__, ret);

View File

@ -809,24 +809,14 @@ struct device *acpi_bus_get_primary_device(struct acpi_device *adev)
}
EXPORT_SYMBOL_GPL(acpi_bus_get_primary_device);
/**
* acpi_get_first_physical_node - Find first physical node of an ACPI device
* @adev: ACPI device in question
*
* Return: First physical node of ACPI device @adev
*/
struct device *acpi_get_first_physical_node(struct acpi_device *adev)
{
guard(mutex)(&adev->physical_node_lock);
return primary_physical_device(adev);
}
EXPORT_SYMBOL_GPL(acpi_get_first_physical_node);
static struct acpi_device *acpi_primary_dev_companion(struct acpi_device *adev,
const struct device *dev)
{
const struct device *phys_dev = acpi_get_first_physical_node(adev);
const struct device *phys_dev;
guard(mutex)(&adev->physical_node_lock);
phys_dev = primary_physical_device(adev);
return phys_dev && phys_dev == dev ? adev : NULL;
}

View File

@ -37,9 +37,9 @@ static long __init parse_acpi_path(const struct efi_dev_path *node,
if (!adev)
return -ENODEV;
phys_dev = acpi_get_first_physical_node(adev);
phys_dev = acpi_bus_get_primary_device(adev);
if (phys_dev) {
*child = get_device(phys_dev);
*child = phys_dev;
acpi_dev_put(adev);
} else
*child = &adev->dev;

View File

@ -5307,7 +5307,7 @@ static void acpi_smmu_dsdt_probe_tegra241_cmdqv(struct acpi_iort_node *node,
adev = acpi_dev_get_first_match_dev("NVDA200C", uid, -1);
if (adev) {
/* Tegra241 CMDQV driver is responsible for put_device() */
smmu->impl_dev = get_device(acpi_get_first_physical_node(adev));
smmu->impl_dev = acpi_bus_get_primary_device(adev);
smmu->options |= ARM_SMMU_OPT_TEGRA241_CMDQV;
dev_info(smmu->dev, "found companion CMDQV device: %s\n",
dev_name(smmu->impl_dev));

View File

@ -353,13 +353,13 @@ static int yogabook_wmi_probe(struct wmi_device *wdev, const void *context)
goto error_put_devs;
}
data->kbd_dev = get_device(acpi_get_first_physical_node(data->kbd_adev));
data->kbd_dev = acpi_bus_get_primary_device(data->kbd_adev);
if (!data->kbd_dev || !data->kbd_dev->driver) {
r = -EPROBE_DEFER;
goto error_put_devs;
}
data->dig_dev = get_device(acpi_get_first_physical_node(data->dig_adev));
data->dig_dev = acpi_bus_get_primary_device(data->dig_adev);
if (!data->dig_dev || !data->dig_dev->driver) {
r = -EPROBE_DEFER;
goto error_put_devs;

View File

@ -74,8 +74,7 @@ get_serdev_controller(const char *serial_ctrl_hid,
return ERR_PTR(-ENODEV);
}
/* get_first_physical_node() returns a weak ref */
parent = get_device(acpi_get_first_physical_node(adev));
parent = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!parent) {
pr_err("error could not get %s/%s serial-ctrl physical node\n",

View File

@ -390,7 +390,6 @@ static int gpio_secondary_fwnode_init(struct device *parent,
{
const struct software_node *const *swnode;
struct fwnode_handle *fwnode;
struct device *phys_dev;
int ret;
if (!node_group)
@ -418,7 +417,8 @@ static int gpio_secondary_fwnode_init(struct device *parent,
if (WARN_ON(!fwnode))
return -ENOENT;
phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
struct device *phys_dev __free(put_device) =
acpi_bus_get_primary_device(to_acpi_device(dev));
if (!phys_dev)
return dev_err_probe(parent, -ENODEV,
"No physical device for ACPI GPIO dev: %pfwP\n",

View File

@ -17,8 +17,8 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
struct acpi_device *adev = acpi_fetch_acpi_dev(handle);
struct fwnode_handle *fwnode;
struct tb_nhi *nhi = data;
struct device *dev = NULL;
struct pci_dev *pdev;
struct device *dev;
if (!adev)
return AE_OK;
@ -37,7 +37,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
* USB3 ports might not even have a physical device yet if xHCI driver
* isn't bound yet.
*/
dev = acpi_get_first_physical_node(adev);
dev = acpi_bus_get_primary_device(adev);
if (!dev || !dev_is_pci(dev))
goto out_put;
@ -74,6 +74,7 @@ static acpi_status tb_acpi_add_link(acpi_handle handle, u32 level, void *data,
}
out_put:
put_device(dev);
fwnode_handle_put(fwnode);
return AE_OK;
}

View File

@ -9,6 +9,8 @@
#ifndef __ACPI_BUS_H__
#define __ACPI_BUS_H__
#ifdef CONFIG_ACPI
#include <linux/completion.h>
#include <linux/container_of.h>
#include <linux/device.h>
@ -58,7 +60,6 @@ bool acpi_dock_match(acpi_handle handle);
bool acpi_check_dsm(acpi_handle handle, const guid_t *guid, u64 rev, u64 funcs);
union acpi_object *acpi_evaluate_dsm(acpi_handle handle, const guid_t *guid,
u64 rev, u64 func, union acpi_object *argv4);
#ifdef CONFIG_ACPI
bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld);
@ -77,7 +78,6 @@ acpi_evaluate_dsm_typed(acpi_handle handle, const guid_t *guid, u64 rev,
return obj;
}
#endif
#define ACPI_INIT_DSM_ARGV4(cnt, eles) \
{ \
@ -90,8 +90,6 @@ bool acpi_dev_found(const char *hid);
bool acpi_dev_present(const char *hid, const char *uid, s64 hrv);
bool acpi_reduced_hardware(void);
#ifdef CONFIG_ACPI
struct proc_dir_entry;
#define ACPI_BUS_FILE_ROOT "acpi"
@ -953,8 +951,21 @@ int acpi_wait_for_acpi_ipmi(void);
int acpi_scan_add_dep(acpi_handle handle, struct acpi_handle_list *dep_devices);
u32 arch_acpi_add_auto_dep(acpi_handle handle);
#else /* CONFIG_ACPI */
static inline struct acpi_device *
acpi_find_child_device(struct acpi_device *parent, u64 address,
bool check_children)
{
return NULL;
}
static inline bool acpi_has_method(acpi_handle handle, char *name)
{
return false;
}
static inline struct device *acpi_bus_get_primary_device(struct acpi_device *adev)
{
return NULL;
@ -970,6 +981,11 @@ static inline const char *acpi_device_hid(struct acpi_device *device)
return "";
}
static inline char *acpi_device_uid(struct acpi_device *device)
{
return NULL;
}
static inline bool
acpi_get_physical_device_location(acpi_handle handle, struct acpi_pld_info **pld)
{

View File

@ -25,6 +25,7 @@ struct irq_domain_ops;
#define _LINUX
#endif
#include <acpi/acpi.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_numa.h>
#ifdef CONFIG_ACPI
@ -37,7 +38,6 @@ DEFINE_FREE(acpi_object_free, union acpi_object *, if (_T) ACPI_FREE(_T));
#include <linux/mutex.h>
#include <linux/fw_table.h>
#include <acpi/acpi_bus.h>
#include <acpi/acpi_drivers.h>
#include <acpi/acpi_io.h>
#include <asm/acpi.h>
@ -107,8 +107,6 @@ static inline const char *acpi_dev_name(struct acpi_device *adev)
return dev_name(&adev->dev);
}
struct device *acpi_get_first_physical_node(struct acpi_device *adev);
enum acpi_irq_model_id {
ACPI_IRQ_MODEL_PIC = 0,
ACPI_IRQ_MODEL_IOAPIC,
@ -940,11 +938,6 @@ static inline const char *acpi_dev_name(struct acpi_device *adev)
return NULL;
}
static inline struct device *acpi_get_first_physical_node(struct acpi_device *adev)
{
return NULL;
}
static inline void acpi_early_init(void) { }
static inline void acpi_subsystem_init(void) { }

View File

@ -109,7 +109,7 @@ static inline bool apple_gmux_detect(struct pnp_dev *pnp_dev, enum apple_gmux_ty
if (!adev)
return false;
dev = get_device(acpi_get_first_physical_node(adev));
dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!dev)
return false;

View File

@ -209,8 +209,7 @@ static int aw88399_hda_acpi_probe(struct aw88399_hda *aw88399)
return -ENODEV;
}
struct device *physdev __free(put_device) =
get_device(acpi_get_first_physical_node(adev));
struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!physdev)
return -ENODEV;

View File

@ -1926,8 +1926,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
}
cs35l41->dacpi = adev;
struct device *physdev __free(put_device) =
get_device(acpi_get_first_physical_node(adev));
struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
if (!physdev) {
acpi_dev_put(adev);
return -ENODEV;

View File

@ -100,8 +100,7 @@ static int tas2781_read_acpi(struct tasdevice_priv *p, const char *hid)
return -ENODEV;
}
struct device *physdev __free(put_device) =
get_device(acpi_get_first_physical_node(adev));
struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
ret = acpi_dev_get_resources(adev, &resources, tas2781_get_i2c_res, p);
if (ret < 0) {
dev_err(p->dev, "Failed to get ACPI resource.\n");

View File

@ -341,8 +341,7 @@ static int tas2781_read_acpi(struct tas2781_hda *tas_hda,
strscpy(p->dev_name, hid, sizeof(p->dev_name));
struct device *physdev __free(put_device) =
get_device(acpi_get_first_physical_node(adev));
struct device *physdev __free(put_device) = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!physdev)
return -ENODEV;

View File

@ -198,7 +198,7 @@ static int st_es8336_late_probe(struct snd_soc_card *card)
if (!adev)
return -ENODEV;
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev) {
dev_err(card->dev, "can not find codec dev\n");

View File

@ -428,7 +428,7 @@ static int acp3x_es83xx_probe(struct snd_soc_card *card)
return -ENXIO;
}
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev) {
dev_warn(dev, "Error cannot find codec device, will defer probe\n");

View File

@ -601,11 +601,11 @@ static int snd_byt_cht_es8316_mc_probe(struct platform_device *pdev)
return -ENOENT;
}
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
priv->codec_dev = codec_dev;
/* override platform name, if required */
byt_cht_es8316_card.dev = dev;

View File

@ -1744,11 +1744,11 @@ static int snd_byt_rt5640_mc_probe(struct platform_device *pdev)
return -ENOENT;
}
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (codec_dev) {
priv->codec_dev = get_device(codec_dev);
priv->codec_dev = codec_dev;
} else {
/*
* Special case for Android tablets where the codec i2c_client

View File

@ -960,11 +960,11 @@ static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
return -ENOENT;
}
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
priv->codec_dev = codec_dev;
/*
* swap SSP0 if bytcr is detected

View File

@ -529,7 +529,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
const char *platform_name;
struct cht_mc_private *drv;
struct acpi_device *adev;
struct device *codec_dev;
bool sof_parent;
bool found = false;
bool is_bytcr = false;
@ -583,8 +582,8 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
return -ENOENT;
}
/* acpi_get_first_physical_node() returns a borrowed ref, no need to deref */
codec_dev = acpi_get_first_physical_node(adev);
struct device *codec_dev __free(put_device) = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev)
return -EPROBE_DEFER;

View File

@ -168,7 +168,7 @@ static int cs35l41_compute_codec_conf(void)
cs35l41_name_prefixes[uid]);
continue;
}
physdev = get_device(acpi_get_first_physical_node(adev));
physdev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!physdev) {
pr_devel("Cannot find physical node for HID %s UID %u (%s)\n", CS35L41_HID,

View File

@ -702,11 +702,11 @@ static int sof_es8336_probe(struct platform_device *pdev)
return -ENOENT;
}
codec_dev = acpi_get_first_physical_node(adev);
codec_dev = acpi_bus_get_primary_device(adev);
acpi_dev_put(adev);
if (!codec_dev)
return -EPROBE_DEFER;
priv->codec_dev = get_device(codec_dev);
priv->codec_dev = codec_dev;
ret = snd_soc_fixup_dai_links_platform_name(&sof_es8336_card,
mach->mach_params.platform);

View File

@ -196,7 +196,6 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
struct snd_soc_card *card = &data->snd_card;
const char *codec_dai_name;
struct acpi_device *adev;
struct device *phy_dev;
int i, ret;
/* fixup platform name based on reference node */
@ -204,7 +203,7 @@ static int loongson_card_parse_acpi(struct loongson_card_data *data)
if (!adev)
return -ENOENT;
phy_dev = acpi_get_first_physical_node(adev);
struct device *phy_dev __free(put_device) = acpi_bus_get_primary_device(adev);
if (!phy_dev)
return -EPROBE_DEFER;