Skip to contentSkip to conversation

soundwire: intel: Remove ununsed function

PATCH In review YueHaibing 3 participants 5 messages Sep 9, 2020 – Sep 10, 2020 SoundWire

lore
Share & tools
lore

YueHaibing

author
#0 lore raw

PATCH 1/1 soundwire: intel: Remove ununsed function

If CONFIG_PM is not set, build warns:

drivers/soundwire/intel.c:488:12: warning: 'intel_link_power_down' defined but not used [-Wunused-function]

Move this to #ifdef block.

---
 drivers/soundwire/intel.c | 137 +++++++++++++++++++-------------------
 1 file changed, 68 insertions(+), 69 deletions(-)
drivers/soundwire/intel.c +68 -69
index e047910d73f5..ea53291c80dd 100644
@@ -399,27 +399,6 @@ static void intel_shim_glue_to_master_ip(struct sdw_intel *sdw)
 	/* at this point Master IP has full control of the I/Os */
 }
 
-/* this needs to be called with shim_lock */
-static void intel_shim_master_ip_to_glue(struct sdw_intel *sdw)
-{
-	unsigned int link_id = sdw->instance;
-	void __iomem *shim = sdw->link_res->shim;
-	u16 ioctl;
-
-	/* Glue logic */
-	ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id));
-	ioctl |= SDW_SHIM_IOCTL_BKE;
-	ioctl |= SDW_SHIM_IOCTL_COE;
-	intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
-	usleep_range(10, 15);
-
-	ioctl &= ~(SDW_SHIM_IOCTL_MIF);
-	intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
-	usleep_range(10, 15);
-
-	/* at this point Integration Glue has full control of the I/Os */
-}
-
 static int intel_shim_init(struct sdw_intel *sdw, bool clock_stop)
 {
 	void __iomem *shim = sdw->link_res->shim;
@@ -485,54 +464,6 @@ static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
 	mutex_unlock(sdw->link_res->shim_lock);
 }
 
