From: Andrew Morton <akpm@linux-foundation.org>
To: Ryan Mallon <ryan@bluewatersys.com>
Cc: Linus Walleij <linus.ml.walleij@gmail.com>,
linux kernel <linux-kernel@vger.kernel.org>,
spi-devel-general@lists.sourceforge.net,
David Woodhouse <dwmw2@infradead.org>
Subject: Re: [PATCH] SST25L (non JEDEC) SPI Flash driver
Date: Wed, 24 Jun 2009 19:40:05 -0700 [thread overview]
Message-ID: <20090624194005.2f9574ce.akpm@linux-foundation.org> (raw)
In-Reply-To: <4A42BDF3.10901@bluewatersys.com>
On Thu, 25 Jun 2009 11:59:47 +1200 Ryan Mallon <ryan@bluewatersys.com> wrote:
> Add support for the non JEDEC SST25L SPI Flash devices.
>
> Signed-off-by: Andre Renaud <andre@bluewatersys.com>
> Signed-off-by: Ryan Mallon <ryan@bluewatersys.com>
> Acked-by: Linus Walleij <linus.walleij@stericsson.com>
It looks OK to my inexperienced eye.
> ...
>
> + bytes = min(mtd->writesize, (u32)(len - i));
The conventional way of suppressing the warning is min_t().
> +static int __init sst25l_probe(struct spi_device *spi)
> +{
> + struct flash_info *flash_info;
> + struct sst25l_flash *flash;
> + struct flash_platform_data *data;
> + int i;
> +
> + flash_info = sst25l_match_device(spi);
> + if (!flash_info)
> + return -ENODEV;
> +
> + flash = kzalloc(sizeof(struct sst25l_flash), GFP_KERNEL);
> + if (!flash)
> + return -ENOMEM;
> +
> + flash->spi = spi;
> + mutex_init(&flash->lock);
> + dev_set_drvdata(&spi->dev, flash);
> +
> + data = spi->dev.platform_data;
> + if (data && data->name)
> + flash->mtd.name = data->name;
> + else
> + flash->mtd.name = dev_name(&spi->dev);
> +
> + flash->mtd.type = MTD_NORFLASH;
> + flash->mtd.flags = MTD_CAP_NORFLASH;
> + flash->mtd.erasesize = flash_info->erase_size;
> + flash->mtd.writesize = flash_info->page_size;
> + flash->mtd.size = flash_info->page_size * flash_info->nr_pages;
> + flash->mtd.erase = sst25l_erase;
> + flash->mtd.read = sst25l_read;
> + flash->mtd.write = sst25l_write;
> +
> + dev_info(&spi->dev, "%s (%lld Kbytes)\n", flash_info->name,
> + (long long)flash->mtd.size >> 10);
> +
> + DEBUG(MTD_DEBUG_LEVEL2,
> + "mtd .name = %s, .size = 0x%llx (%lldMiB) "
> + ".erasesize = 0x%.8x (%uKiB) .numeraseregions = %d\n",
> + flash->mtd.name,
> + (long long)flash->mtd.size, (long long)(flash->mtd.size >> 20),
> + flash->mtd.erasesize, flash->mtd.erasesize / 1024,
> + flash->mtd.numeraseregions);
> +
> + if (flash->mtd.numeraseregions)
> + for (i = 0; i < flash->mtd.numeraseregions; i++)
> + DEBUG(MTD_DEBUG_LEVEL2,
> + "mtd.eraseregions[%d] = { .offset = 0x%llx, "
> + ".erasesize = 0x%.8x (%uKiB), "
> + ".numblocks = %d }\n",
> + i, (long long)flash->mtd.eraseregions[i].offset,
> + flash->mtd.eraseregions[i].erasesize,
> + flash->mtd.eraseregions[i].erasesize / 1024,
> + flash->mtd.eraseregions[i].numblocks);
> +
> + if (mtd_has_partitions()) {
> + struct mtd_partition *parts = NULL;
> + int nr_parts = 0;
> +
> + if (mtd_has_cmdlinepart()) {
> + static const char *part_probes[] =
> + {"cmdlinepart", NULL};
> +
> + nr_parts = parse_mtd_partitions(&flash->mtd,
> + part_probes,
> + &parts, 0);
> + }
> +
> + if (nr_parts <= 0 && data && data->parts) {
> + parts = data->parts;
> + nr_parts = data->nr_parts;
> + }
> +
> + if (nr_parts > 0) {
> + for (i = 0; i < nr_parts; i++) {
> + DEBUG(MTD_DEBUG_LEVEL2, "partitions[%d] = "
> + "{.name = %s, .offset = 0x%llx, "
> + ".size = 0x%llx (%lldKiB) }\n",
> + i, parts[i].name,
> + (long long)parts[i].offset,
> + (long long)parts[i].size,
> + (long long)(parts[i].size >> 10));
> + }
> +
> + flash->partitioned = 1;
> + return add_mtd_partitions(&flash->mtd,
> + parts, nr_parts);
> + }
> +
> + } else if (data->nr_parts) {
> + dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
> + data->nr_parts, data->name);
> + }
> +
> + return add_mtd_device(&flash->mtd) == 1 ? -ENODEV : 0;
If this returns -ENODEV, did we leak the memory at *flash?
> +}
> +
next prev parent reply other threads:[~2009-06-25 2:40 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 23:59 [PATCH] SST25L (non JEDEC) SPI Flash driver Ryan Mallon
2009-06-25 0:08 ` Linus Walleij
2009-07-03 0:50 ` [spi-devel-general] " David Brownell
2009-06-25 2:40 ` Andrew Morton [this message]
2009-06-25 3:07 ` Ryan Mallon
-- strict thread matches above, loose matches on Subject: below --
2009-06-22 3:58 Ryan Mallon
2009-06-22 8:15 ` Artem Bityutskiy
2009-06-22 8:15 ` Artem Bityutskiy
2009-06-22 8:22 ` Linus Walleij
2009-06-22 8:22 ` Linus Walleij
2009-06-22 21:56 ` Ryan Mallon
2009-06-22 21:56 ` Ryan Mallon
2009-06-23 7:04 ` Linus Walleij
2009-06-23 7:04 ` Linus Walleij
2009-06-23 20:48 ` Ryan Mallon
2009-06-23 20:48 ` Ryan Mallon
2009-06-24 22:43 ` Linus Walleij
2009-06-24 22:43 ` Linus Walleij
2009-06-24 22:49 ` Ryan Mallon
2009-06-24 22:49 ` Ryan Mallon
2009-06-24 23:49 ` Linus Walleij
2009-06-24 23:49 ` Linus Walleij
2009-06-25 1:39 ` [spi-devel-general] " H Hartley Sweeten
2009-06-25 2:06 ` Ryan Mallon
[not found] ` <4A42DB93.8020503-7Wk5F4Od5/oYd5yxfr4S2w@public.gmane.org>
2009-06-25 7:49 ` Linus Walleij
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=20090624194005.2f9574ce.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=dwmw2@infradead.org \
--cc=linus.ml.walleij@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=ryan@bluewatersys.com \
--cc=spi-devel-general@lists.sourceforge.net \
/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.