Skip to content

Commit 5a23355

Browse files
hreineckehtejun
authored andcommitted
libata: Separate out ata_dev_config_ncq_send_recv()
Move NCQ SEND/RECEIVE checks into a separate function. Signed-off-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Tejun Heo <tj@kernel.org>
1 parent 661ce1f commit 5a23355

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

‎drivers/ata/libata-core.c‎

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,6 +2079,31 @@ static inline u8 ata_dev_knobble(struct ata_device *dev)
20792079
return ((ap->cbl == ATA_CBL_SATA) && (!ata_id_is_sata(dev->id)));
20802080
}
20812081

2082+
static void ata_dev_config_ncq_send_recv(struct ata_device *dev)
2083+
{
2084+
struct ata_port *ap = dev->link->ap;
2085+
unsigned int err_mask;
2086+
2087+
err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
2088+
0, ap->sector_buf, 1);
2089+
if (err_mask) {
2090+
ata_dev_dbg(dev,
2091+
"failed to get NCQ Send/Recv Log Emask 0x%x\n",
2092+
err_mask);
2093+
} else {
2094+
u8 *cmds = dev->ncq_send_recv_cmds;
2095+
2096+
dev->flags |= ATA_DFLAG_NCQ_SEND_RECV;
2097+
memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE);
2098+
2099+
if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) {
2100+
ata_dev_dbg(dev, "disabling queued TRIM support\n");
2101+
cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &=
2102+
~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM;
2103+
}
2104+
}
2105+
}
2106+
20822107
static int ata_dev_config_ncq(struct ata_device *dev,
20832108
char *desc, size_t desc_sz)
20842109
{
@@ -2124,26 +2149,8 @@ static int ata_dev_config_ncq(struct ata_device *dev,
21242149
ddepth, aa_desc);
21252150

21262151
if ((ap->flags & ATA_FLAG_FPDMA_AUX) &&
2127-
ata_id_has_ncq_send_and_recv(dev->id)) {
2128-
err_mask = ata_read_log_page(dev, ATA_LOG_NCQ_SEND_RECV,
2129-
0, ap->sector_buf, 1);
2130-
if (err_mask) {
2131-
ata_dev_dbg(dev,
2132-
"failed to get NCQ Send/Recv Log Emask 0x%x\n",
2133-
err_mask);
2134-
} else {
2135-
u8 *cmds = dev->ncq_send_recv_cmds;
2136-
2137-
dev->flags |= ATA_DFLAG_NCQ_SEND_RECV;
2138-
memcpy(cmds, ap->sector_buf, ATA_LOG_NCQ_SEND_RECV_SIZE);
2139-
2140-
if (dev->horkage & ATA_HORKAGE_NO_NCQ_TRIM) {
2141-
ata_dev_dbg(dev, "disabling queued TRIM support\n");
2142-
cmds[ATA_LOG_NCQ_SEND_RECV_DSM_OFFSET] &=
2143-
~ATA_LOG_NCQ_SEND_RECV_DSM_TRIM;
2144-
}
2145-
}
2146-
}
2152+
ata_id_has_ncq_send_and_recv(dev->id))
2153+
ata_dev_config_ncq_send_recv(dev);
21472154

21482155
return 0;
21492156
}

0 commit comments

Comments
 (0)