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 | #ifndef _UAPI__SOUND_EMU10K1_H | 23 | #ifndef _UAPI__SOUND_EMU10K1_H |
| 24 | #define _UAPI__SOUND_EMU10K1_H | 24 | #define _UAPI__SOUND_EMU10K1_H |
| 25 | 25 | ||
| 26 | #include <linux/types.h> | ||
| 27 | #include <sound/asound.h> | ||
| 28 | |||
| 29 | /* | 26 | /* |
| 30 | * ---- FX8010 ---- | 27 | * ---- FX8010 ---- |
| 31 | */ | 28 | */ |
| @@ -282,8 +279,22 @@ struct snd_emu10k1_fx8010_info { · 250 unmodified lines | |||
| 282 | #define EMU10K1_GPR_TRANSLATION_TREBLE 3 | 279 | #define EMU10K1_GPR_TRANSLATION_TREBLE 3 |
| 283 | #define EMU10K1_GPR_TRANSLATION_ONOFF 4 | 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 | struct snd_emu10k1_fx8010_control_gpr { | 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 | unsigned int vcount; /* visible count */ | 298 | unsigned int vcount; /* visible count */ |
| 288 | unsigned int count; /* count of GPR (1..16) */ | 299 | unsigned int count; /* count of GPR (1..16) */ |
| 289 | unsigned short gpr[32]; /* GPR number(s) */ | 300 | unsigned short gpr[32]; /* GPR number(s) */ |
| @@ -296,7 +307,7 @@ struct snd_emu10k1_fx8010_control_gpr { · 6 unmodified lines | |||
| 296 | 307 | ||
| 297 | /* old ABI without TLV support */ | 308 | /* old ABI without TLV support */ |
| 298 | struct snd_emu10k1_fx8010_control_old_gpr { | 309 | struct snd_emu10k1_fx8010_control_old_gpr { |
| 299 | struct snd_ctl_elem_id id; | 310 | struct emu10k1_ctl_elem_id id; |
| 300 | unsigned int vcount; | 311 | unsigned int vcount; |
| 301 | unsigned int count; | 312 | unsigned int count; |
| 302 | unsigned short gpr[32]; | 313 | unsigned short gpr[32]; |
| @@ -310,24 +321,24 @@ struct snd_emu10k1_fx8010_code { · 7 unmodified lines | |||
| 310 | char name[128]; | 321 | char name[128]; |
| 311 | 322 | ||
| 312 | __EMU10K1_DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */ | 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 | unsigned int gpr_add_control_count; /* count of GPR controls to add/replace */ | 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 | unsigned int gpr_del_control_count; /* count of GPR controls to remove */ | 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 | unsigned int gpr_list_control_count; /* count of GPR controls to list */ | 332 | unsigned int gpr_list_control_count; /* count of GPR controls to list */ |
| 322 | unsigned int gpr_list_control_total; /* total count of GPR controls */ | 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 | __EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */ | 336 | __EMU10K1_DECLARE_BITMAP(tram_valid, 0x100); /* bitmask of valid initializers */ |
| 326 | __u32 __user *tram_data_map; /* data initializers */ | 337 | __u32 *tram_data_map; /* data initializers */ |
| 327 | __u32 __user *tram_addr_map; /* map initializers */ | 338 | __u32 *tram_addr_map; /* map initializers */ |
| 328 | 339 | ||
| 329 | __EMU10K1_DECLARE_BITMAP(code_valid, 1024); /* bitmask of valid instructions */ | 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 | struct snd_emu10k1_fx8010_tram { | 344 | struct snd_emu10k1_fx8010_tram { |
| @@ -371,11 +382,14 @@ struct snd_emu10k1_fx8010_pcm_rec { · 37 unmodified lines | |||
| 371 | #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) | 382 | #define SNDRV_EMU10K1_IOCTL_SINGLE_STEP _IOW ('H', 0x83, int) |
| 372 | #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) | 383 | #define SNDRV_EMU10K1_IOCTL_DBG_READ _IOR ('H', 0x84, int) |
| 373 | 384 | ||
| 385 | #ifndef __KERNEL__ | ||
| 374 | /* typedefs for compatibility to user-space */ | 386 | /* typedefs for compatibility to user-space */ |
| 375 | typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; | 387 | typedef struct snd_emu10k1_fx8010_info emu10k1_fx8010_info_t; |
| 376 | typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; | 388 | typedef struct snd_emu10k1_fx8010_control_gpr emu10k1_fx8010_control_gpr_t; |
| 377 | typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; | 389 | typedef struct snd_emu10k1_fx8010_code emu10k1_fx8010_code_t; |
| 378 | typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; | 390 | typedef struct snd_emu10k1_fx8010_tram emu10k1_fx8010_tram_t; |
| 379 | typedef struct snd_emu10k1_fx8010_pcm_rec emu10k1_fx8010_pcm_t; | 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 | #endif /* _UAPI__SOUND_EMU10K1_H */ | 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 | static struct snd_emu10k1_fx8010_ctl * | 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 | struct snd_emu10k1_fx8010_ctl *ctl; | 633 | struct snd_emu10k1_fx8010_ctl *ctl; |
| 634 | struct snd_kcontrol *kcontrol; | 634 | struct snd_kcontrol *kcontrol; |
| @@ -714,15 +714,15 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, · 79 unmodified lines | |||
| 714 | bool in_kernel) | 714 | bool in_kernel) |
| 715 | { | 715 | { |
| 716 | unsigned int i; | 716 | unsigned int i; |
| 717 | struct snd_ctl_elem_id __user *_id; | 717 | struct emu10k1_ctl_elem_id __user *_id; |
| 718 | struct snd_ctl_elem_id id; | 718 | struct emu10k1_ctl_elem_id id; |
| 719 | struct snd_emu10k1_fx8010_control_gpr *gctl; | 719 | struct snd_emu10k1_fx8010_control_gpr *gctl; |
| 720 | int err; | 720 | int err; |
| 721 | 721 | ||
| 722 | for (i = 0, _id = icode->gpr_del_controls; | 722 | _id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; |
| 723 | i < icode->gpr_del_control_count; i++, _id++) { | 723 | for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { |
| 724 | if (in_kernel) | 724 | if (in_kernel) |
| 725 | id = *(__force struct snd_ctl_elem_id *)_id; | 725 | id = *(__force struct emu10k1_ctl_elem_id *)_id; |
| 726 | else if (copy_from_user(&id, _id, sizeof(id))) | 726 | else if (copy_from_user(&id, _id, sizeof(id))) |
| 727 | return -EFAULT; | 727 | return -EFAULT; |
| 728 | if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) | 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 | if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) | 741 | if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) |
| 742 | continue; | 742 | continue; |
| 743 | down_read(&emu->card->controls_rwsem); | 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 | up_read(&emu->card->controls_rwsem); | 746 | up_read(&emu->card->controls_rwsem); |
| 746 | err = -EEXIST; | 747 | err = -EEXIST; |
| 747 | goto __error; | 748 | goto __error; |
| @@ -876,15 +877,16 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, · 128 unmodified lines | |||
| 876 | bool in_kernel) | 877 | bool in_kernel) |
| 877 | { | 878 | { |
| 878 | unsigned int i; | 879 | unsigned int i; |
| 879 | struct snd_ctl_elem_id id; | 880 | struct emu10k1_ctl_elem_id id; |
| 880 | struct snd_ctl_elem_id __user *_id; | 881 | struct emu10k1_ctl_elem_id __user *_id; |
| 881 | struct snd_emu10k1_fx8010_ctl *ctl; | 882 | struct snd_emu10k1_fx8010_ctl *ctl; |
| 882 | struct snd_card *card = emu->card; | 883 | struct snd_card *card = emu->card; |
| 883 | 884 | ||
| 884 | for (i = 0, _id = icode->gpr_del_controls; | 885 | _id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; |
| 885 | i < icode->gpr_del_control_count; i++, _id++) { | 886 | |
| 887 | for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { | ||
| 886 | if (in_kernel) | 888 | if (in_kernel) |
| 887 | id = *(__force struct snd_ctl_elem_id *)_id; | 889 | id = *(__force struct emu10k1_ctl_elem_id *)_id; |
| 888 | else if (copy_from_user(&id, _id, sizeof(id))) | 890 | else if (copy_from_user(&id, _id, sizeof(id))) |
| 889 | return -EFAULT; | 891 | return -EFAULT; |
| 890 | down_write(&card->controls_rwsem); | 892 | down_write(&card->controls_rwsem); |