]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
soundwire: bus: Make sdw_nwrite() data pointer argument const
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Wed, 16 Jun 2021 14:59:01 +0000 (15:59 +0100)
committerVinod Koul <vkoul@kernel.org>
Sun, 20 Jun 2021 11:16:14 +0000 (16:46 +0530)
Idiomatically, write functions should take const pointers to the
data buffer, as they don't change the data. They are also likely
to be called from functions that receive a const data pointer.

Internally the pointer is passed to function/structs shared with
the read functions, requiring a cast, but this is an implementation
detail that should be hidden by the public API.

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://lore.kernel.org/r/20210616145901.29402-1-rf@opensource.cirrus.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
drivers/soundwire/bus.c
include/linux/soundwire/sdw.h

index 85bcf60f9697062cbacf6a74d56e1563c55635ab..adcbf3969110ee44fdbcb8ec22fbcb0dd4c44f4c 100644 (file)
@@ -394,13 +394,13 @@ sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
 }
 
 static int
-sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
+sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
 {
        struct sdw_msg msg;
        int ret;
 
        ret = sdw_fill_msg(&msg, slave, addr, count,
-                          slave->dev_num, SDW_MSG_FLAG_WRITE, val);
+                          slave->dev_num, SDW_MSG_FLAG_WRITE, (u8 *)val);
        if (ret < 0)
                return ret;
 
@@ -535,9 +535,9 @@ EXPORT_SYMBOL(sdw_nread);
  * @slave: SDW Slave
  * @addr: Register address
  * @count: length
- * @val: Buffer for values to be read
+ * @val: Buffer for values to be written
  */
-int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
+int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
 {
        int ret;
 
index 8ca736e92d5af53bb4445dcb3440374555df398e..ddbeb00799e41d9905120ed7670d9589c98a8b9e 100644 (file)
@@ -1039,7 +1039,7 @@ int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
 int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value);
 int sdw_read_no_pm(struct sdw_slave *slave, u32 addr);
 int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
-int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
+int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val);
 int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
 void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);