Skip to content

Commit bf1807c

Browse files
committed
ata: libata: Print device quirks only once
In ata_dev_print_quirks(), return early if ata_dev_print_info() returns false or if we already printed quirk information. This is to avoid printing a device quirks multiple times (that is, each time ata_dev_revalidate() is called). To remember if ata_dev_print_quirks() was already executed, define the EH context flag ATA_EHI_DID_PRINT_QUIRKS and set this flag in ata_dev_print_quirks(). Reported-by: Geert Uytterhoeven <[email protected]> Fixes: 58157d6 ("ata: libata: Print quirks applied to devices") Signed-off-by: Damien Le Moal <[email protected]> Tested-by: Geert Uytterhoeven <[email protected]>
1 parent b408245 commit bf1807c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/ata/libata-core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ MODULE_DESCRIPTION("Library module for ATA devices");
160160
MODULE_LICENSE("GPL");
161161
MODULE_VERSION(DRV_VERSION);
162162

163-
static inline bool ata_dev_print_info(struct ata_device *dev)
163+
static inline bool ata_dev_print_info(const struct ata_device *dev)
164164
{
165165
struct ata_eh_context *ehc = &dev->link->eh_context;
166166

@@ -4025,10 +4025,16 @@ static void ata_dev_print_quirks(const struct ata_device *dev,
40254025
const char *model, const char *rev,
40264026
unsigned int quirks)
40274027
{
4028+
struct ata_eh_context *ehc = &dev->link->eh_context;
40284029
int n = 0, i;
40294030
size_t sz;
40304031
char *str;
40314032

4033+
if (!ata_dev_print_info(dev) || ehc->i.flags & ATA_EHI_DID_PRINT_QUIRKS)
4034+
return;
4035+
4036+
ehc->i.flags |= ATA_EHI_DID_PRINT_QUIRKS;
4037+
40324038
if (!quirks)
40334039
return;
40344040

include/linux/libata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ enum {
378378
ATA_EHI_PRINTINFO = (1 << 18), /* print configuration info */
379379
ATA_EHI_SETMODE = (1 << 19), /* configure transfer mode */
380380
ATA_EHI_POST_SETMODE = (1 << 20), /* revalidating after setmode */
381+
ATA_EHI_DID_PRINT_QUIRKS = (1 << 21), /* already printed quirks info */
381382

382383
ATA_EHI_DID_RESET = ATA_EHI_DID_SOFTRESET | ATA_EHI_DID_HARDRESET,
383384

0 commit comments

Comments
 (0)