whitespace cleanup
This commit is contained in:
parent
7ec80eb0e9
commit
9b3761c445
|
@ -320,7 +320,7 @@ ulong flash_read_long (flash_info_t * info, flash_sect_t sect, uint offset)
|
||||||
int cfi_probe (struct device_d *dev)
|
int cfi_probe (struct device_d *dev)
|
||||||
{
|
{
|
||||||
unsigned long size = 0;
|
unsigned long size = 0;
|
||||||
flash_info_t *info = malloc(sizeof(flash_info_t));
|
flash_info_t *info = malloc(sizeof(flash_info_t));
|
||||||
|
|
||||||
dev->priv = (void *)info;
|
dev->priv = (void *)info;
|
||||||
|
|
||||||
|
@ -341,18 +341,18 @@ int cfi_probe (struct device_d *dev)
|
||||||
|
|
||||||
static int flash_find_sector(flash_info_t * info, unsigned long adr)
|
static int flash_find_sector(flash_info_t * info, unsigned long adr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned long end;
|
unsigned long end;
|
||||||
|
|
||||||
for (i = 0; i < info->sector_count; i++) {
|
for (i = 0; i < info->sector_count; i++) {
|
||||||
if (i == info->sector_count)
|
if (i == info->sector_count)
|
||||||
end = info->start[0] + info->size - 1;
|
end = info->start[0] + info->size - 1;
|
||||||
else
|
else
|
||||||
end = info->start[i + 1] - 1;
|
end = info->start[i + 1] - 1;
|
||||||
if (adr >= info->start[i] && adr <= end)
|
if (adr >= info->start[i] && adr <= end)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------
|
/*-----------------------------------------------------------------------
|
||||||
|
@ -387,44 +387,44 @@ int flash_erase_one (flash_info_t * info, long sect)
|
||||||
} else
|
} else
|
||||||
putc ('.');
|
putc ('.');
|
||||||
|
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cfi_erase(struct device_d *dev, size_t count, unsigned long offset)
|
int cfi_erase(struct device_d *dev, size_t count, unsigned long offset)
|
||||||
{
|
{
|
||||||
flash_info_t *finfo = (flash_info_t *)dev->priv;
|
flash_info_t *finfo = (flash_info_t *)dev->priv;
|
||||||
unsigned long start, end;
|
unsigned long start, end;
|
||||||
int i, ret = 0;
|
int i, ret = 0;
|
||||||
|
|
||||||
printf("%s: erase 0x%08x (size %d)\n", __FUNCTION__, offset, count);
|
printf("%s: erase 0x%08x (size %d)\n", __FUNCTION__, offset, count);
|
||||||
|
|
||||||
start = flash_find_sector(finfo, dev->map_base + offset);
|
start = flash_find_sector(finfo, dev->map_base + offset);
|
||||||
end = flash_find_sector(finfo, dev->map_base + offset + count - 1);
|
end = flash_find_sector(finfo, dev->map_base + offset + count - 1);
|
||||||
|
|
||||||
for (i = start; i <= end; i++) {
|
for (i = start; i <= end; i++) {
|
||||||
ret = flash_erase_one (finfo, i);
|
ret = flash_erase_one (finfo, i);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
putc('\n');
|
putc('\n');
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t cfi_write(struct device_d* dev, const void* buf, size_t count, unsigned long offset, ulong flags)
|
static ssize_t cfi_write(struct device_d* dev, const void* buf, size_t count, unsigned long offset, ulong flags)
|
||||||
{
|
{
|
||||||
flash_info_t *finfo = (flash_info_t *)dev->priv;
|
flash_info_t *finfo = (flash_info_t *)dev->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
debug("cfi_write: buf=0x%08x addr=0x%08x count=0x%08x\n",buf, dev->map_base + offset, count);
|
debug("cfi_write: buf=0x%08x addr=0x%08x count=0x%08x\n",buf, dev->map_base + offset, count);
|
||||||
|
|
||||||
ret = write_buff (finfo, buf, dev->map_base + offset, count);
|
ret = write_buff (finfo, buf, dev->map_base + offset, count);
|
||||||
return ret == 0 ? count : -1;
|
return ret == 0 ? count : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfi_info (struct device_d* dev)
|
void cfi_info (struct device_d* dev)
|
||||||
{
|
{
|
||||||
flash_info_t *info = (flash_info_t *)dev->priv;
|
flash_info_t *info = (flash_info_t *)dev->priv;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (info->flash_id != FLASH_MAN_CFI) {
|
if (info->flash_id != FLASH_MAN_CFI) {
|
||||||
|
@ -513,17 +513,17 @@ void cfi_info (struct device_d* dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct driver_d cfi_driver = {
|
static struct driver_d cfi_driver = {
|
||||||
.name = "cfi_flash",
|
.name = "cfi_flash",
|
||||||
.probe = cfi_probe,
|
.probe = cfi_probe,
|
||||||
.read = mem_read,
|
.read = mem_read,
|
||||||
.write = cfi_write,
|
.write = cfi_write,
|
||||||
.erase = cfi_erase,
|
.erase = cfi_erase,
|
||||||
.info = cfi_info,
|
.info = cfi_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cfi_init(void)
|
static int cfi_init(void)
|
||||||
{
|
{
|
||||||
return register_driver(&cfi_driver);
|
return register_driver(&cfi_driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
device_initcall(cfi_init);
|
device_initcall(cfi_init);
|
||||||
|
@ -729,7 +729,7 @@ static int flash_status_check (flash_info_t * info, flash_sect_t sector,
|
||||||
{
|
{
|
||||||
uint64_t start;
|
uint64_t start;
|
||||||
|
|
||||||
tout *= 1000000;
|
tout *= 1000000;
|
||||||
|
|
||||||
/* Wait for command completion */
|
/* Wait for command completion */
|
||||||
start = get_time_ns();
|
start = get_time_ns();
|
||||||
|
|
Loading…
Reference in New Issue