From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932261AbdK2KOJ (ORCPT ); Wed, 29 Nov 2017 05:14:09 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:55876 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752468AbdK2KOF (ORCPT ); Wed, 29 Nov 2017 05:14:05 -0500 Date: Wed, 29 Nov 2017 11:14:03 +0100 From: Greg KH To: "Luis R. Rodriguez" Cc: akpm@linux-foundation.org, keescook@chromium.org, mfuzzey@parkeon.com, zohar@linux.vnet.ibm.com, dhowells@redhat.com, pali.rohar@gmail.com, tiwai@suse.de, arend.vanspriel@broadcom.com, zajec5@gmail.com, nbroeking@me.com, markivx@codeaurora.org, stephen.boyd@linaro.org, broonie@kernel.org, dmitry.torokhov@gmail.com, dwmw2@infradead.org, torvalds@linux-foundation.org, Abhay_Salunke@dell.com, bjorn.andersson@linaro.org, jewalt@lgsinnovations.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2 09/23] firmware: use static inline for to_fw_priv() Message-ID: <20171129101403.GA29506@kroah.com> References: <20171120182409.27348-1-mcgrof@kernel.org> <20171120182409.27348-10-mcgrof@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171120182409.27348-10-mcgrof@kernel.org> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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