Thread (10 messages) 10 messages, 6 authors, 2018-10-18

[PATCH 1/3] driver core: add probe_err log helper

From: Andy Shevchenko <hidden>
Date: 2018-10-16 13:55:14
Also in: lkml

Possibly related (same subject, not in this thread)

On Tue, Oct 16, 2018 at 3:55 PM Andrzej Hajda [off-list ref] wrote:
On 16.10.2018 13:29, Andrzej Hajda wrote:
quoted
On 16.10.2018 13:01, Andy Shevchenko wrote:
quoted
On Tue, Oct 16, 2018 at 10:22 AM Andrzej Hajda [off-list ref] wrote:
quoted
During probe every time driver gets resource it should usually check for error
printk some message if it is not -EPROBE_DEFER and return the error. This
pattern is simple but requires adding few lines after any resource acquisition
code, as a result it is often omited or implemented only partially.
probe_err helps to replace such code seqences with simple call, so code:
        if (err != -EPROBE_DEFER)
                dev_err(dev, ...);
        return err;
becomes:
        return probe_err(dev, err, ...);
quoted
quoted
quoted
+               va_start(args, fmt);
+
+               vaf.fmt = fmt;
+               vaf.va = &args;
+
+               __dev_printk(KERN_ERR, dev, &vaf);
quoted
quoted
It would be nice to print an error code as well, wouldn't it?
Hmm, on probe fail error is printed anyway (with exception of
EPROBE_DEFER, ENODEV and ENXIO):
    "probe of %s failed with error %d\n"
On the other side currently some drivers prints the error code anyway
via dev_err or similar, so I guess during conversion to probe_err it
should be removed then.

If we add error code to probe_err is it OK to report it this way?
    dev_err(dev, "%V, %d\n", &vaf, err);
Ups, I forgot that message passed to probe_err will contain already
newline character.
You may consider not to pass it.
So the err must be before message passed to probe_err, for example:
    dev_err(dev, "err=%d: %V\n", err, &vaf);
Is it OK?
For me would work either (no \n in the message, or err preceding the message).

-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help