Commit 3d645b02d9c6254caf51d9d78e6d9caf72990b33

Authored by Lisa Nguyen
Committed by Konrad Rzeszutek Wilk
1 parent d7e5075044

xen/xenbus: Fixed over 80 character limit issue

Fixed the format length of the xenbus_backend_ioctl()
function to meet the 80 character limit in
xenbus_dev_backend.c

Signed-off-by: Lisa Nguyen <lisa@xenapiadmin.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

Showing 1 changed file with 2 additions and 1 deletions Inline Diff

drivers/xen/xenbus/xenbus_dev_backend.c
1 #include <linux/slab.h> 1 #include <linux/slab.h>
2 #include <linux/types.h> 2 #include <linux/types.h>
3 #include <linux/mm.h> 3 #include <linux/mm.h>
4 #include <linux/fs.h> 4 #include <linux/fs.h>
5 #include <linux/miscdevice.h> 5 #include <linux/miscdevice.h>
6 #include <linux/module.h> 6 #include <linux/module.h>
7 #include <linux/capability.h> 7 #include <linux/capability.h>
8 8
9 #include <xen/xen.h> 9 #include <xen/xen.h>
10 #include <xen/page.h> 10 #include <xen/page.h>
11 #include <xen/xenbus.h> 11 #include <xen/xenbus.h>
12 #include <xen/xenbus_dev.h> 12 #include <xen/xenbus_dev.h>
13 #include <xen/grant_table.h> 13 #include <xen/grant_table.h>
14 #include <xen/events.h> 14 #include <xen/events.h>
15 #include <asm/xen/hypervisor.h> 15 #include <asm/xen/hypervisor.h>
16 16
17 #include "xenbus_comms.h" 17 #include "xenbus_comms.h"
18 18
19 MODULE_LICENSE("GPL"); 19 MODULE_LICENSE("GPL");
20 20
21 static int xenbus_backend_open(struct inode *inode, struct file *filp) 21 static int xenbus_backend_open(struct inode *inode, struct file *filp)
22 { 22 {
23 if (!capable(CAP_SYS_ADMIN)) 23 if (!capable(CAP_SYS_ADMIN))
24 return -EPERM; 24 return -EPERM;
25 25
26 return nonseekable_open(inode, filp); 26 return nonseekable_open(inode, filp);
27 } 27 }
28 28
29 static long xenbus_alloc(domid_t domid) 29 static long xenbus_alloc(domid_t domid)
30 { 30 {
31 struct evtchn_alloc_unbound arg; 31 struct evtchn_alloc_unbound arg;
32 int err = -EEXIST; 32 int err = -EEXIST;
33 33
34 xs_suspend(); 34 xs_suspend();
35 35
36 /* If xenstored_ready is nonzero, that means we have already talked to 36 /* If xenstored_ready is nonzero, that means we have already talked to
37 * xenstore and set up watches. These watches will be restored by 37 * xenstore and set up watches. These watches will be restored by
38 * xs_resume, but that requires communication over the port established 38 * xs_resume, but that requires communication over the port established
39 * below that is not visible to anyone until the ioctl returns. 39 * below that is not visible to anyone until the ioctl returns.
40 * 40 *
41 * This can be resolved by splitting the ioctl into two parts 41 * This can be resolved by splitting the ioctl into two parts
42 * (postponing the resume until xenstored is active) but this is 42 * (postponing the resume until xenstored is active) but this is
43 * unnecessarily complex for the intended use where xenstored is only 43 * unnecessarily complex for the intended use where xenstored is only
44 * started once - so return -EEXIST if it's already running. 44 * started once - so return -EEXIST if it's already running.
45 */ 45 */
46 if (xenstored_ready) 46 if (xenstored_ready)
47 goto out_err; 47 goto out_err;
48 48
49 gnttab_grant_foreign_access_ref(GNTTAB_RESERVED_XENSTORE, domid, 49 gnttab_grant_foreign_access_ref(GNTTAB_RESERVED_XENSTORE, domid,
50 virt_to_mfn(xen_store_interface), 0 /* writable */); 50 virt_to_mfn(xen_store_interface), 0 /* writable */);
51 51
52 arg.dom = DOMID_SELF; 52 arg.dom = DOMID_SELF;
53 arg.remote_dom = domid; 53 arg.remote_dom = domid;
54 54
55 err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &arg); 55 err = HYPERVISOR_event_channel_op(EVTCHNOP_alloc_unbound, &arg);
56 if (err) 56 if (err)
57 goto out_err; 57 goto out_err;
58 58
59 if (xen_store_evtchn > 0) 59 if (xen_store_evtchn > 0)
60 xb_deinit_comms(); 60 xb_deinit_comms();
61 61
62 xen_store_evtchn = arg.port; 62 xen_store_evtchn = arg.port;
63 63
64 xs_resume(); 64 xs_resume();
65 65
66 return arg.port; 66 return arg.port;
67 67
68 out_err: 68 out_err:
69 xs_suspend_cancel(); 69 xs_suspend_cancel();
70 return err; 70 return err;
71 } 71 }
72 72
73 static long xenbus_backend_ioctl(struct file *file, unsigned int cmd, unsigned long data) 73 static long xenbus_backend_ioctl(struct file *file, unsigned int cmd,
74 unsigned long data)
74 { 75 {
75 if (!capable(CAP_SYS_ADMIN)) 76 if (!capable(CAP_SYS_ADMIN))
76 return -EPERM; 77 return -EPERM;
77 78
78 switch (cmd) { 79 switch (cmd) {
79 case IOCTL_XENBUS_BACKEND_EVTCHN: 80 case IOCTL_XENBUS_BACKEND_EVTCHN:
80 if (xen_store_evtchn > 0) 81 if (xen_store_evtchn > 0)
81 return xen_store_evtchn; 82 return xen_store_evtchn;
82 return -ENODEV; 83 return -ENODEV;
83 case IOCTL_XENBUS_BACKEND_SETUP: 84 case IOCTL_XENBUS_BACKEND_SETUP:
84 return xenbus_alloc(data); 85 return xenbus_alloc(data);
85 default: 86 default:
86 return -ENOTTY; 87 return -ENOTTY;
87 } 88 }
88 } 89 }
89 90
90 static int xenbus_backend_mmap(struct file *file, struct vm_area_struct *vma) 91 static int xenbus_backend_mmap(struct file *file, struct vm_area_struct *vma)
91 { 92 {
92 size_t size = vma->vm_end - vma->vm_start; 93 size_t size = vma->vm_end - vma->vm_start;
93 94
94 if (!capable(CAP_SYS_ADMIN)) 95 if (!capable(CAP_SYS_ADMIN))
95 return -EPERM; 96 return -EPERM;
96 97
97 if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0)) 98 if ((size > PAGE_SIZE) || (vma->vm_pgoff != 0))
98 return -EINVAL; 99 return -EINVAL;
99 100
100 if (remap_pfn_range(vma, vma->vm_start, 101 if (remap_pfn_range(vma, vma->vm_start,
101 virt_to_pfn(xen_store_interface), 102 virt_to_pfn(xen_store_interface),
102 size, vma->vm_page_prot)) 103 size, vma->vm_page_prot))
103 return -EAGAIN; 104 return -EAGAIN;
104 105
105 return 0; 106 return 0;
106 } 107 }
107 108
108 static const struct file_operations xenbus_backend_fops = { 109 static const struct file_operations xenbus_backend_fops = {
109 .open = xenbus_backend_open, 110 .open = xenbus_backend_open,
110 .mmap = xenbus_backend_mmap, 111 .mmap = xenbus_backend_mmap,
111 .unlocked_ioctl = xenbus_backend_ioctl, 112 .unlocked_ioctl = xenbus_backend_ioctl,
112 }; 113 };
113 114
114 static struct miscdevice xenbus_backend_dev = { 115 static struct miscdevice xenbus_backend_dev = {
115 .minor = MISC_DYNAMIC_MINOR, 116 .minor = MISC_DYNAMIC_MINOR,
116 .name = "xen/xenbus_backend", 117 .name = "xen/xenbus_backend",
117 .fops = &xenbus_backend_fops, 118 .fops = &xenbus_backend_fops,
118 }; 119 };
119 120
120 static int __init xenbus_backend_init(void) 121 static int __init xenbus_backend_init(void)
121 { 122 {
122 int err; 123 int err;
123 124
124 if (!xen_initial_domain()) 125 if (!xen_initial_domain())
125 return -ENODEV; 126 return -ENODEV;
126 127
127 err = misc_register(&xenbus_backend_dev); 128 err = misc_register(&xenbus_backend_dev);
128 if (err) 129 if (err)
129 printk(KERN_ERR "Could not register xenbus backend device\n"); 130 printk(KERN_ERR "Could not register xenbus backend device\n");
130 return err; 131 return err;
131 } 132 }
132 133
133 static void __exit xenbus_backend_exit(void) 134 static void __exit xenbus_backend_exit(void)
134 { 135 {
135 misc_deregister(&xenbus_backend_dev); 136 misc_deregister(&xenbus_backend_dev);
136 } 137 }
137 138
138 module_init(xenbus_backend_init); 139 module_init(xenbus_backend_init);
139 module_exit(xenbus_backend_exit); 140 module_exit(xenbus_backend_exit);
140 141