diff mbox series

soundwire: stream: uniquify dev_err() logs

Message ID 20230309054905.21507-1-yung-chuan.liao@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series soundwire: stream: uniquify dev_err() logs | expand

Commit Message

Bard Liao March 9, 2023, 5:49 a.m. UTC
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

There are a couple of duplicate logs which makes harder than needed to
follow the error flows. Add __func__ or make the log unique.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
---
 drivers/soundwire/stream.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

Comments

Vinod Koul March 15, 2023, 10:09 a.m. UTC | #1
On 09-03-23, 13:49, Bard Liao wrote:
> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> 
> There are a couple of duplicate logs which makes harder than needed to
> follow the error flows. Add __func__ or make the log unique.
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> ---
>  drivers/soundwire/stream.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> index 2e39587ed1de..dd09855caac9 100644
> --- a/drivers/soundwire/stream.c
> +++ b/drivers/soundwire/stream.c
> @@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
>  
>  	ret = do_bank_switch(stream);
>  	if (ret < 0) {
> -		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
> +		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);

why make it pr_ and loose the dev name? There is a trick to emit
function for dev_err too using dynamic debug


>  		goto restore_params;
>  	}
>  
> @@ -1477,7 +1477,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
>  		/* Program params */
>  		ret = sdw_program_params(bus, false);
>  		if (ret < 0) {
> -			dev_err(bus->dev, "Program params failed: %d\n", ret);
> +			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
>  			return ret;
>  		}
>  
> @@ -1497,7 +1497,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
>  
>  	ret = do_bank_switch(stream);
>  	if (ret < 0) {
> -		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
> +		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
>  		return ret;
>  	}
>  
> @@ -1567,14 +1567,14 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
>  		/* Program params */
>  		ret = sdw_program_params(bus, false);
>  		if (ret < 0) {
> -			dev_err(bus->dev, "Program params failed: %d\n", ret);
> +			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
>  			return ret;
>  		}
>  	}
>  
>  	ret = do_bank_switch(stream);
>  	if (ret < 0) {
> -		pr_err("Bank switch failed: %d\n", ret);
> +		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
>  		return ret;
>  	}
>  
> @@ -1664,7 +1664,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
>  		/* Program params */
>  		ret = sdw_program_params(bus, false);
>  		if (ret < 0) {
> -			dev_err(bus->dev, "Program params failed: %d\n", ret);
> +			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
>  			return ret;
>  		}
>  	}
> @@ -1893,7 +1893,8 @@ int sdw_stream_add_master(struct sdw_bus *bus,
>  
>  	m_rt = sdw_master_rt_alloc(bus, stream);
>  	if (!m_rt) {
> -		dev_err(bus->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
> +		dev_err(bus->dev, "%s: Master runtime alloc failed for stream:%s\n",
> +			__func__, stream->name);
>  		ret = -ENOMEM;
>  		goto unlock;
>  	}
> @@ -2012,7 +2013,8 @@ int sdw_stream_add_slave(struct sdw_slave *slave,
>  	 */
>  	m_rt = sdw_master_rt_alloc(slave->bus, stream);
>  	if (!m_rt) {
> -		dev_err(&slave->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
> +		dev_err(&slave->dev, "%s: Master runtime alloc failed for stream:%s\n",
> +			__func__, stream->name);
>  		ret = -ENOMEM;
>  		goto unlock;
>  	}
> -- 
> 2.25.1
Pierre-Louis Bossart March 15, 2023, 2:38 p.m. UTC | #2
On 3/15/23 05:09, Vinod Koul wrote:
> On 09-03-23, 13:49, Bard Liao wrote:
>> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>>
>> There are a couple of duplicate logs which makes harder than needed to
>> follow the error flows. Add __func__ or make the log unique.
>>
>> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
>> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
>> ---
>>  drivers/soundwire/stream.c | 18 ++++++++++--------
>>  1 file changed, 10 insertions(+), 8 deletions(-)
>>
>> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
>> index 2e39587ed1de..dd09855caac9 100644
>> --- a/drivers/soundwire/stream.c
>> +++ b/drivers/soundwire/stream.c
>> @@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
>>  
>>  	ret = do_bank_switch(stream);
>>  	if (ret < 0) {
>> -		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
>> +		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
> 
> why make it pr_ and loose the dev name? There is a trick to emit
> function for dev_err too using dynamic debug

a stream can be cased on multiple managers/buses.

It's incorrect to use bus->dev in this case, see all other error cases
in stream.c, they all use pr_err already for the same reason. bus->dev
is only valid when dealing with a single bus, typically in loops in that
file.

That said we could have split the two changes where dev_err() is changed
as pr_err() for clarity.
Vinod Koul March 17, 2023, 1:37 p.m. UTC | #3
On 15-03-23, 09:38, Pierre-Louis Bossart wrote:
> 
> 
> On 3/15/23 05:09, Vinod Koul wrote:
> > On 09-03-23, 13:49, Bard Liao wrote:
> >> From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> >>
> >> There are a couple of duplicate logs which makes harder than needed to
> >> follow the error flows. Add __func__ or make the log unique.
> >>
> >> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
> >> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
> >> Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
> >> ---
> >>  drivers/soundwire/stream.c | 18 ++++++++++--------
> >>  1 file changed, 10 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
> >> index 2e39587ed1de..dd09855caac9 100644
> >> --- a/drivers/soundwire/stream.c
> >> +++ b/drivers/soundwire/stream.c
> >> @@ -1389,7 +1389,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
> >>  
> >>  	ret = do_bank_switch(stream);
> >>  	if (ret < 0) {
> >> -		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
> >> +		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
> > 
> > why make it pr_ and loose the dev name? There is a trick to emit
> > function for dev_err too using dynamic debug
> 
> a stream can be cased on multiple managers/buses.
> 
> It's incorrect to use bus->dev in this case, see all other error cases
> in stream.c, they all use pr_err already for the same reason. bus->dev
> is only valid when dealing with a single bus, typically in loops in that
> file.
> 
> That said we could have split the two changes where dev_err() is changed
> as pr_err() for clarity.

Thanks, that would be better way
diff mbox series

Patch

diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c
index 2e39587ed1de..dd09855caac9 100644
--- a/drivers/soundwire/stream.c
+++ b/drivers/soundwire/stream.c
@@ -1389,7 +1389,7 @@  static int _sdw_prepare_stream(struct sdw_stream_runtime *stream,
 
 	ret = do_bank_switch(stream);
 	if (ret < 0) {
-		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
+		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
 		goto restore_params;
 	}
 
@@ -1477,7 +1477,7 @@  static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
 		/* Program params */
 		ret = sdw_program_params(bus, false);
 		if (ret < 0) {
-			dev_err(bus->dev, "Program params failed: %d\n", ret);
+			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
 			return ret;
 		}
 
@@ -1497,7 +1497,7 @@  static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
 
 	ret = do_bank_switch(stream);
 	if (ret < 0) {
-		dev_err(bus->dev, "Bank switch failed: %d\n", ret);
+		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
 		return ret;
 	}
 
@@ -1567,14 +1567,14 @@  static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
 		/* Program params */
 		ret = sdw_program_params(bus, false);
 		if (ret < 0) {
-			dev_err(bus->dev, "Program params failed: %d\n", ret);
+			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
 			return ret;
 		}
 	}
 
 	ret = do_bank_switch(stream);
 	if (ret < 0) {
-		pr_err("Bank switch failed: %d\n", ret);
+		pr_err("%s: do_bank_switch failed: %d\n", __func__, ret);
 		return ret;
 	}
 
@@ -1664,7 +1664,7 @@  static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
 		/* Program params */
 		ret = sdw_program_params(bus, false);
 		if (ret < 0) {
-			dev_err(bus->dev, "Program params failed: %d\n", ret);
+			dev_err(bus->dev, "%s: Program params failed: %d\n", __func__, ret);
 			return ret;
 		}
 	}
@@ -1893,7 +1893,8 @@  int sdw_stream_add_master(struct sdw_bus *bus,
 
 	m_rt = sdw_master_rt_alloc(bus, stream);
 	if (!m_rt) {
-		dev_err(bus->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
+		dev_err(bus->dev, "%s: Master runtime alloc failed for stream:%s\n",
+			__func__, stream->name);
 		ret = -ENOMEM;
 		goto unlock;
 	}
@@ -2012,7 +2013,8 @@  int sdw_stream_add_slave(struct sdw_slave *slave,
 	 */
 	m_rt = sdw_master_rt_alloc(slave->bus, stream);
 	if (!m_rt) {
-		dev_err(&slave->dev, "Master runtime alloc failed for stream:%s\n", stream->name);
+		dev_err(&slave->dev, "%s: Master runtime alloc failed for stream:%s\n",
+			__func__, stream->name);
 		ret = -ENOMEM;
 		goto unlock;
 	}