Skip to contentSkip to conversation

soundwire: code cleanup

PATCH Superseded Pierre-Louis Bossart 2 participants 6 messages Apr 4, 2019 SoundWire

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover soundwire: code cleanup

SoundWire support will be provided in Linux with the Sound Open Firmware (SOF) on Intel platforms. Before we start adding the missing pieces, there are a number of warnings and style issues reported by checkpatch, cppcheck and Coccinelle that need to be cleaned-up.

While I am at it, I could use feedback from maintainers. We are ready to release a number of required patches that were not provided earlier, but the initial contributors have either left Intel or moved on to other domains. While I'd like to give them credit for their work, I don't think leaving the email addresses as is is a good solution (email bounces, etc). I also don't think providing a non-Intel address is correct since the work was funded by Intel. Is there a recommended practice here?

Pierre-Louis Bossart (3):
soundwire: fix style issues
soundwire: bus: remove useless initializations
soundwire: stream: remove useless initialization of local variable

 drivers/soundwire/Kconfig          |   2 +-
 drivers/soundwire/bus.c            |  89 ++++++++--------
 drivers/soundwire/bus.h            |  16 +--
 drivers/soundwire/bus_type.c       |   4 +-
 drivers/soundwire/cadence_master.c |  87 +++++++--------
 drivers/soundwire/cadence_master.h |  22 ++--
 drivers/soundwire/intel.c          |  89 ++++++++--------
 drivers/soundwire/intel.h          |   4 +-
 drivers/soundwire/intel_init.c     |  12 +--
 drivers/soundwire/mipi_disco.c     | 116 +++++++++++---------
 drivers/soundwire/slave.c          |  10 +-
 drivers/soundwire/stream.c         | 163 +++++++++++++++--------------
 12 files changed, 315 insertions(+), 299 deletions(-)
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/3 soundwire: fix style issues

Visual inspections confirmed by checkpatch.pl --strict expose a number of style issues, specifically parameter alignment is inconsistent as if different contributors used different styles. Before we restart support for SoundWire with Sound Open Firmware on Intel platforms, let's clean all this.

Fix Kconfig help, spelling, SPDX format, alignment, spurious parentheses, bool comparisons to true/false, macro argument protection.

No new functionality added.

---
 drivers/soundwire/Kconfig          |   2 +-
 drivers/soundwire/bus.c            |  87 ++++++++--------
 drivers/soundwire/bus.h            |  16 +--
 drivers/soundwire/bus_type.c       |   4 +-
 drivers/soundwire/cadence_master.c |  87 ++++++++--------
 drivers/soundwire/cadence_master.h |  22 ++--
 drivers/soundwire/intel.c          |  89 ++++++++--------
 drivers/soundwire/intel.h          |   4 +-
 drivers/soundwire/intel_init.c     |  12 +--
 drivers/soundwire/mipi_disco.c     | 116 +++++++++++----------
 drivers/soundwire/slave.c          |  10 +-
 drivers/soundwire/stream.c         | 161 +++++++++++++++--------------
 12 files changed, 314 insertions(+), 296 deletions(-)
drivers/soundwire/Kconfig +1 -1
index 19c8efb9a5ee..84876a74874f 100644
@@ -4,7 +4,7 @@
 
 menuconfig SOUNDWIRE
 	bool "SoundWire support"
-	---help---
+	help
 	  SoundWire is a 2-Pin interface with data and clock line ratified
 	  by the MIPI Alliance. SoundWire is used for transporting data
 	  typically related to audio functions. SoundWire interface is
drivers/soundwire/bus.c +43 -44

305 lines not on this page · raw message

drivers/soundwire/bus.h +8 -8
index c77de05b8100..3048ca153f22 100644
@@ -1,5 +1,5 @@
-// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
-// Copyright(c) 2015-17 Intel Corporation.
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
+/* Copyright(c) 2015-17 Intel Corporation. */
 
 #ifndef __SDW_BUS_H
 #define __SDW_BUS_H
