From: Hannes Reinecke <hare@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Tejun Heo <tj@kernel.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
linux-ide@vger.kernel.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 09/40] libata: Add ata_port_classify() helper
Date: Tue, 3 Mar 2020 10:37:42 +0100 [thread overview]
Message-ID: <20200303093813.18523-10-hare@suse.de> (raw)
In-Reply-To: <20200303093813.18523-1-hare@suse.de>
Add an ata_port_classify() helper to print out the results from
the device classification and remove the debugging statements
from ata_dev_classify(). Also provide a mapping ata_dev_class_string()
to provide a string representation for those instances calling
ata_dev_classify() directly.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
drivers/ata/libahci.c | 2 +-
drivers/ata/libata-core.c | 67 ++++++++++++++++++++++++++++++++++-----------
drivers/ata/libata-sff.c | 5 ++++
drivers/ata/sata_fsl.c | 2 +-
drivers/ata/sata_inic162x.c | 2 +-
drivers/ata/sata_sil24.c | 2 +-
include/linux/libata.h | 3 ++
7 files changed, 63 insertions(+), 20 deletions(-)
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 4055071f213f..c1bc973ecc16 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1276,7 +1276,7 @@ unsigned int ahci_dev_classify(struct ata_port *ap)
tf.lbal = (tmp >> 8) & 0xff;
tf.nsect = (tmp) & 0xff;
- return ata_dev_classify(&tf);
+ return ata_port_classify(ap, &tf);
}
EXPORT_SYMBOL_GPL(ahci_dev_classify);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index a9d47a746f77..17abc52ce41e 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -1025,6 +1025,27 @@ const char *sata_spd_string(unsigned int spd)
return spd_str[spd - 1];
}
+const char *ata_dev_class_string(unsigned int class)
+{
+ static const char * const class_str[] = {
+ "unknown",
+ "ATA",
+ "ATA (unsupported)",
+ "ATAPI",
+ "ATAPI (unsupported",
+ "PMP",
+ "PMP (unsupported)",
+ "SEMB",
+ "SEMB (unsupported)",
+ "ZAC",
+ "ZAC (unsupported)",
+ "none",
+ };
+ if (class == 0 || (class - 1) >= ARRAY_SIZE(class_str))
+ return "unknown";
+ return class_str[class - 1];
+}
+
/**
* ata_dev_classify - determine device type based on ATA-spec signature
* @tf: ATA taskfile register set for device to be identified
@@ -1063,35 +1084,48 @@ unsigned int ata_dev_classify(const struct ata_taskfile *tf)
* SEMB signature. This is worked around in
* ata_dev_read_id().
*/
- if ((tf->lbam == 0) && (tf->lbah == 0)) {
- DPRINTK("found ATA device by sig\n");
+ if ((tf->lbam == 0) && (tf->lbah == 0))
return ATA_DEV_ATA;
- }
- if ((tf->lbam == 0x14) && (tf->lbah == 0xeb)) {
- DPRINTK("found ATAPI device by sig\n");
+ if ((tf->lbam == 0x14) && (tf->lbah == 0xeb))
return ATA_DEV_ATAPI;
- }
- if ((tf->lbam == 0x69) && (tf->lbah == 0x96)) {
- DPRINTK("found PMP device by sig\n");
+ if ((tf->lbam == 0x69) && (tf->lbah == 0x96))
return ATA_DEV_PMP;
- }
- if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3)) {
- DPRINTK("found SEMB device by sig (could be ATA device)\n");
+ if ((tf->lbam == 0x3c) && (tf->lbah == 0xc3))
return ATA_DEV_SEMB;
- }
- if ((tf->lbam == 0xcd) && (tf->lbah == 0xab)) {
- DPRINTK("found ZAC device by sig\n");
+ if ((tf->lbam == 0xcd) && (tf->lbah == 0xab))
return ATA_DEV_ZAC;
- }
- DPRINTK("unknown device\n");
return ATA_DEV_UNKNOWN;
}
+/**
+ * ata_port_classify - determine device type based on ATA-spec signature
+ * @ap: ATA port device on which the classification should be run
+ * @tf: ATA taskfile register set for device to be identified
+ *
+ * A wrapper around ata_dev_classify() to provide additional logging
+ *
+ * RETURNS:
+ * Device type, %ATA_DEV_ATA, %ATA_DEV_ATAPI, %ATA_DEV_PMP,
+ * %ATA_DEV_ZAC, or %ATA_DEV_UNKNOWN the event of failure.
+ */
+unsigned int ata_port_classify(struct ata_port *ap,
+ const struct ata_taskfile *tf)
+{
+ unsigned int class = ata_dev_classify(tf);
+
+ if (class != ATA_DEV_UNKNOWN)
+ ata_port_dbg(ap, "found %s device by sig\n",
+ ata_dev_class_string(class));
+ else
+ ata_port_dbg(ap, "found unknown device\n");
+ return class;
+}
+
/**
* ata_id_string - Convert IDENTIFY DEVICE page into string
* @id: IDENTIFY DEVICE results we will examine
@@ -7302,6 +7336,7 @@ EXPORT_SYMBOL_GPL(sata_link_hardreset);
EXPORT_SYMBOL_GPL(sata_std_hardreset);
EXPORT_SYMBOL_GPL(ata_std_postreset);
EXPORT_SYMBOL_GPL(ata_dev_classify);
+EXPORT_SYMBOL_GPL(ata_port_classify);
EXPORT_SYMBOL_GPL(ata_dev_pair);
EXPORT_SYMBOL_GPL(ata_ratelimit);
EXPORT_SYMBOL_GPL(ata_msleep);
diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index 9fbe67f73197..939cda91c56d 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -1839,6 +1839,11 @@ unsigned int ata_sff_dev_classify(struct ata_device *dev, int present,
/* determine if device is ATA or ATAPI */
class = ata_dev_classify(&tf);
+ if (class != ATA_DEV_UNKNOWN)
+ ata_dev_dbg(dev, "found %s device by sig\n",
+ ata_dev_class_string(class));
+ else
+ ata_dev_dbg(dev, "found unknown device\n");
if (class == ATA_DEV_UNKNOWN) {
/* If the device failed diagnostic, it's likely to
diff --git a/drivers/ata/sata_fsl.c b/drivers/ata/sata_fsl.c
index d55ee244d693..0864c4fafa39 100644
--- a/drivers/ata/sata_fsl.c
+++ b/drivers/ata/sata_fsl.c
@@ -812,7 +812,7 @@ static unsigned int sata_fsl_dev_classify(struct ata_port *ap)
tf.lbal = (temp >> 8) & 0xff;
tf.nsect = temp & 0xff;
- return ata_dev_classify(&tf);
+ return ata_port_classify(ap, &tf);
}
static int sata_fsl_hardreset(struct ata_link *link, unsigned int *class,
diff --git a/drivers/ata/sata_inic162x.c b/drivers/ata/sata_inic162x.c
index a6b76cc12a66..12f189f2ab1e 100644
--- a/drivers/ata/sata_inic162x.c
+++ b/drivers/ata/sata_inic162x.c
@@ -657,7 +657,7 @@ static int inic_hardreset(struct ata_link *link, unsigned int *class,
}
inic_tf_read(ap, &tf);
- *class = ata_dev_classify(&tf);
+ *class = ata_port_classify(ap, &tf);
}
return 0;
diff --git a/drivers/ata/sata_sil24.c b/drivers/ata/sata_sil24.c
index 560070d4f1d0..2373cf5d8d14 100644
--- a/drivers/ata/sata_sil24.c
+++ b/drivers/ata/sata_sil24.c
@@ -677,7 +677,7 @@ static int sil24_softreset(struct ata_link *link, unsigned int *class,
}
sil24_read_tf(ap, 0, &tf);
- *class = ata_dev_classify(&tf);
+ *class = ata_port_classify(ap, &tf);
DPRINTK("EXIT, class=%u\n", *class);
return 0;
diff --git a/include/linux/libata.h b/include/linux/libata.h
index 508f501095c9..0b784c298f97 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -1173,7 +1173,10 @@ extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
extern enum ata_completion_errors ata_noop_qc_prep(struct ata_queued_cmd *qc);
extern void ata_sg_init(struct ata_queued_cmd *qc, struct scatterlist *sg,
unsigned int n_elem);
+extern const char *ata_dev_class_string(unsigned int class);
extern unsigned int ata_dev_classify(const struct ata_taskfile *tf);
+extern unsigned int ata_port_classify(struct ata_port *ap,
+ const struct ata_taskfile *tf);
extern void ata_dev_disable(struct ata_device *adev);
extern void ata_id_string(const u16 *id, unsigned char *s,
unsigned int ofs, unsigned int len);
--
2.16.4
next prev parent reply other threads:[~2020-03-03 9:39 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-03 9:37 [PATCHv3 00/40] ata: kill ATA_DEBUG Hannes Reinecke
2020-03-03 9:37 ` [PATCH 01/40] libata: drop BPRINTK() Hannes Reinecke
2020-03-03 9:37 ` [PATCH 02/40] libata.h: whitespace and indentation fixes Hannes Reinecke
2020-03-03 9:37 ` [PATCH 03/40] libata-transport: Whitespace cleanup Hannes Reinecke
2020-03-03 9:37 ` [PATCH 04/40] libata: move ata_{port,link,dev}_dbg to standard dev_XXX() macros Hannes Reinecke
2020-03-24 13:26 ` Geert Uytterhoeven
2020-03-25 14:56 ` Bartlomiej Zolnierkiewicz
2020-03-25 15:34 ` Geert Uytterhoeven
2020-03-25 15:45 ` Bartlomiej Zolnierkiewicz
2020-03-25 16:54 ` Hannes Reinecke
2020-03-03 9:37 ` [PATCH 05/40] libata: move __func__ into ata_{port,link,dev}_dbg() helper Hannes Reinecke
2020-03-03 9:37 ` [PATCH 06/40] libata: remove pointless debugging messages Hannes Reinecke
2020-03-03 9:37 ` [PATCH 07/40] ata_piix: remove " Hannes Reinecke
2020-03-03 9:37 ` [PATCH 08/40] libata-core: remove pointless " Hannes Reinecke
2020-03-03 9:37 ` Hannes Reinecke [this message]
2020-03-03 9:37 ` [PATCH 10/40] libata: move ata_dump_id() to dynamic debugging Hannes Reinecke
2020-03-03 9:37 ` [PATCH 11/40] libata: sanitize ATA_HORKAGE_DUMP_ID Hannes Reinecke
2020-03-03 9:37 ` [PATCH 12/40] sata_mv: replace DPRINTK with 'pci_dump' module parameter Hannes Reinecke
2020-03-03 9:37 ` [PATCH 13/40] sata_mv: kill 'port' argument in mv_dump_all_regs() Hannes Reinecke
2020-03-03 9:37 ` [PATCH 14/40] sata_sx4: move DPRINTK to VPRINTK Hannes Reinecke
2020-03-03 9:37 ` [PATCH 15/40] libata: add reset tracepoints Hannes Reinecke
2020-03-03 9:37 ` [PATCH 16/40] libata: drop DPRINTK() calls in reset Hannes Reinecke
2020-03-03 9:37 ` [PATCH 17/40] libata: tracepoints for bus-master DMA Hannes Reinecke
2020-03-03 9:37 ` [PATCH 18/40] libata: drop debugging statements " Hannes Reinecke
2020-03-03 9:37 ` [PATCH 19/40] pata_octeon_cf: add bmdma tracepoints and drop DPRINTK() calls Hannes Reinecke
2020-03-03 9:37 ` [PATCH 20/40] pata_arasan_cf: use generic tracepoints Hannes Reinecke
2020-03-03 9:37 ` [PATCH 21/40] sata_dwc_460ex: " Hannes Reinecke
2020-03-03 9:37 ` [PATCH 22/40] sata_nv: " Hannes Reinecke
2020-03-03 9:37 ` [PATCH 23/40] libata-sff: tracepoints for HSM state machine Hannes Reinecke
2020-03-03 9:37 ` [PATCH 24/40] libata-sff: add tracepoints for ata_sff_flush_pio_task() Hannes Reinecke
2020-03-03 9:37 ` [PATCH 25/40] libata-scsi: drop DPRINTK calls for cdb translation Hannes Reinecke
2020-03-03 9:37 ` [PATCH 26/40] libata: add tracepoints for ATA error handling Hannes Reinecke
2020-03-03 9:38 ` [PATCH 27/40] libata: drop DPRINTK() calls during " Hannes Reinecke
2020-03-03 9:38 ` [PATCH 28/40] libata-eh: remove DPRINTK() calls for request sense Hannes Reinecke
2020-03-03 9:38 ` [PATCH 29/40] pata_octeon_cf: move DPRINTK to VPRINTK Hannes Reinecke
2020-03-03 9:38 ` [PATCH 30/40] pdc_adma: " Hannes Reinecke
2020-03-03 9:38 ` [PATCH 31/40] sata_rcar: " Hannes Reinecke
2020-03-03 9:38 ` [PATCH 32/40] sata_qstor: " Hannes Reinecke
2020-03-03 9:38 ` [PATCH 33/40] pata_pdc2027x: Replace PDPRINTK() with standard ata logging Hannes Reinecke
2020-03-03 9:38 ` [PATCH 34/40] sata_nv: move DPRINTK to ata debugging Hannes Reinecke
2020-03-03 9:38 ` [PATCH 35/40] sata_fsl: " Hannes Reinecke
2020-03-13 14:43 ` Guenter Roeck
2020-03-03 9:38 ` [PATCH 36/40] libata-core: " Hannes Reinecke
2020-03-03 9:38 ` [PATCH 37/40] libata: remove DPRINTK() macro Hannes Reinecke
2020-03-03 9:38 ` [PATCH 38/40] libata: kill ATA_MSG_INFO Hannes Reinecke
2020-03-03 9:38 ` [PATCH 39/40] libata: kill ATA_MSG_CTL Hannes Reinecke
2020-03-03 9:38 ` [PATCH 40/40] libata: remove references to ATA_DEBUG Hannes Reinecke
2020-03-12 14:04 ` [PATCHv3 00/40] ata: kill ATA_DEBUG Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200303093813.18523-10-hare@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=b.zolnierkie@samsung.com \
--cc=linux-ide@vger.kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).