Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8be2ac44 authored by Banajit Goswami's avatar Banajit Goswami
Browse files

soundwire: add new function to enumerate slave devices



Add a new function call in soundwire framework to
perform any remaining initialization of soundwire
slave devices. This function should be called right
after registering all slave devices with master,
and can perform a number of operations for enumerating
and registering the slave device with appropriate
subsystem (ALSA in this case).

Change-Id: Ie0a2f031eebdf5861eeef489bd94efb3682a0910
Signed-off-by: default avatarBanajit Goswami <bgoswami@codeaurora.org>
parent 88da3f7e
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -128,6 +128,47 @@ err_out:
}
EXPORT_SYMBOL(swr_new_device);

/**
 * swr_startup_devices - perform additional initialization for child devices
 *
 * @swr_dev: pointer to soundwire slave device
 *
 * Performs any additional initialization needed for a soundwire slave device.
 * This is a optional functionality defined by slave devices.
 * Removes the slave node from the list, in case there is any failure.
 */
int swr_startup_devices(struct swr_device *swr_dev)
{
	struct swr_driver *swr_drv;
	struct device *dev;
	int ret = 0;

	if (!swr_dev)
		return -EINVAL;

	dev = &swr_dev->dev;
	if (!dev)
		return -EINVAL;

	swr_drv = to_swr_driver(dev->driver);
	if (!swr_drv)
		return -EINVAL;

	if (swr_drv->startup) {
		ret = swr_drv->startup(swr_dev);
		if (ret)
			goto out;

		dev_dbg(&swr_dev->dev,
			"%s: startup complete for device %lx\n",
			__func__, swr_dev->addr);
	}

out:
	return ret;
}
EXPORT_SYMBOL(swr_startup_devices);

/**
 * of_register_swr_devices - register child devices on to the soundwire bus
 * @master: pointer to soundwire master device
+4 −0
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ static inline struct swr_device *to_swr_device(struct device *dev)
 * @shutdown: standard shutdown callback used during power down/halt
 * @suspend: standard suspend callback used during system suspend
 * @resume: standard resume callback used during system resume
 * @startup: additional init operation for slave devices
 * @driver: soundwire device drivers should initialize name and
 * owner field of this structure
 * @id_table: list of soundwire devices supported by this driver
@@ -193,6 +194,7 @@ struct swr_driver {
	int	(*device_up)(struct swr_device *swr);
	int	(*device_down)(struct swr_device *swr);
	int	(*reset_device)(struct swr_device *swr);
	int	(*startup)(struct swr_device *swr);
	struct device_driver		driver;
	const struct swr_device_id	*id_table;
};
@@ -239,6 +241,8 @@ static inline void swr_set_dev_data(struct swr_device *dev, void *data)
	dev_set_drvdata(&dev->dev, data);
}

extern int swr_startup_devices(struct swr_device *swr_dev);

extern struct swr_device *swr_new_device(struct swr_master *master,
				struct swr_boardinfo const *info);