All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mei: constify passed buffers and structures
@ 2021-07-29 10:28 Krzysztof Kozlowski
  2021-07-29 10:59 ` Arnd Bergmann
  2021-07-29 12:28 ` Winkler, Tomas
  0 siblings, 2 replies; 3+ messages in thread
From: Krzysztof Kozlowski @ 2021-07-29 10:28 UTC (permalink / raw)
  To: Tomas Winkler, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel
  Cc: Krzysztof Kozlowski

Buffers and structures passed to MEI bus and client API can be made
const for safer code and clear indication that it is not modified.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 drivers/misc/mei/bus.c     | 18 +++++++++---------
 drivers/misc/mei/client.h  |  2 +-
 drivers/misc/mei/mei_dev.h |  2 +-
 include/linux/mei_cl_bus.h |  9 +++++----
 4 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c
index 935acc6bbf3c..09188d9afc06 100644
--- a/drivers/misc/mei/bus.c
+++ b/drivers/misc/mei/bus.c
@@ -31,7 +31,7 @@
  *
  * Return: written size bytes or < 0 on error
  */
-ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag,
+ssize_t __mei_cl_send(struct mei_cl *cl, const u8 *buf, size_t length, u8 vtag,
 		      unsigned int mode)
 {
 	struct mei_device *bus;
@@ -232,8 +232,8 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag,
  *  * < 0 on error
  */
 
-ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length,
-			    u8 vtag)
+ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
+			    size_t length, u8 vtag)
 {
 	struct mei_cl *cl = cldev->cl;
 
@@ -296,7 +296,7 @@ EXPORT_SYMBOL_GPL(mei_cldev_recv_nonblock_vtag);
  *  * written size in bytes
  *  * < 0 on error
  */
-ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
+ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf, size_t length)
 {
 	return mei_cldev_send_vtag(cldev, buf, length, 0);
 }
@@ -552,7 +552,7 @@ EXPORT_SYMBOL_GPL(mei_cldev_ver);
  *
  * Return: true if me client is initialized and connected
  */
-bool mei_cldev_enabled(struct mei_cl_device *cldev)
+bool mei_cldev_enabled(const struct mei_cl_device *cldev)
 {
 	return mei_cl_is_connected(cldev->cl);
 }
@@ -771,8 +771,8 @@ EXPORT_SYMBOL_GPL(mei_cldev_disable);
  * Return: id on success; NULL if no id is matching
  */
 static const
-struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev,
-					    struct mei_cl_driver *cldrv)
+struct mei_cl_device_id *mei_cl_device_find(const struct mei_cl_device *cldev,
+					    const struct mei_cl_driver *cldrv)
 {
 	const struct mei_cl_device_id *id;
 	const uuid_le *uuid;
@@ -815,8 +815,8 @@ struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev,
  */
 static int mei_cl_device_match(struct device *dev, struct device_driver *drv)
 {
-	struct mei_cl_device *cldev = to_mei_cl_device(dev);
-	struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
+	const struct mei_cl_device *cldev = to_mei_cl_device(dev);
+	const struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
 	const struct mei_cl_device_id *found_id;
 
 	if (!cldev)
diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h
index b12cdcde9436..418056fb1489 100644
--- a/drivers/misc/mei/client.h
+++ b/drivers/misc/mei/client.h
@@ -160,7 +160,7 @@ int mei_cl_vt_support_check(const struct mei_cl *cl);
  *
  * Return: true if the host client is connected
  */
-static inline bool mei_cl_is_connected(struct mei_cl *cl)
+static inline bool mei_cl_is_connected(const struct mei_cl *cl)
 {
 	return  cl->state == MEI_FILE_CONNECTED;
 }
diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h
index b7b6ef344e80..694f866f87ef 100644
--- a/drivers/misc/mei/mei_dev.h
+++ b/drivers/misc/mei/mei_dev.h
@@ -356,7 +356,7 @@ struct mei_hw_ops {
 /* MEI bus API*/
 void mei_cl_bus_rescan_work(struct work_struct *work);
 void mei_cl_bus_dev_fixup(struct mei_cl_device *dev);
-ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag,
+ssize_t __mei_cl_send(struct mei_cl *cl, const u8 *buf, size_t length, u8 vtag,
 		      unsigned int mode);
 ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag,
 		      unsigned int mode, unsigned long timeout);
diff --git a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h
index 07f5ef8fc456..c6786c12b207 100644
--- a/include/linux/mei_cl_bus.h
+++ b/include/linux/mei_cl_bus.h
@@ -91,12 +91,13 @@ void mei_cldev_driver_unregister(struct mei_cl_driver *cldrv);
 		      mei_cldev_driver_register,\
 		      mei_cldev_driver_unregister)
 
-ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length);
+ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf,
+		       size_t length);
 ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
 ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf,
 				size_t length);
-ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length,
-			    u8 vtag);
+ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
+			    size_t length, u8 vtag);
 ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t length,
 			    u8 *vtag);
 ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8 *buf,
@@ -114,6 +115,6 @@ void mei_cldev_set_drvdata(struct mei_cl_device *cldev, void *data);
 
 int mei_cldev_enable(struct mei_cl_device *cldev);
 int mei_cldev_disable(struct mei_cl_device *cldev);
-bool mei_cldev_enabled(struct mei_cl_device *cldev);
+bool mei_cldev_enabled(const struct mei_cl_device *cldev);
 
 #endif /* _LINUX_MEI_CL_BUS_H */
-- 
2.27.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mei: constify passed buffers and structures
  2021-07-29 10:28 [PATCH] mei: constify passed buffers and structures Krzysztof Kozlowski
@ 2021-07-29 10:59 ` Arnd Bergmann
  2021-07-29 12:28 ` Winkler, Tomas
  1 sibling, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-07-29 10:59 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Tomas Winkler, Arnd Bergmann, Greg Kroah-Hartman,
	Linux Kernel Mailing List

On Thu, Jul 29, 2021 at 12:28 PM Krzysztof Kozlowski
<krzysztof.kozlowski@canonical.com> wrote:
>
> Buffers and structures passed to MEI bus and client API can be made
> const for safer code and clear indication that it is not modified.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

Looks good to me,

Acked-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] mei: constify passed buffers and structures
  2021-07-29 10:28 [PATCH] mei: constify passed buffers and structures Krzysztof Kozlowski
  2021-07-29 10:59 ` Arnd Bergmann
@ 2021-07-29 12:28 ` Winkler, Tomas
  1 sibling, 0 replies; 3+ messages in thread
From: Winkler, Tomas @ 2021-07-29 12:28 UTC (permalink / raw)
  To: Krzysztof Kozlowski, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel
  Cc: Lubart, Vitaly, Usyskin, Alexander



> -----Original Message-----
> From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> Sent: Thursday, July 29, 2021 13:28
> To: Winkler, Tomas <tomas.winkler@intel.com>; Arnd Bergmann
> <arnd@arndb.de>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>;
> linux-kernel@vger.kernel.org
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
> Subject: [PATCH] mei: constify passed buffers and structures
> 
> Buffers and structures passed to MEI bus and client API can be made const
> for safer code and clear indication that it is not modified.
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

Acked-by: Tomas Winkler <tomas.winkler@intel.com> 

> ---
>  drivers/misc/mei/bus.c     | 18 +++++++++---------
>  drivers/misc/mei/client.h  |  2 +-
>  drivers/misc/mei/mei_dev.h |  2 +-
>  include/linux/mei_cl_bus.h |  9 +++++----
>  4 files changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index
> 935acc6bbf3c..09188d9afc06 100644
> --- a/drivers/misc/mei/bus.c
> +++ b/drivers/misc/mei/bus.c
> @@ -31,7 +31,7 @@
>   *
>   * Return: written size bytes or < 0 on error
>   */
> -ssize_t __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag,
> +ssize_t __mei_cl_send(struct mei_cl *cl, const u8 *buf, size_t length,
> +u8 vtag,
>  		      unsigned int mode)
>  {
>  	struct mei_device *bus;
> @@ -232,8 +232,8 @@ ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf,
> size_t length, u8 *vtag,
>   *  * < 0 on error
>   */
> 
> -ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, u8 *buf, size_t
> length,
> -			    u8 vtag)
> +ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
> +			    size_t length, u8 vtag)
>  {
>  	struct mei_cl *cl = cldev->cl;
> 
> @@ -296,7 +296,7 @@
> EXPORT_SYMBOL_GPL(mei_cldev_recv_nonblock_vtag);
>   *  * written size in bytes
>   *  * < 0 on error
>   */
> -ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length)
> +ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf,
> +size_t length)
>  {
>  	return mei_cldev_send_vtag(cldev, buf, length, 0);  } @@ -552,7
> +552,7 @@ EXPORT_SYMBOL_GPL(mei_cldev_ver);
>   *
>   * Return: true if me client is initialized and connected
>   */
> -bool mei_cldev_enabled(struct mei_cl_device *cldev)
> +bool mei_cldev_enabled(const struct mei_cl_device *cldev)
>  {
>  	return mei_cl_is_connected(cldev->cl);  } @@ -771,8 +771,8 @@
> EXPORT_SYMBOL_GPL(mei_cldev_disable);
>   * Return: id on success; NULL if no id is matching
>   */
>  static const
> -struct mei_cl_device_id *mei_cl_device_find(struct mei_cl_device *cldev,
> -					    struct mei_cl_driver *cldrv)
> +struct mei_cl_device_id *mei_cl_device_find(const struct mei_cl_device
> *cldev,
> +					    const struct mei_cl_driver *cldrv)
>  {
>  	const struct mei_cl_device_id *id;
>  	const uuid_le *uuid;
> @@ -815,8 +815,8 @@ struct mei_cl_device_id *mei_cl_device_find(struct
> mei_cl_device *cldev,
>   */
>  static int mei_cl_device_match(struct device *dev, struct device_driver
> *drv)  {
> -	struct mei_cl_device *cldev = to_mei_cl_device(dev);
> -	struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
> +	const struct mei_cl_device *cldev = to_mei_cl_device(dev);
> +	const struct mei_cl_driver *cldrv = to_mei_cl_driver(drv);
>  	const struct mei_cl_device_id *found_id;
> 
>  	if (!cldev)
> diff --git a/drivers/misc/mei/client.h b/drivers/misc/mei/client.h index
> b12cdcde9436..418056fb1489 100644
> --- a/drivers/misc/mei/client.h
> +++ b/drivers/misc/mei/client.h
> @@ -160,7 +160,7 @@ int mei_cl_vt_support_check(const struct mei_cl
> *cl);
>   *
>   * Return: true if the host client is connected
>   */
> -static inline bool mei_cl_is_connected(struct mei_cl *cl)
> +static inline bool mei_cl_is_connected(const struct mei_cl *cl)
>  {
>  	return  cl->state == MEI_FILE_CONNECTED;  } diff --git
> a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index
> b7b6ef344e80..694f866f87ef 100644
> --- a/drivers/misc/mei/mei_dev.h
> +++ b/drivers/misc/mei/mei_dev.h
> @@ -356,7 +356,7 @@ struct mei_hw_ops {
>  /* MEI bus API*/
>  void mei_cl_bus_rescan_work(struct work_struct *work);  void
> mei_cl_bus_dev_fixup(struct mei_cl_device *dev); -ssize_t
> __mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length, u8 vtag,
> +ssize_t __mei_cl_send(struct mei_cl *cl, const u8 *buf, size_t length,
> +u8 vtag,
>  		      unsigned int mode);
>  ssize_t __mei_cl_recv(struct mei_cl *cl, u8 *buf, size_t length, u8 *vtag,
>  		      unsigned int mode, unsigned long timeout); diff --git
> a/include/linux/mei_cl_bus.h b/include/linux/mei_cl_bus.h index
> 07f5ef8fc456..c6786c12b207 100644
> --- a/include/linux/mei_cl_bus.h
> +++ b/include/linux/mei_cl_bus.h
> @@ -91,12 +91,13 @@ void mei_cldev_driver_unregister(struct
> mei_cl_driver *cldrv);
>  		      mei_cldev_driver_register,\
>  		      mei_cldev_driver_unregister)
> 
> -ssize_t mei_cldev_send(struct mei_cl_device *cldev, u8 *buf, size_t length);
> +ssize_t mei_cldev_send(struct mei_cl_device *cldev, const u8 *buf,
> +		       size_t length);
>  ssize_t mei_cldev_recv(struct mei_cl_device *cldev, u8 *buf, size_t length);
> ssize_t mei_cldev_recv_nonblock(struct mei_cl_device *cldev, u8 *buf,
>  				size_t length);
> -ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, u8 *buf, size_t
> length,
> -			    u8 vtag);
> +ssize_t mei_cldev_send_vtag(struct mei_cl_device *cldev, const u8 *buf,
> +			    size_t length, u8 vtag);
>  ssize_t mei_cldev_recv_vtag(struct mei_cl_device *cldev, u8 *buf, size_t
> length,
>  			    u8 *vtag);
>  ssize_t mei_cldev_recv_nonblock_vtag(struct mei_cl_device *cldev, u8
> *buf, @@ -114,6 +115,6 @@ void mei_cldev_set_drvdata(struct
> mei_cl_device *cldev, void *data);
> 
>  int mei_cldev_enable(struct mei_cl_device *cldev);  int
> mei_cldev_disable(struct mei_cl_device *cldev); -bool
> mei_cldev_enabled(struct mei_cl_device *cldev);
> +bool mei_cldev_enabled(const struct mei_cl_device *cldev);
> 
>  #endif /* _LINUX_MEI_CL_BUS_H */
> --
> 2.27.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-29 12:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29 10:28 [PATCH] mei: constify passed buffers and structures Krzysztof Kozlowski
2021-07-29 10:59 ` Arnd Bergmann
2021-07-29 12:28 ` Winkler, Tomas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.