Skip to content

Commit 2e46886

Browse files
committed
ALSA: emu10k1: Make uapi/emu10k1.h compilable again
Recently we updated the content in alsa-lib uapi header files by just copying from the latest Linus kernel uapi/*.h, and noticed that it broke the build of some alsa-tools programs. The reason is that we used to have a modified version in the past, so that the program can be built without referring to the unexported stuff like snd_ctl_elem_id or __user prefix. This patch attempts to restore that, i.e. dropping the stuff that can't be referred in the user-space. For adapting the changes in uapi/emu10k1.h, the emu10k1 driver code is also slightly modified. Most of changes are pointer cast. Link: https://lore.kernel.org/r/20191220153415.2740-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a032ff0 commit 2e46886

2 files changed

Lines changed: 40 additions & 24 deletions

File tree

‎include/uapi/sound/emu10k1.h‎

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@
2323
#ifndef _UAPI__SOUND_EMU10K1_H
2424
#define _UAPI__SOUND_EMU10K1_H
2525

26-
#include <linux/types.h>
27-
#include <sound/asound.h>
28-
2926
/*
3027
* ---- FX8010 ----
3128
*/
@@ -282,8 +279,22 @@ struct snd_emu10k1_fx8010_info {
282279
#define EMU10K1_GPR_TRANSLATION_TREBLE 3
283280
#define EMU10K1_GPR_TRANSLATION_ONOFF 4
284281

282+
enum emu10k1_ctl_elem_iface {
283+
EMU10K1_CTL_ELEM_IFACE_MIXER = 2, /* virtual mixer device */
284+
EMU10K1_CTL_ELEM_IFACE_PCM = 3, /* PCM device */
285+
};
286+
287+
struct emu10k1_ctl_elem_id {
288+
unsigned int pad; /* don't use */
289+
int iface; /* interface identifier */
290+
unsigned int device; /* device/client number */
291+
unsigned int subdevice; /* subdevice (substream) number */
292+
unsigned char name[44]; /* ASCII name of item */
293+
unsigned int index; /* index of item */
294+
};
295+
285296
struct snd_emu10k1_fx8010_control_gpr {
286-
struct snd_ctl_elem_id id; /* full control ID definition */
297+
struct emu10k1_ctl_elem_id id; /* full control ID definition */
287298
unsigned int vcount; /* visible count */
288299
unsigned int count; /* count of GPR (1..16) */
289300
unsigned short gpr[32]; /* GPR number(s) */
@@ -296,7 +307,7 @@ struct snd_emu10k1_fx8010_control_gpr {
296307

297308
/* old ABI without TLV support */
298309
struct snd_emu10k1_fx8010_control_old_gpr {
299-
struct snd_ctl_elem_id id;
310+
struct emu10k1_ctl_elem_id id;
300311
unsigned int vcount;
301312
unsigned int count;
302313
unsigned short gpr[32];
@@ -310,24 +321,24 @@ struct snd_emu10k1_fx8010_code {
310321
char name[128];
311322

312323
__EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */
313-
__u32 __user *gpr_map; /* initializers */
324+
__u32 *gpr_map; /* initializers */
314325

315326
unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */
316-
struct snd_emu10k1_fx8010_control_gpr __user *gpr_add_controls; /* GPR controls to add/replace */
327+
struct snd_emu10k1_fx8010_control_gpr *gpr_add_controls; /* GPR controls to add/replace */
317328

318329
unsigned int gpr_del_control_count; /* count of GPR controls to remove */
319-
struct snd_ctl_elem_id __user *gpr_del_controls; /* IDs of GPR controls to remove */
330+
struct emu10k1_ctl_elem_id *gpr_del_controls; /* IDs of GPR controls to remove */
320331

321332
unsigned int gpr_list_control_count; /* count of GPR controls to list */
322333
unsigned int gpr_list_control_total; /* total count of GPR controls */
323-
struct snd_emu10k1_fx8010_control_gpr __user *gpr_list_controls; /* listed GPR controls */
334+
struct snd_emu10k1_fx8010_control_gpr *gpr_list_controls; /* listed GPR controls */
324335

325336
__EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */
326-
__u32 __user *tram_data_map; /* data initializers */
327-
__u32 __user *tram_addr_map; /* map initializers */
337+
__u32 *tram_data_map; /* data initializers */
338+
__u32 *tram_addr_map; /* map initializers */
328339

329340
__EMU10K1_DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */
330-
__u32 __user *code; /* one instruction - 64 bits */
341+
__u32 *code; /* one instruction - 64 bits */
331342
};
332343

333344
struct snd_emu10k1_fx8010_tram {
@@ -371,11 +382,14 @@ struct snd_emu10k1_fx8010_pcm_rec {
371382
#define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int)
372383
#define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int)
373384

385+
#ifndef __KERNEL__
374386
/* typedefs for compatibility to user-space */
375387
typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t;
376388
typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t;
377389
typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t;
378390
typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t;
379391
typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t;
392+
typedef struct emu10k1_ctl_elem_id emu10k1_ctl_elem_id_t;
393+
#endif
380394

381395
#endif /* _UAPI__SOUND_EMU10K1_H */

‎sound/pci/emu10k1/emufx.c‎

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu,
628628
}
629629

630630
static struct snd_emu10k1_fx8010_ctl *
631-
snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct snd_ctl_elem_id *id)
631+
snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct emu10k1_ctl_elem_id *id)
632632
{
633633
struct snd_emu10k1_fx8010_ctl *ctl;
634634
struct snd_kcontrol *kcontrol;
@@ -714,15 +714,15 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
714714
bool in_kernel)
715715
{
716716
unsigned int i;
717-
struct snd_ctl_elem_id __user *_id;
718-
struct snd_ctl_elem_id id;
717+
struct emu10k1_ctl_elem_id __user *_id;
718+
struct emu10k1_ctl_elem_id id;
719719
struct snd_emu10k1_fx8010_control_gpr *gctl;
720720
int err;
721721

722-
for (i = 0, _id = icode->gpr_del_controls;
723-
i < icode->gpr_del_control_count; i++, _id++) {
722+
_id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls;
723+
for (i = 0; i < icode->gpr_del_control_count; i++, _id++) {
724724
if (in_kernel)
725-
id = *(__force struct snd_ctl_elem_id *)_id;
725+
id = *(__force struct emu10k1_ctl_elem_id *)_id;
726726
else if (copy_from_user(&id, _id, sizeof(id)))
727727
return -EFAULT;
728728
if (snd_emu10k1_look_for_ctl(emu, &id) == NULL)
@@ -741,7 +741,8 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
741741
if (snd_emu10k1_look_for_ctl(emu, &gctl->id))
742742
continue;
743743
down_read(&emu->card->controls_rwsem);
744-
if (snd_ctl_find_id(emu->card, &gctl->id) != NULL) {
744+
if (snd_ctl_find_id(emu->card,
745+
(struct snd_ctl_elem_id *)&gctl->id)) {
745746
up_read(&emu->card->controls_rwsem);
746747
err = -EEXIST;
747748
goto __error;
@@ -876,15 +877,16 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu,
876877
bool in_kernel)
877878
{
878879
unsigned int i;
879-
struct snd_ctl_elem_id id;
880-
struct snd_ctl_elem_id __user *_id;
880+
struct emu10k1_ctl_elem_id id;
881+
struct emu10k1_ctl_elem_id __user *_id;
881882
struct snd_emu10k1_fx8010_ctl *ctl;
882883
struct snd_card *card = emu->card;
883884

884-
for (i = 0, _id = icode->gpr_del_controls;
885-
i < icode->gpr_del_control_count; i++, _id++) {
885+
_id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls;
886+
887+
for (i = 0; i < icode->gpr_del_control_count; i++, _id++) {
886888
if (in_kernel)
887-
id = *(__force struct snd_ctl_elem_id *)_id;
889+
id = *(__force struct emu10k1_ctl_elem_id *)_id;
888890
else if (copy_from_user(&id, _id, sizeof(id)))
889891
return -EFAULT;
890892
down_write(&card->controls_rwsem);

0 commit comments

Comments
 (0)