[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <06a1bcfc-eeca-b3ec-1d74-e6ac9cadce53@linaro.org>
Date: Thu, 16 Nov 2017 16:05:29 +0000
From: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To: Vinod Koul <vinod.koul@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
ALSA <alsa-devel@...a-project.org>, Mark <broonie@...nel.org>,
Takashi <tiwai@...e.de>,
Pierre <pierre-louis.bossart@...ux.intel.com>,
Sanyog Kale <sanyog.r.kale@...el.com>,
Shreyas NC <shreyas.nc@...el.com>, patches.audio@...el.com,
alan@...ux.intel.com,
Charles Keepax <ckeepax@...nsource.cirrus.com>,
Sagar Dharia <sdharia@...eaurora.org>, plai@...eaurora.org,
Sudheer Papothi <spapothi@...eaurora.org>
Subject: Re: [PATCH v2 08/14] soundwire: Add Slave status handling helpers
Minor Comment!
On 10/11/17 11:49, Vinod Koul wrote:
> From: Sanyog Kale <sanyog.r.kale@...el.com>
>
> SoundWire Slaves report status to bus. Add helpers to handle
> the status changes.
>
> Signed-off-by: Hardik T Shah <hardik.t.shah@...el.com>
> Signed-off-by: Sanyog Kale <sanyog.r.kale@...el.com>
> Signed-off-by: Vinod Koul <vinod.koul@...el.com>
> ---
> +static int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id)
> +{
> +
> + if ((slave->id.unique_id != id.unique_id) ||
> + (slave->id.mfg_id != id.mfg_id) ||
> + (slave->id.part_id != id.part_id) ||
> + (slave->id.class_id != id.class_id))
> + return -ENODEV;
> +
> + return 0;
> +}
> +
> +/* called with bus_lock held */
> +static int sdw_get_device_num(struct sdw_slave *slave)
> +{
If we use ida we would not need this function.
> + int bit;
> +
> + bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES);
> + if (bit == SDW_MAX_DEVICES) {
> + bit = -ENODEV;
> + goto err;
> + }
> +
> + /*
> + * Do not update dev_num in Slave data structure here,
> + * Update once program dev_num is successful
> + */
> + set_bit(bit, slave->bus->assigned);
> +
> +err:
> + return bit;
> +}
> +
> +static int sdw_assign_device_num(struct sdw_slave *slave)
> +{
> + int ret, dev_num;
> +
> + /* check first if device number is assigned, if so reuse that */
> + if (!slave->dev_num) {
> + mutex_lock(&slave->bus->bus_lock);
> + dev_num = sdw_get_device_num(slave);
> + mutex_unlock(&slave->bus->bus_lock);
> + if (dev_num < 0) {
> + dev_err(slave->bus->dev, "Get dev_num failed: %d",
> + dev_num);
> + return dev_num;
> + }
> + } else {
> + dev_info(slave->bus->dev,
> + "Slave already registered dev_num:%d",
> + slave->dev_num);
> +
> + /* Clear the slave->dev_num to transfer message on device 0 */
> + dev_num = slave->dev_num;
> + slave->dev_num = 0;
> +
> + }
> +
> + ret = sdw_write(slave, SDW_SCP_DEVNUMBER, dev_num);
> + if (ret < 0) {
> + dev_err(&slave->dev, "Program device_num failed: %d", ret);
> + return ret;
> + }
> +
> + /* After xfer of msg, restore dev_num */
> + slave->dev_num = dev_num;
> +
> + return 0;
> +}
> +
> void sdw_extract_slave_id(struct sdw_bus *bus,
> u64 addr, struct sdw_slave_id *id)
> {
> @@ -447,3 +534,129 @@ void sdw_extract_slave_id(struct sdw_bus *bus,
> id->unique_id, id->sdw_version);
>
> }
> +
>
Powered by blists - more mailing lists