[v2,09/23] firmware: use static inline for to_fw_priv()
diff mbox

Message ID 20171120182409.27348-10-mcgrof@kernel.org
State New
Headers show

Commit Message

Luis Chamberlain Nov. 20, 2017, 6:23 p.m. UTC
This lets us type check the callers.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
---
 drivers/base/firmware_class.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Greg KH Nov. 29, 2017, 10:14 a.m. UTC | #1
On Mon, Nov 20, 2017 at 10:23:55AM -0800, Luis R. Rodriguez wrote:
> This lets us type check the callers.
> 
> Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
> ---
>  drivers/base/firmware_class.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
> index dcc1281789e4..4f64410fe7e6 100644
> --- a/drivers/base/firmware_class.c
> +++ b/drivers/base/firmware_class.c
> @@ -125,7 +125,10 @@ struct fw_name_devm {
>  	const char *name;
>  };
>  
> -#define to_fw_priv(d) container_of(d, struct fw_priv, ref)
> +static inline struct fw_priv *to_fw_priv(struct kref *ref)
> +{
> +	return container_of(ref, struct fw_priv, ref);
> +}

It's a kref, no need to typecheck anything, if it isn't the right
structure it will usually just break the build anyway.  So this isn't
really needed, especially as most of the to_* calls in the kernel are
macros like this.

I'll take it, but really, this isn't needed, you are only trying to
protect yourself from your own coding :)

greg k-h

Patch
diff mbox

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index dcc1281789e4..4f64410fe7e6 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -125,7 +125,10 @@  struct fw_name_devm {
 	const char *name;
 };
 
-#define to_fw_priv(d) container_of(d, struct fw_priv, ref)
+static inline struct fw_priv *to_fw_priv(struct kref *ref)
+{
+	return container_of(ref, struct fw_priv, ref);
+}
 
 #define	FW_LOADER_NO_CACHE	0
 #define	FW_LOADER_START_CACHE	1