~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/char/mem.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
#ifndef ARCH_HAS_VALID_PHYS_ADDR_RANGE
48
48
static inline int valid_phys_addr_range(unsigned long addr, size_t count)
49
49
{
50
 
        if (addr + count > __pa(high_memory))
51
 
                return 0;
52
 
 
53
 
        return 1;
 
50
        return addr + count <= __pa(high_memory);
54
51
}
55
52
 
56
53
static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t size)
809
806
};
810
807
#endif
811
808
 
812
 
static ssize_t kmsg_write(struct file *file, const char __user *buf,
813
 
                          size_t count, loff_t *ppos)
 
809
static ssize_t kmsg_writev(struct kiocb *iocb, const struct iovec *iv,
 
810
                           unsigned long count, loff_t pos)
814
811
{
815
 
        char *tmp;
816
 
        ssize_t ret;
 
812
        char *line, *p;
 
813
        int i;
 
814
        ssize_t ret = -EFAULT;
 
815
        size_t len = iov_length(iv, count);
817
816
 
818
 
        tmp = kmalloc(count + 1, GFP_KERNEL);
819
 
        if (tmp == NULL)
 
817
        line = kmalloc(len + 1, GFP_KERNEL);
 
818
        if (line == NULL)
820
819
                return -ENOMEM;
821
 
        ret = -EFAULT;
822
 
        if (!copy_from_user(tmp, buf, count)) {
823
 
                tmp[count] = 0;
824
 
                ret = printk("%s", tmp);
825
 
                if (ret > count)
826
 
                        /* printk can add a prefix */
827
 
                        ret = count;
 
820
 
 
821
        /*
 
822
         * copy all vectors into a single string, to ensure we do
 
823
         * not interleave our log line with other printk calls
 
824
         */
 
825
        p = line;
 
826
        for (i = 0; i < count; i++) {
 
827
                if (copy_from_user(p, iv[i].iov_base, iv[i].iov_len))
 
828
                        goto out;
 
829
                p += iv[i].iov_len;
828
830
        }
829
 
        kfree(tmp);
 
831
        p[0] = '\0';
 
832
 
 
833
        ret = printk("%s", line);
 
834
        /* printk can add a prefix */
 
835
        if (ret > len)
 
836
                ret = len;
 
837
out:
 
838
        kfree(line);
830
839
        return ret;
831
840
}
832
841
 
833
842
static const struct file_operations kmsg_fops = {
834
 
        .write = kmsg_write,
 
843
        .aio_write = kmsg_writev,
835
844
        .llseek = noop_llseek,
836
845
};
837
846