All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Thomas Koeller <thomas.koeller@baslerweb.com>
Cc: linux-mtd@lists.infradead.org, linux-mips@linux-mips.org
Subject: Re: [PATCH] eXcite nand flash driver
Date: Thu, 08 Feb 2007 16:48:57 +0100	[thread overview]
Message-ID: <1170949737.3646.29.camel@chaos> (raw)
In-Reply-To: <200702080157.25432.thomas.koeller@baslerweb.com>

On Thu, 2007-02-08 at 01:57 +0100, Thomas Koeller wrote:

> +static inline const struct resource *excite_nand_get_resource
> +    (struct platform_device *d, unsigned long flags, const char *basename) {

Move curly bracket to new line.

> +	const char fmt[] = "%s_%u";

Please move the format into the snprintf

> +	char buf[80];
> +
> +	if (unlikely
> +	    (snprintf(buf, sizeof buf, fmt, basename, d->id) >= sizeof buf))
> +		return NULL;

Useless unlikely

> +	return platform_get_resource_byname(d, flags, buf);
> +}
> +
> +static inline io_reg_t
> +excite_nand_map_regs(struct platform_device *d, const char *basename)
> +{
> +	void *result = NULL;
> +	const struct resource *const r =
> +	    excite_nand_get_resource(d, IORESOURCE_MEM, basename);

Blank line between variable declaration and code.

> +	if (likely(r))
> +		result = ioremap_nocache(r->start, r->end + 1 - r->start);

Useless likely

> +	return result;
> +}


