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.
Unified · Split
| @@ -23,9 +23,6 @@ · 22 unmodified lines | ||
| 23 | 23 | #ifndef _UAPI__SOUND_EMU10K1_H |
| 24 | 24 | #define _UAPI__SOUND_EMU10K1_H |
| 25 | 25 | |
| 26 | −#include <linux/types.h> | |
| 27 | −#include <sound/asound.h> | |
| 28 | − | |
| 29 | 26 | /* |
| 30 | 27 | * ---- FX8010 ---- |
| 31 | 28 | */ |
| @@ -282,8 +279,22 @@ struct snd_emu10k1_fx8010_info { · 250 unmodified lines | ||
| 282 | 279 | #define EMU10K1_GPR_TRANSLATION_TREBLE 3 |
| 283 | 280 | #define EMU10K1_GPR_TRANSLATION_ONOFF 4 |
| 284 | 281 | |
| 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 | + | |
| 285 | 296 | 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 */ | |
| 287 | 298 | unsigned int vcount; /* visible count */ |
| 288 | 299 | unsigned int count; /* count of GPR (1..16) */ |
| 289 | 300 | unsigned short gpr[32]; /* GPR number(s) */ |
| @@ -296,7 +307,7 @@ struct snd_emu10k1_fx8010_control_gpr { · 6 unmodified lines | ||
| 296 | 307 | |
| 297 | 308 | /* old ABI without TLV support */ |
| 298 | 309 | struct snd_emu10k1_fx8010_control_old_gpr { |
| 299 | − struct snd_ctl_elem_id id; | |
| 310 | + struct emu10k1_ctl_elem_id id; | |
| 300 | 311 | unsigned int vcount; |
| 301 | 312 | unsigned int count; |
| 302 | 313 | unsigned short gpr[32]; |
| @@ -310,24 +321,24 @@ struct snd_emu10k1_fx8010_code { · 7 unmodified lines | ||
| 310 | 321 | char name[128]; |
| 311 | 322 | |
| 312 | 323 | __EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */ |
| 313 | − __u32 __user *gpr_map; /* initializers */ | |
| 324 | + __u32 *gpr_map; /* initializers */ | |
| 314 | 325 | |
| 315 | 326 | 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 */ | |
| 317 | 328 | |
| 318 | 329 | 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 */ | |
| 320 | 331 | |
| 321 | 332 | unsigned int gpr_list_control_count; /* count of GPR controls to list */ |
| 322 | 333 | 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 */ | |
| 324 | 335 | |
| 325 | 336 | __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 */ | |
| 328 | 339 | |
| 329 | 340 | __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 */ | |
| 331 | 342 | }; |
| 332 | 343 | |
| 333 | 344 | struct snd_emu10k1_fx8010_tram { |
| @@ -371,11 +382,14 @@ struct snd_emu10k1_fx8010_pcm_rec { · 37 unmodified lines | ||
| 371 | 382 | #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) |
| 372 | 383 | #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) |
| 373 | 384 | |
| 385 | +#ifndef __KERNEL__ | |
| 374 | 386 | /* typedefs for compatibility to user-space */ |
| 375 | 387 | typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; |
| 376 | 388 | typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; |
| 377 | 389 | typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; |
| 378 | 390 | typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; |
| 379 | 391 | 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 | |
| 380 | 394 | |
| 381 | 395 | #endif /* _UAPI__SOUND_EMU10K1_H */ |
| @@ -628,7 +628,7 @@ static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, · 627 unmodified lines | ||
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | 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) | |
| 632 | 632 | { |
| 633 | 633 | struct snd_emu10k1_fx8010_ctl *ctl; |
| 634 | 634 | struct snd_kcontrol *kcontrol; |
| @@ -714,15 +714,15 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, · 79 unmodified lines | ||
| 714 | 714 | bool in_kernel) |
| 715 | 715 | { |
| 716 | 716 | 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; | |
| 719 | 719 | struct snd_emu10k1_fx8010_control_gpr *gctl; |
| 720 | 720 | int err; |
| 721 | 721 | |
| 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++) { | |
| 724 | 724 | if (in_kernel) |
| 725 | − id = *(__force struct snd_ctl_elem_id *)_id; | |
| 725 | + id = *(__force struct emu10k1_ctl_elem_id *)_id; | |
| 726 | 726 | else if (copy_from_user(&id, _id, sizeof(id))) |
| 727 | 727 | return -EFAULT; |
| 728 | 728 | if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) |
| @@ -741,7 +741,8 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, · 12 unmodified lines | ||
| 741 | 741 | if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) |
| 742 | 742 | continue; |
| 743 | 743 | 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)) { | |
| 745 | 746 | up_read(&emu->card->controls_rwsem); |
| 746 | 747 | err = -EEXIST; |
| 747 | 748 | goto __error; |
| @@ -876,15 +877,16 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, · 128 unmodified lines | ||
| 876 | 877 | bool in_kernel) |
| 877 | 878 | { |
| 878 | 879 | 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; | |
| 881 | 882 | struct snd_emu10k1_fx8010_ctl *ctl; |
| 882 | 883 | struct snd_card *card = emu->card; |
| 883 | 884 | |
| 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++) { | |
| 886 | 888 | if (in_kernel) |
| 887 | − id = *(__force struct snd_ctl_elem_id *)_id; | |
| 889 | + id = *(__force struct emu10k1_ctl_elem_id *)_id; | |
| 888 | 890 | else if (copy_from_user(&id, _id, sizeof(id))) |
| 889 | 891 | return -EFAULT; |
| 890 | 892 | down_write(&card->controls_rwsem); |