Skip to content

Commit 873abd7

Browse files
floatiousdamien-lemoal
authored andcommitted
ata: libata: Add ata_force_get_fe_for_dev() helper
Add ata_force_get_fe_for_dev() helper to get the struct ata_force_ent for a struct ata_device. Use the helper in ata_force_quirks(). The helper will also be used in follow up commits. No functional change intended. Signed-off-by: Niklas Cassel <cassel@kernel.org> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
1 parent 59b7bb3 commit 873abd7

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

drivers/ata/libata-core.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -474,19 +474,10 @@ static void ata_force_xfermask(struct ata_device *dev)
474474
}
475475
}
476476

477-
/**
478-
* ata_force_quirks - force quirks according to libata.force
479-
* @dev: ATA device of interest
480-
*
481-
* Force quirks according to libata.force and whine about it.
482-
* For consistency with link selection, device number 15 selects
483-
* the first device connected to the host link.
484-
*
485-
* LOCKING:
486-
* EH context.
487-
*/
488-
static void ata_force_quirks(struct ata_device *dev)
477+
static const struct ata_force_ent *
478+
ata_force_get_fe_for_dev(struct ata_device *dev)
489479
{
480+
const struct ata_force_ent *fe;
490481
int devno = dev->link->pmp + dev->devno;
491482
int alt_devno = devno;
492483
int i;
@@ -496,25 +487,46 @@ static void ata_force_quirks(struct ata_device *dev)
496487
alt_devno += 15;
497488

498489
for (i = 0; i < ata_force_tbl_size; i++) {
499-
const struct ata_force_ent *fe = &ata_force_tbl[i];
500-
490+
fe = &ata_force_tbl[i];
501491
if (fe->port != -1 && fe->port != dev->link->ap->print_id)
502492
continue;
503493

504494
if (fe->device != -1 && fe->device != devno &&
505495
fe->device != alt_devno)
506496
continue;
507497

508-
if (!(~dev->quirks & fe->param.quirk_on) &&
509-
!(dev->quirks & fe->param.quirk_off))
510-
continue;
498+
return fe;
499+
}
511500

512-
dev->quirks |= fe->param.quirk_on;
513-
dev->quirks &= ~fe->param.quirk_off;
501+
return NULL;
502+
}
514503

515-
ata_dev_notice(dev, "FORCE: modified (%s)\n",
516-
fe->param.name);
517-
}
504+
/**
505+
* ata_force_quirks - force quirks according to libata.force
506+
* @dev: ATA device of interest
507+
*
508+
* Force quirks according to libata.force and whine about it.
509+
* For consistency with link selection, device number 15 selects
510+
* the first device connected to the host link.
511+
*
512+
* LOCKING:
513+
* EH context.
514+
*/
515+
static void ata_force_quirks(struct ata_device *dev)
516+
{
517+
const struct ata_force_ent *fe = ata_force_get_fe_for_dev(dev);
518+
519+
if (!fe)
520+
return;
521+
522+
if (!(~dev->quirks & fe->param.quirk_on) &&
523+
!(dev->quirks & fe->param.quirk_off))
524+
return;
525+
526+
dev->quirks |= fe->param.quirk_on;
527+
dev->quirks &= ~fe->param.quirk_off;
528+
529+
ata_dev_notice(dev, "FORCE: modified (%s)\n", fe->param.name);
518530
}
519531
#else
520532
static inline void ata_force_pflags(struct ata_port *ap) { }

0 commit comments

Comments
 (0)