Ignore:
Timestamp:
Apr 3, 2017, 4:51:56 PM (8 years ago)
Author:
David Azarewicz
Message:

Merged/reintegrated v2 branch into trunk. Trunk is now v2

Location:
GPL/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GPL/trunk

  • GPL/trunk/alsa-kernel/pci/emu10k1/emuproc.c

    r399 r598  
    342342#define A_TOTAL_SIZE_CODE       (0x400*8)
    343343
    344 static long snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
    345                                     void *file_private_data,
    346                                     struct file *file, char __user *buf,
    347                                     unsigned long count, unsigned long pos)
    348 {
    349         long size;
     344static ssize_t snd_emu10k1_fx8010_read(struct snd_info_entry *entry,
     345                                       void *file_private_data,
     346                                       struct file *file, char __user *buf,
     347                                       size_t count, loff_t pos)
     348{
    350349        struct snd_emu10k1 *emu = entry->private_data;
    351350        unsigned int offset;
    352351        int tram_addr = 0;
     352        unsigned int *tmp;
     353        long res;
     354        unsigned int idx;
    353355       
    354356        if (!strcmp(entry->name, "fx8010_tram_addr")) {
     
    362364                offset = emu->audigy ? A_FXGPREGBASE : FXGPREGBASE;
    363365        }
    364         size = count;
    365         if (pos + size > entry->size)
    366                 size = (long)entry->size - pos;
    367         if (size > 0) {
    368                 unsigned int *tmp;
    369                 long res;
    370                 unsigned int idx;
    371                 if ((tmp = kmalloc(size + 8, GFP_KERNEL)) == NULL)
    372                         return -ENOMEM;
    373                 for (idx = 0; idx < ((pos & 3) + size + 3) >> 2; idx++)
    374                         if (tram_addr && emu->audigy) {
    375                                 tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0) >> 11;
    376                                 tmp[idx] |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
    377                         } else
    378                                 tmp[idx] = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
    379                 if (copy_to_user(buf, ((char *)tmp) + (pos & 3), size))
    380                         res = -EFAULT;
    381                 else {
    382                         res = size;
     366
     367        tmp = kmalloc(count + 8, GFP_KERNEL);
     368        if (!tmp)
     369                return -ENOMEM;
     370        for (idx = 0; idx < ((pos & 3) + count + 3) >> 2; idx++) {
     371                unsigned int val;
     372                val = snd_emu10k1_ptr_read(emu, offset + idx + (pos >> 2), 0);
     373                if (tram_addr && emu->audigy) {
     374                        val >>= 11;
     375                        val |= snd_emu10k1_ptr_read(emu, 0x100 + idx + (pos >> 2), 0) << 20;
    383376                }
    384                 kfree(tmp);
    385                 return res;
    386         }
    387         return 0;
     377                tmp[idx] = val;
     378        }
     379        if (copy_to_user(buf, ((char *)tmp) + (pos & 3), count))
     380                res = -EFAULT;
     381        else
     382                res = count;
     383        kfree(tmp);
     384        return res;
    388385}
    389386
     
    452449                if (sscanf(line, "%x %x", &reg, &val) != 2)
    453450                        continue;
    454                 if ((reg < 0x40) && (reg >= 0) && (val <= 0xffffffff) ) {
     451                if (reg < 0x40 && val <= 0xffffffff) {
    455452                        spin_lock_irqsave(&emu->emu_lock, flags);
    456453                        outl(val, emu->port + (reg & 0xfffffffc));
     
    528525                if (sscanf(line, "%x %x %x", &reg, &channel_id, &val) != 3)
    529526                        continue;
    530                 if ((reg < 0xa0) && (reg >= 0) && (val <= 0xffffffff) && (channel_id >= 0) && (channel_id <= 3) )
     527                if (reg < 0xa0 && val <= 0xffffffff && channel_id <= 3)
    531528                        snd_ptr_write(emu, iobase, reg, channel_id, val);
    532529        }
Note: See TracChangeset for help on using the changeset viewer.