soundwire: Move device init functionality from master
Move from master probe to the slave probe, the device init functionality of swr slave. Provide device remove functionality to remove a given device from the master list. CRs-fixed: 2036684 Change-Id: Iee95c146d8b148e15dca5a8c10de65368cf3b55a Signed-off-by: Karthikeyan Mani <kmani@codeaurora.org>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
@@ -67,6 +67,27 @@ static void swr_dev_release(struct device *dev)
|
||||
kfree(swr_dev);
|
||||
}
|
||||
|
||||
/**
|
||||
* swr_remove_device - remove a soundwire device
|
||||
* @swr_dev: soundwire device to remove
|
||||
*
|
||||
* Remove a soundwire device. Go through the soundwire
|
||||
* device list that master has and remove swr_dev from
|
||||
* it.
|
||||
*/
|
||||
void swr_remove_device(struct swr_device *swr_dev)
|
||||
{
|
||||
struct swr_device *swr_dev_loop, *safe;
|
||||
|
||||
list_for_each_entry_safe(swr_dev_loop, safe,
|
||||
&swr_dev->master->devices,
|
||||
dev_list) {
|
||||
if (swr_dev == swr_dev_loop)
|
||||
list_del(&swr_dev_loop->dev_list);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(swr_remove_device);
|
||||
|
||||
/**
|
||||
* swr_new_device - instantiate a new soundwire device
|
||||
* @master: Controller to which device is connected
|
||||
@@ -128,47 +149,6 @@ 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
|
||||
@@ -610,7 +590,7 @@ int swr_device_up(struct swr_device *swr_dev)
|
||||
dev = &swr_dev->dev;
|
||||
sdrv = to_swr_driver(dev->driver);
|
||||
if (!sdrv)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
|
||||
if (sdrv->device_up)
|
||||
return sdrv->device_up(to_swr_device(dev));
|
||||
@@ -638,7 +618,7 @@ int swr_device_down(struct swr_device *swr_dev)
|
||||
dev = &swr_dev->dev;
|
||||
sdrv = to_swr_driver(dev->driver);
|
||||
if (!sdrv)
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
|
||||
if (sdrv->device_down)
|
||||
return sdrv->device_down(to_swr_device(dev));
|
||||
|
||||
@@ -1369,7 +1369,6 @@ static int swrm_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct swr_mstr_ctrl *swrm;
|
||||
struct swr_ctrl_platform_data *pdata;
|
||||
struct swr_device *swr_dev, *safe;
|
||||
int ret;
|
||||
|
||||
/* Allocate soundwire master driver structure */
|
||||
@@ -1470,9 +1469,6 @@ static int swrm_probe(struct platform_device *pdev)
|
||||
goto err_mstr_fail;
|
||||
}
|
||||
|
||||
if (pdev->dev.of_node)
|
||||
of_register_swr_devices(&swrm->master);
|
||||
|
||||
/* Add devices registered with board-info as the
|
||||
controller will be up now
|
||||
*/
|
||||
@@ -1489,15 +1485,11 @@ static int swrm_probe(struct platform_device *pdev)
|
||||
}
|
||||
swrm->version = swrm->read(swrm->handle, SWRM_COMP_HW_VERSION);
|
||||
|
||||
/* Enumerate slave devices */
|
||||
list_for_each_entry_safe(swr_dev, safe, &swrm->master.devices,
|
||||
dev_list) {
|
||||
ret = swr_startup_devices(swr_dev);
|
||||
if (ret)
|
||||
list_del(&swr_dev->dev_list);
|
||||
}
|
||||
mutex_unlock(&swrm->mlock);
|
||||
|
||||
if (pdev->dev.of_node)
|
||||
of_register_swr_devices(&swrm->master);
|
||||
|
||||
dbgswrm = swrm;
|
||||
debugfs_swrm_dent = debugfs_create_dir(dev_name(&pdev->dev), 0);
|
||||
if (!IS_ERR(debugfs_swrm_dent)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
@@ -309,4 +309,6 @@ extern int swr_reset_device(struct swr_device *swr_dev);
|
||||
extern int swr_slvdev_datapath_control(struct swr_device *swr_dev, u8 dev_num,
|
||||
bool enable);
|
||||
extern int swr_remove_from_group(struct swr_device *dev, u8 dev_num);
|
||||
|
||||
extern void swr_remove_device(struct swr_device *swr_dev);
|
||||
#endif /* _LINUX_SOUNDWIRE_H */
|
||||
|
||||
Reference in New Issue
Block a user