From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752165AbbJFIsJ (ORCPT ); Tue, 6 Oct 2015 04:48:09 -0400 Received: from mail-wi0-f174.google.com ([209.85.212.174]:36225 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbbJFIsF (ORCPT ); Tue, 6 Oct 2015 04:48:05 -0400 Date: Tue, 6 Oct 2015 09:47:50 +0100 From: Mike Rapoport To: itai.katz@freescale.com Cc: gregkh@linuxfoundation.org, arnd@arndb.de, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, stuart.yoder@freescale.com, bhupesh.sharma@freescale.com, german.rivera@freescale.com, agraf@suse.de, bhamciu1@freescale.com, nir.erez@freescale.com, scottwood@freescale.com, lijun.pan@freescale.com, R89243@freescale.com, dan.carpenter@oracle.com, richard.schmitt@freescale.com Subject: Re: [PATCH 2/5] staging: fsl-mc: abstract test for whether a dprc is a root dprc Message-ID: <20151006084750.GA25573@zed.theccd.local> References: <1443942594-7189-1-git-send-email-itai.katz@freescale.com> <1443942594-7189-3-git-send-email-itai.katz@freescale.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1443942594-7189-3-git-send-email-itai.katz@freescale.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 04, 2015 at 10:09:51AM +0300, itai.katz@freescale.com wrote: > From: Itai Katz > > Instead of relying on assumptions about fields in data > structures, abstract the test for whether a dprc is a root > dprc into a function. > > Signed-off-by: Itai Katz > --- > drivers/staging/fsl-mc/bus/mc-bus.c | 16 +++++++++++++--- > 1 file changed, 13 insertions(+), 3 deletions(-) > > diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c > index 2aaeb3a..6a6c5a6 100644 > --- a/drivers/staging/fsl-mc/bus/mc-bus.c > +++ b/drivers/staging/fsl-mc/bus/mc-bus.c > @@ -22,6 +22,8 @@ > > static struct kmem_cache *mc_dev_cache; > > +static bool fsl_mc_is_root_dprc(struct device *dev); Prefer defining functions before they are used rather than using forward declarations. > + > /** > * fsl_mc_bus_match - device to driver matching callback > * @dev: the MC object device structure to match against > @@ -50,7 +52,7 @@ static int fsl_mc_bus_match(struct device *dev, struct device_driver *drv) > * Only exception is the root DPRC, which is a special case. > */ > if ((mc_dev->obj_desc.state & DPRC_OBJ_STATE_PLUGGED) == 0 && > - &mc_dev->dev != fsl_mc_bus_type.dev_root) > + !fsl_mc_is_root_dprc(&mc_dev->dev)) > goto out; > > /* > @@ -215,6 +217,14 @@ bool fsl_mc_bus_exists(void) > } > EXPORT_SYMBOL_GPL(fsl_mc_bus_exists); > > +/** > + * fsl_mc_is_root_dprc - function to check if a given device is a root dprc > + */ > +static bool fsl_mc_is_root_dprc(struct device *dev) > +{ > + return dev == fsl_mc_bus_type.dev_root; > +} > + > static int get_dprc_icid(struct fsl_mc_io *mc_io, > int container_id, u16 *icid) > { > @@ -500,7 +510,7 @@ void fsl_mc_device_remove(struct fsl_mc_device *mc_dev) > mc_dev->mc_io = NULL; > } > > - if (&mc_dev->dev == fsl_mc_bus_type.dev_root) > + if (fsl_mc_is_root_dprc(&mc_dev->dev)) > fsl_mc_bus_type.dev_root = NULL; > } > > @@ -726,7 +736,7 @@ static int fsl_mc_bus_remove(struct platform_device *pdev) > { > struct fsl_mc *mc = platform_get_drvdata(pdev); > > - if (WARN_ON(&mc->root_mc_bus_dev->dev != fsl_mc_bus_type.dev_root)) > + if (WARN_ON(!fsl_mc_is_root_dprc(&mc->root_mc_bus_dev->dev))) > return -EINVAL; > > fsl_mc_device_remove(mc->root_mc_bus_dev); > -- > 1.7.9.5 > > _______________________________________________ > devel mailing list > devel@linuxdriverproject.org > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel