Commit efe205a3 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Tejun Heo

libata: factor out a ata_log_supported helper

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent f01f62c2
...@@ -2111,6 +2111,15 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log, ...@@ -2111,6 +2111,15 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
return err_mask; return err_mask;
} }
static bool ata_log_supported(struct ata_device *dev, u8 log)
{
struct ata_port *ap = dev->link->ap;
if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, ap->sector_buf, 1))
return false;
return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false;
}
static int ata_do_link_spd_horkage(struct ata_device *dev) static int ata_do_link_spd_horkage(struct ata_device *dev)
{ {
struct ata_link *plink = ata_dev_phys_link(dev); struct ata_link *plink = ata_dev_phys_link(dev);
...@@ -2158,21 +2167,9 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev) ...@@ -2158,21 +2167,9 @@ static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
{ {
struct ata_port *ap = dev->link->ap; struct ata_port *ap = dev->link->ap;
unsigned int err_mask; unsigned int err_mask;
int log_index = ATA_LOG_NCQ_SEND_RECV * 2;
u16 log_pages;
err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY, if (!ata_log_supported(dev, ATA_LOG_NCQ_SEND_RECV)) {
0, ap->sector_buf, 1); ata_dev_warn(dev, "NCQ Send/Recv Log not supported\n");
if (err_mask) {
ata_dev_dbg(dev,
"failed to get Log Directory Emask 0x%x\n",
err_mask);
return;
}
log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
if (!log_pages) {
ata_dev_warn(dev,
"NCQ Send/Recv Log not supported\n");
return; return;
} }
err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV, err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
...@@ -2199,19 +2196,8 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev) ...@@ -2199,19 +2196,8 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev)
{ {
struct ata_port *ap = dev->link->ap; struct ata_port *ap = dev->link->ap;
unsigned int err_mask; unsigned int err_mask;
int log_index = ATA_LOG_NCQ_NON_DATA * 2;
u16 log_pages;
err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY, if (!ata_log_supported(dev, ATA_LOG_NCQ_NON_DATA)) {
0, ap->sector_buf, 1);
if (err_mask) {
ata_dev_dbg(dev,
"failed to get Log Directory Emask 0x%x\n",
err_mask);
return;
}
log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
if (!log_pages) {
ata_dev_warn(dev, ata_dev_warn(dev,
"NCQ Send/Recv Log not supported\n"); "NCQ Send/Recv Log not supported\n");
return; return;
...@@ -2339,7 +2325,7 @@ static void ata_dev_config_zac(struct ata_device *dev) ...@@ -2339,7 +2325,7 @@ static void ata_dev_config_zac(struct ata_device *dev)
struct ata_port *ap = dev->link->ap; struct ata_port *ap = dev->link->ap;
unsigned int err_mask; unsigned int err_mask;
u8 *identify_buf = ap->sector_buf; u8 *identify_buf = ap->sector_buf;
int log_index = ATA_LOG_SATA_ID_DEV_DATA * 2, i, found = 0; int i, found = 0;
u16 log_pages; u16 log_pages;
dev->zac_zones_optimal_open = U32_MAX; dev->zac_zones_optimal_open = U32_MAX;
...@@ -2360,24 +2346,11 @@ static void ata_dev_config_zac(struct ata_device *dev) ...@@ -2360,24 +2346,11 @@ static void ata_dev_config_zac(struct ata_device *dev)
if (!(dev->flags & ATA_DFLAG_ZAC)) if (!(dev->flags & ATA_DFLAG_ZAC))
return; return;
/* if (!ata_log_supported(dev, ATA_LOG_SATA_ID_DEV_DATA)) {
* Read Log Directory to figure out if IDENTIFY DEVICE log ata_dev_warn(dev, "ATA Identify Device Log not supported\n");
* is supported.
*/
err_mask = ata_read_log_page(dev, ATA_LOG_DIRECTORY,
0, ap->sector_buf, 1);
if (err_mask) {
ata_dev_info(dev,
"failed to get Log Directory Emask 0x%x\n",
err_mask);
return;
}
log_pages = get_unaligned_le16(&ap->sector_buf[log_index]);
if (log_pages == 0) {
ata_dev_warn(dev,
"ATA Identify Device Log not supported\n");
return; return;
} }
/* /*
* Read IDENTIFY DEVICE data log, page 0, to figure out * Read IDENTIFY DEVICE data log, page 0, to figure out
* if page 9 is supported. * if page 9 is supported.
......
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