@@ -16,7 +16,7 @@ static inline int sdw_acpi_find_slaves(struct sdw_bus *bus)
 #endif
 
 void sdw_extract_slave_id(struct sdw_bus *bus,
-			u64 addr, struct sdw_slave_id *id);
+			  u64 addr, struct sdw_slave_id *id);
 
 enum {
 	SDW_MSG_FLAG_READ = 0,
@@ -116,19 +116,19 @@ struct sdw_master_runtime {
 };
 
 struct sdw_dpn_prop *sdw_get_slave_dpn_prop(struct sdw_slave *slave,
-				enum sdw_data_direction direction,
-				unsigned int port_num);
+					    enum sdw_data_direction direction,
+					    unsigned int port_num);
 int sdw_configure_dpn_intr(struct sdw_slave *slave, int port,
-					bool enable, int mask);
+			   bool enable, int mask);
 
 int sdw_transfer(struct sdw_bus *bus, struct sdw_msg *msg);
 int sdw_transfer_defer(struct sdw_bus *bus, struct sdw_msg *msg,
-				struct sdw_defer *defer);
+		       struct sdw_defer *defer);
 
 #define SDW_READ_INTR_CLEAR_RETRY	10
 
 int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
-		u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
+		 u32 addr, size_t count, u16 dev_num, u8 flags, u8 *buf);
 
 /* Read-Modify-Write Slave register */
 static inline int
drivers/soundwire/bus_type.c +2 -2
index 283b2832728e..2655602f0cfb 100644
@@ -107,7 +107,7 @@ static int sdw_drv_probe(struct device *dev)
 		slave->prop.clk_stop_timeout = 300;
 
 	slave->bus->clk_stop_timeout = max_t(u32, slave->bus->clk_stop_timeout,
-					slave->prop.clk_stop_timeout);
+					     slave->prop.clk_stop_timeout);
 
 	return 0;
 }
@@ -148,7 +148,7 @@ int __sdw_register_driver(struct sdw_driver *drv, struct module *owner)
 
 	if (!drv->probe) {
 		pr_err("driver %s didn't provide SDW probe routine\n",
-							drv->name);
+		       drv->name);
 		return -EINVAL;
 	}
 
drivers/soundwire/cadence_master.c +44 -43

279 lines not on this page · raw message

drivers/soundwire/cadence_master.h +11 -11
index eb902b19c5a4..fe2af62958b1 100644
@@ -1,5 +1,5 @@
-// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
-// Copyright(c) 2015-17 Intel Corporation.
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
+/* Copyright(c) 2015-17 Intel Corporation. */
 #include <sound/soc.h>
 
 #ifndef __SDW_CADENCE_H
@@ -160,24 +160,24 @@ irqreturn_t sdw_cdns_thread(int irq, void *dev_id);
 
 int sdw_cdns_init(struct sdw_cdns *cdns);
 int sdw_cdns_pdi_init(struct sdw_cdns *cdns,
-			struct sdw_cdns_stream_config config);
+		      struct sdw_cdns_stream_config config);
 int sdw_cdns_enable_interrupt(struct sdw_cdns *cdns);
 
 int sdw_cdns_get_stream(struct sdw_cdns *cdns,
 			struct sdw_cdns_streams *stream,
 			u32 ch, u32 dir);
 int sdw_cdns_alloc_stream(struct sdw_cdns *cdns,
-			struct sdw_cdns_streams *stream,
-			struct sdw_cdns_port *port, u32 ch, u32 dir);
+			  struct sdw_cdns_streams *stream,
+			  struct sdw_cdns_port *port, u32 ch, u32 dir);
 void sdw_cdns_config_stream(struct sdw_cdns *cdns, struct sdw_cdns_port *port,
-			u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
+			    u32 ch, u32 dir, struct sdw_cdns_pdi *pdi);
 
 void sdw_cdns_shutdown(struct snd_pcm_substream *substream,
-				struct snd_soc_dai *dai);
+		       struct snd_soc_dai *dai);
 int sdw_cdns_pcm_set_stream(struct snd_soc_dai *dai,
-				void *stream, int direction);
+			    void *stream, int direction);
 int sdw_cdns_pdm_set_stream(struct snd_soc_dai *dai,
-				void *stream, int direction);
+			    void *stream, int direction);
 
 enum sdw_command_response
 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
@@ -187,7 +187,7 @@ cdns_xfer_msg(struct sdw_bus *bus, struct sdw_msg *msg);
 
 enum sdw_command_response
 cdns_xfer_msg_defer(struct sdw_bus *bus,
-		struct sdw_msg *msg, struct sdw_defer *defer);
+		    struct sdw_msg *msg, struct sdw_defer *defer);
 
 enum sdw_command_response
 cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
