Skip to contentSkip to conversation

usb: f_mass_storage: Fix compile on x86

PATCH New Bryan O'Donoghue 3 participants 5 messages Apr 26, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: f_mass_storage: Fix compile on x86

Compiling the f_mass_storage driver for an x86 target results in a compilation error as set_bit and clear_bit are provided by bitops.h

Fix that now by only compiling up the local definition of set_bit and clear_bit only if not already provided by the environment.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
---
 drivers/usb/gadget/f_mass_storage.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/f_mass_storage.c +2 -0
index 1ecb92ac6b..2e856af6ed 100644
@@ -283,6 +283,7 @@ static const char fsg_string_interface[] = "Mass Storage";
 struct kref {int x; };
 struct completion {int x; };
 
+#ifndef _I386_BITOPS_H
 inline void set_bit(int nr, volatile void *addr)
 {
 	int	mask;
@@ -302,6 +303,7 @@ inline void clear_bit(int nr, volatile void *addr)
 	mask = 1 << (nr & 0x1f);
 	*a &= ~mask;
 }
+#endif /* _I386_BITOPTS_H */
 
 struct fsg_dev;
 struct fsg_common;
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 usb: f_mass_storage: Fix compile on x86

Quoted 26 lines · Bryan O'Donoghue

Compiling the f_mass_storage driver for an x86 target results in a compilation error as set_bit and clear_bit are provided by bitops.h

Fix that now by only compiling up the local definition of set_bit and clear_bit only if not already provided by the environment.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
---
 drivers/usb/gadget/f_mass_storage.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/usb/gadget/f_mass_storage.c +1 -0
index 1ecb92ac6b..2e856af6ed 100644
@@ -283,6 +283,7 @@ static const char fsg_string_interface[] = "Mass Storage";
 struct kref {int x; };
 struct completion {int x; };
 
+#ifndef _I386_BITOPS_H
 inline void set_bit(int nr, volatile void *addr)
 {
 	int	mask;

drivers/usb/gadget/f_mass_storage.c inline void clear_bit(int nr, volatile void *addr) · line 306

Quoted 4 lines
drivers/usb/gadget/f_mass_storage.c +1 -0
@@ -302,6 +303,7 @@ inline void clear_bit(int nr, volatile void *addr)
 	mask = 1 << (nr & 0x1f);
 	*a &= ~mask;
 }
+#endif /* _I386_BITOPTS_H */

This doesn't look right, generic driver shouldn't contain arch-specific fixup or ifdef. Can this be somehow abstracted out?

Quoted 3 lines
drivers/usb/gadget/f_mass_storage.c +0 -0
 struct fsg_dev;
 struct fsg_common;
 
Signature · 2 lines
Best regards,
Marek Vasut
#2 lore raw

PATCH 1/1 usb: f_mass_storage: Fix compile on x86

Quoted 22 lines · Marek Vasut
Quoted 21 lines · Bryan O'Donoghue

Compiling the f_mass_storage driver for an x86 target results in a compilation error as set_bit and clear_bit are provided by bitops.h

Fix that now by only compiling up the local definition of set_bit and clear_bit only if not already provided by the environment.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>
---
  drivers/usb/gadget/f_mass_storage.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/usb/gadget/f_mass_storage.c +0 -0
index 1ecb92ac6b..2e856af6ed 100644
@@ -283,6 +283,7 @@ static const char fsg_string_interface[] = "Mass Storage";
  struct kref {int x; };
  struct completion {int x; };
 
Quoted 13 lines

drivers/usb/gadget/f_mass_storage.c inline void clear_bit(int nr, volatile void *addr) · line 306

Quoted 9 lines
drivers/usb/gadget/f_mass_storage.c +2 -0
+#ifndef _I386_BITOPS_H
  inline void set_bit(int nr, volatile void *addr)
  {
  	int	mask;
@@ -302,6 +303,7 @@ inline void clear_bit(int nr, volatile void *addr)
  	mask = 1 << (nr & 0x1f);
  	*a &= ~mask;
  }
+#endif /* _I386_BITOPTS_H */

