* [PATCH] fix warnings in drivers/mtd/devices/doc200?.c
@ 2004-06-09 0:24 Jesper Juhl
2004-06-09 0:29 ` David Woodhouse
0 siblings, 1 reply; 3+ messages in thread
From: Jesper Juhl @ 2004-06-09 0:24 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-kernel
Here's an attempt to fix the following warnings :
drivers/mtd/devices/doc2000.c: In function `DoC2k_init':
drivers/mtd/devices/doc2000.c:567: warning: assignment from incompatible pointer type
drivers/mtd/devices/doc2000.c:568: warning: assignment from incompatible pointer type
drivers/mtd/devices/doc2001.c: In function `DoCMil_init':
drivers/mtd/devices/doc2001.c:376: warning: assignment from incompatible pointer type
drivers/mtd/devices/doc2001.c:377: warning: assignment from incompatible pointer type
What goes on in both files is identical, and my attempted fix is also
identical for both files.
Here's what goes on:
An function pointer is assigned to the read_ecc and write_ecc members of a
struct mtd_info. These members are if the following form :
int (*read_ecc) (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
int (*write_ecc) (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf, u_char *eccbuf, struct nand_oobinfo *oobsel);
but the protype of the function a pointer to which is assigned to them
looks like this:
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel);
The difference is the last parameter "int oobsel" vs the expected "struct nand_oobinfo *oobsel"
I must admit that I do not know what the purpose of "oobsel" is, nor do I
know very much about these functions or mtd devices in general, but since
the doc_*_ecc functions do not use the oobsel parameter at all I still
think I can propose a safe fix by simply changing the functions to take a
struct nand_oobinfo * argument instead of their current int argument.
Comments??
In any case, here are two patches that change the functions to take the
expected argument types and thus kill the warnings. If this looks sane to
you, then please consider applying. If I've missed something then feel
free to point out my error. I've only compile tested these patches.
Patches are against 2.6.7-rc3 :
--- linux-2.6.7-rc3/drivers/mtd/devices/doc2000.c-orig 2004-06-09 02:01:43.000000000 +0200
+++ linux-2.6.7-rc3/drivers/mtd/devices/doc2000.c 2004-06-09 02:03:22.000000000 +0200
@@ -53,9 +53,11 @@ static int doc_read(struct mtd_info *mtd
static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
size_t *retlen, u_char *buf);
static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -601,7 +603,8 @@ static int doc_read(struct mtd_info *mtd
}
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t * retlen, u_char * buf, u_char * eccbuf, int oobsel)
+ size_t * retlen, u_char * buf, u_char * eccbuf,
+ struct nand_oobinfo *oobsel)
{
struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
unsigned long docptr;
@@ -750,7 +753,7 @@ static int doc_write(struct mtd_info *mt
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf,
- u_char * eccbuf, int oobsel)
+ u_char * eccbuf, struct nand_oobinfo *oobsel)
{
struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
int di; /* Yes, DI is a hangover from when I was disassembling the binary driver */
--- linux-2.6.7-rc3/drivers/mtd/devices/doc2001.c-orig 2004-06-09 02:04:32.000000000 +0200
+++ linux-2.6.7-rc3/drivers/mtd/devices/doc2001.c 2004-06-09 02:06:32.000000000 +0200
@@ -37,9 +37,11 @@ static int doc_read(struct mtd_info *mtd
static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
size_t *retlen, u_char *buf);
static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -399,15 +401,16 @@ static void DoCMil_init(struct mtd_info
}
}
-static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
+static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
/* Just a special case of doc_read_ecc */
return doc_read_ecc(mtd, from, len, retlen, buf, NULL, 0);
}
-static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel)
+static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel)
{
int i, ret;
volatile char dummy;
@@ -525,15 +528,16 @@ static int doc_read_ecc (struct mtd_info
return ret;
}
-static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,
+static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
char eccbuf[6];
return doc_write_ecc(mtd, to, len, retlen, buf, eccbuf, 0);
}
-static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel)
+static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel)
{
int i,ret = 0;
volatile char dummy;
--
Jesper Juhl <juhl-lkml@dif.dk>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix warnings in drivers/mtd/devices/doc200?.c
2004-06-09 0:24 [PATCH] fix warnings in drivers/mtd/devices/doc200?.c Jesper Juhl
@ 2004-06-09 0:29 ` David Woodhouse
2004-06-09 0:46 ` Jesper Juhl
0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2004-06-09 0:29 UTC (permalink / raw)
To: Jesper Juhl; +Cc: linux-kernel
On Wed, 2004-06-09 at 02:24 +0200, Jesper Juhl wrote:
> I must admit that I do not know what the purpose of "oobsel" is, nor do I
> know very much about these functions or mtd devices in general, but since
> the doc_*_ecc functions do not use the oobsel parameter at all I still
> think I can propose a safe fix by simply changing the functions to take a
> struct nand_oobinfo * argument instead of their current int argument.
> Comments??
That works, but please don't do it without also adding something like:
#warning This driver should be updated to the new ECC API.
Or you could just leave the warning we already have :)
It works at the moment because the only thing that _uses_ the driver in
question is something which also doesn't use the new argument. We're
working on a new driver and at that point we'll also update the code
which uses it.
--
dwmw2
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fix warnings in drivers/mtd/devices/doc200?.c
2004-06-09 0:29 ` David Woodhouse
@ 2004-06-09 0:46 ` Jesper Juhl
0 siblings, 0 replies; 3+ messages in thread
From: Jesper Juhl @ 2004-06-09 0:46 UTC (permalink / raw)
To: David Woodhouse; +Cc: linux-kernel
On Wed, 9 Jun 2004, David Woodhouse wrote:
> On Wed, 2004-06-09 at 02:24 +0200, Jesper Juhl wrote:
> > I must admit that I do not know what the purpose of "oobsel" is, nor do I
> > know very much about these functions or mtd devices in general, but since
> > the doc_*_ecc functions do not use the oobsel parameter at all I still
> > think I can propose a safe fix by simply changing the functions to take a
> > struct nand_oobinfo * argument instead of their current int argument.
> > Comments??
>
> That works, but please don't do it without also adding something like:
>
> #warning This driver should be updated to the new ECC API.
>
Ok, that seems preferable to me since then at least it states that "we
know something needs updating here" as opposed to just a compiler warning
which (to a regular user) indicates something along the lines of "nobody
bothered to clean up this code". Personally I prefer the explicit "we know
about this" warning and then having the code compile cleanly.
> Or you could just leave the warning we already have :) >
> It works at the moment because the only thing that _uses_ the driver in
> question is something which also doesn't use the new argument. We're
> working on a new driver and at that point we'll also update the code
> which uses it.
>
Ok. For the time being, here's an updated version of my patchs fixing the
argument type and adding an explicit #warning - still against 2.5.7-rc3 :
--- linux-2.6.7-rc3/drivers/mtd/devices/doc2000.c-orig 2004-06-09 02:01:43.000000000 +0200
+++ linux-2.6.7-rc3/drivers/mtd/devices/doc2000.c 2004-06-09 02:41:34.000000000 +0200
@@ -24,6 +24,8 @@
#include <linux/mtd/nand.h>
#include <linux/mtd/doc2000.h>
+#warning This driver should be updated to the new ECC API.
+
#define DOC_SUPPORT_2000
#define DOC_SUPPORT_MILLENNIUM
@@ -53,9 +55,11 @@ static int doc_read(struct mtd_info *mtd
static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
size_t *retlen, u_char *buf);
static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -601,7 +605,8 @@ static int doc_read(struct mtd_info *mtd
}
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t * retlen, u_char * buf, u_char * eccbuf, int oobsel)
+ size_t * retlen, u_char * buf, u_char * eccbuf,
+ struct nand_oobinfo *oobsel)
{
struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
unsigned long docptr;
@@ -750,7 +755,7 @@ static int doc_write(struct mtd_info *mt
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
size_t * retlen, const u_char * buf,
- u_char * eccbuf, int oobsel)
+ u_char * eccbuf, struct nand_oobinfo *oobsel)
{
struct DiskOnChip *this = (struct DiskOnChip *) mtd->priv;
int di; /* Yes, DI is a hangover from when I was disassembling the binary driver */
--- linux-2.6.7-rc3/drivers/mtd/devices/doc2001.c-orig 2004-06-09 02:04:32.000000000 +0200
+++ linux-2.6.7-rc3/drivers/mtd/devices/doc2001.c 2004-06-09 02:41:44.000000000 +0200
@@ -24,6 +24,8 @@
#include <linux/mtd/nand.h>
#include <linux/mtd/doc2000.h>
+#warning This driver should be updated to the new ECC API.
+
/* #define ECC_DEBUG */
/* I have no idea why some DoC chips can not use memcop_form|to_io().
@@ -37,9 +39,11 @@ static int doc_read(struct mtd_info *mtd
static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf);
static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel);
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel);
static int doc_read_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
size_t *retlen, u_char *buf);
static int doc_write_oob(struct mtd_info *mtd, loff_t ofs, size_t len,
@@ -399,15 +403,16 @@ static void DoCMil_init(struct mtd_info
}
}
-static int doc_read (struct mtd_info *mtd, loff_t from, size_t len,
+static int doc_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf)
{
/* Just a special case of doc_read_ecc */
return doc_read_ecc(mtd, from, len, retlen, buf, NULL, 0);
}
-static int doc_read_ecc (struct mtd_info *mtd, loff_t from, size_t len,
- size_t *retlen, u_char *buf, u_char *eccbuf, int oobsel)
+static int doc_read_ecc(struct mtd_info *mtd, loff_t from, size_t len,
+ size_t *retlen, u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel)
{
int i, ret;
volatile char dummy;
@@ -525,15 +530,16 @@ static int doc_read_ecc (struct mtd_info
return ret;
}
-static int doc_write (struct mtd_info *mtd, loff_t to, size_t len,
+static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
size_t *retlen, const u_char *buf)
{
char eccbuf[6];
return doc_write_ecc(mtd, to, len, retlen, buf, eccbuf, 0);
}
-static int doc_write_ecc (struct mtd_info *mtd, loff_t to, size_t len,
- size_t *retlen, const u_char *buf, u_char *eccbuf, int oobsel)
+static int doc_write_ecc(struct mtd_info *mtd, loff_t to, size_t len,
+ size_t *retlen, const u_char *buf, u_char *eccbuf,
+ struct nand_oobinfo *oobsel)
{
int i,ret = 0;
volatile char dummy;
--
Jesper Juhl <juhl-lkml@dif.dk>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-09 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-09 0:24 [PATCH] fix warnings in drivers/mtd/devices/doc200?.c Jesper Juhl
2004-06-09 0:29 ` David Woodhouse
2004-06-09 0:46 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox