From: Takashi Iwai Subject: Re: [PATCH 18/98] include/uapi/sound/emu10k1.h: added EMU10K1 version of DECLARE_BITMAP etc macros Date: Sun, 31 May 2015 09:18:57 +0200 Message-ID: References: <1433000370-19509-1-git-send-email-mikko.rapeli@iki.fi> <1433000370-19509-19-git-send-email-mikko.rapeli@iki.fi> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: In-Reply-To: <1433000370-19509-19-git-send-email-mikko.rapeli-X3B1VOXEql0@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Mikko Rapeli Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jaroslav Kysela , alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-Id: alsa-devel@alsa-project.org At Sat, 30 May 2015 17:38:10 +0200, Mikko Rapeli wrote: >=20 > Fixes userspace compilation error: >=20 > error: expected specifier-qualifier-list before =E2=80=98DECLARE_BITM= AP=E2=80=99 > DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers = */ >=20 > DECLARE_BITMAP etc macros are not meant for userspace headers and thu= s > added here as private copies for emu10k.h. >=20 > Fix was suggested by Arnd Bergmann in message > <2168807.4Yxh5gl11Q@wuerfel> on lkml. >=20 > Signed-off-by: Mikko Rapeli > --- > include/uapi/sound/emu10k1.h | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) >=20 > diff --git a/include/uapi/sound/emu10k1.h b/include/uapi/sound/emu10k= 1.h > index ec1535b..7575f0f 100644 > --- a/include/uapi/sound/emu10k1.h > +++ b/include/uapi/sound/emu10k1.h > @@ -34,6 +34,23 @@ > =20 > #define EMU10K1_FX8010_PCM_COUNT 8 > =20 > +/* > + * Following definitions are copies from kernel headers to support c= ompiling > + * this header file in userspace. The definitions are not generally = available > + * in uapi headers so the needed things are copied here wtih __EMU10= k1 prefix. > + */ > + > +/* From include/linux/bitops.h */ > +#define __EMU10K1_BITS_PER_BYTE 8 > +/* From include/linux/kernel.h */ > +#define __EMU10K1_DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > +/* From include/linux/bitops.h */ > +#define __EMU10K1_BITS_TO_LONGS(nr) \ > + __EMU10K1_DIV_ROUND_UP(nr, __EMU10K1_BITS_PER_BYTE * sizeof(= long)) > +/* From include/linux/types.h */ > +#define __EMU10K1_DECLARE_BITMAP(name,bits) \ > + unsigned long name[__EMU10K1_BITS_TO_LONGS(bits)] This is way too complicated just for a few expansion of the aligned size arrays, IMO. Rather simplify it like below with a comment: /* the array must be aligned to unsigned long (i.e. 4 or 8 bytes) */ #define __EMU10K1_DECLARE_BITMAP(name) \ unsigned long name[(bits) / sizeof(unsigned long)] =09 or expand as is at each place like: unsigned long gpr_valid[0x200 / sizeof(unsigned long)]; thanks, Takashi > /* instruction set */ > #define iMAC0 0x00 /* R =3D A + (X * Y >> 31) ; saturation */ > #define iMAC1 0x01 /* R =3D A + (-X * Y >> 31) ; saturation */ > @@ -300,7 +317,7 @@ struct snd_emu10k1_fx8010_control_old_gpr { > struct snd_emu10k1_fx8010_code { > char name[128]; > =20 > - DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers = */ > + __EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid ini= tializers */ > __u32 __user *gpr_map; /* initializers */ > =20 > unsigned int gpr_add_control_count; /* count of GPR controls to add= /replace */ > @@ -313,11 +330,11 @@ struct snd_emu10k1_fx8010_code { > unsigned int gpr_list_control_total; /* total count of GPR controls= */ > struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /*= listed GPR controls */ > =20 > - DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers= */ > + __EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid in= itializers */ > __u32 __user *tram_data_map; /* data initializers */ > __u32 __user *tram_addr_map; /* map initializers */ > =20 > - DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions = */ > + __EMU10K1_DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid ins= tructions */ > __u32 __user *code; /* one instruction - 64 bits */ > }; > =20 > --=20 > 2.1.4 >=20