From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christoph Hellwig Subject: Re: [PATCH v2 1/2] dma-mapping: move dma configuration to bus infrastructure Date: Thu, 22 Mar 2018 09:15:30 +0100 Message-ID: <20180322081530.GA29444@lst.de> References: <1520868292-2479-1-git-send-email-nipun.gupta@nxp.com> <1521615323-4752-1-git-send-email-nipun.gupta@nxp.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <1521615323-4752-1-git-send-email-nipun.gupta-3arQi8VN3Tc@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Nipun Gupta Cc: zajec5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org, david.brown-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, thierry.reding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, hch-jcswGhMUV9g@public.gmane.org, vinod.koul-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, rafael.j.wysocki-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org, andy.gross-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, msuchanek-l3A5Bk7waGM@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-tegra-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-msm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, johan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org, bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, dan.j.williams-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org, linux-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, leoyang.li-3arQi8VN3Tc@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, dmaengine-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: devicetree@vger.kernel.org > +static int amba_dma_configure(struct device *dev) > +{ > + return dma_common_configure(dev); > +} So it turns out we only end with two callers of dma_common_configure after this series. Based ont hat I'm tempted with the suggestion from Robin to just have amba call platform_dma_configure, and move the code from dma_common_configure to platform_dma_configure. > +int dma_configure(struct device *dev) > +{ > + if (dev->bus->dma_configure) > + return dev->bus->dma_configure(dev); > + > + return 0; > +} > void dma_deconfigure(struct device *dev) As grep pointed out this wants a blank line after the function, and while in nitpicking mode I'd suggest to remove the blank line above the return statement while at it. > diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c > index 88a3558..fa9896d 100644 > --- a/drivers/gpu/host1x/bus.c > +++ b/drivers/gpu/host1x/bus.c > @@ -314,6 +314,14 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) > return strcmp(dev_name(dev), drv->name) == 0; > } > > +static int host1x_dma_configure(struct device *dev) > +{ > + if (dev->of_node) > + return of_dma_configure(dev, dev->of_node); > + > + return 0; Same here. > + */ > +static int pci_dma_configure(struct device *dev) > +{ > + struct device *bridge; > + enum dev_dma_attr attr; > + int ret = 0; > + > + bridge = pci_get_host_bridge_device(to_pci_dev(dev)); > + > + if (IS_ENABLED(CONFIG_OF) && bridge->parent && > + bridge->parent->of_node) { > + ret = of_dma_configure(dev, bridge->parent->of_node); > + } else if (has_acpi_companion(bridge)) { > + attr = acpi_get_dma_attr(to_acpi_device_node(bridge->fwnode)); > + if (attr != DEV_DMA_NOT_SUPPORTED) > + ret = acpi_dma_configure(dev, attr); > + } The attr declaration can be moved into the inner scope here. > + pci_put_host_bridge_device(bridge); > + > + return ret; Drop the blank line after the return, please.