Skip to contentSkip to conversation

add_mtd_partition question

DISCUSSION Clive Davies 2 participants 7 messages Jul 9, 2002 – Jul 10, 2002 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

So if there are no objections, I'll commit the following change...

Index: drivers/mtd/mtdpart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdpart.c,v
retrieving revision 1.27
diff -r1.27 mtdpart.c
231a232

Quoted 1 line
              slave->mtd.priv=master->priv;

---------- Forwarded Message ----------

Subject: Re: add_mtd_partition question
Date: Fri, 5 Jul 2002 08:58:27 +0100
From: Clive Davies <[email protected]>
To: [email protected]

Sorry, I meant slave->mtd.priv

Quoted 6 lines · Clive Davies

Is there a reason why when you add a partition with add_mtd_partition master->priv doesn't get copied into slave->priv ? If not, does anyone object if I add it in? I'm trying to fix the read_user_prot_reg accesses which no longer seem to work for me.

Clive

-------------------------------------------------------

#1 lore raw
Quoted 1 line · [email protected] said:

So if there are no objections, I'll commit the following change...

Er, why? It's private to the underlying MTD driver, and all the partition wrappers should be passing the _original_ mtd_info to the underlying driver, shouldn't they?

--
dwmw2

#2 lore raw
Quoted 3 lines

Er, why? It's private to the underlying MTD driver, and all the partition wrappers should be passing the _original_ mtd_info to the underlying driver, shouldn't they?

Ok, I think I see where I've gone wrong. I'll try and fix it properly and then submit the changes for you to check for sanity.

#3 lore raw
In reply to David Woodhouse

I think this is probably a more correct fix. If you could let me know if it looks ok, if so then I'll commit it.

Index: mtdpart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdpart.c,v
retrieving revision 1.27
diff -r1.27 mtdpart.c
72a73,88

Quoted 1 line

static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from,

size_t len,

Quoted 8 lines

size_t *retlen, u_char *buf)

{
      struct mtd_part *part = PART(mtd);
      return part->master->read_user_prot_reg (part->master, from,
                                      len, retlen, buf);
}

static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from,

size_t len,

Quoted 7 lines

size_t *retlen, u_char *buf)

{
      struct mtd_part *part = PART(mtd);
      return part->master->read_user_prot_reg (part->master, from,
                                      len, retlen, buf);
}

100a117,124

Quoted 1 line

static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from,

size_t len,

Quoted 7 lines

size_t *retlen, u_char *buf)

{
      struct mtd_part *part = PART(mtd);
      return part->master->write_user_prot_reg (part->master, from,
                                      len, retlen, buf);
}

229,231d252

<               slave->mtd.read_user_prot_reg = master->read_user_prot_reg;
<               slave->mtd.read_fact_prot_reg = master->read_fact_prot_reg;
<               slave->mtd.write_user_prot_reg = master->write_user_prot_reg;

243a265,270

Quoted 2 lines
              if(master->read_user_prot_reg)
                      slave->mtd.read_user_prot_reg = 

part_read_user_prot_reg;

Quoted 2 lines
              if(master->read_fact_prot_reg)
                      slave->mtd.read_fact_prot_reg = 

part_read_fact_prot_reg;

Quoted 2 lines
              if(master->write_user_prot_reg)
                      slave->mtd.write_user_prot_reg = 

part_write_user_prot_reg;

#4 lore raw
Quoted 2 lines · [email protected] said:

I think this is probably a more correct fix. If you could let me know if it looks ok, if so then I'll commit it.

Please resend after

	echo "diff -up"  >> ~/.cvsrc 

--
dwmw2

#5 lore raw
Quoted 2 lines

Please resend after

	echo "diff -up"  >> ~/.cvsrc

Index: mtdpart.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/mtdpart.c,v
retrieving revision 1.27

mtdpart.c 10 Jul 2002 08:22:04 -0000 renamed from mtdpart.c 8 Mar 2002 16:34:35 -0000 1.27 +1 -0
diff -u -p -r1.27 mtdpart.c
@@ -70,6 +70,22 @@ static int part_read_oob (struct mtd_inf
                                        len, retlen, buf);
 }
 
+static int part_read_user_prot_reg (struct mtd_info *mtd, loff_t from, 

size_t len,
+ size_t *retlen, u_char *buf)
+{
+ struct mtd_part *part = PART(mtd);
+ return part->master->read_user_prot_reg (part->master, from,
+ len, retlen, buf);
+}
+
+static int part_read_fact_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf)
+{
+ struct mtd_part *part = PART(mtd);
+ return part->master->read_user_prot_reg (part->master, from,
+ len, retlen, buf);
+}
+
static int part_write (struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
@@ -98,6 +114,14 @@ static int part_write_oob (struct mtd_in

                                        len, retlen, buf);

}

+static int part_write_user_prot_reg (struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf)
+{
+ struct mtd_part *part = PART(mtd);
+ return part->master->write_user_prot_reg (part->master, from,
+ len, retlen, buf);
+}
+
static int part_writev (struct mtd_info *mtd, const struct iovec *vecs,
unsigned long count, loff_t to, size_t *retlen)
{
@@ -226,9 +250,6 @@ int add_mtd_partitions(struct mtd_info *

                slave->mtd.oobsize = master->oobsize;
                slave->mtd.ecctype = master->ecctype;
                slave->mtd.eccsize = master->eccsize;
-               slave->mtd.read_user_prot_reg = master->read_user_prot_reg;
-               slave->mtd.read_fact_prot_reg = master->read_fact_prot_reg;
-               slave->mtd.write_user_prot_reg = master->write_user_prot_reg;
                slave->mtd.name = parts[i].name;
                slave->mtd.bank_size = master->bank_size;
@@ -241,6 +262,12 @@ int add_mtd_partitions(struct mtd_info *
                        slave->mtd.read_oob = part_read_oob;
                if (master->write_oob)
                        slave->mtd.write_oob = part_write_oob;

+ if(master->read_user_prot_reg)
+ slave->mtd.read_user_prot_reg =
part_read_user_prot_reg;
+ if(master->read_fact_prot_reg)
+ slave->mtd.read_fact_prot_reg =
part_read_fact_prot_reg;
+ if(master->write_user_prot_reg)
+ slave->mtd.write_user_prot_reg =

part_write_user_prot_reg;
                if (master->sync)
                        slave->mtd.sync = part_sync;
                if (!i && master->suspend && master->resume) {
#6 lore raw
Quoted 3 lines · [email protected] said:

Please resend after

	echo "diff -up"  >> ~/.cvsrc

Index: mtdpart.c

Oh, right -- yeah, now I can read it, it looks fine. Go ahead; thanks.

--
dwmw2