Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Niklas Cassel and committed by
Damien Le Moal
873abd72 59b7bb3d

+36 -24
+36 -24
drivers/ata/libata-core.c
··· 474 474 } 475 475 } 476 476 477 + static const struct ata_force_ent * 478 + ata_force_get_fe_for_dev(struct ata_device *dev) 479 + { 480 + const struct ata_force_ent *fe; 481 + int devno = dev->link->pmp + dev->devno; 482 + int alt_devno = devno; 483 + int i; 484 + 485 + /* allow n.15/16 for devices attached to host port */ 486 + if (ata_is_host_link(dev->link)) 487 + alt_devno += 15; 488 + 489 + for (i = 0; i < ata_force_tbl_size; i++) { 490 + fe = &ata_force_tbl[i]; 491 + if (fe->port != -1 && fe->port != dev->link->ap->print_id) 492 + continue; 493 + 494 + if (fe->device != -1 && fe->device != devno && 495 + fe->device != alt_devno) 496 + continue; 497 + 498 + return fe; 499 + } 500 + 501 + return NULL; 502 + } 503 + 477 504 /** 478 505 * ata_force_quirks - force quirks according to libata.force 479 506 * @dev: ATA device of interest ··· 514 487 */ 515 488 static void ata_force_quirks(struct ata_device *dev) 516 489 { 517 - int devno = dev->link->pmp + dev->devno; 518 - int alt_devno = devno; 519 - int i; 490 + const struct ata_force_ent *fe = ata_force_get_fe_for_dev(dev); 520 491 521 - /* allow n.15/16 for devices attached to host port */ 522 - if (ata_is_host_link(dev->link)) 523 - alt_devno += 15; 492 + if (!fe) 493 + return; 524 494 525 - for (i = 0; i < ata_force_tbl_size; i++) { 526 - const struct ata_force_ent *fe = &ata_force_tbl[i]; 495 + if (!(~dev->quirks & fe->param.quirk_on) && 496 + !(dev->quirks & fe->param.quirk_off)) 497 + return; 527 498 528 - if (fe->port != -1 && fe->port != dev->link->ap->print_id) 529 - continue; 499 + dev->quirks |= fe->param.quirk_on; 500 + dev->quirks &= ~fe->param.quirk_off; 530 501 531 - if (fe->device != -1 && fe->device != devno && 532 - fe->device != alt_devno) 533 - continue; 534 - 535 - if (!(~dev->quirks & fe->param.quirk_on) && 536 - !(dev->quirks & fe->param.quirk_off)) 537 - continue; 538 - 539 - dev->quirks |= fe->param.quirk_on; 540 - dev->quirks &= ~fe->param.quirk_off; 541 - 542 - ata_dev_notice(dev, "FORCE: modified (%s)\n", 543 - fe->param.name); 544 - } 502 + ata_dev_notice(dev, "FORCE: modified (%s)\n", fe->param.name); 545 503 } 546 504 #else 547 505 static inline void ata_force_pflags(struct ata_port *ap) { }