public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Bjorn Eriksson" <mdeans@algonet.se>
To: "Steven J. Hill" <sjhill@cotw.com>, "MTD List" <mtd@infradead.org>
Subject: Re: First release of NAND flash device driver... / Comments
Date: Tue, 3 Oct 2000 13:50:29 +0200	[thread overview]
Message-ID: <001001c02d30$20a2e380$0800a8c0@win95.inteloop.se> (raw)
In-Reply-To: <39D44220.FB9C32E4@cotw.com>


 I've had quick peek at your code this morning. I hope to spend some more
time on this issue this week. I started out trying to understand why you
want a 'static u_char *ecc_read_buf;' (uppercase initial-letter or some such
would be nice IMHO) but instead stumbled upon spia_init() (which is 'void'
BTW, perhaps it should be 'int' and return -ENOMEM etc.).

 Small change suggestion: [I know this will forever mark me as a wanker who
can't read others code...]

The code in question: (spia_init())
	/* Allocate memory for MTD device structure and private data */
	spia_mtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_info),
				GFP_KERNEL);
	if (!spia_mtd) {
		printk("Unable to allocate SPIA NAND MTD device structure.\n");
		return;
	}

	/* Get pointer to private data */
	this = (struct nand_info *) (&spia_mtd[1]);

	/* Initialize structures */
	memset((char *) spia_mtd, 0, sizeof(struct mtd_info));
	memset((char *) this, 0, sizeof(struct nand_info));

	/* Link the private data with the MTD structure */
	spia_mtd->priv = this;

I think this makes the intent clearer:

	/* Allocate memory for MTD device structure and private data */
	struct combined_kmalloc_struct {		/* Struct for combined kmalloc()
		struct mtd_info mtd_info_struct;	 * of mtd_info_struct and ...
		struct nand_info nand_info_struct;	 * nand_info_struct. */
	} *p = kmalloc(sizeof(struct combined_kmalloc_struct), GFP_KERNEL);

	if (!p) {
		printk("Unable to allocate SPIA NAND MTD device structure.\n");
		return -ENOMEM;
	}

	/* Initialize structures */
	memset((char *)p, 0, sizeof(*p));

	/* Get pointers to private data */
	spia_mtd = &p->mtd_info_struct;
	spia_mtd->priv = this = &p->nand_info_struct;

 I assume (never a good idea) that the intent is to reduce the kmalloc()
overhead.


--
//Björnen [I'll go into hiding now...]




To unsubscribe, send "unsubscribe mtd" to majordomo@infradead.org

      reply	other threads:[~2000-10-03 11:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-29  7:17 First release of NAND flash device driver Steven J. Hill
2000-10-03 11:50 ` Bjorn Eriksson [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='001001c02d30$20a2e380$0800a8c0@win95.inteloop.se' \
    --to=mdeans@algonet.se \
    --cc=mtd@infradead.org \
    --cc=sjhill@cotw.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