Skip to content

Commit 031e668

Browse files
rfvirgilvinodkoul
authored andcommitted
soundwire: bus: Make sdw_nwrite() data pointer argument const
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>
1 parent 29a269c commit 031e668

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

  • drivers/soundwire
  • include/linux/soundwire

drivers/soundwire/bus.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,13 +394,13 @@ sdw_nread_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
394394
}
395395

396396
static int
397-
sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
397+
sdw_nwrite_no_pm(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
398398
{
399399
struct sdw_msg msg;
400400
int ret;
401401

402402
ret = sdw_fill_msg(&msg, slave, addr, count,
403-
slave->dev_num, SDW_MSG_FLAG_WRITE, val);
403+
slave->dev_num, SDW_MSG_FLAG_WRITE, (u8 *)val);
404404
if (ret < 0)
405405
return ret;
406406

@@ -535,9 +535,9 @@ EXPORT_SYMBOL(sdw_nread);
535535
* @slave: SDW Slave
536536
* @addr: Register address
537537
* @count: length
538-
* @val: Buffer for values to be read
538+
* @val: Buffer for values to be written
539539
*/
540-
int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val)
540+
int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val)
541541
{
542542
int ret;
543543

include/linux/soundwire/sdw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ int sdw_write(struct sdw_slave *slave, u32 addr, u8 value);
10391039
int sdw_write_no_pm(struct sdw_slave *slave, u32 addr, u8 value);
10401040
int sdw_read_no_pm(struct sdw_slave *slave, u32 addr);
10411041
int sdw_nread(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
1042-
int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, u8 *val);
1042+
int sdw_nwrite(struct sdw_slave *slave, u32 addr, size_t count, const u8 *val);
10431043
int sdw_compare_devid(struct sdw_slave *slave, struct sdw_slave_id id);
10441044
void sdw_extract_slave_id(struct sdw_bus *bus, u64 addr, struct sdw_slave_id *id);
10451045

0 commit comments

Comments
 (0)