| .. | .. |
|---|
| 83 | 83 | 4 * PAGE_SIZE); |
|---|
| 84 | 84 | } |
|---|
| 85 | 85 | |
|---|
| 86 | | -static const struct file_operations proc_scsi_fops = { |
|---|
| 87 | | - .open = proc_scsi_host_open, |
|---|
| 88 | | - .release = single_release, |
|---|
| 89 | | - .read = seq_read, |
|---|
| 90 | | - .llseek = seq_lseek, |
|---|
| 91 | | - .write = proc_scsi_host_write |
|---|
| 86 | +static const struct proc_ops proc_scsi_ops = { |
|---|
| 87 | + .proc_open = proc_scsi_host_open, |
|---|
| 88 | + .proc_release = single_release, |
|---|
| 89 | + .proc_read = seq_read, |
|---|
| 90 | + .proc_lseek = seq_lseek, |
|---|
| 91 | + .proc_write = proc_scsi_host_write |
|---|
| 92 | 92 | }; |
|---|
| 93 | 93 | |
|---|
| 94 | 94 | /** |
|---|
| .. | .. |
|---|
| 146 | 146 | |
|---|
| 147 | 147 | sprintf(name,"%d", shost->host_no); |
|---|
| 148 | 148 | p = proc_create_data(name, S_IRUGO | S_IWUSR, |
|---|
| 149 | | - sht->proc_dir, &proc_scsi_fops, shost); |
|---|
| 149 | + sht->proc_dir, &proc_scsi_ops, shost); |
|---|
| 150 | 150 | if (!p) |
|---|
| 151 | 151 | printk(KERN_ERR "%s: Failed to register host %d in" |
|---|
| 152 | 152 | "%s\n", __func__, shost->host_no, |
|---|
| .. | .. |
|---|
| 311 | 311 | size_t length, loff_t *ppos) |
|---|
| 312 | 312 | { |
|---|
| 313 | 313 | int host, channel, id, lun; |
|---|
| 314 | | - char *buffer, *p; |
|---|
| 314 | + char *buffer, *end, *p; |
|---|
| 315 | 315 | int err; |
|---|
| 316 | 316 | |
|---|
| 317 | 317 | if (!buf || length > PAGE_SIZE) |
|---|
| .. | .. |
|---|
| 326 | 326 | goto out; |
|---|
| 327 | 327 | |
|---|
| 328 | 328 | err = -EINVAL; |
|---|
| 329 | | - if (length < PAGE_SIZE) |
|---|
| 330 | | - buffer[length] = '\0'; |
|---|
| 331 | | - else if (buffer[PAGE_SIZE-1]) |
|---|
| 332 | | - goto out; |
|---|
| 329 | + if (length < PAGE_SIZE) { |
|---|
| 330 | + end = buffer + length; |
|---|
| 331 | + *end = '\0'; |
|---|
| 332 | + } else { |
|---|
| 333 | + end = buffer + PAGE_SIZE - 1; |
|---|
| 334 | + if (*end) |
|---|
| 335 | + goto out; |
|---|
| 336 | + } |
|---|
| 333 | 337 | |
|---|
| 334 | 338 | /* |
|---|
| 335 | 339 | * Usage: echo "scsi add-single-device 0 1 2 3" >/proc/scsi/scsi |
|---|
| .. | .. |
|---|
| 338 | 342 | if (!strncmp("scsi add-single-device", buffer, 22)) { |
|---|
| 339 | 343 | p = buffer + 23; |
|---|
| 340 | 344 | |
|---|
| 341 | | - host = simple_strtoul(p, &p, 0); |
|---|
| 342 | | - channel = simple_strtoul(p + 1, &p, 0); |
|---|
| 343 | | - id = simple_strtoul(p + 1, &p, 0); |
|---|
| 344 | | - lun = simple_strtoul(p + 1, &p, 0); |
|---|
| 345 | + host = (p < end) ? simple_strtoul(p, &p, 0) : 0; |
|---|
| 346 | + channel = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 347 | + id = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 348 | + lun = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 345 | 349 | |
|---|
| 346 | 350 | err = scsi_add_single_device(host, channel, id, lun); |
|---|
| 347 | 351 | |
|---|
| .. | .. |
|---|
| 352 | 356 | } else if (!strncmp("scsi remove-single-device", buffer, 25)) { |
|---|
| 353 | 357 | p = buffer + 26; |
|---|
| 354 | 358 | |
|---|
| 355 | | - host = simple_strtoul(p, &p, 0); |
|---|
| 356 | | - channel = simple_strtoul(p + 1, &p, 0); |
|---|
| 357 | | - id = simple_strtoul(p + 1, &p, 0); |
|---|
| 358 | | - lun = simple_strtoul(p + 1, &p, 0); |
|---|
| 359 | + host = (p < end) ? simple_strtoul(p, &p, 0) : 0; |
|---|
| 360 | + channel = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 361 | + id = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 362 | + lun = (p + 1 < end) ? simple_strtoul(p + 1, &p, 0) : 0; |
|---|
| 359 | 363 | |
|---|
| 360 | 364 | err = scsi_remove_single_device(host, channel, id, lun); |
|---|
| 361 | 365 | } |
|---|
| .. | .. |
|---|
| 372 | 376 | return err; |
|---|
| 373 | 377 | } |
|---|
| 374 | 378 | |
|---|
| 375 | | -static int always_match(struct device *dev, void *data) |
|---|
| 376 | | -{ |
|---|
| 377 | | - return 1; |
|---|
| 378 | | -} |
|---|
| 379 | | - |
|---|
| 380 | 379 | static inline struct device *next_scsi_device(struct device *start) |
|---|
| 381 | 380 | { |
|---|
| 382 | | - struct device *next = bus_find_device(&scsi_bus_type, start, NULL, |
|---|
| 383 | | - always_match); |
|---|
| 381 | + struct device *next = bus_find_next_device(&scsi_bus_type, start); |
|---|
| 382 | + |
|---|
| 384 | 383 | put_device(start); |
|---|
| 385 | 384 | return next; |
|---|
| 386 | 385 | } |
|---|
| .. | .. |
|---|
| 441 | 440 | return seq_open(file, &scsi_seq_ops); |
|---|
| 442 | 441 | } |
|---|
| 443 | 442 | |
|---|
| 444 | | -static const struct file_operations proc_scsi_operations = { |
|---|
| 445 | | - .owner = THIS_MODULE, |
|---|
| 446 | | - .open = proc_scsi_open, |
|---|
| 447 | | - .read = seq_read, |
|---|
| 448 | | - .write = proc_scsi_write, |
|---|
| 449 | | - .llseek = seq_lseek, |
|---|
| 450 | | - .release = seq_release, |
|---|
| 443 | +static const struct proc_ops scsi_scsi_proc_ops = { |
|---|
| 444 | + .proc_open = proc_scsi_open, |
|---|
| 445 | + .proc_read = seq_read, |
|---|
| 446 | + .proc_write = proc_scsi_write, |
|---|
| 447 | + .proc_lseek = seq_lseek, |
|---|
| 448 | + .proc_release = seq_release, |
|---|
| 451 | 449 | }; |
|---|
| 452 | 450 | |
|---|
| 453 | 451 | /** |
|---|
| .. | .. |
|---|
| 461 | 459 | if (!proc_scsi) |
|---|
| 462 | 460 | goto err1; |
|---|
| 463 | 461 | |
|---|
| 464 | | - pde = proc_create("scsi/scsi", 0, NULL, &proc_scsi_operations); |
|---|
| 462 | + pde = proc_create("scsi/scsi", 0, NULL, &scsi_scsi_proc_ops); |
|---|
| 465 | 463 | if (!pde) |
|---|
| 466 | 464 | goto err2; |
|---|
| 467 | 465 | |
|---|