Lines Matching +full:port +full:- +full:id

1 // SPDX-License-Identifier: GPL-2.0
3 * Parallel port device probing code
5 * Authors: Carsten Gross, carsten@sol.wohnheim.uni-ulm.de
37 static void pretty_print(struct parport *port, int device) in pretty_print() argument
39 struct parport_device_info *info = &port->probe_info[device + 1]; in pretty_print()
41 pr_info("%s", port->name); in pretty_print()
46 pr_cont(": %s", classes[info->class].descr); in pretty_print()
47 if (info->class) in pretty_print()
48 pr_cont(", %s %s", info->mfr, info->model); in pretty_print()
53 static void parse_data(struct parport *port, int device, char *str) in parse_data() argument
58 struct parport_device_info *info = &port->probe_info[device + 1]; in parse_data()
61 pr_warn("%s probe: memory squeeze\n", port->name); in parse_data()
74 u = sep + strlen (sep) - 1; in parse_data()
76 *u-- = '\0'; in parse_data()
79 kfree(info->mfr); in parse_data()
80 info->mfr = kstrdup(sep, GFP_KERNEL); in parse_data()
82 kfree(info->model); in parse_data()
83 info->model = kstrdup(sep, GFP_KERNEL); in parse_data()
87 kfree(info->class_name); in parse_data()
88 info->class_name = kstrdup(sep, GFP_KERNEL); in parse_data()
92 info->class = i; in parse_data()
97 port->name, sep); in parse_data()
98 info->class = PARPORT_CLASS_OTHER; in parse_data()
101 kfree(info->cmdset); in parse_data()
102 info->cmdset = kstrdup(sep, GFP_KERNEL); in parse_data()
108 kfree(info->description); in parse_data()
109 info->description = kstrdup(sep, GFP_KERNEL); in parse_data()
121 if (info->class == PARPORT_CLASS_UNSPEC) in parse_data()
122 info->class = guessed_class; in parse_data()
124 pretty_print (port, device); in parse_data()
129 /* Read up to count-1 bytes of device id. Terminate buffer with
130 * '\0'. Buffer begins with two Device ID length bytes as given by
132 static ssize_t parport_read_device_id (struct parport *port, char *buffer, in parport_read_device_id() argument
144 retval = parport_read (port, length, 2); in parport_read_device_id()
149 return -EIO; in parport_read_device_id()
172 /* Some devices don't truly implement Device ID, but in parport_read_device_id()
176 printk(KERN_DEBUG "%s: reported broken Device ID length of %#zX bytes\n", in parport_read_device_id()
177 port->name, idlens[0]); in parport_read_device_id()
178 return -EIO; in parport_read_device_id()
183 /* Try to respect the given ID length despite all the bugs in in parport_read_device_id()
184 * the ID length. Read according to shortest possible ID in parport_read_device_id()
191 retval = parport_read (port, buffer+len, idlen-len); in parport_read_device_id()
197 if (port->physport->ieee1284.phase != IEEE1284_PH_HBUSY_DAVAIL) { in parport_read_device_id()
199 printk(KERN_DEBUG "%s: Device ID was %zd bytes while device told it would be %d bytes\n", in parport_read_device_id()
200 port->name, len, belen); in parport_read_device_id()
205 /* This might end reading the Device ID too in parport_read_device_id()
209 if (buffer[len-1] == ';') { in parport_read_device_id()
210 …printk(KERN_DEBUG "%s: Device ID reading stopped before device told data not available. Current id… in parport_read_device_id()
211 port->name, current_idlen, numidlens, in parport_read_device_id()
220 retval = parport_read (port, buffer+len, count-len-1); in parport_read_device_id()
225 /* Read the whole ID since some devices would not in parport_read_device_id()
226 * otherwise give back the Device ID from beginning in parport_read_device_id()
232 retval = parport_read (port, tmp, in parport_read_device_id()
233 min(sizeof tmp, idlen-len2)); in parport_read_device_id()
240 even finish off with a semi-colon. We do not need to care in parport_read_device_id()
247 /* Get Std 1284 Device ID. */
250 ssize_t retval = -ENXIO; in parport_device_id()
253 return -ENXIO; in parport_device_id()
257 /* Negotiate to compatibility mode, and then to device ID in parport_device_id()
258 * mode. (This so that we start form beginning of device ID if in parport_device_id()
259 * already in device ID mode.) */ in parport_device_id()
260 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); in parport_device_id()
261 retval = parport_negotiate (dev->port, in parport_device_id()
265 retval = parport_read_device_id (dev->port, buffer, count); in parport_device_id()
266 parport_negotiate (dev->port, IEEE1284_MODE_COMPAT); in parport_device_id()
268 parse_data (dev->port, dev->daisy, buffer+2); in parport_device_id()