From 916fa097997a5e1b70768ce944de28e038d4bebf Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Fri, 23 Nov 2018 17:36:19 +0100 Subject: [PATCH] usb: composite: Move bitmap related operations to ./include/linux/bitmap.h The BITMAP related operations can now be moved to ./include/linux/bitmap.h file to mimic the Linux kernel directory tree. This change also allows to remove the lin_gadget_compat.h header file (which is a legacy code only for composite U-boot layer). It was also possible to remove #includes from several USB gadget drivers. Signed-off-by: Lukasz Majewski Reviewed-by: Stefan Agner --- drivers/usb/dwc3/gadget.c | 1 - drivers/usb/dwc3/ti_usb_phy.c | 1 - drivers/usb/eth/r8152.c | 1 - drivers/usb/gadget/at91_udc.c | 1 - drivers/usb/gadget/atmel_usba_udc.c | 1 - drivers/usb/gadget/dwc2_udc_otg.c | 1 - drivers/usb/gadget/dwc2_udc_otg_phy.c | 1 - drivers/usb/gadget/dwc2_udc_otg_priv.h | 1 - drivers/usb/gadget/f_mass_storage.c | 2 +- drivers/usb/gadget/pxa25x_udc.c | 1 - include/linux/bitmap.h | 23 +++++++++++++++++ include/linux/types.h | 3 +++ include/linux/usb/composite.h | 2 +- include/usb/lin_gadget_compat.h | 35 -------------------------- 14 files changed, 28 insertions(+), 46 deletions(-) create mode 100644 include/linux/bitmap.h delete mode 100644 include/usb/lin_gadget_compat.h diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index e340cb268f..085f7b8968 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include diff --git a/drivers/usb/dwc3/ti_usb_phy.c b/drivers/usb/dwc3/ti_usb_phy.c index d168e868e3..e7ea12c163 100644 --- a/drivers/usb/dwc3/ti_usb_phy.c +++ b/drivers/usb/dwc3/ti_usb_phy.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/usb/eth/r8152.c b/drivers/usb/eth/r8152.c index 941158abdd..e5f73e3d4c 100644 --- a/drivers/usb/eth/r8152.c +++ b/drivers/usb/eth/r8152.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include "usb_ether.h" diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 39ea87005c..2a6626b443 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c @@ -24,7 +24,6 @@ #include #include #include -#include #include "at91_udc.h" diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index c9d483318f..dffa5117f9 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -16,7 +16,6 @@ #include #include #include -#include #include "atmel_usba_udc.h" diff --git a/drivers/usb/gadget/dwc2_udc_otg.c b/drivers/usb/gadget/dwc2_udc_otg.c index e3edd10e29..3c7ad033e3 100644 --- a/drivers/usb/gadget/dwc2_udc_otg.c +++ b/drivers/usb/gadget/dwc2_udc_otg.c @@ -33,7 +33,6 @@ #include "dwc2_udc_otg_regs.h" #include "dwc2_udc_otg_priv.h" -#include /***********************************************************/ diff --git a/drivers/usb/gadget/dwc2_udc_otg_phy.c b/drivers/usb/gadget/dwc2_udc_otg_phy.c index 47aa78ae94..c4338af0d7 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_phy.c +++ b/drivers/usb/gadget/dwc2_udc_otg_phy.c @@ -33,7 +33,6 @@ #include "dwc2_udc_otg_regs.h" #include "dwc2_udc_otg_priv.h" -#include #include diff --git a/drivers/usb/gadget/dwc2_udc_otg_priv.h b/drivers/usb/gadget/dwc2_udc_otg_priv.h index b64e222b6d..aaa90187fb 100644 --- a/drivers/usb/gadget/dwc2_udc_otg_priv.h +++ b/drivers/usb/gadget/dwc2_udc_otg_priv.h @@ -12,7 +12,6 @@ #include #include #include -#include #include /*-------------------------------------------------------------------------*/ diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index a3101afa0d..45c7b58eed 100644 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -256,7 +256,7 @@ #include #include #include -#include +#include #include /*------------------------------------------------------------------------*/ diff --git a/drivers/usb/gadget/pxa25x_udc.c b/drivers/usb/gadget/pxa25x_udc.c index 44092df25b..09c0a30b2b 100644 --- a/drivers/usb/gadget/pxa25x_udc.c +++ b/drivers/usb/gadget/pxa25x_udc.c @@ -29,7 +29,6 @@ #include #include -#include #include #include "pxa25x_udc.h" diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h new file mode 100644 index 0000000000..4a54ae0509 --- /dev/null +++ b/include/linux/bitmap.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0+ +#ifndef __LINUX_BITMAP_H +#define __LINUX_BITMAP_H + +#include +#include +#include + +#define small_const_nbits(nbits) \ + (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) + +static inline void bitmap_zero(unsigned long *dst, int nbits) +{ + if (small_const_nbits(nbits)) { + *dst = 0UL; + } else { + int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); + + memset(dst, 0, len); + } +} + +#endif /* __LINUX_BITMAP_H */ diff --git a/include/linux/types.h b/include/linux/types.h index 1f3cd63b8f..cc6f7cb39e 100644 --- a/include/linux/types.h +++ b/include/linux/types.h @@ -158,4 +158,7 @@ struct ustat { char f_fpack[6]; }; +#define DECLARE_BITMAP(name, bits) \ + unsigned long name[BITS_TO_LONGS(bits)] + #endif /* _LINUX_TYPES_H */ diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 30c464ce39..a49a66f2f8 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -24,7 +24,7 @@ #include #include #include -#include +#include /* * USB function drivers should return USB_GADGET_DELAYED_STATUS if they diff --git a/include/usb/lin_gadget_compat.h b/include/usb/lin_gadget_compat.h deleted file mode 100644 index e5dba473b7..0000000000 --- a/include/usb/lin_gadget_compat.h +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (c) 2011 Samsung Electronics - * Lukasz Majewski - * - * This is a Linux kernel compatibility layer for USB Gadget - */ - -#ifndef __LIN_COMPAT_H__ -#define __LIN_COMPAT_H__ - -#include -#include - -/* common */ -#define DECLARE_BITMAP(name, bits) \ - unsigned long name[BITS_TO_LONGS(bits)] - -#define small_const_nbits(nbits) \ - (__builtin_constant_p(nbits) && (nbits) <= BITS_PER_LONG) - -static inline void bitmap_zero(unsigned long *dst, int nbits) -{ - if (small_const_nbits(nbits)) - *dst = 0UL; - else { - int len = BITS_TO_LONGS(nbits) * sizeof(unsigned long); - memset(dst, 0, len); - } -} - -#define dma_cache_maint(addr, size, mode) cache_flush() -void cache_flush(void); - -#endif /* __LIN_COMPAT_H__ */ -- 2.39.5