^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Sysctl interface for parport devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Authors: David Campbell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Tim Waugh <tim@cyberelk.demon.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Philip Blundell <philb@gnu.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Andrea Arcangeli
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Riccardo Facchetti <fizban@tin.it>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * based on work by Grant Guenther <grant@torque.net>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * and Philip Blundell
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Cleaned up include files - Russell King <linux@arm.uk.linux.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/parport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/sysctl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #if defined(CONFIG_SYSCTL) && defined(CONFIG_PROC_FS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define PARPORT_MIN_TIMESLICE_VALUE 1ul
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define PARPORT_MAX_TIMESLICE_VALUE ((unsigned long) HZ)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define PARPORT_MIN_SPINTIME_VALUE 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define PARPORT_MAX_SPINTIME_VALUE 1000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int do_active_device(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct parport *port = (struct parport *)table->extra1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) char buffer[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct pardevice *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) if (write) /* can't happen anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) for (dev = port->devices; dev ; dev = dev->next) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) if(dev == port->cad) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) len += sprintf(buffer, "%s\n", dev->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if(!len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) len += sprintf(buffer, "%s\n", "none");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #ifdef CONFIG_PARPORT_1284
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) static int do_autoprobe(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct parport_device_info *info = table->extra2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) const char *str;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) char buffer[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) if (write) /* permissions stop this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if ((str = info->class_name) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) len += sprintf (buffer + len, "CLASS:%s;\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) if ((str = info->model) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) len += sprintf (buffer + len, "MODEL:%s;\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if ((str = info->mfr) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) len += sprintf (buffer + len, "MANUFACTURER:%s;\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) if ((str = info->description) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) len += sprintf (buffer + len, "DESCRIPTION:%s;\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) if ((str = info->cmdset) != NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) len += sprintf (buffer + len, "COMMAND SET:%s;\n", str);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #endif /* IEEE1284.3 support. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static int do_hardware_base_addr(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct parport *port = (struct parport *)table->extra1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) char buffer[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (write) /* permissions prevent this anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) len += sprintf (buffer, "%lu\t%lu\n", port->base, port->base_hi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) static int do_hardware_irq(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct parport *port = (struct parport *)table->extra1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) char buffer[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (write) /* permissions prevent this anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) len += sprintf (buffer, "%d\n", port->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) static int do_hardware_dma(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) struct parport *port = (struct parport *)table->extra1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) char buffer[20];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (write) /* permissions prevent this anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) len += sprintf (buffer, "%d\n", port->dma);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) static int do_hardware_modes(struct ctl_table *table, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) void *result, size_t *lenp, loff_t *ppos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) struct parport *port = (struct parport *)table->extra1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) char buffer[40];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) int len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (*ppos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) *lenp = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (write) /* permissions prevent this anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) #define printmode(x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) do { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (port->modes & PARPORT_MODE_##x) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) len += sprintf(buffer + len, "%s%s", f++ ? "," : "", #x); \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int f = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) printmode(PCSPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) printmode(TRISTATE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) printmode(COMPAT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) printmode(EPP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) printmode(ECP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) printmode(DMA);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) #undef printmode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) buffer[len++] = '\n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (len > *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) len = *lenp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) *lenp = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) *ppos += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) memcpy(result, buffer, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) #define PARPORT_PORT_DIR(CHILD) { .procname = NULL, .mode = 0555, .child = CHILD }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) #define PARPORT_PARPORT_DIR(CHILD) { .procname = "parport", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) .mode = 0555, .child = CHILD }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) #define PARPORT_DEV_DIR(CHILD) { .procname = "dev", .mode = 0555, .child = CHILD }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) #define PARPORT_DEVICES_ROOT_DIR { .procname = "devices", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) .mode = 0555, .child = NULL }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) static const unsigned long parport_min_timeslice_value =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) PARPORT_MIN_TIMESLICE_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) static const unsigned long parport_max_timeslice_value =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) PARPORT_MAX_TIMESLICE_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) static const int parport_min_spintime_value =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) PARPORT_MIN_SPINTIME_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static const int parport_max_spintime_value =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) PARPORT_MAX_SPINTIME_VALUE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) struct parport_sysctl_table {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct ctl_table_header *sysctl_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct ctl_table vars[12];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) struct ctl_table device_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) struct ctl_table port_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) struct ctl_table parport_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) struct ctl_table dev_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) static const struct parport_sysctl_table parport_sysctl_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) .sysctl_header = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) .procname = "spintime",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) .maxlen = sizeof(int),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) .proc_handler = proc_dointvec_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) .extra1 = (void*) &parport_min_spintime_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) .extra2 = (void*) &parport_max_spintime_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) .procname = "base-addr",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) .proc_handler = do_hardware_base_addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) .procname = "irq",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) .proc_handler = do_hardware_irq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) .procname = "dma",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) .proc_handler = do_hardware_dma
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) .procname = "modes",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) .proc_handler = do_hardware_modes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) PARPORT_DEVICES_ROOT_DIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) #ifdef CONFIG_PARPORT_1284
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) .procname = "autoprobe",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) .proc_handler = do_autoprobe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .procname = "autoprobe0",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) .proc_handler = do_autoprobe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) .procname = "autoprobe1",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) .proc_handler = do_autoprobe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) .procname = "autoprobe2",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) .proc_handler = do_autoprobe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) .procname = "autoprobe3",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) .proc_handler = do_autoprobe
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) #endif /* IEEE 1284 support */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) .procname = "active",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) .mode = 0444,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) .proc_handler = do_active_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) PARPORT_PORT_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) PARPORT_PARPORT_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) PARPORT_DEV_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) struct parport_device_sysctl_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) struct ctl_table_header *sysctl_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) struct ctl_table vars[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) struct ctl_table device_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) struct ctl_table devices_root_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) struct ctl_table port_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) struct ctl_table parport_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) struct ctl_table dev_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) static const struct parport_device_sysctl_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) parport_device_sysctl_template = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) .sysctl_header = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) .procname = "timeslice",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) .maxlen = sizeof(unsigned long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) .proc_handler = proc_doulongvec_ms_jiffies_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) .extra1 = (void*) &parport_min_timeslice_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) .extra2 = (void*) &parport_max_timeslice_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) .procname = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) .data = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) .maxlen = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) .mode = 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) .child = NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) PARPORT_DEVICES_ROOT_DIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) PARPORT_PORT_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) PARPORT_PARPORT_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) PARPORT_DEV_DIR(NULL),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) struct parport_default_sysctl_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) struct ctl_table_header *sysctl_header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) struct ctl_table vars[3];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) struct ctl_table default_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) struct ctl_table parport_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) struct ctl_table dev_dir[2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) static struct parport_default_sysctl_table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) parport_default_sysctl_table = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) .sysctl_header = NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) .procname = "timeslice",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) .data = &parport_default_timeslice,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) .maxlen = sizeof(parport_default_timeslice),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) .proc_handler = proc_doulongvec_ms_jiffies_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) .extra1 = (void*) &parport_min_timeslice_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) .extra2 = (void*) &parport_max_timeslice_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) .procname = "spintime",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) .data = &parport_default_spintime,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) .maxlen = sizeof(parport_default_spintime),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) .mode = 0644,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) .proc_handler = proc_dointvec_minmax,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) .extra1 = (void*) &parport_min_spintime_value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) .extra2 = (void*) &parport_max_spintime_value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) .procname = "default",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) .mode = 0555,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .child = parport_default_sysctl_table.vars
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) PARPORT_PARPORT_DIR(parport_default_sysctl_table.default_dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) PARPORT_DEV_DIR(parport_default_sysctl_table.parport_dir),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) {}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) int parport_proc_register(struct parport *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) struct parport_sysctl_table *t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) t = kmemdup(&parport_sysctl_template, sizeof(*t), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) if (t == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) t->device_dir[0].extra1 = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) for (i = 0; i < 5; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) t->vars[i].extra1 = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) t->vars[0].data = &port->spintime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) t->vars[5].child = t->device_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) for (i = 0; i < 5; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) t->vars[6 + i].extra2 = &port->probe_info[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) t->port_dir[0].procname = port->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) t->port_dir[0].child = t->vars;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) t->parport_dir[0].child = t->port_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) t->dev_dir[0].child = t->parport_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) t->sysctl_header = register_sysctl_table(t->dev_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) if (t->sysctl_header == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) kfree(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) t = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) port->sysctl_table = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) int parport_proc_unregister(struct parport *port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) if (port->sysctl_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) struct parport_sysctl_table *t = port->sysctl_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) port->sysctl_table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) unregister_sysctl_table(t->sysctl_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) kfree(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) int parport_device_proc_register(struct pardevice *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) struct parport_device_sysctl_table *t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) struct parport * port = device->port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) t = kmemdup(&parport_device_sysctl_template, sizeof(*t), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) if (t == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) t->dev_dir[0].child = t->parport_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) t->parport_dir[0].child = t->port_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) t->port_dir[0].procname = port->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) t->port_dir[0].child = t->devices_root_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) t->devices_root_dir[0].child = t->device_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) t->device_dir[0].procname = device->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) t->device_dir[0].child = t->vars;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) t->vars[0].data = &device->timeslice;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) t->sysctl_header = register_sysctl_table(t->dev_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) if (t->sysctl_header == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) kfree(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) t = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) device->sysctl_table = t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) int parport_device_proc_unregister(struct pardevice *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (device->sysctl_table) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) struct parport_device_sysctl_table *t = device->sysctl_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) device->sysctl_table = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) unregister_sysctl_table(t->sysctl_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) kfree(t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) static int __init parport_default_proc_register(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) parport_default_sysctl_table.sysctl_header =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) register_sysctl_table(parport_default_sysctl_table.dev_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (!parport_default_sysctl_table.sysctl_header)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) ret = parport_bus_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) unregister_sysctl_table(parport_default_sysctl_table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) sysctl_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) static void __exit parport_default_proc_unregister(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) if (parport_default_sysctl_table.sysctl_header) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) unregister_sysctl_table(parport_default_sysctl_table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) sysctl_header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) parport_default_sysctl_table.sysctl_header = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) parport_bus_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) #else /* no sysctl or no procfs*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) int parport_proc_register(struct parport *pp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) int parport_proc_unregister(struct parport *pp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) int parport_device_proc_register(struct pardevice *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) int parport_device_proc_unregister(struct pardevice *device)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) static int __init parport_default_proc_register (void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) return parport_bus_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) static void __exit parport_default_proc_unregister (void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) parport_bus_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) subsys_initcall(parport_default_proc_register)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) module_exit(parport_default_proc_unregister)