@@ -195,5 +195,5 @@ cdns_reset_page_addr(struct sdw_bus *bus, unsigned int dev_num);
 int cdns_bus_conf(struct sdw_bus *bus, struct sdw_bus_params *params);
 
 int cdns_set_sdw_stream(struct snd_soc_dai *dai,
-		void *stream, bool pcm, int direction);
+			void *stream, bool pcm, int direction);
 #endif /* __SDW_CADENCE_H */
drivers/soundwire/intel.c +44 -45

222 lines not on this page · raw message

drivers/soundwire/intel.h +2 -2
index c1a5bac6212e..71050e5f643d 100644
@@ -1,5 +1,5 @@
-// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
-// Copyright(c) 2015-17 Intel Corporation.
+/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
+/* Copyright(c) 2015-17 Intel Corporation. */
 
 #ifndef __SDW_INTEL_LOCAL_H
 #define __SDW_INTEL_LOCAL_H
drivers/soundwire/intel_init.c +6 -6
index 5c8a20d99878..5123c8f79591 100644
@@ -67,7 +67,7 @@ static struct sdw_intel_ctx
 	/* Found controller, find links supported */
 	count = 0;
 	ret = fwnode_property_read_u8_array(acpi_fwnode_handle(adev),
-				  "mipi-sdw-master-count", &count, 1);
+					    "mipi-sdw-master-count", &count, 1);
 
 	/* Don't fail on error, continue and use hw value */
 	if (ret) {
@@ -85,7 +85,7 @@ static struct sdw_intel_ctx
 	/* Check count is within bounds */
 	if (count > SDW_MAX_LINKS) {
 		dev_err(&adev->dev, "Link count %d exceeds max %d\n",
-						count, SDW_MAX_LINKS);
+			count, SDW_MAX_LINKS);
 		return NULL;
 	}
 
@@ -145,7 +145,7 @@ static struct sdw_intel_ctx
 }
 
 static acpi_status sdw_intel_acpi_cb(acpi_handle handle, u32 level,
-					void *cdata, void **return_value)
+				     void *cdata, void **return_value)
 {
 	struct sdw_intel_res *res = cdata;
 	struct acpi_device *adev;
@@ -172,9 +172,9 @@ void *sdw_intel_init(acpi_handle *parent_handle, struct sdw_intel_res *res)
 	acpi_status status;
 
 	status = acpi_walk_namespace(ACPI_TYPE_DEVICE,
-					parent_handle, 1,
-					sdw_intel_acpi_cb,
-					NULL, res, NULL);
+				     parent_handle, 1,
+				     sdw_intel_acpi_cb,
+				     NULL, res, NULL);
 	if (ACPI_FAILURE(status))
 		return NULL;
 
drivers/soundwire/mipi_disco.c +64 -52

308 lines not on this page · raw message

drivers/soundwire/slave.c +5 -5
index ac103bd0c176..f39a5815e25d 100644
@@ -14,7 +14,7 @@ static void sdw_slave_release(struct device *dev)
 }
 
 static int sdw_slave_add(struct sdw_bus *bus,
-		struct sdw_slave_id *id, struct fwnode_handle *fwnode)
+			 struct sdw_slave_id *id, struct fwnode_handle *fwnode)
 {
 	struct sdw_slave *slave;
 	int ret;
@@ -30,8 +30,8 @@ static int sdw_slave_add(struct sdw_bus *bus,
 
 	/* name shall be sdw:link:mfg:part:class:unique */
 	dev_set_name(&slave->dev, "sdw:%x:%x:%x:%x:%x",
-			bus->link_id, id->mfg_id, id->part_id,
-			id->class_id, id->unique_id);
+		     bus->link_id, id->mfg_id, id->part_id,
+		     id->class_id, id->unique_id);
 
 	slave->dev.release = sdw_slave_release;
 	slave->dev.bus = &sdw_bus_type;
@@ -84,11 +84,11 @@ int sdw_acpi_find_slaves(struct sdw_bus *bus)
 		acpi_status status;
 
 		status = acpi_evaluate_integer(adev->handle,
-					METHOD_NAME__ADR, NULL, &addr);
+					       METHOD_NAME__ADR, NULL, &addr);
 
 		if (ACPI_FAILURE(status)) {
 			dev_err(bus->dev, "_ADR resolution failed: %x\n",
-							status);
+				status);
 			return status;
 		}
 
drivers/soundwire/stream.c +84 -77

444 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/3] soundwire: fix style issues

Quoted 11 lines · Pierre-Louis Bossart

