Skip to contentSkip to conversation

C99 initializers for drivers/mtd files

PATCH New Art Haas 3 participants 9 messages Feb 26, 2003 – Mar 3, 2003 Memory technology devices (MTD)

lore
Share & tools
lore

Art Haas

author
#0 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Hi.

Here is a set of patches for converting files in drivers/mtd to use C99 initializers. The patches are against the current BK.

Art Haas

===== drivers/mtd/ftl.c 1.43 vs edited =====

drivers/mtd/ftl.c +2 -2
@@ -155,8 +155,8 @@
 void ftl_freepart(partition_t *part);
 
 static struct mtd_notifier ftl_notifier = {
-	add:	ftl_notify_add,
-	remove:	ftl_notify_remove,
+	.add	= ftl_notify_add,
+	.remove	= ftl_notify_remove,
 };
 
 /* Partition state flags */

===== drivers/mtd/mtdchar.c 1.10 vs edited =====

drivers/mtd/mtdchar.c +9 -9
@@ -19,8 +19,8 @@
 static void mtd_notify_remove(struct mtd_info* mtd);
 
 static struct mtd_notifier notifier = {
-	add:	mtd_notify_add,
-	remove:	mtd_notify_remove,
+	.add	= mtd_notify_add,
+	.remove	= mtd_notify_remove,
 };
 
 #endif
@@ -445,13 +445,13 @@
 } /* memory_ioctl */
 
 static struct file_operations mtd_fops = {
-	owner:		THIS_MODULE,
-	llseek:		mtd_lseek,     	/* lseek */
-	read:		mtd_read,	/* read */
-	write: 		mtd_write, 	/* write */
-	ioctl:		mtd_ioctl,	/* ioctl */
-	open:		mtd_open,	/* open */
-	release:	mtd_close,	/* release */
+	.owner		= THIS_MODULE,
+	.llseek		= mtd_lseek,	/* lseek */
+	.read		= mtd_read,	/* read */
+	.write 		= mtd_write, 	/* write */
+	.ioctl		= mtd_ioctl,	/* ioctl */
+	.open		= mtd_open,	/* open */
+	.release	= mtd_close,	/* release */
 };
 
 

===== drivers/mtd/nftlcore.c 1.39 vs edited =====

drivers/mtd/nftlcore.c +2 -2
@@ -914,8 +914,8 @@
  ****************************************************************************/
 
 static struct mtd_notifier nftl_notifier = {
-	add:	NFTL_notify_add,
-	remove:	NFTL_notify_remove
+	.add	= NFTL_notify_add,
+	.remove	= NFTL_notify_remove
 };
 
 extern char nftlmountrev[];
Signature · 3 lines
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
#1 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Quoted 3 lines · Art Haas

Here is a set of patches for converting files in drivers/mtd to use C99 initializers. The patches are against the current BK.

Looks trivial, although a bit lengthy. Do you have cvs commit access? If not, but me next Monday (got a cold right now) if noone committed it before.

J?rn

Signature · 2 lines
Data expands to fill the space available for storage.
-- Parkinson's Law
author
#2 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Quoted 9 lines · J?rn Engel
Quoted 3 lines · Art Haas

Here is a set of patches for converting files in drivers/mtd to use C99 initializers. The patches are against the current BK.

Looks trivial, although a bit lengthy. Do you have cvs commit access? If not, but me next Monday (got a cold right now) if noone committed it before.

No, I don't have cvs access, so I can't commit any of the patches I've mailed.

Art Haas

Signature · 3 lines
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
#3 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Quoted 3 lines · Art Haas

No, I don't have cvs access, so I can't commit any of the patches I've mailed.

Patch 1 and 4 are committed, 2 and 3 don't apply cleanly and will follow later...

J?rn

Signature · 2 lines
Time? What's that? Time is only worth what you do with it.
-- Theo de Raadt
#4 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

--=-UIgGkC/XGO+JaNvyNuOE
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I like the C99 initialization. I was tempted to make these changes myself, but I had a concern so I never did anything.

What does Marcelo think about the C99 initialization syntax? GCC 2.95 does not understand C99 and will fail to compile kernels that require this syntax. Is Marcelo willing to break 2.95 and require newer compilers? Is the MTD community willing to maintain two patch sets: one with GCC initializers and one with C99 initializers? (granted the old GCC way is deprecated).

Quoted 9 lines · On Sun, 2003-03-02 at 11:56, J=F6rn Engel wrote:
Quoted 3 lines · Art Haas

=20
No, I don't have cvs access, so I can't commit any of the patches I've mailed.

=20
Patch 1 and 4 are committed, 2 and 3 don't apply cleanly and will follow later...
=20
J=F6rn

--=20
Thayne Harbaugh
Linux Networx