This doesn't look right, generic driver shouldn't contain arch-specific fixup or ifdef. Can this be somehow abstracted out?

Hmm.

On a second look - the name of these functions should change not to conflict with bitops.h - there's some funny bit-shifting going on there..

---
bod

#3 lore raw

PATCH 1/1 usb: f_mass_storage: Fix compile on x86

Quoted 38 lines · Bryan O'Donoghue
Quoted 27 lines · Marek Vasut
Quoted 26 lines · Bryan O'Donoghue

Compiling the f_mass_storage driver for an x86 target results in a compilation error as set_bit and clear_bit are provided by bitops.h

Fix that now by only compiling up the local definition of set_bit and clear_bit only if not already provided by the environment.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>

---
  drivers/usb/gadget/f_mass_storage.c | 2 ++

  1 file changed, 2 insertions(+)
drivers/usb/gadget/f_mass_storage.c +0 -0
index 1ecb92ac6b..2e856af6ed 100644
@@ -283,6 +283,7 @@ static const char fsg_string_interface[] = "Mass
 Storage";
   struct kref {int x; };
   struct completion {int x; };

  +#ifndef _I386_BITOPS_H
  inline void set_bit(int nr, volatile void *addr) {
      int    mask;

Quoted 9 lines

drivers/usb/gadget/f_mass_storage.c inline void clear_bit(int nr, volatile void *addr) · line 306

Quoted 5 lines
drivers/usb/gadget/f_mass_storage.c +1 -0
@@ -302,6 +303,7 @@ inline void clear_bit(int nr, volatile void *addr)
       mask = 1 << (nr & 0x1f);
       *a &= ~mask;
   }
+#endif /* _I386_BITOPTS_H */

This doesn't look right, generic driver shouldn't contain arch-specific fixup or ifdef. Can this be somehow abstracted out?

Quoted 4 lines

Hmm.

On a second look - the name of these functions should change not to conflict with bitops.h - there's some funny bit-shifting going on there..

Better :)

Signature · 2 lines
Best regards,
Marek Vasut
#4 lore raw

PATCH 1/1 usb: f_mass_storage: Fix compile on x86

Hi,

Quoted 40 lines · Bryan O'Donoghue
Quoted 39 lines · Marek Vasut
Quoted 37 lines · Bryan O'Donoghue
Quoted 28 lines

Compiling the f_mass_storage driver for an x86 target results in a compilation error as set_bit and clear_bit are provided by bitops.h

Fix that now by only compiling up the local definition of set_bit and clear_bit only if not already provided by the environment.

Cc Lukasz Majewski <[email protected]>
Cc Marek Vasut <[email protected]>

---
  drivers/usb/gadget/f_mass_storage.c | 2 ++

  1 file changed, 2 insertions(+)
drivers/usb/gadget/f_mass_storage.c +0 -0
index 1ecb92ac6b..2e856af6ed 100644
@@ -283,6 +283,7 @@ static const char fsg_string_interface[] =
 "Mass Storage";
   struct kref {int x; };
   struct completion {int x; };

  +#ifndef _I386_BITOPS_H
  inline void set_bit(int nr, volatile void *addr) {
      int    mask;

drivers/usb/gadget/f_mass_storage.c inline void clear_bit(int nr, volatile void · line 306

Quoted 4 lines
drivers/usb/gadget/f_mass_storage.c +1 -0
@@ -302,6 +303,7 @@ inline void clear_bit(int nr, volatile void
 *addr) mask = 1 << (nr & 0x1f);
       *a &= ~mask;
   }
+#endif /* _I386_BITOPTS_H */  

This doesn't look right, generic driver shouldn't contain arch-specific fixup or ifdef. Can this be somehow abstracted out?

Quoted 8 lines
Quoted 5 lines

Hmm.

On a second look - the name of these functions should change not to conflict with bitops.h - there's some funny bit-shifting going on there..

Better :)

The best option would be to replace those inlines with functions already provided in bitops.h - delete local instances and then re-use ones from the generic header.

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de -------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180426/3dae2472/attachment.sig>