kdebugfs.c (5b45fe6b39e1d01c45de7b8e6d3ff72585eee6cf) | kdebugfs.c (f7750a79568788473c5e8092ee58a52248f34329) |
---|---|
1/* 2 * Architecture specific debugfs files 3 * 4 * Copyright (C) 2007, Intel Corp. 5 * Huang Ying <ying.huang@intel.com> 6 * 7 * This file is released under the GPLv2. 8 */ --- 19 unchanged lines hidden (view full) --- 28}; 29 30static ssize_t setup_data_read(struct file *file, char __user *user_buf, 31 size_t count, loff_t *ppos) 32{ 33 struct setup_data_node *node = file->private_data; 34 unsigned long remain; 35 loff_t pos = *ppos; | 1/* 2 * Architecture specific debugfs files 3 * 4 * Copyright (C) 2007, Intel Corp. 5 * Huang Ying <ying.huang@intel.com> 6 * 7 * This file is released under the GPLv2. 8 */ --- 19 unchanged lines hidden (view full) --- 28}; 29 30static ssize_t setup_data_read(struct file *file, char __user *user_buf, 31 size_t count, loff_t *ppos) 32{ 33 struct setup_data_node *node = file->private_data; 34 unsigned long remain; 35 loff_t pos = *ppos; |
36 struct page *pg; | |
37 void *p; 38 u64 pa; 39 40 if (pos < 0) 41 return -EINVAL; 42 43 if (pos >= node->len) 44 return 0; 45 46 if (count > node->len - pos) 47 count = node->len - pos; 48 49 pa = node->paddr + sizeof(struct setup_data) + pos; | 36 void *p; 37 u64 pa; 38 39 if (pos < 0) 40 return -EINVAL; 41 42 if (pos >= node->len) 43 return 0; 44 45 if (count > node->len - pos) 46 count = node->len - pos; 47 48 pa = node->paddr + sizeof(struct setup_data) + pos; |
50 pg = pfn_to_page((pa + count - 1) >> PAGE_SHIFT); 51 if (PageHighMem(pg)) { 52 p = ioremap_cache(pa, count); 53 if (!p) 54 return -ENXIO; 55 } else 56 p = __va(pa); | 49 p = memremap(pa, count, MEMREMAP_WB); 50 if (!p) 51 return -ENOMEM; |
57 58 remain = copy_to_user(user_buf, p, count); 59 | 52 53 remain = copy_to_user(user_buf, p, count); 54 |
60 if (PageHighMem(pg)) 61 iounmap(p); | 55 memunmap(p); |
62 63 if (remain) 64 return -EFAULT; 65 66 *ppos = pos + count; 67 68 return count; 69} --- 34 unchanged lines hidden (view full) --- 104} 105 106static int __init create_setup_data_nodes(struct dentry *parent) 107{ 108 struct setup_data_node *node; 109 struct setup_data *data; 110 int error; 111 struct dentry *d; | 56 57 if (remain) 58 return -EFAULT; 59 60 *ppos = pos + count; 61 62 return count; 63} --- 34 unchanged lines hidden (view full) --- 98} 99 100static int __init create_setup_data_nodes(struct dentry *parent) 101{ 102 struct setup_data_node *node; 103 struct setup_data *data; 104 int error; 105 struct dentry *d; |
112 struct page *pg; | |
113 u64 pa_data; 114 int no = 0; 115 116 d = debugfs_create_dir("setup_data", parent); 117 if (!d) 118 return -ENOMEM; 119 120 pa_data = boot_params.hdr.setup_data; 121 122 while (pa_data) { 123 node = kmalloc(sizeof(*node), GFP_KERNEL); 124 if (!node) { 125 error = -ENOMEM; 126 goto err_dir; 127 } 128 | 106 u64 pa_data; 107 int no = 0; 108 109 d = debugfs_create_dir("setup_data", parent); 110 if (!d) 111 return -ENOMEM; 112 113 pa_data = boot_params.hdr.setup_data; 114 115 while (pa_data) { 116 node = kmalloc(sizeof(*node), GFP_KERNEL); 117 if (!node) { 118 error = -ENOMEM; 119 goto err_dir; 120 } 121 |
129 pg = pfn_to_page((pa_data+sizeof(*data)-1) >> PAGE_SHIFT); 130 if (PageHighMem(pg)) { 131 data = ioremap_cache(pa_data, sizeof(*data)); 132 if (!data) { 133 kfree(node); 134 error = -ENXIO; 135 goto err_dir; 136 } 137 } else 138 data = __va(pa_data); | 122 data = memremap(pa_data, sizeof(*data), MEMREMAP_WB); 123 if (!data) { 124 kfree(node); 125 error = -ENOMEM; 126 goto err_dir; 127 } |
139 140 node->paddr = pa_data; 141 node->type = data->type; 142 node->len = data->len; 143 error = create_setup_data_node(d, no, node); 144 pa_data = data->next; 145 | 128 129 node->paddr = pa_data; 130 node->type = data->type; 131 node->len = data->len; 132 error = create_setup_data_node(d, no, node); 133 pa_data = data->next; 134 |
146 if (PageHighMem(pg)) 147 iounmap(data); | 135 memunmap(data); |
148 if (error) 149 goto err_dir; 150 no++; 151 } 152 153 return 0; 154 155err_dir: --- 59 unchanged lines hidden --- | 136 if (error) 137 goto err_dir; 138 no++; 139 } 140 141 return 0; 142 143err_dir: --- 59 unchanged lines hidden --- |