Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 360353
b: refs/heads/master
c: a2f74a7
h: refs/heads/master
i:
  360351: 086cdec
v: v3
  • Loading branch information
Rafał Miłecki authored and Artem Bityutskiy committed Feb 4, 2013
1 parent adf1949 commit de1564f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 396afe553bd607dca4d28b00b6cab2ea826acba2
refs/heads/master: a2f74a7dacc1c17a0b146eb3112217874c5db436
37 changes: 24 additions & 13 deletions trunk/drivers/mtd/devices/bcm47xxsflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include <linux/platform_device.h>
#include <linux/bcma/bcma.h>

#include "bcm47xxsflash.h"

MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("Serial flash driver for BCMA bus");

Expand All @@ -13,26 +15,27 @@ static const char *probes[] = { "bcm47xxpart", NULL };
static int bcm47xxsflash_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
struct bcma_sflash *sflash = mtd->priv;
struct bcm47xxsflash *b47s = mtd->priv;

/* Check address range */
if ((from + len) > mtd->size)
return -EINVAL;

memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(sflash->window + from),
memcpy_fromio(buf, (void __iomem *)KSEG0ADDR(b47s->window + from),
len);

return len;
}

static void bcm47xxsflash_fill_mtd(struct bcma_sflash *sflash,
struct mtd_info *mtd)
static void bcm47xxsflash_fill_mtd(struct bcm47xxsflash *b47s)
{
mtd->priv = sflash;
struct mtd_info *mtd = &b47s->mtd;

mtd->priv = b47s;
mtd->name = "bcm47xxsflash";
mtd->owner = THIS_MODULE;
mtd->type = MTD_ROM;
mtd->size = sflash->size;
mtd->size = b47s->size;
mtd->_read = bcm47xxsflash_read;

/* TODO: implement writing support and verify/change following code */
Expand All @@ -43,16 +46,23 @@ static void bcm47xxsflash_fill_mtd(struct bcma_sflash *sflash,
static int bcm47xxsflash_probe(struct platform_device *pdev)
{
struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
struct bcm47xxsflash *b47s;
int err;

sflash->mtd = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
if (!sflash->mtd) {
b47s = kzalloc(sizeof(*b47s), GFP_KERNEL);
if (!b47s) {
err = -ENOMEM;
goto out;
}
bcm47xxsflash_fill_mtd(sflash, sflash->mtd);
sflash->priv = b47s;

b47s->window = sflash->window;
b47s->blocksize = sflash->blocksize;
b47s->numblocks = sflash->numblocks;
b47s->size = sflash->size;
bcm47xxsflash_fill_mtd(b47s);

err = mtd_device_parse_register(sflash->mtd, probes, NULL, NULL, 0);
err = mtd_device_parse_register(&b47s->mtd, probes, NULL, NULL, 0);
if (err) {
pr_err("Failed to register MTD device: %d\n", err);
goto err_dev_reg;
Expand All @@ -61,17 +71,18 @@ static int bcm47xxsflash_probe(struct platform_device *pdev)
return 0;

err_dev_reg:
kfree(sflash->mtd);
kfree(&b47s->mtd);
out:
return err;
}

static int bcm47xxsflash_remove(struct platform_device *pdev)
{
struct bcma_sflash *sflash = dev_get_platdata(&pdev->dev);
struct bcm47xxsflash *b47s = sflash->priv;

mtd_device_unregister(sflash->mtd);
kfree(sflash->mtd);
mtd_device_unregister(&b47s->mtd);
kfree(b47s);

return 0;
}
Expand Down
15 changes: 15 additions & 0 deletions trunk/drivers/mtd/devices/bcm47xxsflash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef __BCM47XXSFLASH_H
#define __BCM47XXSFLASH_H

#include <linux/mtd/mtd.h>

struct bcm47xxsflash {
u32 window;
u32 blocksize;
u16 numblocks;
u32 size;

struct mtd_info mtd;
};

#endif /* BCM47XXSFLASH */
1 change: 1 addition & 0 deletions trunk/include/linux/bcma/bcma_driver_chipcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ struct bcma_sflash {
u32 size;

struct mtd_info *mtd;
void *priv;
};
#endif

Expand Down

0 comments on commit de1564f

Please sign in to comment.