Skip to contentSkip to conversation

sym53c8xx: Fix bogus sym_que_entry re-implementation of container_of

PATCH In review Benjamin Herrenschmidt 2 participants 4 messages Jul 7, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sym53c8xx: Fix bogus sym_que_entry re-implementation of container_of

The sym53c8xx driver, for some reason, seems to mostly re-implement linux/list.h with added bogosity. The main one is it's implementation of sym_que_entry which spits warnings with recent gcc's on some 64 bits architectures.

---

Can somebody with that HW test the patch in case I did something stupid ? I don't have a symbios controller at hand, it's just that this driver is part of our defconfig :-)

 drivers/scsi/sym53c8xx_2/sym_misc.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/sym53c8xx_2/sym_misc.h +1 -3
@@ -121,9 +121,7 @@ static __inline void sym_que_move(struct
 	}
 }
 
-#define sym_que_entry(ptr, type, member) \
-	((type *)((char *)(ptr)-(unsigned int)(&((type *)0)->member)))
-
+#define sym_que_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define sym_insque(new, pos)		__sym_que_add(new, pos, (pos)->flink)
 
#1 lore raw

{+ willy]

Quoted 4 lines · Benjamin Herrenschmidt

The sym53c8xx driver, for some reason, seems to mostly re-implement linux/list.h with added bogosity. The main one is it's implementation of sym_que_entry which spits warnings with recent gcc's on some 64 bits architectures.

Yup - the implementation doesn't look so good to me either.

Quoted 7 lines

---

Can somebody with that HW test the patch in case I did something stupid? I don't have a symbios controller at hand, it's just that this driver is part of our defconfig :-)

If willy can't test this soon, I can give it a shot.

drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 static __inline void sym_que_move(struct · line 124

Quoted 13 lines
 drivers/scsi/sym53c8xx_2/sym_misc.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 renamed from drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:42:03.000000000 +1000 +1 -3
@@ -121,9 +121,7 @@ static __inline void sym_que_move(struct
       }
 }
 
-#define sym_que_entry(ptr, type, member) \
-       ((type *)((char *)(ptr)-(unsigned int)(&((type *)0)->member)))
-
+#define sym_que_entry(ptr, type, member) container_of(ptr, type, member)

There are 11 uses of sym_que_entry() macro. Is that too many to completely remove it's use?
(question for willy to decide I guess).

cheers,
grant

Quoted 8 lines
drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 renamed from drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:42:03.000000000 +1000 +0 -1
 #define sym_insque(new, pos)           __sym_que_add(new, pos, (pos)->flink)
 
--

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 6 lines · Grant Grundler
Quoted 6 lines
drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 renamed from drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:42:03.000000000 +1000 +0 -0
@@ -121,9 +121,7 @@ static __inline void sym_que_move(struct
       }
 }
 
Quoted 8 lines

drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 static __inline void sym_que_move(struct · line 124

Quoted 4 lines
drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:44:41.000000000 +1000 renamed from drivers/scsi/sym53c8xx_2/sym_misc.h 2008-07-07 10:42:03.000000000 +1000 +1 -3
-#define sym_que_entry(ptr, type, member) \
-       ((type *)((char *)(ptr)-(unsigned int)(&((type *)0)->member)))
-
+#define sym_que_entry(ptr, type, member) container_of(ptr, type, member)

There are 11 uses of sym_que_entry() macro. Is that too many to completely remove it's use?
(question for willy to decide I guess).

Willy wants to completely remove the queue management. While that might be the right thing to do, I'd like the small fixup to go in to at least remove the warnings in the meantime.

Cheers,
Ben.

#3 lore raw
Quoted 1 line · Benjamin Herrenschmidt

On Sun, 2008-07-06 at 23:35 -0700, Grant Grundler wrote:

...

Quoted 7 lines
Quoted 3 lines

There are 11 uses of sym_que_entry() macro. Is that too many to completely remove it's use?
(question for willy to decide I guess).

Willy wants to completely remove the queue management. While that might be the right thing to do, I'd like the small fixup to go in to at least remove the warnings in the meantime.

ok - I didn't know the long term plan. That seems reasonable to me.

BTW, I realized this morning sym_que_entry() should really be an inline function and drop the "struct sym_ccb" argument.

thanks,
grant