Re: [alsa-devel] [PATCH v4 08/15] soundwire: Add Slave status handling helpers

From: Vinod Koul
Date: Sun Dec 03 2017 - 22:09:51 EST


On Sun, Dec 03, 2017 at 09:07:29PM -0600, Pierre-Louis Bossart wrote:
> On 12/3/17 11:08 AM, Vinod Koul wrote:
> >On Fri, Dec 01, 2017 at 05:36:47PM -0600, Pierre-Louis Bossart wrote:
> >
> >>>+/* called with bus_lock held */
> >>>+static int sdw_get_device_num(struct sdw_slave *slave)
> >>>+{
> >>>+ int bit;
> >>>+
> >>>+ bit = find_first_zero_bit(slave->bus->assigned, SDW_MAX_DEVICES);
> >>>+ if (bit == SDW_MAX_DEVICES) {
> >>>+ bit = -ENODEV;
> >>>+ goto err;
> >>
> >>My brain is starting to fry but is this correct? Bit11 seems like a valid
> >>value. Should it be bit > 15 (assuming bit 12,13,14 are set to avoid using
> >>groups and master)?
> >
> >this is correct. You are confusing SDW concept and API return types!
> >That should be hint for you to start weekend if you didn't do so :D
> >
> >This API returns max value it was provided (last arg) if it doesn't
> >find free bit. That's an indication to caller that we ran out of devices
> >hence ENODEV error!
>
> Can you just make sure bit11 is included?

yes it is, refer to the masks we set for bit, only 0 and 15 and now 12,13
and 14 will be masked out. So we can get from 1 to 11 both inclusive.

--
~Vinod