Re: [RFC 8/9] ata_dev_printk: Add durable name to output

James Bottomley
2019-12-24T00:56:06Z

On Mon, 2019-12-23 at 16:55 -0600, Tony Asleson wrote:
> If we have a durable name we will add to output, else
> we will default to existing message output format.
>
> Signed-off-by: Tony Asleson <tasleson@redhat.com>
> ---
> drivers/ata/libata-core.c | 26 +++++++++++++++++++++++---
> 1 file changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
> index 28c492be0a57..b57a74cfb529 100644
> --- a/drivers/ata/libata-core.c
> +++ b/drivers/ata/libata-core.c
> @@ -7249,6 +7249,9 @@ EXPORT_SYMBOL(ata_link_printk);
> void ata_dev_printk(const struct ata_device *dev, const char *level,
> const char *fmt, ...)
> {
> + char dict[128];
> + int dict_len = 0;
> +
> struct va_format vaf;
> va_list args;
>
> @@ -7257,9 +7260,26 @@ void ata_dev_printk(const struct ata_device
> *dev, const char *level,
> vaf.fmt = fmt;
> vaf.va = &args;
>
> - printk("%sata%u.%02u: %pV",
> - level, dev->link->ap->print_id, dev->link->pmp + dev-
> >devno,
> - &vaf);
> + if (dev->sdev) {
> + dict_len = dev_durable_name(
> + &dev->sdev->sdev_gendev,
> + dict,
> + sizeof(dict));
> + }
> +
> + if (dict_len > 0) {
> + printk_emit(0, level[1] - '0', dict, dict_len,
> + "sata%u.%02u: %pV",
> + dev->link->ap->print_id,
> + dev->link->pmp + dev->devno,
> + &vaf);
> + } else {
> + printk("%sata%u.%02u: %pV",
> + level,
> + dev->link->ap->print_id,
> + dev->link->pmp + dev->devno,
> + &vaf);
> + }

As I said, I think ata_dev_printk should expand to dev_printk, which
would render all the above unnecessary, but just in case there's a
problem, printk_emit() with a dict_len == 0 is directly equivalent to
printk() so the whole if (dict_len > 0) is unnecessary.

James