Visual inspections confirmed by checkpatch.pl --strict expose a number of style issues, specifically parameter alignment is inconsistent as if different contributors used different styles. Before we restart support for SoundWire with Sound Open Firmware on Intel platforms, let's clean all this.

Fix Kconfig help, spelling, SPDX format, alignment, spurious parentheses, bool comparisons to true/false, macro argument protection.

No new functionality added.

[]

drivers/soundwire/bus.c

Quoted 1 line
drivers/soundwire/bus.c +0 -0

[]

drivers/soundwire/bus.c static int sdw_assign_device_num(struct sdw_slave *slave) · line 461

Quoted 6 lines
drivers/soundwire/bus.c +1 -1
@@ -458,13 +458,13 @@ static int sdw_assign_device_num(struct sdw_slave *slave)
 		mutex_unlock(&slave->bus->bus_lock);
 		if (dev_num < 0) {
 			dev_err(slave->bus->dev, "Get dev_num failed: %d",
-								dev_num);
+				dev_num);

You could also add the missing terminating '\n' to these formats like:

dev_err(slave->bus->dev, "Get dev_num failed: %d\n",

drivers/soundwire/bus.c static int sdw_assign_device_num(struct sdw_slave *slave) · line 467

Quoted 8 lines
drivers/soundwire/bus.c +2 -2
 			return dev_num;
 		}
 	} else {
 		dev_info(slave->bus->dev,
-				"Slave already registered dev_num:%d",
-				slave->dev_num);
+			 "Slave already registered dev_num:%d",
+			 slave->dev_num);

etc...

#3 lore raw

Re: [alsa-devel] [PATCH 1/3] soundwire: fix style issues

Thanks for the review Joe,

@@ -458,13 +458,13 @@ static int sdw_assign_device_num(struct sdw_slave *slave)

Quoted 9 lines

drivers/soundwire/bus.c static int sdw_assign_device_num(struct sdw_slave *slave) · line 461

Quoted 5 lines
  		mutex_unlock(&slave->bus->bus_lock);
  		if (dev_num < 0) {
  			dev_err(slave->bus->dev, "Get dev_num failed: %d",
drivers/soundwire/bus.c +1 -1
-								dev_num);
+				dev_num);

You could also add the missing terminating '\n' to these formats like:

dev_err(slave->bus->dev, "Get dev_num failed: %d\n",

Yes indeed, I just fixed that tools reported, but that is a miss. Will fix with a v2 (hopefully with other comments).

-Pierre

#4 lore raw

PATCH 2/3 soundwire: bus: remove useless initializations

In reply to Pierre-Louis Bossart

No need for explicit initialization of page and ssp fields, they are already zeroed with a memset.

Detected with cppcheck:

[drivers/soundwire/bus.c:309]: (style) Variable 'msg->page' is reassigned a value before the old one has been used.

---
 drivers/soundwire/bus.c | 2 --
 1 file changed, 2 deletions(-)
drivers/soundwire/bus.c +0 -2
index 691a31df9732..bb697fd68580 100644
@@ -271,8 +271,6 @@ int sdw_fill_msg(struct sdw_msg *msg, struct sdw_slave *slave,
 	msg->dev_num = dev_num;
 	msg->flags = flags;
 	msg->buf = buf;
-	msg->ssp_sync = false;
-	msg->page = false;
 
 	if (addr < SDW_REG_NO_PAGE) { /* no paging area */
 		return 0;
Signature · 1 line
2.17.1
#5 lore raw

PATCH 3/3 soundwire: stream: remove useless initialization of local variable

In reply to Pierre-Louis Bossart

no need to reset return value.

Detected with cppcheck:
[drivers/soundwire/stream.c:332]: (style) Variable 'ret' is assigned a value that is never used.

---
 drivers/soundwire/stream.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soundwire/stream.c +1 -1
index e3d2bc5cba80..ab64c2c4c33f 100644
@@ -329,7 +329,7 @@ static int sdw_enable_disable_master_ports(struct sdw_master_runtime *m_rt,
 	struct sdw_transport_params *t_params = &p_rt->transport_params;
 	struct sdw_bus *bus = m_rt->bus;
 	struct sdw_enable_ch enable_ch;
-	int ret = 0;
+	int ret;
 
 	enable_ch.port_num = p_rt->num;
 	enable_ch.ch_mask = p_rt->ch_mask;
Signature · 1 line
2.17.1