From: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
To: barebox@lists.infradead.org
Subject: [PATCH 16/16] cfi: convert to struct resource
Date: Tue, 19 Jul 2011 18:09:12 +0200 [thread overview]
Message-ID: <1311091752-9114-16-git-send-email-plagnioj@jcrosoft.com> (raw)
In-Reply-To: <20110719160758.GK5727@game.jcrosoft.org>
From: Sascha Hauer <s.hauer@pengutronix.de>
This is the non invasive approach. All this type casting
shows this driver should be really cleaned up (or retired)
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/nor/cfi_flash.c | 36 +++++++++++++++++-------------------
1 files changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/nor/cfi_flash.c b/drivers/nor/cfi_flash.c
index 39c2bf1..c995962 100644
--- a/drivers/nor/cfi_flash.c
+++ b/drivers/nor/cfi_flash.c
@@ -283,7 +283,7 @@ static int flash_detect_cfi (struct flash_info *info, struct cfi_qry *qry)
/*
* The following code cannot be run from FLASH!
*/
-static ulong flash_get_size (struct flash_info *info, ulong base)
+static ulong flash_get_size (struct flash_info *info)
{
int i, j;
flash_sect_t sect_cnt;
@@ -295,6 +295,7 @@ static ulong flash_get_size (struct flash_info *info, ulong base)
int erase_region_count;
int cur_offset = 0;
struct cfi_qry qry;
+ unsigned long base = (unsigned long)info->base;
memset(&qry, 0, sizeof(qry));
@@ -464,8 +465,9 @@ static int __cfi_erase(struct cdev *cdev, size_t count, unsigned long offset,
debug("%s: erase 0x%08lx (size %d)\n", __func__, offset, count);
- start = find_sector(finfo, cdev->dev->map_base + offset);
- end = find_sector(finfo, cdev->dev->map_base + offset + count - 1);
+ start = find_sector(finfo, (unsigned long)finfo->base + offset);
+ end = find_sector(finfo, (unsigned long)finfo->base + offset +
+ count - 1);
if (verbose)
init_progression_bar(end - start);
@@ -633,11 +635,11 @@ static int cfi_protect(struct cdev *cdev, size_t count, unsigned long offset, in
int i, ret = 0;
const char *action = (prot? "protect" : "unprotect");
- printf("%s: %s 0x%08lx (size %d)\n", __FUNCTION__,
- action, cdev->dev->map_base + offset, count);
+ printf("%s: %s 0x%p (size %d)\n", __func__,
+ action, finfo->base + offset, count);
- start = find_sector(finfo, cdev->dev->map_base + offset);
- end = find_sector(finfo, cdev->dev->map_base + offset + count - 1);
+ start = find_sector(finfo, (unsigned long)finfo->base + offset);
+ end = find_sector(finfo, (unsigned long)finfo->base + offset + count - 1);
for (i = start; i <= end; i++) {
ret = flash_real_protect (finfo, i, prot);
@@ -654,10 +656,10 @@ static ssize_t cfi_write(struct cdev *cdev, const void *buf, size_t count, unsig
struct flash_info *finfo = (struct flash_info *)cdev->priv;
int ret;
- debug("cfi_write: buf=0x%p addr=0x%08lx count=0x%08x\n",buf, cdev->dev->map_base + offset, count);
+ debug("cfi_write: buf=0x%p addr=0x%08lx count=0x%08x\n",buf, finfo->base + offset, count);
- ret = write_buff (finfo, buf, cdev->dev->map_base + offset, count);
- return ret == 0 ? count : -1;
+ ret = write_buff(finfo, buf, (unsigned long)finfo->base + offset, count);
+ return ret == 0 ? count : -1;
}
static void cfi_info (struct device_d* dev)
@@ -978,18 +980,11 @@ static int cfi_probe (struct device_d *dev)
dev->priv = (void *)info;
- printf("cfi_probe: %s base: 0x%08x size: 0x%08x\n", dev->name, dev->map_base, dev->size);
-
/* Init: no FLASHes known */
info->flash_id = FLASH_UNKNOWN;
info->cmd_reset = FLASH_CMD_RESET;
- info->size = flash_get_size(info, dev->map_base);
- info->base = (void __iomem *)dev->map_base;
-
- if (dev->size == 0) {
- printf("cfi_probe: size : 0x%08lx\n", info->size);
- dev->size = info->size;
- }
+ info->base = dev_request_mem_region(dev, 0);
+ info->size = flash_get_size(info);
if (info->flash_id == FLASH_UNKNOWN) {
printf ("## Unknown FLASH on Bank at 0x%08x - Size = 0x%08lx = %ld MB\n",
@@ -997,6 +992,9 @@ static int cfi_probe (struct device_d *dev)
return -ENODEV;
}
+ dev_info(dev, "found cfi flash at %p, size %ld\n",
+ info->base, info->size);
+
info->cdev.name = asprintf("nor%d", dev->id);
info->cdev.size = info->size;
info->cdev.dev = dev;
--
1.7.5.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2011-07-19 16:26 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-19 16:07 [PATCH v2] resources work Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:08 ` [PATCH 01/16] register_device: Add IORESOURCE_MEM flag Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:08 ` [PATCH 02/16] device: Add a dev_request_mem_region function Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:08 ` [PATCH 03/16] mem: replace DEVFS_RDWR by IORESOURCE_MEM_WRITEABLE Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 04/16] add a add_mem_device function Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 17:07 ` [PATCH 04/16 v3] " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 17:19 ` [PATCH 04/16] " Sascha Hauer
2011-07-19 17:10 ` Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 05/16] mem_read/write: use resources Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 06/16] nand i.MX: convert to struct resource Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 07/16] video " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 08/16] serial " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 09/16] i2c " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 10/16] mci " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 11/16] net i.MX fec: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 12/16] mci i.MX esdhc: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 13/16] spi i.MX: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 14/16] video i.MX ipu: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` [PATCH 15/16] i.MX devices: " Jean-Christophe PLAGNIOL-VILLARD
2011-07-19 16:09 ` Jean-Christophe PLAGNIOL-VILLARD [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=1311091752-9114-16-git-send-email-plagnioj@jcrosoft.com \
--to=plagnioj@jcrosoft.com \
--cc=barebox@lists.infradead.org \
/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