Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: divasproc.c,v 1.19.4.3 2005/01/31 12:22:20 armin Exp $ |
| 2 | * |
| 3 | * Low level driver for Eicon DIVA Server ISDN cards. |
| 4 | * /proc functions |
| 5 | * |
| 6 | * Copyright 2000-2003 by Armin Schindler (mac@melware.de) |
| 7 | * Copyright 2000-2003 Cytronics & Melware (info@melware.de) |
| 8 | * |
| 9 | * This software may be used and distributed according to the terms |
| 10 | * of the GNU General Public License, incorporated herein by reference. |
| 11 | */ |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/poll.h> |
| 16 | #include <linux/proc_fs.h> |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 17 | #include <linux/seq_file.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/list.h> |
| 19 | #include <asm/uaccess.h> |
| 20 | |
| 21 | #include "platform.h" |
| 22 | #include "debuglib.h" |
| 23 | #undef ID_MASK |
| 24 | #undef N_DATA |
| 25 | #include "pc.h" |
| 26 | #include "di_defs.h" |
| 27 | #include "divasync.h" |
| 28 | #include "di.h" |
| 29 | #include "io.h" |
| 30 | #include "xdi_msg.h" |
| 31 | #include "xdi_adapter.h" |
| 32 | #include "diva.h" |
| 33 | #include "diva_pci.h" |
| 34 | |
| 35 | |
| 36 | extern PISDN_ADAPTER IoAdapters[MAX_ADAPTER]; |
| 37 | extern void divas_get_version(char *); |
| 38 | extern void diva_get_vserial_number(PISDN_ADAPTER IoAdapter, char *buf); |
| 39 | |
| 40 | /********************************************************* |
| 41 | ** Functions for /proc interface / File operations |
| 42 | *********************************************************/ |
| 43 | |
| 44 | static char *divas_proc_name = "divas"; |
| 45 | static char *adapter_dir_name = "adapter"; |
| 46 | static char *info_proc_name = "info"; |
| 47 | static char *grp_opt_proc_name = "group_optimization"; |
| 48 | static char *d_l1_down_proc_name = "dynamic_l1_down"; |
| 49 | |
| 50 | /* |
| 51 | ** "divas" entry |
| 52 | */ |
| 53 | |
| 54 | extern struct proc_dir_entry *proc_net_eicon; |
| 55 | static struct proc_dir_entry *divas_proc_entry = NULL; |
| 56 | |
| 57 | static ssize_t |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 58 | divas_read(struct file *file, char __user *buf, size_t count, loff_t *off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | { |
| 60 | int len = 0; |
| 61 | int cadapter; |
| 62 | char tmpbuf[80]; |
| 63 | char tmpser[16]; |
| 64 | |
| 65 | if (*off) |
| 66 | return 0; |
| 67 | |
| 68 | divas_get_version(tmpbuf); |
| 69 | if (copy_to_user(buf + len, &tmpbuf, strlen(tmpbuf))) |
| 70 | return -EFAULT; |
| 71 | len += strlen(tmpbuf); |
| 72 | |
| 73 | for (cadapter = 0; cadapter < MAX_ADAPTER; cadapter++) { |
| 74 | if (IoAdapters[cadapter]) { |
| 75 | diva_get_vserial_number(IoAdapters[cadapter], |
| 76 | tmpser); |
| 77 | sprintf(tmpbuf, |
| 78 | "%2d: %-30s Serial:%-10s IRQ:%2d\n", |
| 79 | cadapter + 1, |
| 80 | IoAdapters[cadapter]->Properties.Name, |
| 81 | tmpser, |
| 82 | IoAdapters[cadapter]->irq_info.irq_nr); |
| 83 | if ((strlen(tmpbuf) + len) > count) |
| 84 | break; |
| 85 | if (copy_to_user |
| 86 | (buf + len, &tmpbuf, |
| 87 | strlen(tmpbuf))) return -EFAULT; |
| 88 | len += strlen(tmpbuf); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | *off += len; |
| 93 | return (len); |
| 94 | } |
| 95 | |
| 96 | static ssize_t |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 97 | divas_write(struct file *file, const char __user *buf, size_t count, loff_t *off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
| 99 | return (-ENODEV); |
| 100 | } |
| 101 | |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 102 | static unsigned int divas_poll(struct file *file, poll_table *wait) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | { |
| 104 | return (POLLERR); |
| 105 | } |
| 106 | |
| 107 | static int divas_open(struct inode *inode, struct file *file) |
| 108 | { |
| 109 | return nonseekable_open(inode, file); |
| 110 | } |
| 111 | |
| 112 | static int divas_close(struct inode *inode, struct file *file) |
| 113 | { |
| 114 | return (0); |
| 115 | } |
| 116 | |
Arjan van de Ven | 2b8693c | 2007-02-12 00:55:32 -0800 | [diff] [blame] | 117 | static const struct file_operations divas_fops = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 118 | .owner = THIS_MODULE, |
| 119 | .llseek = no_llseek, |
| 120 | .read = divas_read, |
| 121 | .write = divas_write, |
| 122 | .poll = divas_poll, |
| 123 | .open = divas_open, |
| 124 | .release = divas_close |
| 125 | }; |
| 126 | |
| 127 | int create_divas_proc(void) |
| 128 | { |
Alexey Dobriyan | 495b36b | 2008-06-10 12:49:31 -0700 | [diff] [blame] | 129 | divas_proc_entry = proc_create(divas_proc_name, S_IFREG | S_IRUGO, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 130 | proc_net_eicon, &divas_fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | if (!divas_proc_entry) |
| 132 | return (0); |
| 133 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | return (1); |
| 135 | } |
| 136 | |
| 137 | void remove_divas_proc(void) |
| 138 | { |
| 139 | if (divas_proc_entry) { |
| 140 | remove_proc_entry(divas_proc_name, proc_net_eicon); |
| 141 | divas_proc_entry = NULL; |
| 142 | } |
| 143 | } |
| 144 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 145 | static ssize_t grp_opt_proc_write(struct file *file, const char __user *buffer, |
| 146 | size_t count, loff_t *pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 148 | diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 150 | |
| 151 | if ((count == 1) || (count == 2)) { |
| 152 | char c; |
| 153 | if (get_user(c, buffer)) |
| 154 | return -EFAULT; |
| 155 | switch (c) { |
| 156 | case '0': |
| 157 | IoAdapter->capi_cfg.cfg_1 &= |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 158 | ~DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | break; |
| 160 | case '1': |
| 161 | IoAdapter->capi_cfg.cfg_1 |= |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 162 | DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | break; |
| 164 | default: |
| 165 | return (-EINVAL); |
| 166 | } |
| 167 | return (count); |
| 168 | } |
| 169 | return (-EINVAL); |
| 170 | } |
| 171 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 172 | static ssize_t d_l1_down_proc_write(struct file *file, const char __user *buffer, |
| 173 | size_t count, loff_t *pos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 175 | diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 177 | |
| 178 | if ((count == 1) || (count == 2)) { |
| 179 | char c; |
| 180 | if (get_user(c, buffer)) |
| 181 | return -EFAULT; |
| 182 | switch (c) { |
| 183 | case '0': |
| 184 | IoAdapter->capi_cfg.cfg_1 &= |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 185 | ~DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | break; |
| 187 | case '1': |
| 188 | IoAdapter->capi_cfg.cfg_1 |= |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 189 | DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | break; |
| 191 | default: |
| 192 | return (-EINVAL); |
| 193 | } |
| 194 | return (count); |
| 195 | } |
| 196 | return (-EINVAL); |
| 197 | } |
| 198 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 199 | static int d_l1_down_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 201 | diva_os_xdi_adapter_t *a = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 203 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 204 | seq_printf(m, "%s\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 205 | (IoAdapter->capi_cfg. |
| 206 | cfg_1 & DIVA_XDI_CAPI_CFG_1_DYNAMIC_L1_ON) ? "1" : |
| 207 | "0"); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 208 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 211 | static int d_l1_down_proc_open(struct inode *inode, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 213 | return single_open(file, d_l1_down_proc_show, PDE_DATA(inode)); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | static const struct file_operations d_l1_down_proc_fops = { |
| 217 | .owner = THIS_MODULE, |
| 218 | .open = d_l1_down_proc_open, |
| 219 | .read = seq_read, |
| 220 | .llseek = seq_lseek, |
| 221 | .release = single_release, |
| 222 | .write = d_l1_down_proc_write, |
| 223 | }; |
| 224 | |
| 225 | static int grp_opt_proc_show(struct seq_file *m, void *v) |
| 226 | { |
| 227 | diva_os_xdi_adapter_t *a = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 229 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 230 | seq_printf(m, "%s\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 231 | (IoAdapter->capi_cfg. |
| 232 | cfg_1 & DIVA_XDI_CAPI_CFG_1_GROUP_POPTIMIZATION_ON) |
| 233 | ? "1" : "0"); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 234 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 237 | static int grp_opt_proc_open(struct inode *inode, struct file *file) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 239 | return single_open(file, grp_opt_proc_show, PDE_DATA(inode)); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | static const struct file_operations grp_opt_proc_fops = { |
| 243 | .owner = THIS_MODULE, |
| 244 | .open = grp_opt_proc_open, |
| 245 | .read = seq_read, |
| 246 | .llseek = seq_lseek, |
| 247 | .release = single_release, |
| 248 | .write = grp_opt_proc_write, |
| 249 | }; |
| 250 | |
| 251 | static ssize_t info_proc_write(struct file *file, const char __user *buffer, |
| 252 | size_t count, loff_t *pos) |
| 253 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 254 | diva_os_xdi_adapter_t *a = PDE_DATA(file_inode(file)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 256 | char c[4]; |
| 257 | |
| 258 | if (count <= 4) |
| 259 | return -EINVAL; |
| 260 | |
| 261 | if (copy_from_user(c, buffer, 4)) |
| 262 | return -EFAULT; |
| 263 | |
| 264 | /* this is for test purposes only */ |
| 265 | if (!memcmp(c, "trap", 4)) { |
| 266 | (*(IoAdapter->os_trap_nfy_Fnc)) (IoAdapter, IoAdapter->ANum); |
| 267 | return (count); |
| 268 | } |
| 269 | return (-EINVAL); |
| 270 | } |
| 271 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 272 | static int info_proc_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | { |
| 274 | int i = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | char *p; |
| 276 | char tmpser[16]; |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 277 | diva_os_xdi_adapter_t *a = m->private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | PISDN_ADAPTER IoAdapter = IoAdapters[a->controller - 1]; |
| 279 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 280 | seq_printf(m, "Name : %s\n", IoAdapter->Properties.Name); |
| 281 | seq_printf(m, "DSP state : %08x\n", a->dsp_mask); |
| 282 | seq_printf(m, "Channels : %02d\n", IoAdapter->Properties.Channels); |
| 283 | seq_printf(m, "E. max/used : %03d/%03d\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 284 | IoAdapter->e_max, IoAdapter->e_count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | diva_get_vserial_number(IoAdapter, tmpser); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 286 | seq_printf(m, "Serial : %s\n", tmpser); |
| 287 | seq_printf(m, "IRQ : %d\n", IoAdapter->irq_info.irq_nr); |
| 288 | seq_printf(m, "CardIndex : %d\n", a->CardIndex); |
| 289 | seq_printf(m, "CardOrdinal : %d\n", a->CardOrdinal); |
| 290 | seq_printf(m, "Controller : %d\n", a->controller); |
| 291 | seq_printf(m, "Bus-Type : %s\n", |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 292 | (a->Bus == |
| 293 | DIVAS_XDI_ADAPTER_BUS_ISA) ? "ISA" : "PCI"); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 294 | seq_printf(m, "Port-Name : %s\n", a->port_name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | if (a->Bus == DIVAS_XDI_ADAPTER_BUS_PCI) { |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 296 | seq_printf(m, "PCI-bus : %d\n", a->resources.pci.bus); |
| 297 | seq_printf(m, "PCI-func : %d\n", a->resources.pci.func); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | for (i = 0; i < 8; i++) { |
| 299 | if (a->resources.pci.bar[i]) { |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 300 | seq_printf(m, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 301 | "Mem / I/O %d : 0x%x / mapped : 0x%lx", |
| 302 | i, a->resources.pci.bar[i], |
| 303 | (unsigned long) a->resources. |
| 304 | pci.addr[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | if (a->resources.pci.length[i]) { |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 306 | seq_printf(m, |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 307 | " / length : %d", |
| 308 | a->resources.pci. |
| 309 | length[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | } |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 311 | seq_putc(m, '\n'); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | } |
| 313 | } |
| 314 | } |
| 315 | if ((!a->xdi_adapter.port) && |
| 316 | ((!a->xdi_adapter.ram) || |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 317 | (!a->xdi_adapter.reset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | || (!a->xdi_adapter.cfg))) { |
| 319 | if (!IoAdapter->irq_info.irq_nr) { |
| 320 | p = "slave"; |
| 321 | } else { |
| 322 | p = "out of service"; |
| 323 | } |
| 324 | } else if (a->xdi_adapter.trapped) { |
| 325 | p = "trapped"; |
| 326 | } else if (a->xdi_adapter.Initialized) { |
| 327 | p = "active"; |
| 328 | } else { |
| 329 | p = "ready"; |
| 330 | } |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 331 | seq_printf(m, "State : %s\n", p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 333 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 336 | static int info_proc_open(struct inode *inode, struct file *file) |
| 337 | { |
Al Viro | d9dda78 | 2013-03-31 18:16:14 -0400 | [diff] [blame] | 338 | return single_open(file, info_proc_show, PDE_DATA(inode)); |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | static const struct file_operations info_proc_fops = { |
| 342 | .owner = THIS_MODULE, |
| 343 | .open = info_proc_open, |
| 344 | .read = seq_read, |
| 345 | .llseek = seq_lseek, |
| 346 | .release = single_release, |
| 347 | .write = info_proc_write, |
| 348 | }; |
| 349 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 350 | /* |
| 351 | ** adapter proc init/de-init |
| 352 | */ |
| 353 | |
| 354 | /* -------------------------------------------------------------------------- |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 355 | Create adapter directory and files in proc file system |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 356 | -------------------------------------------------------------------------- */ |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 357 | int create_adapter_proc(diva_os_xdi_adapter_t *a) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | { |
| 359 | struct proc_dir_entry *de, *pe; |
| 360 | char tmp[16]; |
| 361 | |
| 362 | sprintf(tmp, "%s%d", adapter_dir_name, a->controller); |
Al Viro | 6660022 | 2005-09-28 22:32:57 +0100 | [diff] [blame] | 363 | if (!(de = proc_mkdir(tmp, proc_net_eicon))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | return (0); |
| 365 | a->proc_adapter_dir = (void *) de; |
| 366 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 367 | pe = proc_create_data(info_proc_name, S_IRUGO | S_IWUSR, de, |
| 368 | &info_proc_fops, a); |
| 369 | if (!pe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 370 | return (0); |
| 371 | a->proc_info = (void *) pe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 373 | pe = proc_create_data(grp_opt_proc_name, S_IRUGO | S_IWUSR, de, |
| 374 | &grp_opt_proc_fops, a); |
| 375 | if (pe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | a->proc_grp_opt = (void *) pe; |
Alexey Dobriyan | 9a58a80 | 2010-01-14 03:10:54 -0800 | [diff] [blame] | 377 | pe = proc_create_data(d_l1_down_proc_name, S_IRUGO | S_IWUSR, de, |
| 378 | &d_l1_down_proc_fops, a); |
| 379 | if (pe) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | a->proc_d_l1_down = (void *) pe; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
| 382 | DBG_TRC(("proc entry %s created", tmp)); |
| 383 | |
| 384 | return (1); |
| 385 | } |
| 386 | |
| 387 | /* -------------------------------------------------------------------------- |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 388 | Remove adapter directory and files in proc file system |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | -------------------------------------------------------------------------- */ |
Joe Perches | 475be4d | 2012-02-19 19:52:38 -0800 | [diff] [blame] | 390 | void remove_adapter_proc(diva_os_xdi_adapter_t *a) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | { |
| 392 | char tmp[16]; |
| 393 | |
| 394 | if (a->proc_adapter_dir) { |
| 395 | if (a->proc_d_l1_down) { |
| 396 | remove_proc_entry(d_l1_down_proc_name, |
| 397 | (struct proc_dir_entry *) a->proc_adapter_dir); |
| 398 | } |
| 399 | if (a->proc_grp_opt) { |
| 400 | remove_proc_entry(grp_opt_proc_name, |
| 401 | (struct proc_dir_entry *) a->proc_adapter_dir); |
| 402 | } |
| 403 | if (a->proc_info) { |
| 404 | remove_proc_entry(info_proc_name, |
| 405 | (struct proc_dir_entry *) a->proc_adapter_dir); |
| 406 | } |
| 407 | sprintf(tmp, "%s%d", adapter_dir_name, a->controller); |
| 408 | remove_proc_entry(tmp, proc_net_eicon); |
| 409 | DBG_TRC(("proc entry %s%d removed", adapter_dir_name, |
| 410 | a->controller)); |
| 411 | } |
| 412 | } |