-static int intel_link_power_down(struct sdw_intel *sdw)
-{
-	u32 link_control, spa_mask, cpa_mask;
-	unsigned int link_id = sdw->instance;
-	void __iomem *shim = sdw->link_res->shim;
-	u32 *shim_mask = sdw->link_res->shim_mask;
-	int ret = 0;
-
-	mutex_lock(sdw->link_res->shim_lock);
-
-	intel_shim_master_ip_to_glue(sdw);
-
-	if (!(*shim_mask & BIT(link_id)))
-		dev_err(sdw->cdns.dev,
-			"%s: Unbalanced power-up/down calls\n", __func__);
-
-	*shim_mask &= ~BIT(link_id);
-
-	if (!*shim_mask) {
-
-		dev_dbg(sdw->cdns.dev, "%s: powering down all links\n", __func__);
-
-		/* Link power down sequence */
-		link_control = intel_readl(shim, SDW_SHIM_LCTL);
-
-		/* only power-down enabled links */
-		spa_mask = FIELD_PREP(SDW_SHIM_LCTL_SPA_MASK, ~sdw->link_res->link_mask);
-		cpa_mask = FIELD_PREP(SDW_SHIM_LCTL_CPA_MASK, sdw->link_res->link_mask);
-
-		link_control &=  spa_mask;
-
-		ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
-	}
-
-	link_control = intel_readl(shim, SDW_SHIM_LCTL);
-
-	mutex_unlock(sdw->link_res->shim_lock);
-
-	if (ret < 0) {
-		dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__);
-
-		return ret;
-	}
-
-	sdw->cdns.link_up = false;
-	return 0;
-}
-
 static void intel_shim_sync_arm(struct sdw_intel *sdw)
 {
 	void __iomem *shim = sdw->link_res->shim;
@@ -1541,6 +1472,74 @@ int intel_master_process_wakeen_event(struct platform_device *pdev)
  */
 
 #ifdef CONFIG_PM
+/* this needs to be called with shim_lock */
+static void intel_shim_master_ip_to_glue(struct sdw_intel *sdw)
+{
+	unsigned int link_id = sdw->instance;
+	void __iomem *shim = sdw->link_res->shim;
+	u16 ioctl;
+
+	/* Glue logic */
+	ioctl = intel_readw(shim, SDW_SHIM_IOCTL(link_id));
+	ioctl |= SDW_SHIM_IOCTL_BKE;
+	ioctl |= SDW_SHIM_IOCTL_COE;
+	intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
+	usleep_range(10, 15);
+
+	ioctl &= ~(SDW_SHIM_IOCTL_MIF);
+	intel_writew(shim, SDW_SHIM_IOCTL(link_id), ioctl);
+	usleep_range(10, 15);
+
+	/* at this point Integration Glue has full control of the I/Os */
+}
+
+static int intel_link_power_down(struct sdw_intel *sdw)
+{
+	u32 link_control, spa_mask, cpa_mask;
+	unsigned int link_id = sdw->instance;
+	void __iomem *shim = sdw->link_res->shim;
+	u32 *shim_mask = sdw->link_res->shim_mask;
+	int ret = 0;
+
+	mutex_lock(sdw->link_res->shim_lock);
+
+	intel_shim_master_ip_to_glue(sdw);
+
+	if (!(*shim_mask & BIT(link_id)))
+		dev_err(sdw->cdns.dev,
+			"%s: Unbalanced power-up/down calls\n", __func__);
+
+	*shim_mask &= ~BIT(link_id);
+
+	if (!*shim_mask) {
+
+		dev_dbg(sdw->cdns.dev, "%s: powering down all links\n", __func__);
+
+		/* Link power down sequence */
+		link_control = intel_readl(shim, SDW_SHIM_LCTL);
+
+		/* only power-down enabled links */
+		spa_mask = FIELD_PREP(SDW_SHIM_LCTL_SPA_MASK, ~sdw->link_res->link_mask);
+		cpa_mask = FIELD_PREP(SDW_SHIM_LCTL_CPA_MASK, sdw->link_res->link_mask);
+
+		link_control &=  spa_mask;
+
+		ret = intel_clear_bit(shim, SDW_SHIM_LCTL, link_control, cpa_mask);
+	}
+
+	link_control = intel_readl(shim, SDW_SHIM_LCTL);
+
+	mutex_unlock(sdw->link_res->shim_lock);
+
+	if (ret < 0) {
+		dev_err(sdw->cdns.dev, "%s: could not power down link\n", __func__);
+
+		return ret;
+	}
+
+	sdw->cdns.link_up = false;
+	return 0;
+}
 
 static int __maybe_unused intel_suspend(struct device *dev)
 {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · YueHaibing

If CONFIG_PM is not set, build warns:

drivers/soundwire/intel.c:488:12: warning: 'intel_link_power_down' defined but not used [-Wunused-function]

Move this to #ifdef block.

Yes, thanks for the report, it's a valid issue, but maybe the fix is to add __maybe_unused more consistently and remove the CONFIG_PM dependency.

Vinod, what would you prefer?

drivers/soundwire/intel.c +2 -6
index e047910d73f5..7640308174ab 100644
@@ -1540,8 +1540,6 @@ int intel_master_process_wakeen_event(struct platform_device *pdev)
  * PM calls
  */
 
-#ifdef CONFIG_PM
-
 static int __maybe_unused intel_suspend(struct device *dev)
 {
        struct sdw_cdns *cdns = dev_get_drvdata(dev);
@@ -1596,7 +1594,7 @@ static int __maybe_unused intel_suspend(struct device *dev)
        return 0;
 }
 
-static int intel_suspend_runtime(struct device *dev)
+static int __maybe_unused intel_suspend_runtime(struct device *dev)
 {
        struct sdw_cdns *cdns = dev_get_drvdata(dev);
        struct sdw_intel *sdw = cdns_to_intel(cdns);
@@ -1751,7 +1749,7 @@ static int __maybe_unused intel_resume(struct device *dev)
        return ret;
 }
 
-static int intel_resume_runtime(struct device *dev)
+static int __maybe_unused intel_resume_runtime(struct device *dev)
 {
        struct sdw_cdns *cdns = dev_get_drvdata(dev);
        struct sdw_intel *sdw = cdns_to_intel(cdns);
@@ -1924,8 +1922,6 @@ static int intel_resume_runtime(struct device *dev)
        return ret;
 }
 
-#endif
-
 static const struct dev_pm_ops intel_pm = {
        SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
        SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, 

NULL)

maintainer
#2 lore raw
Quoted 5 lines · Pierre-Louis Bossart
Quoted 2 lines · YueHaibing

If CONFIG_PM is not set, build warns:

Quoted 8 lines
Quoted 3 lines

drivers/soundwire/intel.c:488:12: warning: 'intel_link_power_down' defined but not used [-Wunused-function]

Move this to #ifdef block.

Yes, thanks for the report, it's a valid issue, but maybe the fix is to add __maybe_unused more consistently and remove the CONFIG_PM dependency.

Vinod, what would you prefer?

__maybe_unused is the recommendation, it should be updated to use that

Thanks

Signature · 1 line
~Vinod
author
#3 lore raw
Quoted 8 lines · Vinod Koul
Quoted 7 lines · Pierre-Louis Bossart
Quoted 4 lines · YueHaibing

If CONFIG_PM is not set, build warns:

drivers/soundwire/intel.c:488:12: warning: 'intel_link_power_down' defined but not used [-Wunused-function]

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Move this to #ifdef block.

Yes, thanks for the report, it's a valid issue, but maybe the fix is to add __maybe_unused more consistently and remove the CONFIG_PM dependency.

Vinod, what would you prefer?

__maybe_unused is the recommendation, it should be updated to use that

Ok, will respin.

Quoted 3 lines

Thanks

author
#4 lore raw

PATCH 1/1 soundwire: intel: Fix -Wunused-function warning

In reply to YueHaibing

If CONFIG_PM is not set, build warns:

drivers/soundwire/intel.c:488:12: warning: 'intel_link_power_down' defined but not used [-Wunused-function]

Mark the functions __maybe_unused and remove the CONFIG_PM dependency.

---
 drivers/soundwire/intel.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/soundwire/intel.c +4 -8
index e047910d73f5..48ae8800594a 100644
@@ -400,7 +400,7 @@ static void intel_shim_glue_to_master_ip(struct sdw_intel *sdw)
 }
 
 /* this needs to be called with shim_lock */
-static void intel_shim_master_ip_to_glue(struct sdw_intel *sdw)
+static void __maybe_unused intel_shim_master_ip_to_glue(struct sdw_intel *sdw)
 {
 	unsigned int link_id = sdw->instance;
 	void __iomem *shim = sdw->link_res->shim;
@@ -485,7 +485,7 @@ static void intel_shim_wake(struct sdw_intel *sdw, bool wake_enable)
 	mutex_unlock(sdw->link_res->shim_lock);
 }
 
-static int intel_link_power_down(struct sdw_intel *sdw)
+static int __maybe_unused intel_link_power_down(struct sdw_intel *sdw)
 {
 	u32 link_control, spa_mask, cpa_mask;
 	unsigned int link_id = sdw->instance;
@@ -1540,8 +1540,6 @@ int intel_master_process_wakeen_event(struct platform_device *pdev)
  * PM calls
  */
 
-#ifdef CONFIG_PM
-
 static int __maybe_unused intel_suspend(struct device *dev)
 {
 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
@@ -1596,7 +1594,7 @@ static int __maybe_unused intel_suspend(struct device *dev)
 	return 0;
 }
 
-static int intel_suspend_runtime(struct device *dev)
+static int __maybe_unused intel_suspend_runtime(struct device *dev)
 {
 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
@@ -1751,7 +1749,7 @@ static int __maybe_unused intel_resume(struct device *dev)
 	return ret;
 }
 
-static int intel_resume_runtime(struct device *dev)
+static int __maybe_unused intel_resume_runtime(struct device *dev)
 {
 	struct sdw_cdns *cdns = dev_get_drvdata(dev);
 	struct sdw_intel *sdw = cdns_to_intel(cdns);
@@ -1924,8 +1922,6 @@ static int intel_resume_runtime(struct device *dev)
 	return ret;
 }
 
-#endif
-
 static const struct dev_pm_ops intel_pm = {
 	SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
 	SET_RUNTIME_PM_OPS(intel_suspend_runtime, intel_resume_runtime, NULL)
Signature · 1 line
2.17.1