linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH -next] driver core: switch to use dev_err_probe()
  2022-08-19  9:46 [PATCH -next] driver core: switch to use dev_err_probe() Yang Yingliang
@ 2022-08-19  9:42 ` Greg KH
  2022-08-22  2:10   ` Yang Yingliang
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-08-19  9:42 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, rafael

On Fri, Aug 19, 2022 at 05:46:56PM +0800, Yang Yingliang wrote:
> Use dev_err_probe() to simplify code and print error code.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/base/core.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 753e7cca0f40..e51a09f9d0ec 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -2507,11 +2507,9 @@ static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
>  	int rc;
>  
>  	rc = kobject_synth_uevent(&dev->kobj, buf, count);
> -
> -	if (rc) {
> -		dev_err(dev, "uevent: failed to send synthetic uevent\n");
> -		return rc;
> -	}
> +	if (rc)
> +		return dev_err_probe(dev, rc,
> +				     "uevent: failed to send synthetic uevent\n");

I do not understand this at all, this is not on the probe path at all,
so why is this function needed?

Have you tested this?  What was the resulting output before and after
this change?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next] driver core: switch to use dev_err_probe()
@ 2022-08-19  9:46 Yang Yingliang
  2022-08-19  9:42 ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-08-19  9:46 UTC (permalink / raw)
  To: linux-kernel, rafael; +Cc: gregkh

Use dev_err_probe() to simplify code and print error code.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/base/core.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 753e7cca0f40..e51a09f9d0ec 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2507,11 +2507,9 @@ static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
 	int rc;
 
 	rc = kobject_synth_uevent(&dev->kobj, buf, count);
-
-	if (rc) {
-		dev_err(dev, "uevent: failed to send synthetic uevent\n");
-		return rc;
-	}
+	if (rc)
+		return dev_err_probe(dev, rc,
+				     "uevent: failed to send synthetic uevent\n");
 
 	return count;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] driver core: switch to use dev_err_probe()
  2022-08-19  9:42 ` Greg KH
@ 2022-08-22  2:10   ` Yang Yingliang
  2022-08-22  6:09     ` Greg KH
  0 siblings, 1 reply; 5+ messages in thread
From: Yang Yingliang @ 2022-08-22  2:10 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, rafael

Hi,

On 2022/8/19 17:42, Greg KH wrote:
> On Fri, Aug 19, 2022 at 05:46:56PM +0800, Yang Yingliang wrote:
>> Use dev_err_probe() to simplify code and print error code.
>>
>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>> ---
>>   drivers/base/core.c | 8 +++-----
>>   1 file changed, 3 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>> index 753e7cca0f40..e51a09f9d0ec 100644
>> --- a/drivers/base/core.c
>> +++ b/drivers/base/core.c
>> @@ -2507,11 +2507,9 @@ static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
>>   	int rc;
>>   
>>   	rc = kobject_synth_uevent(&dev->kobj, buf, count);
>> -
>> -	if (rc) {
>> -		dev_err(dev, "uevent: failed to send synthetic uevent\n");
>> -		return rc;
>> -	}
>> +	if (rc)
>> +		return dev_err_probe(dev, rc,
>> +				     "uevent: failed to send synthetic uevent\n");
> I do not understand this at all, this is not on the probe path at all,
> so why is this function needed?
>
> Have you tested this?  What was the resulting output before and after
> this change?
Yes, after this change, the error code will be print.
>
> thanks,
>
> greg k-h
> .

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] driver core: switch to use dev_err_probe()
  2022-08-22  2:10   ` Yang Yingliang
@ 2022-08-22  6:09     ` Greg KH
  2022-08-22  6:35       ` Yang Yingliang
  0 siblings, 1 reply; 5+ messages in thread
From: Greg KH @ 2022-08-22  6:09 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, rafael