> +/* command and control functions */
> +static void excite_nand_control(struct mtd_info *mtd, int cmd,
> +				       unsigned int ctrl)
> +{
> +	io_reg_t regs =
> +	    container_of(mtd, struct excite_nand_drvdata, board_mtd)->regs;
> +	static void __iomem *tgt = NULL;
> +
> +	switch (ctrl) {
> +	case NAND_CTRL_CHANGE | NAND_CTRL_CLE:
> +		tgt = regs + EXCITE_NANDFLASH_CMD_BYTE;
> +		break;
> +	case NAND_CTRL_CHANGE | NAND_CTRL_ALE:
> +		tgt = regs + EXCITE_NANDFLASH_ADDR_BYTE;
> +		break;
> +	case NAND_CTRL_CHANGE | NAND_NCE:
> +		tgt = regs + EXCITE_NANDFLASH_DATA_BYTE;
> +		break;
> +	}

Err, did this ever work ? I doubt it. From nand_base.c:

                chip->cmd_ctrl(mtd, page_addr, ctrl);                                                                                                        
                ctrl &= ~NAND_CTRL_CHANGE;                                                                                                                   
                chip->cmd_ctrl(mtd, page_addr >> 8, ctrl);  

So I expect an OOPS happens on a regular base.

> +static int excite_nand_devready(struct mtd_info *mtd)
> +{
> +	struct excite_nand_drvdata * const drvdata =
> +	    container_of(mtd, struct excite_nand_drvdata, board_mtd);

Blank line missing

> +	return io_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS_BYTE);
> +}
> +
> +/* excite_nand_remove
> + *
> + * called by device layer to remove the driver
> + * the binding to the mtd and all allocated
> + * resources are released
> + */
> +static int __exit excite_nand_remove(struct device *dev)
> +{
> +	struct excite_nand_drvdata * const this = dev_get_drvdata(dev);
> +
> +	dev_set_drvdata(dev, NULL);
> +
> +	if (unlikely(!this)) {
> +		printk(KERN_ERR "%s: called %s without private data!!",
> +		       module_id, __func__);
> +		return -EINVAL;
> +	}
> +
> +	/* first thing we need to do is release our mtd
> +	 * then go through freeing the resource used
> +	 */
> +	nand_release(&this->board_mtd);
> +
> +	/* free the common resources */
> +	if (likely(this->regs)) {

Why should you ever come here with no mapping ?

	tglx

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: Thomas Koeller <thomas.koeller@baslerweb.com>
Cc: linux-mips@linux-mips.org, linux-mtd@lists.infradead.org
Subject: Re: [PATCH] eXcite nand flash driver
Date: Thu, 08 Feb 2007 16:48:57 +0100	[thread overview]
Message-ID: <1170949737.3646.29.camel@chaos> (raw)
In-Reply-To: <200702080157.25432.thomas.koeller@baslerweb.com>

On Thu, 2007-02-08 at 01:57 +0100, Thomas Koeller wrote:

> +static inline const struct resource *excite_nand_get_resource
> +    (struct platform_device *d, unsigned long flags, const char *basename) {

Move curly bracket to new line.

> +	const char fmt[] = "%s_%u";

Please move the format into the snprintf

> +	char buf[80];
> +
> +	if (unlikely
> +	    (snprintf(buf, sizeof buf, fmt, basename, d->id) >= sizeof buf))
> +		return NULL;

Useless unlikely

> +	return platform_get_resource_byname(d, flags, buf);
> +}
> +
> +static inline io_reg_t
> +excite_nand_map_regs(struct platform_device *d, const char *basename)
> +{
> +	void *result = NULL;
> +	const struct resource *const r =
> +	    excite_nand_get_resource(d, IORESOURCE_MEM, basename);

Blank line between variable declaration and code.

> +	if (likely(r))
> +		result = ioremap_nocache(r->start, r->end + 1 - r->start);

Useless likely

> +	return result;
> +}


> +/* command and control functions */
> +static void excite_nand_control(struct mtd_info *mtd, int cmd,
> +				       unsigned int ctrl)
> +{
> +	io_reg_t regs =
> +	    container_of(mtd, struct excite_nand_drvdata, board_mtd)->regs;
> +	static void __iomem *tgt = NULL;
> +
> +	switch (ctrl) {
> +	case NAND_CTRL_CHANGE | NAND_CTRL_CLE:
> +		tgt = regs + EXCITE_NANDFLASH_CMD_BYTE;
> +		break;
> +	case NAND_CTRL_CHANGE | NAND_CTRL_ALE:
> +		tgt = regs + EXCITE_NANDFLASH_ADDR_BYTE;
> +		break;
> +	case NAND_CTRL_CHANGE | NAND_NCE:
> +		tgt = regs + EXCITE_NANDFLASH_DATA_BYTE;
> +		break;
> +	}

Err, did this ever work ? I doubt it. From nand_base.c:

                chip->cmd_ctrl(mtd, page_addr, ctrl);                                                                                                        
                ctrl &= ~NAND_CTRL_CHANGE;                                                                                                                   
                chip->cmd_ctrl(mtd, page_addr >> 8, ctrl);  

So I expect an OOPS happens on a regular base.

> +static int excite_nand_devready(struct mtd_info *mtd)
> +{
> +	struct excite_nand_drvdata * const drvdata =
> +	    container_of(mtd, struct excite_nand_drvdata, board_mtd);

Blank line missing

> +	return io_readb(drvdata->regs + EXCITE_NANDFLASH_STATUS_BYTE);
> +}
> +
> +/* excite_nand_remove
> + *
> + * called by device layer to remove the driver
> + * the binding to the mtd and all allocated
> + * resources are released
> + */
> +static int __exit excite_nand_remove(struct device *dev)
> +{
> +	struct excite_nand_drvdata * const this = dev_get_drvdata(dev);
> +
> +	dev_set_drvdata(dev, NULL);
> +
> +	if (unlikely(!this)) {
> +		printk(KERN_ERR "%s: called %s without private data!!",
> +		       module_id, __func__);
> +		return -EINVAL;
> +	}
> +
> +	/* first thing we need to do is release our mtd
> +	 * then go through freeing the resource used
> +	 */
> +	nand_release(&this->board_mtd);
> +
> +	/* free the common resources */
> +	if (likely(this->regs)) {

Why should you ever come here with no mapping ?

	tglx

  parent reply	other threads:[~2007-02-08 15:49 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08  0:57 [PATCH] eXcite nand flash driver Thomas Koeller
2007-02-08  8:20 ` Ulrich Eckhardt
2007-02-08 10:20   ` Thomas Koeller
2007-02-08 13:50 ` Josh Boyer
2007-02-08 13:50   ` Josh Boyer
2007-02-08 13:55   ` Artem Bityutskiy
2007-02-08 13:55     ` Artem Bityutskiy
2007-02-08 15:48 ` Thomas Gleixner [this message]
2007-02-08 15:48   ` Thomas Gleixner
2007-02-10 10:22   ` Thomas Koeller
2007-02-10 10:22     ` Thomas Koeller
2007-02-11 15:44     ` Thomas Gleixner
2007-02-11 15:44       ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2007-02-10 10:21 Thomas Koeller
2007-02-11 15:50 ` Thomas Gleixner

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=1170949737.3646.29.camel@chaos \
    --to=tglx@linutronix.de \
    --cc=linux-mips@linux-mips.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=thomas.koeller@baslerweb.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.