lkml.org 
[lkml]   [2022]   [Dec]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/4] firmware_loader: fix up to_fw_sysfs() to preserve const
Date
to_fw_sysfs() was changed in commit 23680f0b7d7f ("driver core: make
struct class.dev_uevent() take a const *") to pass in a const pointer
but not pass it back out to handle some changes in the driver core.
That isn't the best idea as it could cause problems if used incorrectly,
so switch to use the container_of_const() macro instead which will
preserve the const status of the pointer and enforce it by the compiler.

Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Russ Weight <russell.h.weight@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Fixes: 23680f0b7d7f ("driver core: make struct class.dev_uevent() take a const *")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/base/firmware_loader/sysfs.h | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/base/firmware_loader/sysfs.h b/drivers/base/firmware_loader/sysfs.h
index fd0b4ad9bdbb..0f0b1f7bf335 100644
--- a/drivers/base/firmware_loader/sysfs.h
+++ b/drivers/base/firmware_loader/sysfs.h
@@ -80,11 +80,8 @@ struct fw_sysfs {
struct firmware *fw;
void *fw_upload_priv;
};
-
-static inline struct fw_sysfs *to_fw_sysfs(const struct device *dev)
-{
- return container_of(dev, struct fw_sysfs, dev);
-}
+#define to_fw_sysfs(__dev) \
+ container_of_const(struct device, __dev, struct fw_sysfs, dev)

void __fw_load_abort(struct fw_priv *fw_priv);

--
2.38.1
\
 
 \ /
  Last update: 2022-12-01 20:33    [W:0.099 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site