* move ata_do_link_spd_horkage() to libata-core-sata.c * add static inline for CONFIG_SATA_HOST=n case Code size savings on m68k arch using atari_defconfig: text data bss dec hex filename before: 36762 572 40 37374 91fe drivers/ata/libata-core.o after: 36627 572 40 37239 9177 drivers/ata/libata-core.o Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@xxxxxxxxxxx> --- drivers/ata/libata-core-sata.c | 33 +++++++++++++++++++++++++++++++++ drivers/ata/libata-core.c | 33 --------------------------------- drivers/ata/libata.h | 7 +++++++ 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/drivers/ata/libata-core-sata.c b/drivers/ata/libata-core-sata.c index 8b939d2db0a6..fed8009981c0 100644 --- a/drivers/ata/libata-core-sata.c +++ b/drivers/ata/libata-core-sata.c @@ -87,6 +87,39 @@ void ata_tf_from_fis(const u8 *fis, struct ata_taskfile *tf) } EXPORT_SYMBOL_GPL(ata_tf_from_fis); +int ata_do_link_spd_horkage(struct ata_device *dev) +{ + struct ata_link *plink = ata_dev_phys_link(dev); + u32 target, target_limit; + + if (!sata_scr_valid(plink)) + return 0; + + if (dev->horkage & ATA_HORKAGE_1_5_GBPS) + target = 1; + else + return 0; + + target_limit = (1 << target) - 1; + + /* if already on stricter limit, no need to push further */ + if (plink->sata_spd_limit <= target_limit) + return 0; + + plink->sata_spd_limit = target_limit; + + /* Request another EH round by returning -EAGAIN if link is + * going faster than the target speed. Forward progress is + * guaranteed by setting sata_spd_limit to target_limit above. + */ + if (plink->sata_spd > target) { + ata_dev_info(dev, "applying link speed limit horkage to %s\n", + sata_spd_string(target)); + return -EAGAIN; + } + return 0; +} + /** * sata_link_scr_lpm - manipulate SControl IPM and SPM fields * @link: ATA link to manipulate SControl for diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 24b8ee668e6f..52bd81bad484 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2074,39 +2074,6 @@ static bool ata_identify_page_supported(struct ata_device *dev, u8 page) return false; } -static int ata_do_link_spd_horkage(struct ata_device *dev) -{ - struct ata_link *plink = ata_dev_phys_link(dev); - u32 target, target_limit; - - if (!sata_scr_valid(plink)) - return 0; - - if (dev->horkage & ATA_HORKAGE_1_5_GBPS) - target = 1; - else - return 0; - - target_limit = (1 << target) - 1; - - /* if already on stricter limit, no need to push further */ - if (plink->sata_spd_limit <= target_limit) - return 0; - - plink->sata_spd_limit = target_limit; - - /* Request another EH round by returning -EAGAIN if link is - * going faster than the target speed. Forward progress is - * guaranteed by setting sata_spd_limit to target_limit above. - */ - if (plink->sata_spd > target) { - ata_dev_info(dev, "applying link speed limit horkage to %s\n", - sata_spd_string(target)); - return -EAGAIN; - } - return 0; -} - static inline u8 ata_dev_knobble(struct ata_device *dev) { struct ata_port *ap = dev->link->ap; diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index cd8090ad43e5..9eebe4e0be39 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -87,6 +87,13 @@ extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, #define to_ata_port(d) container_of(d, struct ata_port, tdev) +/* libata-core-sata.c */ +#ifdef CONFIG_SATA_HOST +int ata_do_link_spd_horkage(struct ata_device *dev); +#else +static inline int ata_do_link_spd_horkage(struct ata_device *dev) { return 0; } +#endif + /* libata-acpi.c */ #ifdef CONFIG_ATA_ACPI extern unsigned int ata_acpi_gtf_filter; -- 2.24.1