[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200128133343.29905-21-b.zolnierkie@samsung.com>
Date: Tue, 28 Jan 2020 14:33:35 +0100
From: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
To: Jens Axboe <axboe@...nel.dk>
Cc: Michael Schmitz <schmitzmic@...il.com>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
linux-ide@...r.kernel.org, linux-kernel@...r.kernel.org,
b.zolnierkie@...sung.com
Subject: [PATCH 20/28] ata: move sata_link_init_spd() to libata-core-sata.c
* move sata_link_init_spd() to libata-core-sata.c
* add static inline for CONFIG_SATA_HOST=n case
* cover ata_force_link_limits() with CONFIG_SATA_HOST ifdef (it
depends on code from libata-core.c while its only user is in
libata-core-sata.c)
Code size savings on m68k arch using atari_defconfig:
text data bss dec hex filename
before:
33574 572 40 34186 858a drivers/ata/libata-core.o
after:
33212 572 40 33824 8420 drivers/ata/libata-core.o
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>
---
drivers/ata/libata-core-sata.c | 33 ++++++++++++++++++++++++++++++
drivers/ata/libata-core.c | 37 +++-------------------------------
drivers/ata/libata.h | 7 ++++++-
3 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/drivers/ata/libata-core-sata.c b/drivers/ata/libata-core-sata.c
index b43207396829..8c6ed82dc166 100644
--- a/drivers/ata/libata-core-sata.c
+++ b/drivers/ata/libata-core-sata.c
@@ -772,6 +772,39 @@ int sata_link_hardreset(struct ata_link *link, const unsigned long *timing,
}
EXPORT_SYMBOL_GPL(sata_link_hardreset);
+/**
+ * sata_link_init_spd - Initialize link->sata_spd_limit
+ * @link: Link to configure sata_spd_limit for
+ *
+ * Initialize @link->[hw_]sata_spd_limit to the currently
+ * configured value.
+ *
+ * LOCKING:
+ * Kernel thread context (may sleep).
+ *
+ * RETURNS:
+ * 0 on success, -errno on failure.
+ */
+int sata_link_init_spd(struct ata_link *link)
+{
+ u8 spd;
+ int rc;
+
+ rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol);
+ if (rc)
+ return rc;
+
+ spd = (link->saved_scontrol >> 4) & 0xf;
+ if (spd)
+ link->hw_sata_spd_limit &= (1 << spd) - 1;
+
+ ata_force_link_limits(link);
+
+ link->sata_spd_limit = link->hw_sata_spd_limit;
+
+ return 0;
+}
+
/**
* ata_slave_link_init - initialize slave link
* @ap: port to initialize slave link for
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index bd82cab2996e..17f1d98eab71 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -338,6 +338,7 @@ void ata_force_cbl(struct ata_port *ap)
}
}
+#ifdef CONFIG_SATA_HOST
/**
* ata_force_link_limits - force link limits according to libata.force
* @link: ATA link of interest
@@ -354,7 +355,7 @@ void ata_force_cbl(struct ata_port *ap)
* LOCKING:
* EH context.
*/
-static void ata_force_link_limits(struct ata_link *link)
+void ata_force_link_limits(struct ata_link *link)
{
bool did_spd = false;
int linkno = link->pmp;
@@ -389,6 +390,7 @@ static void ata_force_link_limits(struct ata_link *link)
}
}
}
+#endif
/**
* ata_force_xfermask - force xfermask according to libata.force
@@ -5078,39 +5080,6 @@ void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp)
}
}
-/**
- * sata_link_init_spd - Initialize link->sata_spd_limit
- * @link: Link to configure sata_spd_limit for
- *
- * Initialize @link->[hw_]sata_spd_limit to the currently
- * configured value.
- *
- * LOCKING:
- * Kernel thread context (may sleep).
- *
- * RETURNS:
- * 0 on success, -errno on failure.
- */
-int sata_link_init_spd(struct ata_link *link)
-{
- u8 spd;
- int rc;
-
- rc = sata_scr_read(link, SCR_CONTROL, &link->saved_scontrol);
- if (rc)
- return rc;
-
- spd = (link->saved_scontrol >> 4) & 0xf;
- if (spd)
- link->hw_sata_spd_limit &= (1 << spd) - 1;
-
- ata_force_link_limits(link);
-
- link->sata_spd_limit = link->hw_sata_spd_limit;
-
- return 0;
-}
-
/**
* ata_port_alloc - allocate and initialize basic ATA port resources
* @host: ATA host this allocated port belongs to
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
index 518a8e08a26d..8f5da7be88fe 100644
--- a/drivers/ata/libata.h
+++ b/drivers/ata/libata.h
@@ -76,7 +76,6 @@ extern bool ata_phys_link_online(struct ata_link *link);
extern bool ata_phys_link_offline(struct ata_link *link);
extern void ata_dev_init(struct ata_device *dev);
extern void ata_link_init(struct ata_port *ap, struct ata_link *link, int pmp);
-extern int sata_link_init_spd(struct ata_link *link);
extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg);
extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg);
extern struct ata_port *ata_port_alloc(struct ata_host *host);
@@ -85,6 +84,7 @@ extern int ata_port_probe(struct ata_port *ap);
extern void __ata_port_probe(struct ata_port *ap);
extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log,
u8 page, void *buf, unsigned int sectors);
+extern void ata_force_link_limits(struct ata_link *link);
static inline bool ata_sstatus_online(u32 sstatus)
{
@@ -108,6 +108,7 @@ int ata_do_link_spd_horkage(struct ata_device *dev);
int ata_dev_config_ncq(struct ata_device *dev, char *desc, size_t desc_sz);
void sata_print_link_status(struct ata_link *link);
int sata_down_spd_limit(struct ata_link *link, u32 spd_limit);
+int sata_link_init_spd(struct ata_link *link);
#else
static inline int ata_do_link_spd_horkage(struct ata_device *dev) { return 0; }
static inline int ata_dev_config_ncq(struct ata_device *dev, char *desc,
@@ -121,6 +122,10 @@ static inline int sata_down_spd_limit(struct ata_link *link, u32 spd_limit)
{
return -EOPNOTSUPP;
}
+static inline int sata_link_init_spd(struct ata_link *link)
+{
+ return -EOPNOTSUPP;
+}
#endif
/* libata-acpi.c */
--
2.24.1
Powered by blists - more mailing lists