[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<TY0PR06MB496072786197162F19ED7DDD89D62@TY0PR06MB4960.apcprd06.prod.outlook.com>
Date: Mon, 10 Mar 2025 10:05:37 +0000
From: Kevin Chen <kevin_chen@...eedtech.com>
To: Krzysztof Kozlowski <krzk@...nel.org>, "lee@...nel.org" <lee@...nel.org>,
"robh@...nel.org" <robh@...nel.org>, "krzk+dt@...nel.org"
<krzk+dt@...nel.org>, "conor+dt@...nel.org" <conor+dt@...nel.org>,
"joel@....id.au" <joel@....id.au>, "andrew@...econstruct.com.au"
<andrew@...econstruct.com.au>, "derek.kiernan@....com"
<derek.kiernan@....com>, "dragan.cvetic@....com" <dragan.cvetic@....com>,
"arnd@...db.de" <arnd@...db.de>, "gregkh@...uxfoundation.org"
<gregkh@...uxfoundation.org>, "devicetree@...r.kernel.org"
<devicetree@...r.kernel.org>, "linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>, "linux-aspeed@...ts.ozlabs.org"
<linux-aspeed@...ts.ozlabs.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v2 3/3] soc: aspeed: lpc-pcc: Add PCC controller support
> On 04/03/2025 11:44, Kevin Chen wrote:
> > +
> > +static int aspeed_pcc_probe(struct platform_device *pdev) {
> > + int rc;
> > + struct aspeed_pcc_ctrl *pcc;
> > + struct device *dev;
> > + uint32_t fifo_size = PAGE_SIZE;
> > +
> > + dev = &pdev->dev;
>
> This goes to declaration.
OK. I will move it to declaration.
>
> > +
> > + pcc = devm_kzalloc(&pdev->dev, sizeof(*pcc), GFP_KERNEL);
>
> Maybe my previous comment was not clear, but you agreed with it. Anyway
> nothing improved here.
Could I reserve the pcc variable using for the pcc_ctrl data structure?
Pcc_ctrl data include the regmap/irq/io_port/dma/kfifo.
If I change the name to dev, it does not make sense for these data to be.
>
> If you have 'dev' variable, use it.
Do you mean just use the pdev->dev not local dev variable?
>
> > + if (!pcc)
> > + return -ENOMEM;
> > +
> > + pcc->regmap = syscon_node_to_regmap(pdev->dev.parent->of_node);
>
> same here and everywhere else.
>
> > + if (IS_ERR(pcc->regmap)) {
> > + dev_err(dev, "Couldn't get regmap\n");
> > + return -ENODEV;
> > + }
> > +
> > + rc = of_property_read_u32(dev->of_node, "pcc-ports", &pcc->port);
> > + if (rc) {
> > + dev_err(dev, "no pcc ports configured\n");
> > + return -ENODEV;
> > + }
> > +
> > + rc = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
> > + if (rc) {
> > + dev_err(dev, "cannot set 64-bits DMA mask\n");
> > + return rc;
> > + }
> > +
> > + pcc->dma.size = PCC_DMA_BUFSZ;
> > + pcc->dma.virt = dmam_alloc_coherent(dev,
> > + pcc->dma.size,
> > + &pcc->dma.addr,
> > + GFP_KERNEL);
> > + if (!pcc->dma.virt) {
> > + dev_err(dev, "cannot allocate DMA buffer\n");
> > + return -ENOMEM;
> > + }
> > +
> > + fifo_size = roundup(pcc->dma.size, PAGE_SIZE);
> > + rc = kfifo_alloc(&pcc->fifo, fifo_size, GFP_KERNEL);
> > + if (rc) {
> > + dev_err(dev, "cannot allocate kFIFO\n");
>
> Drop
Agree.
>
> > + return -ENOMEM;
> > + }
> > +
> > + /* Disable PCC to clean up DMA buffer before request IRQ. */
> > + rc = aspeed_pcc_disable(pcc);
> > + if (rc) {
> > + dev_err(dev, "Couldn't disable PCC\n");
> > + goto err_free_kfifo;
> > + }
> > +
> > + pcc->irq = platform_get_irq(pdev, 0);
> > + if (pcc->irq < 0) {
> > + dev_err(dev, "Couldn't get IRQ\n");
>
> Drop, core already prints this. Do not duplicate messages.
Agree.
>
> > + rc = -ENODEV;
>
> Why not using pcc->irq as rc?
Agree.
>
> > + goto err_free_kfifo;
> > + }
> > +
> Best regards,
> Krzysztof
Powered by blists - more mailing lists