--=-UIgGkC/XGO+JaNvyNuOE
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA+Y7/WfsBPTKE6HMkRArz5AJ9tfjUesiCmDcgec1pJN+NBixeZbwCdFgqn Ig0FGZ3p2atYKuxNHTi7J/o=
=UWXZ
-----END PGP SIGNATURE-----

--=-UIgGkC/XGO+JaNvyNuOE--

#5 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Quoted 3 lines · Thayne Harbaugh

GCC 2.95 does not understand C99 and will fail to compile kernels that require this syntax.

You had me for a moment. But at least Debians gcc 2.95.4 does not fail too badly:

joern at Limerick:~/foo$ cat foo.c

struct foo {
        int bar;
        int baz;
};
struct foo fufu = {
        .bar = 0,
        .baz = 0
};

joern at Limerick:~/foo$ gcc --version
2.95.4
joern at Limerick:~/foo$ gcc -c foo.c
joern at Limerick:~/foo$ ls
foo.c foo.o
joern at Limerick:~/foo$

What compiler do you have that breaks with C99 initializers?

J?rn

Signature · 2 lines
Invincibility is in oneself, vulnerability is in the opponent.
-- Sun Tzu
#6 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

--=-VG6xTcuLBgQIdyzP0w2K
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hmmm. I guess C99 mostly works - with the exception of array initializers:

[thayne at tubarao tmp]$ cat foo.c

                                                                           =
    =20
struct foo {
  int bar;
  int baz;
};
                                                                           =
    =20
struct foo fufu[] =3D {
  [0].bar =3D 0,
  [0].baz =3D 0
};
                                                                           =
    =20

[thayne at tubarao tmp]$ gcc -c foo.c foo.c:8: unknown field `bar' specified in initializer

It's the array initialization that I want to use. Grrrr!

Quoted 18 lines · On Mon, 2003-03-03 at 14:06, J=F6rn Engel wrote:
Quoted 3 lines · Thayne Harbaugh

=20
GCC 2.95 does not understand C99 and will fail to compile kernels that require this syntax.

=20
You had me for a moment. But at least Debians gcc 2.95.4 does not fail too badly:
=20
joern at Limerick:~/foo$ cat foo.c

struct foo {
        int bar;
        int baz;
};
=20
struct foo fufu =3D {
        .bar =3D 0,
        .baz =3D 0
};
Quoted 10 lines

joern at Limerick:~/foo$ gcc --version
2.95.4
joern at Limerick:~/foo$ gcc -c foo.c
joern at Limerick:~/foo$ ls
foo.c foo.o
joern at Limerick:~/foo$ =20
=20
What compiler do you have that breaks with C99 initializers? =20
J=F6rn

--=20
Thayne Harbaugh
Linux Networx

--=-VG6xTcuLBgQIdyzP0w2K
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA+Y8dYfsBPTKE6HMkRAnOQAJ9NZnPOXRGbE+t0GVcUpKvy+fBB3ACfWAp0 9g5zrdqObx7vv79g80fbU9E=
=zBXV
-----END PGP SIGNATURE-----

--=-VG6xTcuLBgQIdyzP0w2K--

author
#7 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

Quoted 15 lines · Thayne Harbaugh

Hmmm. I guess C99 mostly works - with the exception of array initializers:

[thayne at tubarao tmp]$ cat foo.c

struct foo {
int bar;
int baz;
};

struct foo fufu[] = {
[0].bar = 0,
[0].baz = 0
};

Quoted 6 lines

[thayne at tubarao tmp]$ gcc -c foo.c foo.c:8: unknown field `bar' specified in initializer

It's the array initialization that I want to use. Grrrr!

Array initializers should work in GCC-2.95.X also, your syntax is just a little off ...

$ cat foo.c
struct foo {
	int bar;
	int baz;
};
struct foo fufu[] = {
	[0] = {
		.bar = 0,
		.baz = 0
	},
};
$ gcc-2.95 -c foo.c
$
$ gcc-2.95 -v
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
$

The above foo.c compiles fine with gcc-3.2 and gcc-3.3 also. The C99 syntax should be no problem for gcc-2.95, or really any GCC release after gcc-2.5, as gcc-2.5 is where the current documents say the syntax with the ":" became obsolete.

Art Haas

Signature · 3 lines
They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety.
 -- Benjamin Franklin, Historical Review of Pennsylvania, 1759
#8 lore raw

PATCH 1/1 C99 initializers for drivers/mtd files

--=-cJT9OdOoENZRrdNpTALp
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

My bad - the [INDEX].DATA_MEMBER works in GCC 3.2. Thanks for setting me straight (I'll go back to sleep now).

Quoted 1 line · Art Haas

On Mon, Mar 03, 2003 at 02:21:29PM -0700, Thayne Harbaugh wrote:

<embarrassing evidence removed for brevity and to protect the guilty>

Quoted 2 lines

=20
Art Haas

--=20
Thayne Harbaugh
Linux Networx

--=-cJT9OdOoENZRrdNpTALp
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQA+Y8wIfsBPTKE6HMkRArZ2AJ9ySsD3J5/PMvY5tpoKb2my5LLjrgCfeMjJ yXKx2GjUrD1rpx4k989vgyk=
=VNaK
-----END PGP SIGNATURE-----

--=-cJT9OdOoENZRrdNpTALp--

Quoted 1 line

From Brian Mon Mar 3 20:21:39 2003

From: Brian (Brian)
Date: Mon, 3 Mar 2003 19:21:39 -0600
Subject: linux not mounting jffs2 partition properly?
Message-ID: <001f01c2e1ec$68189c50$0200a8c0@athlon1200>

Hello,

I have an embedded build I am migrating from kernel 2.2.18 using JFFS2/v1.18 to kernel 2.4.20/JFFS2 v1.35. I have patched the kernel with the current CVS, and my utilities directory. Everything compiles. On bootup, however, it almost looks like that the kernel is not mounting the JFFS2 partition properly, and cannot run any commands (kmod, modprobe, open /dev/console, etc...). Below is a snip of my bootup sequence. The flash is an Intel 16mb ROM, 128k sectors. Erase size when creating the image was also 128k.

/tmp/current_build/user/mtd-utils/build/mkfs.jffs2 -v -o /tmp/current_build/images/jffs2.img -q -e 131072 -d /tmp/current_build/romfs

My older build with 2.2.18/v1.18 works fine.

Any help is appreciated.

Thanks!

-Brian

--snip--
Loading..............................................
Linux version 2.4.20 (root at Smog) (gcc version 2.96 20000731 (Red Hat Linux 7.2 2.96-112.7.2)) #96 Fri Feb 28 17:49:33 CST 2003
BIOS-provided physical RAM map:
BIOS-e801: 0000000000000000 - 000000000009f000 (usable)
BIOS-e801: 0000000000100000 - 0000000002000000 (usable)
32MB LOWMEM available.
On node 0 totalpages: 8192
zone(0): 4096 pages.
zone(1): 4096 pages.
zone(2): 0 pages.
Kernel command line:
Initializing CPU#0
Calibrating delay loop... 49.56 BogoMIPS
Memory: 30580k/32768k available (952k kernel code, 1800k reserved, 227k data, 64k init, 0k highmem)
Checking if this processor honours the WP bit even in supervisor mode... Ok. Dentry cache hash table entries: 4096 (order: 3, 32768 bytes) Inode cache hash table entries: 2048 (order: 2, 16384 bytes) Mount-cache hash table entries: 512 (order: 0, 4096 bytes) Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes) Page-cache hash table entries: 8192 (order: 3, 32768 bytes)
CPU: AMD 486 DX/4-WB stepping 04
Checking 'hlt' instruction... OK.
POSIX conformance testing by UNIFIX
PCI: Using configuration type 1
PCI: Probing PCI hardware
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039 Initializing RT netlink socket
Starting kswapd
JFFS2 version 2.1. (C) 2001, 2002 Red Hat, Inc., designed by Axis Communications AB.
Serial driver version 5.05c (2001-07-08) with MANY_PORTS SHARE_IRQ SERIAL_PCI enabled
ttyS00 at 0x03f8 (irq = 4) is a 16550A
ttyS03 at 0x02e8 (irq = 3) is a 16550A
SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256).
CSLIP: code copyright 1989 Regents of the University of California. RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize PPP generic driver version 2.4.2
kmod: failed to exec /sbin/modprobe -s -k jedec_probe, errno = 2
cfi_cmdset_0001: Erase suspend on write enabled
Using buffer write method
cfi_cmdset_0001: Erase suspend on write enabled
Using buffer write method
SNAPGEAR: Intel flash device size = 16384K
Creating 6 MTD partitions on "SnapGear Intel":
0x00000000-0x00080000 : "JBM kernel"
0x000a0000-0x00fe0000 : "JBM filesystem"
0x00080000-0x000a0000 : "JBM config"
0x00000000-0x01000000 : "JBM Intel"
0x00fe0000-0x01000000 : "JBM BIOS Config"
0x00fe0000-0x01000000 : "JBM BIOS"
JBMgw137 Battery Backed RAM device: 1f000 at 18021000
kmod: failed to exec /sbin/modprobe -s -k ram, errno = 2
kmod: failed to exec /sbin/modprobe -s -k rom, errno = 2
NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 2048 bind 4096)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0. jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477238:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0047723c:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477240:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477244:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477248:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0047724c:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477250:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477254:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00477258:
0x1a1a instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0047725c:
0x1a1a instead
Further such events for this erase block will not be printed
VFS: Mounted root (jffs2 filesystem) readonly.
Freeing unused kernel memory: 64k freed
Warning: unable to open an initial console.

--snip--