Commit 487db1c7 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] dmasound annotation

dmasound (core + ppc-specific parts) annotated
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0a333133
......@@ -44,12 +44,12 @@
#define le2be16dbl(x) (((x)<<8 & 0xff00ff00) | ((x)>>8 & 0x00ff00ff))
#define IOCTL_IN(arg, ret) \
do { int error = get_user(ret, (int *)(arg)); \
do { int error = get_user(ret, (int __user *)(arg)); \
if (error) return error; \
} while (0)
#define IOCTL_OUT(arg, ret) ioctl_return((int *)(arg), ret)
#define IOCTL_OUT(arg, ret) ioctl_return((int __user *)(arg), ret)
static inline int ioctl_return(int *addr, int value)
static inline int ioctl_return(int __user *addr, int value)
{
return value < 0 ? value : put_user(value, addr);
}
......@@ -153,14 +153,14 @@ typedef struct {
*/
typedef struct {
ssize_t (*ct_ulaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_alaw)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u8)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u16be)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u16le)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_ulaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_alaw)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u8)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u16be)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_s16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_u16le)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
} TRANS;
struct sound_settings {
......
......@@ -326,12 +326,12 @@ extern int daca_leave_sleep(void);
#undef IOCTL_OUT
#define IOCTL_IN(arg, ret) \
rc = get_user(ret, (int *)(arg)); \
rc = get_user(ret, (int __user *)(arg)); \
if (rc) break;
#define IOCTL_OUT(arg, ret) \
ioctl_return2((int *)(arg), ret)
ioctl_return2((int __user *)(arg), ret)
static inline int ioctl_return2(int *addr, int value)
static inline int ioctl_return2(int __user *addr, int value)
{
return value < 0 ? value : put_user(value, addr);
}
......@@ -514,6 +514,7 @@ tas_set_frame_rate(void)
static int
tas_mixer_ioctl(u_int cmd, u_long arg)
{
int __user *argp = (int __user *)arg;
int data;
int rc;
......@@ -524,16 +525,16 @@ tas_mixer_ioctl(u_int cmd, u_long arg)
if ((cmd & ~0xff) == MIXER_WRITE(0) &&
tas_supported_mixers() & (1<<(cmd & 0xff))) {
rc = get_user(data, (int *)(arg));
rc = get_user(data, argp);
if (rc<0) return rc;
tas_set_mixer_level(cmd & 0xff, data);
tas_get_mixer_level(cmd & 0xff, &data);
return ioctl_return2((int *)(arg), data);
return ioctl_return2(argp, data);
}
if ((cmd & ~0xff) == MIXER_READ(0) &&
tas_supported_mixers() & (1<<(cmd & 0xff))) {
tas_get_mixer_level(cmd & 0xff, &data);
return ioctl_return2((int *)(arg), data);
return ioctl_return2(argp, data);
}
switch(cmd) {
......
......@@ -279,11 +279,11 @@ static int sound_set_stereo(int stereo)
return stereo;
}
static ssize_t sound_copy_translate(TRANS *trans, const u_char *userPtr,
static ssize_t sound_copy_translate(TRANS *trans, const u_char __user *userPtr,
size_t userCount, u_char frame[],
ssize_t *frameUsed, ssize_t frameLeft)
{
ssize_t (*ct_func)(const u_char *, size_t, u_char *, ssize_t *, ssize_t);
ssize_t (*ct_func)(const u_char __user *, size_t, u_char *, ssize_t *, ssize_t);
switch (dmasound.soft.format) {
case AFMT_MU_LAW:
......@@ -361,7 +361,7 @@ static int mixer_ioctl(struct inode *inode, struct file *file, u_int cmd,
strlcpy(info.id, dmasound.mach.name2, sizeof(info.id));
strlcpy(info.name, dmasound.mach.name2, sizeof(info.name));
info.modify_counter = mixer.modify_counter;
if (copy_to_user((int *)arg, &info, sizeof(info)))
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
}
......@@ -546,7 +546,7 @@ static inline void sq_play(void)
dmasound.mach.play();
}
static ssize_t sq_write(struct file *file, const char *src, size_t uLeft,
static ssize_t sq_write(struct file *file, const char __user *src, size_t uLeft,
loff_t *ppos)
{
ssize_t uWritten = 0;
......@@ -703,7 +703,7 @@ static unsigned int sq_poll(struct file *file, struct poll_table_struct *wait)
* it and restart the DMA.
*/
static ssize_t sq_read(struct file *file, char *dst, size_t uLeft,
static ssize_t sq_read(struct file *file, char __user *dst, size_t uLeft,
loff_t *ppos)
{
......@@ -1321,7 +1321,7 @@ static int sq_ioctl(struct inode *inode, struct file *file, u_int cmd,
info.fragstotal = write_sq.max_active;
info.fragsize = write_sq.user_frag_size;
info.bytes = info.fragments * info.fragsize;
if (copy_to_user((void *)arg, &info, sizeof(info)))
if (copy_to_user((void __user *)arg, &info, sizeof(info)))
return -EFAULT;
return 0;
} else
......@@ -1547,7 +1547,7 @@ static int state_release(struct inode *inode, struct file *file)
return 0;
}
static ssize_t state_read(struct file *file, char *buf, size_t count,
static ssize_t state_read(struct file *file, char __user *buf, size_t count,
loff_t *ppos)
{
int n = state.len - state.ptr;
......
......@@ -452,8 +452,9 @@ tas3001c_eq_rw( struct tas3001c_data_t *self,
{
int rc;
struct tas_biquad_ctrl_t biquad;
void __user *argp = (void __user *)arg;
if (copy_from_user((void *)&biquad, (const void *)arg, sizeof(struct tas_biquad_ctrl_t))) {
if (copy_from_user(&biquad, argp, sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -466,7 +467,7 @@ tas3001c_eq_rw( struct tas3001c_data_t *self,
rc=tas3001c_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
if (rc != 0) return rc;
if (copy_to_user((void *)arg, (const void *)&biquad, sizeof(struct tas_biquad_ctrl_t))) {
if (copy_to_user(argp, &biquad, sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -485,27 +486,21 @@ tas3001c_eq_list_rw( struct tas3001c_data_t *self,
int i,j;
char sync_required[2][6];
struct tas_biquad_ctrl_t biquad;
struct tas_biquad_ctrl_list_t __user *argp = (void __user *)arg;
memset(sync_required,0,sizeof(sync_required));
if (copy_from_user((void *)&filter_count,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,filter_count),
sizeof(int))) {
if (copy_from_user(&filter_count, &argp->filter_count, sizeof(int)))
return -EFAULT;
}
if (copy_from_user((void *)&flags,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,flags),
sizeof(int))) {
if (copy_from_user(&flags, &argp->flags, sizeof(int)))
return -EFAULT;
}
if (cmd & SIOC_IN) {
}
for (i=0; i < filter_count; i++) {
if (copy_from_user((void *)&biquad,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
if (copy_from_user(&biquad, &argp->biquads[i],
sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -520,8 +515,7 @@ tas3001c_eq_list_rw( struct tas3001c_data_t *self,
rc=tas3001c_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
if (rc != 0) return rc;
if (copy_to_user((void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
(const void *)&biquad,
if (copy_to_user(&argp->biquads[i], &biquad,
sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -596,12 +590,10 @@ tas3001c_drce_rw( struct tas3001c_data_t *self,
{
int rc;
struct tas_drce_ctrl_t drce_ctrl;
void __user *argp = (void __user *)arg;
if (copy_from_user((void *)&drce_ctrl,
(const void *)arg,
sizeof(struct tas_drce_ctrl_t))) {
if (copy_from_user(&drce_ctrl, argp, sizeof(struct tas_drce_ctrl_t)))
return -EFAULT;
}
#ifdef DEBUG_DRCE
printk("DRCE IOCTL: input [ FLAGS:%x ENABLE:%x THRESH:%x\n",
......@@ -623,8 +615,7 @@ tas3001c_drce_rw( struct tas3001c_data_t *self,
if (drce_ctrl.flags & TAS_DRCE_THRESHOLD)
drce_ctrl.data.threshold = self->drce_state.threshold;
if (copy_to_user((void *)arg,
(const void *)&drce_ctrl,
if (copy_to_user(argp, &drce_ctrl,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......@@ -703,6 +694,7 @@ tas3001c_device_ioctl( struct tas3001c_data_t *self,
u_int cmd,
u_long arg)
{
uint __user *argp = (void __user *)arg;
switch (cmd) {
case TAS_READ_EQ:
case TAS_WRITE_EQ:
......@@ -713,11 +705,11 @@ tas3001c_device_ioctl( struct tas3001c_data_t *self,
return tas3001c_eq_list_rw(self, cmd, arg);
case TAS_READ_EQ_FILTER_COUNT:
put_user(TAS3001C_BIQUAD_FILTER_COUNT, (uint *)(arg));
put_user(TAS3001C_BIQUAD_FILTER_COUNT, argp);
return 0;
case TAS_READ_EQ_CHANNEL_COUNT:
put_user(TAS3001C_BIQUAD_CHANNEL_COUNT, (uint *)(arg));
put_user(TAS3001C_BIQUAD_CHANNEL_COUNT, argp);
return 0;
case TAS_READ_DRCE:
......@@ -725,15 +717,14 @@ tas3001c_device_ioctl( struct tas3001c_data_t *self,
return tas3001c_drce_rw(self, cmd, arg);
case TAS_READ_DRCE_CAPS:
put_user(TAS_DRCE_ENABLE | TAS_DRCE_THRESHOLD, (uint *)(arg));
put_user(TAS_DRCE_ENABLE | TAS_DRCE_THRESHOLD, argp);
return 0;
case TAS_READ_DRCE_MIN:
case TAS_READ_DRCE_MAX: {
struct tas_drce_ctrl_t drce_ctrl;
if (copy_from_user((void *)&drce_ctrl,
(const void *)arg,
if (copy_from_user(&drce_ctrl, argp,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......@@ -746,8 +737,7 @@ tas3001c_device_ioctl( struct tas3001c_data_t *self,
}
}
if (copy_to_user((void *)arg,
(const void *)&drce_ctrl,
if (copy_to_user(argp, &drce_ctrl,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......
......@@ -3,12 +3,12 @@
static struct tas_drce_t eqp_0e_2_1_drce = {
.enable = 1,
.above { .val = 3.0 * (1<<8), .expand = 0 },
.below { .val = 1.0 * (1<<8), .expand = 0 },
.threshold -15.33 * (1<<8),
.energy 2.4 * (1<<12),
.attack 0.013 * (1<<12),
.decay 0.212 * (1<<12),
.above = { .val = 3.0 * (1<<8), .expand = 0 },
.below = { .val = 1.0 * (1<<8), .expand = 0 },
.threshold = -15.33 * (1<<8),
.energy = 2.4 * (1<<12),
.attack = 0.013 * (1<<12),
.decay = 0.212 * (1<<12),
};
static struct tas_biquad_ctrl_t eqp_0e_2_1_biquads[]={
......
......@@ -635,10 +635,11 @@ tas3004_eq_rw( struct tas3004_data_t *self,
u_int cmd,
u_long arg)
{
void __user *argp = (void __user *)arg;
int rc;
struct tas_biquad_ctrl_t biquad;
if (copy_from_user((void *)&biquad, (const void *)arg, sizeof(struct tas_biquad_ctrl_t))) {
if (copy_from_user((void *)&biquad, argp, sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -651,7 +652,7 @@ tas3004_eq_rw( struct tas3004_data_t *self,
rc=tas3004_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
if (rc != 0) return rc;
if (copy_to_user((void *)arg, (const void *)&biquad, sizeof(struct tas_biquad_ctrl_t))) {
if (copy_to_user(argp, &biquad, sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -670,27 +671,21 @@ tas3004_eq_list_rw( struct tas3004_data_t *self,
int i,j;
char sync_required[TAS3004_BIQUAD_CHANNEL_COUNT][TAS3004_BIQUAD_FILTER_COUNT];
struct tas_biquad_ctrl_t biquad;
struct tas_biquad_ctrl_list_t __user *argp = (void __user *)arg;
memset(sync_required,0,sizeof(sync_required));
if (copy_from_user((void *)&filter_count,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,filter_count),
sizeof(int))) {
if (copy_from_user(&filter_count, &argp->filter_count, sizeof(int)))
return -EFAULT;
}
if (copy_from_user((void *)&flags,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t,flags),
sizeof(int))) {
if (copy_from_user(&flags, &argp->flags, sizeof(int)))
return -EFAULT;
}
if (cmd & SIOC_IN) {
}
for (i=0; i < filter_count; i++) {
if (copy_from_user((void *)&biquad,
(const void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
if (copy_from_user(&biquad, &argp->biquads[i],
sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -705,8 +700,7 @@ tas3004_eq_list_rw( struct tas3004_data_t *self,
rc=tas3004_read_biquad(self, biquad.channel, biquad.filter, &biquad.data);
if (rc != 0) return rc;
if (copy_to_user((void *)arg + offsetof(struct tas_biquad_ctrl_list_t, biquads[i]),
(const void *)&biquad,
if (copy_to_user(&argp->biquads[i], &biquad,
sizeof(struct tas_biquad_ctrl_t))) {
return -EFAULT;
}
......@@ -840,12 +834,10 @@ tas3004_drce_rw( struct tas3004_data_t *self,
{
int rc;
struct tas_drce_ctrl_t drce_ctrl;
void __user *argp = (void __user *)arg;
if (copy_from_user((void *)&drce_ctrl,
(const void *)arg,
sizeof(struct tas_drce_ctrl_t))) {
if (copy_from_user(&drce_ctrl, argp, sizeof(struct tas_drce_ctrl_t)))
return -EFAULT;
}
#ifdef DEBUG_DRCE
printk("DRCE: input [ FLAGS:%x ENABLE:%x ABOVE:%x/%x BELOW:%x/%x THRESH:%x ENERGY:%x ATTACK:%x DECAY:%x\n",
......@@ -880,8 +872,7 @@ tas3004_drce_rw( struct tas3004_data_t *self,
if (drce_ctrl.flags & TAS_DRCE_DECAY)
drce_ctrl.data.decay = self->drce_state.decay;
if (copy_to_user((void *)arg,
(const void *)&drce_ctrl,
if (copy_to_user(argp, &drce_ctrl,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......@@ -952,6 +943,7 @@ tas3004_device_ioctl( struct tas3004_data_t *self,
u_int cmd,
u_long arg)
{
uint __user *argp = (void __user *)arg;
switch (cmd) {
case TAS_READ_EQ:
case TAS_WRITE_EQ:
......@@ -962,11 +954,11 @@ tas3004_device_ioctl( struct tas3004_data_t *self,
return tas3004_eq_list_rw(self, cmd, arg);
case TAS_READ_EQ_FILTER_COUNT:
put_user(TAS3004_BIQUAD_FILTER_COUNT, (uint *)(arg));
put_user(TAS3004_BIQUAD_FILTER_COUNT, argp);
return 0;
case TAS_READ_EQ_CHANNEL_COUNT:
put_user(TAS3004_BIQUAD_CHANNEL_COUNT, (uint *)(arg));
put_user(TAS3004_BIQUAD_CHANNEL_COUNT, argp);
return 0;
case TAS_READ_DRCE:
......@@ -981,7 +973,7 @@ tas3004_device_ioctl( struct tas3004_data_t *self,
TAS_DRCE_ENERGY |
TAS_DRCE_ATTACK |
TAS_DRCE_DECAY,
(uint *)(arg));
argp);
return 0;
case TAS_READ_DRCE_MIN:
......@@ -989,8 +981,7 @@ tas3004_device_ioctl( struct tas3004_data_t *self,
struct tas_drce_ctrl_t drce_ctrl;
const struct tas_drce_t *drce_copy;
if (copy_from_user((void *)&drce_ctrl,
(const void *)arg,
if (copy_from_user(&drce_ctrl, argp,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......@@ -1020,8 +1011,7 @@ tas3004_device_ioctl( struct tas3004_data_t *self,
drce_ctrl.data.decay=drce_copy->decay;
}
if (copy_to_user((void *)arg,
(const void *)&drce_ctrl,
if (copy_to_user(argp, &drce_ctrl,
sizeof(struct tas_drce_ctrl_t))) {
return -EFAULT;
}
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment