Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1268663

Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver

From bayi cheng <bayi.cheng@mediatek.com>
Newsgroups linux.kernel
Subject Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver
Date 2015-11-13 08:30 +0100
Message-ID <qugY1-3nN-9@gated-at.bofh.it> (permalink)
References <qrRr4-6mq-19@gated-at.bofh.it> <qrRr4-6mq-17@gated-at.bofh.it> <qtLrb-8iQ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, 2015-11-11 at 13:41 -0800, Brian Norris wrote:
> One more small comment, since you're respinning this:
> 
> On Fri, Nov 06, 2015 at 11:48:08PM +0800, Bayi Cheng wrote:
> > diff --git a/drivers/mtd/spi-nor/mtk-quadspi.c b/drivers/mtd/spi-nor/mtk-quadspi.c
> > new file mode 100644
> > index 0000000..6582811
> > --- /dev/null
> > +++ b/drivers/mtd/spi-nor/mtk-quadspi.c
> > @@ -0,0 +1,475 @@
> 
> ...
> 
> > +static int mtk_nor_drv_probe(struct platform_device *pdev)
> > +{
> > +	struct device_node *flash_np;
> > +	struct resource *res;
> > +	int ret;
> > +	struct mt8173_nor *mt8173_nor;
> > +
> > +	if (!pdev->dev.of_node) {
> > +		dev_err(&pdev->dev, "No DT found\n");
> > +		return -EINVAL;
> > +	}
> > +
> > +	mt8173_nor = devm_kzalloc(&pdev->dev, sizeof(*mt8173_nor), GFP_KERNEL);
> > +	if (!mt8173_nor)
> > +		return -ENOMEM;
> > +	platform_set_drvdata(pdev, mt8173_nor);
> > +
> > +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > +	mt8173_nor->base = devm_ioremap_resource(&pdev->dev, res);
> > +	if (IS_ERR(mt8173_nor->base))
> > +		return PTR_ERR(mt8173_nor->base);
> > +
> > +	mt8173_nor->spi_clk = devm_clk_get(&pdev->dev, "spi");
> > +	if (IS_ERR(mt8173_nor->spi_clk)) {
> > +		ret = PTR_ERR(mt8173_nor->spi_clk);
> > +		goto nor_free;
> > +	}
> > +
> > +	mt8173_nor->nor_clk = devm_clk_get(&pdev->dev, "sf");
> > +	if (IS_ERR(mt8173_nor->nor_clk)) {
> > +		ret = PTR_ERR(mt8173_nor->nor_clk);
> > +		goto nor_free;
> > +	}
> > +
> > +	mt8173_nor->dev = &pdev->dev;
> > +	clk_prepare_enable(mt8173_nor->spi_clk);
> > +	clk_prepare_enable(mt8173_nor->nor_clk);
> 
> You enable the clocks here, but...
> 
> > +
> > +	/* only support one attached flash */
> > +	flash_np = of_get_next_available_child(pdev->dev.of_node, NULL);
> > +	if (!flash_np) {
> 
> ... you might bail out here if there is no available flash node, and you
> never disable the clocks. (Same is true if we fail to detect the flash;
> you leave the no-longer-needed clocks enabled.) Seems like maybe you
> should disable clocks on failure.

Yes, I have forgot to disable these clocks on failure. and I will fix it
in the next patch! Thanks!
> 
> > +		dev_err(&pdev->dev, "no SPI flash device to configure\n");
> > +		ret = -ENODEV;
> > +		goto nor_free;
> > +	}
> > +	ret = mtk_nor_init(mt8173_nor, flash_np);
> > +
> > +nor_free:
> > +	return ret;
> > +}
> 
> Brian


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver Bayi Cheng <bayi.cheng@mediatek.com> - 2015-11-06 16:50 +0100
  [PATCH] mtd: mtk-nor: fix compare_const_fl.cocci warnings kbuild test robot <lkp@intel.com> - 2015-11-06 18:30 +0100
  Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver Brian Norris <computersforpeace@gmail.com> - 2015-11-10 04:10 +0100
    Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver bayi cheng <bayi.cheng@mediatek.com> - 2015-11-11 15:00 +0100
  Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver Brian Norris <computersforpeace@gmail.com> - 2015-11-11 22:50 +0100
    Re: [PATCH v6 2/3] mtd: mtk-nor: mtk serial flash controller driver bayi cheng <bayi.cheng@mediatek.com> - 2015-11-13 08:30 +0100

csiph-web