[alsa-devel] [PATCH 06/14] soundwire: add support for sdw_slave_type

Pierre-Louis Bossart pierre-louis.bossart at linux.intel.com
Mon Nov 4 20:41:46 CET 2019



>> @@ -49,9 +49,16 @@ int sdw_slave_modalias(const struct sdw_slave 
>> *slave, char *buf, size_t size)
>>   static int sdw_uevent(struct device *dev, struct kobj_uevent_env *env)
>>   {
>> -    struct sdw_slave *slave = to_sdw_slave_device(dev);
>> +    struct sdw_slave *slave;
>>       char modalias[32];
>> +    if (is_sdw_slave(dev)) {
>> +        slave = to_sdw_slave_device(dev);
>> +    } else {
>> +        dev_warn(dev, "uevent for unknown Soundwire type\n");
>> +        return -EINVAL;
>> +    }
>> +
>>       sdw_slave_modalias(slave, modalias, sizeof(modalias));
>>       if (add_uevent_var(env, "MODALIAS=%s", modalias))
> 
> Positive evaluation of is_sdw_slave() check is required for function to 
> continue, thus you might as well do:
> 
> if (!is_sdw_slave(dev)) {
>      dev_warn();
>      return -EINVAL;
> }
> 
> slave = to_sdw_slave_device(dev);

see the following patch 7, it becomes a 2-case test (slave and master).
I am all for optimizations but wait until the actual changes are added...


More information about the Alsa-devel mailing list