[v4,15/27] ata: let compiler optimize out ata_eh_set_lpm() on non-SATA hosts
diff mbox series

Message ID 20200317144333.2904-16-b.zolnierkie@samsung.com
State Not Applicable
Delegated to: David Miller
Headers show
Series
  • [v4,01/27] ata: remove stale maintainership information from core code
Related show

Commit Message

Bartlomiej Zolnierkiewicz March 17, 2020, 2:43 p.m. UTC
Add !IS_ENABLED(CONFIG_SATA_HOST) to ata_eh_set_lpm() to allow
compiler to optimize out the function for non-SATA configs (for
PATA hosts "ap && !ap->ops->set_lpm" condition is always true so
it's sufficient for the function to return zero).

Code size savings on m68k arch using (modified) atari_defconfig:

   text    data     bss     dec     hex filename
before:
  17353      18       0   17371    43db drivers/ata/libata-eh.o
after:
  16607      18       0   16625    40f1 drivers/ata/libata-eh.o

Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
---
 drivers/ata/libata-eh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

hch@lst.de March 26, 2020, 9:50 a.m. UTC | #1
On Tue, Mar 17, 2020 at 03:43:21PM +0100, Bartlomiej Zolnierkiewicz wrote:
> Add !IS_ENABLED(CONFIG_SATA_HOST) to ata_eh_set_lpm() to allow
> compiler to optimize out the function for non-SATA configs (for
> PATA hosts "ap && !ap->ops->set_lpm" condition is always true so
> it's sufficient for the function to return zero).

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

Patch
diff mbox series

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 3b8d276b5107..452c30024f81 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -3449,7 +3449,8 @@  static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy,
 	int rc;
 
 	/* if the link or host doesn't do LPM, noop */
-	if ((link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
+	if (!IS_ENABLED(CONFIG_SATA_HOST) ||
+	    (link->flags & ATA_LFLAG_NO_LPM) || (ap && !ap->ops->set_lpm))
 		return 0;
 
 	/*