On Mon, Aug 22, 2022 at 10:10:22AM +0800, Yang Yingliang wrote:
> Hi,
> 
> On 2022/8/19 17:42, Greg KH wrote:
> > On Fri, Aug 19, 2022 at 05:46:56PM +0800, Yang Yingliang wrote:
> > > Use dev_err_probe() to simplify code and print error code.
> > > 
> > > Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> > > ---
> > >   drivers/base/core.c | 8 +++-----
> > >   1 file changed, 3 insertions(+), 5 deletions(-)
> > > 
> > > diff --git a/drivers/base/core.c b/drivers/base/core.c
> > > index 753e7cca0f40..e51a09f9d0ec 100644
> > > --- a/drivers/base/core.c
> > > +++ b/drivers/base/core.c
> > > @@ -2507,11 +2507,9 @@ static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
> > >   	int rc;
> > >   	rc = kobject_synth_uevent(&dev->kobj, buf, count);
> > > -
> > > -	if (rc) {
> > > -		dev_err(dev, "uevent: failed to send synthetic uevent\n");
> > > -		return rc;
> > > -	}
> > > +	if (rc)
> > > +		return dev_err_probe(dev, rc,
> > > +				     "uevent: failed to send synthetic uevent\n");
> > I do not understand this at all, this is not on the probe path at all,
> > so why is this function needed?
> > 
> > Have you tested this?  What was the resulting output before and after
> > this change?
> Yes, after this change, the error code will be print.

You did not answer my question.

Again, this is not on the probe() callback path, so why are you wanting
to call dev_err_probe()?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next] driver core: switch to use dev_err_probe()
  2022-08-22  6:09     ` Greg KH
@ 2022-08-22  6:35       ` Yang Yingliang
  0 siblings, 0 replies; 5+ messages in thread
From: Yang Yingliang @ 2022-08-22  6:35 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, rafael


On 2022/8/22 14:09, Greg KH wrote:
> On Mon, Aug 22, 2022 at 10:10:22AM +0800, Yang Yingliang wrote:
>> Hi,
>>
>> On 2022/8/19 17:42, Greg KH wrote:
>>> On Fri, Aug 19, 2022 at 05:46:56PM +0800, Yang Yingliang wrote:
>>>> Use dev_err_probe() to simplify code and print error code.
>>>>
>>>> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
>>>> ---
>>>>    drivers/base/core.c | 8 +++-----
>>>>    1 file changed, 3 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/base/core.c b/drivers/base/core.c
>>>> index 753e7cca0f40..e51a09f9d0ec 100644
>>>> --- a/drivers/base/core.c
>>>> +++ b/drivers/base/core.c
>>>> @@ -2507,11 +2507,9 @@ static ssize_t uevent_store(struct device *dev, struct device_attribute *attr,
>>>>    	int rc;
>>>>    	rc = kobject_synth_uevent(&dev->kobj, buf, count);
>>>> -
>>>> -	if (rc) {
>>>> -		dev_err(dev, "uevent: failed to send synthetic uevent\n");
>>>> -		return rc;
>>>> -	}
>>>> +	if (rc)
>>>> +		return dev_err_probe(dev, rc,
>>>> +				     "uevent: failed to send synthetic uevent\n");
>>> I do not understand this at all, this is not on the probe path at all,
>>> so why is this function needed?
>>>
>>> Have you tested this?  What was the resulting output before and after
>>> this change?
>> Yes, after this change, the error code will be print.
> You did not answer my question.
>
> Again, this is not on the probe() callback path, so why are you wanting
> to call dev_err_probe()?
I was trying to simplify the code, I think I misuse the helper, you can 
ignore this patch.

Thanks,
Yang
>
> thanks,
>
> greg k-h
> .

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-22  6:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-19  9:46 [PATCH -next] driver core: switch to use dev_err_probe() Yang Yingliang
2022-08-19  9:42 ` Greg KH
2022-08-22  2:10   ` Yang Yingliang
2022-08-22  6:09     ` Greg KH
2022-08-22  6:35       ` Yang Yingliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).