Commit 742bef47 authored by Hannes Reinecke's avatar Hannes Reinecke Committed by Damien Le Moal

ata: libata: move ata_{port,link,dev}_dbg to standard pr_XXX() macros

Use standard pr_{debug,info,notice,warn,err} macros instead of the
hand-crafted printk helpers.
Signed-off-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
parent c318458c
...@@ -650,9 +650,7 @@ static int ata_acpi_run_tf(struct ata_device *dev, ...@@ -650,9 +650,7 @@ static int ata_acpi_run_tf(struct ata_device *dev,
struct ata_taskfile *pptf = NULL; struct ata_taskfile *pptf = NULL;
struct ata_taskfile tf, ptf, rtf; struct ata_taskfile tf, ptf, rtf;
unsigned int err_mask; unsigned int err_mask;
const char *level;
const char *descr; const char *descr;
char msg[60];
int rc; int rc;
if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0) if ((gtf->tf[0] == 0) && (gtf->tf[1] == 0) && (gtf->tf[2] == 0)
...@@ -666,6 +664,10 @@ static int ata_acpi_run_tf(struct ata_device *dev, ...@@ -666,6 +664,10 @@ static int ata_acpi_run_tf(struct ata_device *dev,
pptf = &ptf; pptf = &ptf;
} }
descr = ata_get_cmd_descript(tf.command);
if (!descr)
descr = "unknown";
if (!ata_acpi_filter_tf(dev, &tf, pptf)) { if (!ata_acpi_filter_tf(dev, &tf, pptf)) {
rtf = tf; rtf = tf;
err_mask = ata_exec_internal(dev, &rtf, NULL, err_mask = ata_exec_internal(dev, &rtf, NULL,
...@@ -673,40 +675,42 @@ static int ata_acpi_run_tf(struct ata_device *dev, ...@@ -673,40 +675,42 @@ static int ata_acpi_run_tf(struct ata_device *dev,
switch (err_mask) { switch (err_mask) {
case 0: case 0:
level = KERN_DEBUG; ata_dev_dbg(dev,
snprintf(msg, sizeof(msg), "succeeded"); "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x"
"(%s) succeeded\n",
tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device, descr);
rc = 1; rc = 1;
break; break;
case AC_ERR_DEV: case AC_ERR_DEV:
level = KERN_INFO; ata_dev_info(dev,
snprintf(msg, sizeof(msg), "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x"
"rejected by device (Stat=0x%02x Err=0x%02x)", "(%s) rejected by device (Stat=0x%02x Err=0x%02x)",
rtf.command, rtf.feature); tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device, descr,
rtf.command, rtf.feature);
rc = 0; rc = 0;
break; break;
default: default:
level = KERN_ERR; ata_dev_err(dev,
snprintf(msg, sizeof(msg), "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x"
"failed (Emask=0x%x Stat=0x%02x Err=0x%02x)", "(%s) failed (Emask=0x%x Stat=0x%02x Err=0x%02x)",
err_mask, rtf.command, rtf.feature); tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device, descr,
err_mask, rtf.command, rtf.feature);
rc = -EIO; rc = -EIO;
break; break;
} }
} else { } else {
level = KERN_INFO; ata_dev_info(dev,
snprintf(msg, sizeof(msg), "filtered out"); "ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x"
"(%s) filtered out\n",
tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device, descr);
rc = 0; rc = 0;
} }
descr = ata_get_cmd_descript(tf.command);
ata_dev_printk(dev, level,
"ACPI cmd %02x/%02x:%02x:%02x:%02x:%02x:%02x (%s) %s\n",
tf.command, tf.feature, tf.nsect, tf.lbal,
tf.lbam, tf.lbah, tf.device,
(descr ? descr : "unknown"), msg);
return rc; return rc;
} }
......
...@@ -6510,67 +6510,6 @@ const struct ata_port_info ata_dummy_port_info = { ...@@ -6510,67 +6510,6 @@ const struct ata_port_info ata_dummy_port_info = {
}; };
EXPORT_SYMBOL_GPL(ata_dummy_port_info); EXPORT_SYMBOL_GPL(ata_dummy_port_info);
/*
* Utility print functions
*/
void ata_port_printk(const struct ata_port *ap, const char *level,
const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk("%sata%u: %pV", level, ap->print_id, &vaf);
va_end(args);
}
EXPORT_SYMBOL(ata_port_printk);
void ata_link_printk(const struct ata_link *link, const char *level,
const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
if (sata_pmp_attached(link->ap) || link->ap->slave_link)
printk("%sata%u.%02u: %pV",
level, link->ap->print_id, link->pmp, &vaf);
else
printk("%sata%u: %pV",
level, link->ap->print_id, &vaf);
va_end(args);
}
EXPORT_SYMBOL(ata_link_printk);
void ata_dev_printk(const struct ata_device *dev, const char *level,
const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk("%sata%u.%02u: %pV",
level, dev->link->ap->print_id, dev->link->pmp + dev->devno,
&vaf);
va_end(args);
}
EXPORT_SYMBOL(ata_dev_printk);
void ata_print_version(const struct device *dev, const char *version) void ata_print_version(const struct device *dev, const char *version)
{ {
dev_printk(KERN_DEBUG, dev, "version %s\n", version); dev_printk(KERN_DEBUG, dev, "version %s\n", version);
......
...@@ -114,7 +114,7 @@ static void ixp4xx_set_piomode(struct ata_port *ap, struct ata_device *adev) ...@@ -114,7 +114,7 @@ static void ixp4xx_set_piomode(struct ata_port *ap, struct ata_device *adev)
{ {
struct ixp4xx_pata *ixpp = ap->host->private_data; struct ixp4xx_pata *ixpp = ap->host->private_data;
ata_dev_printk(adev, KERN_INFO, "configured for PIO%d 8bit\n", ata_dev_info(adev, "configured for PIO%d 8bit\n",
adev->pio_mode - XFER_PIO_0); adev->pio_mode - XFER_PIO_0);
ixp4xx_set_8bit_timing(ixpp, adev->pio_mode); ixp4xx_set_8bit_timing(ixpp, adev->pio_mode);
} }
...@@ -132,8 +132,8 @@ static unsigned int ixp4xx_mmio_data_xfer(struct ata_queued_cmd *qc, ...@@ -132,8 +132,8 @@ static unsigned int ixp4xx_mmio_data_xfer(struct ata_queued_cmd *qc,
struct ixp4xx_pata *ixpp = ap->host->private_data; struct ixp4xx_pata *ixpp = ap->host->private_data;
unsigned long flags; unsigned long flags;
ata_dev_printk(adev, KERN_DEBUG, "%s %d bytes\n", (rw == READ) ? "READ" : "WRITE", ata_dev_dbg(adev, "%s %d bytes\n", (rw == READ) ? "READ" : "WRITE",
buflen); buflen);
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
/* set the expansion bus in 16bit mode and restore /* set the expansion bus in 16bit mode and restore
......
...@@ -1489,51 +1489,61 @@ static inline int sata_srst_pmp(struct ata_link *link) ...@@ -1489,51 +1489,61 @@ static inline int sata_srst_pmp(struct ata_link *link)
return link->pmp; return link->pmp;
} }
/* #define ata_port_printk(level, ap, fmt, ...) \
* printk helpers pr_ ## level ("ata%u: " fmt, (ap)->print_id, ##__VA_ARGS__)
*/
__printf(3, 4)
void ata_port_printk(const struct ata_port *ap, const char *level,
const char *fmt, ...);
__printf(3, 4)
void ata_link_printk(const struct ata_link *link, const char *level,
const char *fmt, ...);
__printf(3, 4)
void ata_dev_printk(const struct ata_device *dev, const char *level,
const char *fmt, ...);
#define ata_port_err(ap, fmt, ...) \ #define ata_port_err(ap, fmt, ...) \
ata_port_printk(ap, KERN_ERR, fmt, ##__VA_ARGS__) ata_port_printk(err, ap, fmt, ##__VA_ARGS__)
#define ata_port_warn(ap, fmt, ...) \ #define ata_port_warn(ap, fmt, ...) \
ata_port_printk(ap, KERN_WARNING, fmt, ##__VA_ARGS__) ata_port_printk(warn, ap, fmt, ##__VA_ARGS__)
#define ata_port_notice(ap, fmt, ...) \ #define ata_port_notice(ap, fmt, ...) \
ata_port_printk(ap, KERN_NOTICE, fmt, ##__VA_ARGS__) ata_port_printk(notice, ap, fmt, ##__VA_ARGS__)
#define ata_port_info(ap, fmt, ...) \ #define ata_port_info(ap, fmt, ...) \
ata_port_printk(ap, KERN_INFO, fmt, ##__VA_ARGS__) ata_port_printk(info, ap, fmt, ##__VA_ARGS__)
#define ata_port_dbg(ap, fmt, ...) \ #define ata_port_dbg(ap, fmt, ...) \
ata_port_printk(ap, KERN_DEBUG, fmt, ##__VA_ARGS__) ata_port_printk(debug, ap, fmt, ##__VA_ARGS__)
#define ata_link_printk(level, link, fmt, ...) \
do { \
if (sata_pmp_attached((link)->ap) || \
(link)->ap->slave_link) \
pr_ ## level ("ata%u.%02u: " fmt, \
(link)->ap->print_id, \
(link)->pmp, \
##__VA_ARGS__); \
else \
pr_ ## level ("ata%u: " fmt, \
(link)->ap->print_id, \
##__VA_ARGS__); \
} while (0)
#define ata_link_err(link, fmt, ...) \ #define ata_link_err(link, fmt, ...) \
ata_link_printk(link, KERN_ERR, fmt, ##__VA_ARGS__) ata_link_printk(err, link, fmt, ##__VA_ARGS__)
#define ata_link_warn(link, fmt, ...) \ #define ata_link_warn(link, fmt, ...) \
ata_link_printk(link, KERN_WARNING, fmt, ##__VA_ARGS__) ata_link_printk(warn, link, fmt, ##__VA_ARGS__)
#define ata_link_notice(link, fmt, ...) \ #define ata_link_notice(link, fmt, ...) \
ata_link_printk(link, KERN_NOTICE, fmt, ##__VA_ARGS__) ata_link_printk(notice, link, fmt, ##__VA_ARGS__)
#define ata_link_info(link, fmt, ...) \ #define ata_link_info(link, fmt, ...) \
ata_link_printk(link, KERN_INFO, fmt, ##__VA_ARGS__) ata_link_printk(info, link, fmt, ##__VA_ARGS__)
#define ata_link_dbg(link, fmt, ...) \ #define ata_link_dbg(link, fmt, ...) \
ata_link_printk(link, KERN_DEBUG, fmt, ##__VA_ARGS__) ata_link_printk(debug, link, fmt, ##__VA_ARGS__)
#define ata_dev_printk(level, dev, fmt, ...) \
pr_ ## level("ata%u.%02u: " fmt, \
(dev)->link->ap->print_id, \
(dev)->link->pmp + (dev)->devno, \
##__VA_ARGS__)
#define ata_dev_err(dev, fmt, ...) \ #define ata_dev_err(dev, fmt, ...) \
ata_dev_printk(dev, KERN_ERR, fmt, ##__VA_ARGS__) ata_dev_printk(err, dev, fmt, ##__VA_ARGS__)
#define ata_dev_warn(dev, fmt, ...) \ #define ata_dev_warn(dev, fmt, ...) \
ata_dev_printk(dev, KERN_WARNING, fmt, ##__VA_ARGS__) ata_dev_printk(warn, dev, fmt, ##__VA_ARGS__)
#define ata_dev_notice(dev, fmt, ...) \ #define ata_dev_notice(dev, fmt, ...) \
ata_dev_printk(dev, KERN_NOTICE, fmt, ##__VA_ARGS__) ata_dev_printk(notice, dev, fmt, ##__VA_ARGS__)
#define ata_dev_info(dev, fmt, ...) \ #define ata_dev_info(dev, fmt, ...) \
ata_dev_printk(dev, KERN_INFO, fmt, ##__VA_ARGS__) ata_dev_printk(info, dev, fmt, ##__VA_ARGS__)
#define ata_dev_dbg(dev, fmt, ...) \ #define ata_dev_dbg(dev, fmt, ...) \
ata_dev_printk(dev, KERN_DEBUG, fmt, ##__VA_ARGS__) ata_dev_printk(debug, dev, fmt, ##__VA_ARGS__)
void ata_print_version(const struct device *dev, const char *version); void ata_print_version(const struct device *dev, const char *version);
...@@ -2067,11 +2077,8 @@ static inline u8 ata_wait_idle(struct ata_port *ap) ...@@ -2067,11 +2077,8 @@ static inline u8 ata_wait_idle(struct ata_port *ap)
{ {
u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); u8 status = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000);
#ifdef ATA_DEBUG
if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ))) if (status != 0xff && (status & (ATA_BUSY | ATA_DRQ)))
ata_port_printk(ap, KERN_DEBUG, "abnormal Status 0x%X\n", ata_port_dbg(ap, "abnormal Status 0x%X\n", status);
status);
#endif
return status; return status;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment