Skip to contentSkip to conversation

misc: mark write buffer const

PATCH In review John Keeping 3 participants 3 messages Jan 11, 2022 – Jan 24, 2022 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 misc: mark write buffer const

The write operation in misc_ops already takes a "const void *" buffer, but misc_write() takes a mutable "void *". There's no reason for this, so make misc_write() consistent with the standard write() prototype.

---
 drivers/misc/misc-uclass.c | 2 +-
 include/misc.h             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/misc/misc-uclass.c +1 -1
index cbfacc3801..cfe9d562fa 100644
@@ -26,7 +26,7 @@ int misc_read(struct udevice *dev, int offset, void *buf, int size)
 	return ops->read(dev, offset, buf, size);
 }
 
-int misc_write(struct udevice *dev, int offset, void *buf, int size)
+int misc_write(struct udevice *dev, int offset, const void *buf, int size)
 {
 	const struct misc_ops *ops = device_get_ops(dev);
 
include/misc.h +1 -1
index 82ec2ce793..6f042625c9 100644
@@ -28,7 +28,7 @@ int misc_read(struct udevice *dev, int offset, void *buf, int size);
  *
  * Return: number of bytes written if OK (may be < @size), -ve on error
  */
-int misc_write(struct udevice *dev, int offset, void *buf, int size);
+int misc_write(struct udevice *dev, int offset, const void *buf, int size);
 
 /**
  * misc_ioctl() - Assert command to the device, optional.
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · John Keeping

The write operation in misc_ops already takes a "const void *" buffer, but misc_write() takes a mutable "void *". There's no reason for this, so make misc_write() consistent with the standard write() prototype.

---
 drivers/misc/misc-uclass.c | 2 +-
 include/misc.h             | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)