public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: andy.shevchenko@gmail.com
Cc: Nikita Shubin <nikita.shubin@maquefel.me>,
	Alexander Sverdlin <alexander.sverdlin@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Linus Walleij <linus.walleij@linaro.org>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	Stephen Boyd <sboyd@kernel.org>,
	Christophe Kerello <christophe.kerello@foss.st.com>,
	Jean Delvare <jdelvare@suse.de>,
	Liang Yang <liang.yang@amlogic.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Michael Peters <mpeters@embeddedts.com>,
	Kris Bahnsen <kris@embeddedts.com>,
	linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH v1 24/43] mtd: nand: add support for ts72xx
Date: Mon, 5 Jun 2023 10:22:08 +0200	[thread overview]
Message-ID: <20230605102208.4e6d26f3@xps-13> (raw)
In-Reply-To: <ZHugqa697eGqHnr4@surfacebook>

Hi andy.shevchenko@gmail.com,

andy.shevchenko@gmail.com wrote on Sat, 3 Jun 2023 23:20:57 +0300:

> Thu, Jun 01, 2023 at 08:45:29AM +0300, Nikita Shubin kirjoitti:
> > Technologic Systems has it's own nand controller implementation in CPLD.
> > 
> > This patch adds support for TS-72XX boards family.  
> 
> Use imperative mode, this is documented in the Submitting Patches,
> 
> ...
> 
> > +/*
> > + * Technologic Systems TS72xx NAND controller driver
> > + *
> > + * Copyright (C) 2023 Nikita Shubin <nikita.shubin@maquefel.me>
> > + *
> > + * derived: plat_nand.c  
> 
> Derived from:
> 
> > + *  Author: Vitaly Wool <vitalywool@gmail.com>
> > + */  
> 
> ...
> 
> > +#include <linux/err.h>
> > +#include <linux/io.h>
> > +#include <linux/module.h>
> > +#include <linux/platform_device.h>
> > +#include <linux/slab.h>  
> 
> + Blank line?
> 
> > +#include <linux/mtd/mtd.h>
> > +#include <linux/mtd/platnand.h>  
> 
> ...
> 
> > +		bits = readb(addr) & ~0x07;  
> 
> GENMASK()?
> 
> ...
> 
> > +	addr += (1 << TS72XX_NAND_BUSY_ADDR_LINE);  
> 
> BIT() ?
> 
> ...
> 
> > +	return !!(readb(addr) & 0x20);  
> 
> BIT() ?
> 
> ...
> 
> > +	struct ts72xx_nand_data *data;
> > +	struct mtd_info *mtd;
> > +	int err = 0;  
> 
> Redundant assignment.
> 
> > +	/* Allocate memory for the device structure (and zero it) */
> > +	data = devm_kzalloc(&pdev->dev, sizeof(struct ts72xx_nand_data),  
> 
> sizeof(*data) and make it a single line.
> 
> > +			    GFP_KERNEL);
> > +	if (!data)
> > +		return -ENOMEM;  
> 
> ...
> 
> > +	nand_set_flash_node(&data->chip, pdev->dev.of_node);  
> 
> Hmm... wondering why this uses OF node instead of fwnode... But okay, this is
> question to the subsystem maintaners.
> 
> 
> > +	err = mtd_device_parse_register(mtd, NULL, NULL,
> > +					NULL, 0);  
> 
> There is plenty of space on the previous line.
> 
> > +  
> 
> Redundant blank line.
> 
> > +	if (!err)
> > +		return err;
> > +
> > +	nand_cleanup(&data->chip);
> > +
> > +	return 0;  
> 
> This seems at least weird and rather broken.

Yeah, I made the same comment.

> To me it looks like
> 
> 	if (err) {
> 		nand_cleanup(&data->chip);
> 		return err;
> 	}
> 
> 	return 0;
> 
> has to be here.
> 
> > +}  
> 
> ...
> 
> > +	ret = mtd_device_unregister(nand_to_mtd(chip));
> > +	WARN_ON(ret);  
> 
> WARN_ON()?! Why?

This is actually something that is expected for now, the device
unregistration should not fail and the return value should not be used
to skip other cleanups. I cannot find the original discussion anymore
but we decided to use that construction. We might actually switch that
one to void someday.

> 
> > +	nand_cleanup(chip);
> > +}  
> 


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      reply	other threads:[~2023-06-05  8:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 12:34 [PATCH 00/43] ep93xx device tree conversion Nikita Shubin
2023-04-24 11:31 ` Arnd Bergmann
2023-04-24 22:29   ` Jakub Kicinski
2023-04-25  9:20     ` Krzysztof Kozlowski
2023-04-25 13:27       ` Arnd Bergmann
2023-04-24 12:34 ` [PATCH 22/43] dt-bindings: mtd: add DT bindings for ts7250 nand Nikita Shubin
2023-04-24 16:17   ` Rob Herring
2023-05-02  9:48   ` Miquel Raynal
2023-05-15 15:48     ` Nikita Shubin
2023-05-22 14:18       ` Miquel Raynal
2023-04-24 12:34 ` [PATCH 23/43] mtd: ts72xx_nand: add platform helper Nikita Shubin
2023-04-26 20:56 ` [PATCH 00/43] ep93xx device tree conversion Linus Walleij
2023-04-26 21:01   ` Mark Brown
2023-04-26 21:06     ` Linus Walleij
2023-05-16  3:47 ` Florian Fainelli
2023-05-16 10:37   ` Nikita Shubin
2023-06-01  5:45 ` [PATCH v1 23/43] dt-bindings: mtd: Add ts7250 nand-controller Nikita Shubin
2023-06-01  7:45   ` Miquel Raynal
2023-06-01  8:11   ` Krzysztof Kozlowski
2023-06-01  5:45 ` [PATCH v1 24/43] mtd: nand: add support for ts72xx Nikita Shubin
2023-06-01  7:49   ` Miquel Raynal
2023-06-03 20:20   ` andy.shevchenko
2023-06-05  8:22     ` Miquel Raynal [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230605102208.4e6d26f3@xps-13 \
    --to=miquel.raynal@bootlin.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alexander.sverdlin@gmail.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=arnd@arndb.de \
    --cc=christophe.kerello@foss.st.com \
    --cc=f.fainelli@gmail.com \
    --cc=jdelvare@suse.de \
    --cc=kris@embeddedts.com \
    --cc=liang.yang@amlogic.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mpeters@embeddedts.com \
    --cc=nikita.shubin@maquefel.me \
    --cc=richard@nod.at \
    --cc=sboyd@kernel.org \
    --cc=vigneshr@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox