From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2665AC77B73 for ; Sat, 3 Jun 2023 20:39:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RANRtGEi9hTOPRM0Dh/p19KqM6t3SvSRJbh2xuaKUJI=; b=1tcGVkmogq6mMr N2wlrZ1GALL2TRrf3fawqhqzFMhcuYPcR6YqTeLCtQxTnrVSgLtra2vy3vt8norTAaB3FS3956IbX oo4YhdGSVohaP0woxPnsf7obTSmT0fYK2BTyBVR18SaYI40ByYGlhBRhFnu9HL9mawWceJgzfDXf2 lL8SyTpAQzIjvffevStKP86C3FqvPdtjJ9tjfjsdgb5kdmReV8q7MWTwy0I3HDQkpbr0MRiTF1zxo 9IjfV72uOVi+DdxcITxOneHwbRJdD7o+yyRf0hiD0ZZr8XnPVEpKXqF/wkEKmdCPIDRR4J+PExlGE F9sNvGGhUuAVjlKfh9Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q5Y1n-00AYAH-09; Sat, 03 Jun 2023 20:39:11 +0000 Received: from fgw23-7.mail.saunalahti.fi ([62.142.5.84]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q5Y1j-00AY9a-20 for linux-arm-kernel@lists.infradead.org; Sat, 03 Jun 2023 20:39:09 +0000 Received: from localhost (88-113-26-95.elisa-laajakaista.fi [88.113.26.95]) by fgw23.mail.saunalahti.fi (Halon) with ESMTP id ae644b8c-024e-11ee-b972-005056bdfda7; Sat, 03 Jun 2023 23:39:05 +0300 (EEST) From: andy.shevchenko@gmail.com Date: Sat, 3 Jun 2023 23:39:05 +0300 To: Nikita Shubin Cc: Alexander Sverdlin , Arnd Bergmann , Linus Walleij , Hartley Sweeten , Russell King , Vinod Koul , Michael Peters , Kris Bahnsen , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org Subject: Re: [PATCH v1 22/43] dma: cirrus: add DT support for Cirrus EP93xx Message-ID: References: <20230424123522.18302-1-nikita.shubin@maquefel.me> <20230601054549.10843-4-nikita.shubin@maquefel.me> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20230601054549.10843-4-nikita.shubin@maquefel.me> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230603_133908_008084_625E2ADA X-CRM114-Status: GOOD ( 19.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Thu, Jun 01, 2023 at 08:45:27AM +0300, Nikita Shubin kirjoitti: > - find register range from the device tree > - get clocks, interrupts from device tree ... > --- a/arch/arm/mach-ep93xx/dma.c > +++ b/arch/arm/mach-ep93xx/dma.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > #include > > #include Stray change. ... > --- a/drivers/dma/ep93xx_dma.c > +++ b/drivers/dma/ep93xx_dma.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include ... > - struct ep93xx_dma_chan channels[]; > + struct ep93xx_dma_chan *channels; Why? This is helpful to allocate main structure and channels in one go. ... > @@ -875,9 +881,11 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan) > if (!edmac->edma->m2m) { > if (!data) > return -EINVAL; > + > if (data->port < EP93XX_DMA_I2S1 || > data->port > EP93XX_DMA_IRDA) > return -EINVAL; > + > if (data->direction != ep93xx_dma_chan_direction(chan)) > return -EINVAL; > } else { Seems unrelated change. > ep93xx_dma_advance_work(to_ep93xx_dma_chan(chan)); > } ... > +static const struct of_device_id ep93xx_dma_of_ids[] = { > + { .compatible = "cirrus,ep9301-dma-m2p", .data = &edma_m2p }, > + { .compatible = "cirrus,ep9301-dma-m2m", .data = &edma_m2m }, > + { /* sentinel */ } > +}; > +MODULE_DEVICE_TABLE(of, ep93xx_dma_of_ids); Move this closer to the real user (see below). Also this ID table shouldn't be under ifdeffery. ... > + struct device_node *np = pdev->dev.of_node; > + const struct of_device_id *match = of_match_node(ep93xx_dma_of_ids, pdev->dev.of_node); > + const struct ep93xx_edma_data *data = match->data; No NULL check? Why do you have this duplication, btw? > + struct dma_device *dma_dev = &edma->dma_dev; > + int num_channels; > + int i; > + > + match = of_match_device((ep93xx_dma_of_ids), &pdev->dev); > + if (!match || !match->data) { > + dev_err(&pdev->dev, "No device match found\n"); > + return -ENODEV; > + } Use of_device_get_match_data(). ... > + edma->channels = devm_kzalloc(&pdev->dev, > + num_channels * sizeof(struct ep93xx_dma_chan), > + GFP_KERNEL); > + if (!edma->channels) > + return -ENOMEM; Simply no. See below what to do. ... > + for (i = 0; i < num_channels; i++) { > + struct ep93xx_dma_chan *edmac = &edma->channels[i]; > + > + edmac->chan.device = dma_dev; > + edmac->regs = devm_platform_ioremap_resource(pdev, i); No error check? > + edmac->irq = platform_get_irq(pdev, i); No error check? > + edmac->edma = edma; > + > + edmac->clk = of_clk_get(np, i); Can this actually use clk_get() or its devm_*() variant? > + Redundant blank line. > + if (IS_ERR(edmac->clk)) { > + dev_warn(&pdev->dev, "failed to get clock\n"); > + continue; > + } > + > + spin_lock_init(&edmac->lock); > + INIT_LIST_HEAD(&edmac->active); > + INIT_LIST_HEAD(&edmac->queue); > + INIT_LIST_HEAD(&edmac->free_list); > + tasklet_setup(&edmac->tasklet, ep93xx_dma_tasklet); > + > + list_add_tail(&edmac->chan.device_node, > + &dma_dev->channels); > + } ... > - edma_size = pdata->num_channels * sizeof(struct ep93xx_dma_chan); > - edma = kzalloc(sizeof(*edma) + edma_size, GFP_KERNEL); > - if (!edma) > + edma->channels = devm_kzalloc(&pdev->dev, > + pdata->num_channels * sizeof(struct ep93xx_dma_chan), > + GFP_KERNEL); > + if (!edma->channels) > return -ENOMEM; No. Just include overflow.h and use struct_size(). ... > + edma = devm_kzalloc(&pdev->dev, sizeof(*edma), GFP_KERNEL); > + No error check?! ... > + if (platform_get_device_id(pdev)) > + ret = ep93xx_init_from_pdata(pdev, edma); > + else > + ret = ep93xx_dma_of_probe(pdev, edma); > + Redundant blank line. > + if (ret) > + return ret; -- With Best Regards, Andy Shevchenko _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel