Unverified Commit 4b224ff8 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown
Browse files

ASoC/soundwire: remove sdw_slave_extended_id



This structure is used to copy information from the 'sdw_slave'
structures, it's better to create a flexible array of 'sdw_slave'
pointers and directly access the information. This will also help
access additional information stored in the 'sdw_slave' structure,
such as an SDCA context.

This patch does not add new functionality, it only modified how the
information is retrieved.

Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: default avatarPéter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
Link: https://patch.msgid.link/20241016102333.294448-3-yung-chuan.liao@linux.intel.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent f35533a0
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -177,7 +177,7 @@ EXPORT_SYMBOL_NS(sdw_amd_probe, SOUNDWIRE_AMD_INIT);
void sdw_amd_exit(struct sdw_amd_ctx *ctx)
{
	sdw_amd_cleanup(ctx);
	kfree(ctx->ids);
	kfree(ctx->peripherals);
	kfree(ctx);
}
EXPORT_SYMBOL_NS(sdw_amd_exit, SOUNDWIRE_AMD_INIT);
@@ -204,10 +204,11 @@ int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx)
			num_slaves++;
	}

	ctx->ids = kcalloc(num_slaves, sizeof(*ctx->ids), GFP_KERNEL);
	if (!ctx->ids)
	ctx->peripherals = kmalloc(struct_size(ctx->peripherals, array, num_slaves),
				   GFP_KERNEL);
	if (!ctx->peripherals)
		return -ENOMEM;
	ctx->num_slaves = num_slaves;
	ctx->peripherals->num_peripherals = num_slaves;
	for (index = 0; index < ctx->count; index++) {
		if (!(ctx->link_mask & BIT(index)))
			continue;
@@ -215,8 +216,7 @@ int sdw_amd_get_slave_info(struct sdw_amd_ctx *ctx)
		if (amd_manager) {
			bus = &amd_manager->bus;
			list_for_each_entry(slave, &bus->slaves, node) {
				ctx->ids[i].id = slave->id;
				ctx->ids[i].link_id = bus->link_id;
				ctx->peripherals->array[i] = slave;
				i++;
			}
		}
+6 −7
Original line number Diff line number Diff line
@@ -252,17 +252,16 @@ static struct sdw_intel_ctx
			num_slaves++;
	}

	ctx->ids = kcalloc(num_slaves, sizeof(*ctx->ids), GFP_KERNEL);
	if (!ctx->ids)
	ctx->peripherals = kmalloc(struct_size(ctx->peripherals, array, num_slaves),
				   GFP_KERNEL);
	if (!ctx->peripherals)
		goto err;

	ctx->num_slaves = num_slaves;
	ctx->peripherals->num_peripherals = num_slaves;
	i = 0;
	list_for_each_entry(link, &ctx->link_list, list) {
		bus = &link->cdns->bus;
		list_for_each_entry(slave, &bus->slaves, node) {
			ctx->ids[i].id = slave->id;
			ctx->ids[i].link_id = bus->link_id;
			ctx->peripherals->array[i] = slave;
			i++;
		}
	}
@@ -371,7 +370,7 @@ void sdw_intel_exit(struct sdw_intel_ctx *ctx)
	}

	sdw_intel_cleanup(ctx);
	kfree(ctx->ids);
	kfree(ctx->peripherals);
	kfree(ctx->ldev);
	kfree(ctx);
}
+3 −3
Original line number Diff line number Diff line
@@ -488,9 +488,9 @@ struct sdw_slave_id {
	__u8 sdw_version:4;
};

struct sdw_extended_slave_id {
	int link_id;
	struct sdw_slave_id id;
struct sdw_peripherals {
	int num_peripherals;
	struct sdw_slave *array[];
};

/*
+2 −5
Original line number Diff line number Diff line
@@ -115,19 +115,16 @@ struct sdw_amd_acpi_info {
 * struct sdw_amd_ctx - context allocated by the controller driver probe
 *
 * @count: link count
 * @num_slaves: total number of devices exposed across all enabled links
 * @link_mask: bit-wise mask listing SoundWire links reported by the
 * Controller
 * @ids: array of slave_id, representing Slaves exposed across all enabled
 * links
 * @pdev: platform device structure
 * @peripherals: array representing Peripherals exposed across all enabled links
 */
struct sdw_amd_ctx {
	int count;
	int num_slaves;
	u32 link_mask;
	struct sdw_extended_slave_id *ids;
	struct platform_device *pdev[AMD_SDW_MAX_MANAGER_COUNT];
	struct sdw_peripherals *peripherals;
};

/**
+2 −5
Original line number Diff line number Diff line
@@ -287,31 +287,28 @@ struct hdac_bus;
 * hardware capabilities after all power dependencies are settled.
 * @link_mask: bit-wise mask listing SoundWire links reported by the
 * Controller
 * @num_slaves: total number of devices exposed across all enabled links
 * @handle: ACPI parent handle
 * @ldev: information for each link (controller-specific and kept
 * opaque here)
 * @ids: array of slave_id, representing Slaves exposed across all enabled
 * links
 * @link_list: list to handle interrupts across all links
 * @shim_lock: mutex to handle concurrent rmw access to shared SHIM registers.
 * @shim_mask: flags to track initialization of SHIM shared registers
 * @shim_base: sdw shim base.
 * @alh_base: sdw alh base.
 * @peripherals: array representing Peripherals exposed across all enabled links
 */
struct sdw_intel_ctx {
	int count;
	void __iomem *mmio_base;
	u32 link_mask;
	int num_slaves;
	acpi_handle handle;
	struct sdw_intel_link_dev **ldev;
	struct sdw_extended_slave_id *ids;
	struct list_head link_list;
	struct mutex shim_lock; /* lock for access to shared SHIM registers */
	u32 shim_mask;
	u32 shim_base;
	u32 alh_base;
	struct sdw_peripherals *peripherals;
};

/**
Loading