提交 18b61b97 编写于 作者: D Dominik Brodowski

pcmcia: convert pcmciamtd driver to use new CIS helpers

Convert the (broken) pcmciamtd driver to use the new CIS helpers.

CC: David.Woodhouse@intel.com
CC: linux-mtd@lists.infradead.org
Signed-off-by: NDominik Brodowski <linux@dominikbrodowski.net>
上级 37ace3d4
...@@ -354,85 +354,77 @@ static void pcmciamtd_release(struct pcmcia_device *link) ...@@ -354,85 +354,77 @@ static void pcmciamtd_release(struct pcmcia_device *link)
} }
static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name) #ifdef CONFIG_MTD_DEBUG
static int pcmciamtd_cistpl_format(struct pcmcia_device *p_dev,
tuple_t *tuple,
void *priv_data)
{ {
int rc;
tuple_t tuple;
cisparse_t parse; cisparse_t parse;
u_char buf[64];
tuple.Attributes = 0;
tuple.TupleData = (cisdata_t *)buf;
tuple.TupleDataMax = sizeof(buf);
tuple.TupleOffset = 0;
tuple.DesiredTuple = RETURN_FIRST_TUPLE;
rc = pcmcia_get_first_tuple(link, &tuple);
while (rc == 0) {
rc = pcmcia_get_tuple_data(link, &tuple);
if (rc != 0) {
cs_error(link, GetTupleData, rc);
break;
}
rc = pcmcia_parse_tuple(&tuple, &parse);
if (rc != 0) {
cs_error(link, ParseTuple, rc);
break;
}
switch(tuple.TupleCode) { if (!pcmcia_parse_tuple(tuple, &parse)) {
case CISTPL_FORMAT: {
cistpl_format_t *t = &parse.format; cistpl_format_t *t = &parse.format;
(void)t; /* Shut up, gcc */ (void)t; /* Shut up, gcc */
DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u", DEBUG(2, "Format type: %u, Error Detection: %u, offset = %u, length =%u",
t->type, t->edc, t->offset, t->length); t->type, t->edc, t->offset, t->length);
break; }
return -ENOSPC;
}
static int pcmciamtd_cistpl_jedec(struct pcmcia_device *p_dev,
tuple_t *tuple,
void *priv_data)
{
cisparse_t parse;
int i;
if (!pcmcia_parse_tuple(tuple, &parse)) {
cistpl_jedec_t *t = &parse.jedec;
for (i = 0; i < t->nid; i++)
DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info);
} }
return -ENOSPC;
}
#endif
case CISTPL_DEVICE: { static int pcmciamtd_cistpl_device(struct pcmcia_device *p_dev,
tuple_t *tuple,
void *priv_data)
{
struct pcmciamtd_dev *dev = priv_data;
cisparse_t parse;
cistpl_device_t *t = &parse.device; cistpl_device_t *t = &parse.device;
int i; int i;
if (pcmcia_parse_tuple(tuple, &parse))
return -EINVAL;
DEBUG(2, "Common memory:"); DEBUG(2, "Common memory:");
dev->pcmcia_map.size = t->dev[0].size; dev->pcmcia_map.size = t->dev[0].size;
for(i = 0; i < t->ndev; i++) { /* from here on: DEBUG only */
for (i = 0; i < t->ndev; i++) {
DEBUG(2, "Region %d, type = %u", i, t->dev[i].type); DEBUG(2, "Region %d, type = %u", i, t->dev[i].type);
DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp); DEBUG(2, "Region %d, wp = %u", i, t->dev[i].wp);
DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed); DEBUG(2, "Region %d, speed = %u ns", i, t->dev[i].speed);
DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size); DEBUG(2, "Region %d, size = %u bytes", i, t->dev[i].size);
} }
break; return 0;
} }
case CISTPL_VERS_1: { static int pcmciamtd_cistpl_geo(struct pcmcia_device *p_dev,
cistpl_vers_1_t *t = &parse.version_1; tuple_t *tuple,
void *priv_data)
{
struct pcmciamtd_dev *dev = priv_data;
cisparse_t parse;
cistpl_device_geo_t *t = &parse.device_geo;
int i; int i;
if(t->ns) {
dev->mtd_name[0] = '\0';
for(i = 0; i < t->ns; i++) {
if(i)
strcat(dev->mtd_name, " ");
strcat(dev->mtd_name, t->str+t->ofs[i]);
}
}
DEBUG(2, "Found name: %s", dev->mtd_name);
break;
}
case CISTPL_JEDEC_C: { if (pcmcia_parse_tuple(tuple, &parse))
cistpl_jedec_t *t = &parse.jedec; return -EINVAL;
int i;
for(i = 0; i < t->nid; i++) {
DEBUG(2, "JEDEC: 0x%02x 0x%02x", t->id[i].mfr, t->id[i].info);
}
break;
}
case CISTPL_DEVICE_GEO: {
cistpl_device_geo_t *t = &parse.device_geo;
int i;
dev->pcmcia_map.bankwidth = t->geo[0].buswidth; dev->pcmcia_map.bankwidth = t->geo[0].buswidth;
for(i = 0; i < t->ngeo; i++) { /* from here on: DEBUG only */
for (i = 0; i < t->ngeo; i++) {
DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth); DEBUG(2, "region: %d bankwidth = %u", i, t->geo[i].buswidth);
DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block); DEBUG(2, "region: %d erase_block = %u", i, t->geo[i].erase_block);
DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block); DEBUG(2, "region: %d read_block = %u", i, t->geo[i].read_block);
...@@ -440,15 +432,32 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, ...@@ -440,15 +432,32 @@ static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link,
DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition); DEBUG(2, "region: %d partition = %u", i, t->geo[i].partition);
DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave); DEBUG(2, "region: %d interleave = %u", i, t->geo[i].interleave);
} }
break; return 0;
} }
default:
DEBUG(2, "Unknown tuple code %d", tuple.TupleCode);
}
rc = pcmcia_get_next_tuple(link, &tuple); static void card_settings(struct pcmciamtd_dev *dev, struct pcmcia_device *link, int *new_name)
{
int i;
if (p_dev->prod_id[0]) {
dev->mtd_name[0] = '\0';
for (i = 0; i < 4; i++) {
if (i)
strcat(dev->mtd_name, " ");
if (p_dev->prod_id[i])
strcat(dev->mtd_name, p_dev->prod_id[i]);
}
DEBUG(2, "Found name: %s", dev->mtd_name);
} }
#ifdef CONFIG_MTD_DEBUG
pcmcia_loop_tuple(p_dev, CISTPL_FORMAT, pcmciamtd_cistpl_format, NULL);
pcmcia_loop_tuple(p_dev, CISTPL_JEDEC_C, pcmciamtd_cistpl_jedec, NULL);
#endif
pcmcia_loop_tuple(p_dev, CISTPL_DEVICE, pcmciamtd_cistpl_device, dev);
pcmcia_loop_tuple(p_dev, CISTPL_DEVICE_GEO, pcmciamtd_cistpl_geo, dev);
if(!dev->pcmcia_map.size) if(!dev->pcmcia_map.size)
dev->pcmcia_map.size = MAX_PCMCIA_ADDR; dev->pcmcia_map.size = MAX_PCMCIA_ADDR;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册