Skip to content

Commit 62eef53

Browse files
floatiousdamien-lemoal
authored andcommitted
ata: libata-eh: Add ata_eh_set_lpm() WARN_ON_ONCE
link->lpm_policy is initialized to ATA_LPM_UNKNOWN in ata_eh_reset(). ata_eh_set_lpm() is then only called if link->lpm_policy != ap->target_lpm_policy (after reset) and then only if link->lpm_policy > ATA_LPM_MAX_POWER (before revalidation). This means that ata_eh_set_lpm() is currently never called with policy == ATA_LPM_UNKNOWN. Add a WARN_ON_ONCE so that it is more obvious from reading the code that this function is never called with policy == ATA_LPM_UNKNOWN. Signed-off-by: Niklas Cassel <cassel@kernel.org> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent 381d43b commit 62eef53

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/ata/libata-eh.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3442,6 +3442,13 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
34423442
(link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
34433443
return 0;
34443444

3445+
/*
3446+
* This function currently assumes that it will never be supplied policy
3447+
* ATA_LPM_UNKNOWN.
3448+
*/
3449+
if (WARN_ON_ONCE(policy == ATA_LPM_UNKNOWN))
3450+
return 0;
3451+
34453452
/*
34463453
* DIPM is enabled only for ATA_LPM_MIN_POWER,
34473454
* ATA_LPM_MIN_POWER_WITH_PARTIAL, and ATA_LPM_MED_POWER_WITH_DIPM, as

0 commit comments

Comments
 (0)