4 #include <linux/kernel.h>
5 #include <linux/module.h>
9 #include <linux/slab.h>
36 static const char spaces[] =
" ";
37 static unsigned scsi_default_dev_flags;
39 static char scsi_dev_flags[256];
75 {
"MEDIAVIS",
"RENO CD-ROMX2A",
"2.03",
BLIST_NOLUN},
115 {
"MITSUMI",
"CD-R CR-2201CS",
"6119",
BLIST_NOLUN},
119 {
"QUANTUM",
"FIREBALL ST4.3S",
"0F0C",
BLIST_NOLUN},
266 if (devinfo_table->key == key) {
273 return devinfo_table;
280 static void scsi_strcpy_devinfo(
char *
name,
char *to,
size_t to_length,
285 from_length =
strlen(from);
286 strncpy(to, from,
min(to_length, from_length));
287 if (from_length < to_length) {
292 to[from_length] =
'\0';
297 strncpy(&to[from_length], spaces,
298 to_length - from_length);
301 if (from_length > to_length)
303 __func__, name, from);
322 static int scsi_dev_info_list_add(
int compatible,
char *
vendor,
char *model,
323 char *strflags,
int flags)
349 char *strflags,
int flags,
int key)
353 scsi_devinfo_lookup_by_key(key);
355 if (IS_ERR(devinfo_table))
356 return PTR_ERR(devinfo_table);
364 scsi_strcpy_devinfo(
"vendor", devinfo->
vendor,
sizeof(devinfo->
vendor),
366 scsi_strcpy_devinfo(
"model", devinfo->
model,
sizeof(devinfo->
model),
403 scsi_devinfo_lookup_by_key(key);
405 if (IS_ERR(devinfo_table))
406 return PTR_ERR(devinfo_table);
424 while ((max > 0) && *vendor ==
' ') {
443 while ((max > 0) && *model ==
' ') {
453 sizeof(devinfo->
vendor)) &&
455 sizeof(devinfo->
model)))
484 static int scsi_dev_info_list_add_str(
char *
dev_list)
491 if (next && next[0] ==
'"') {
505 for (vendor =
strsep(&next,
":"); vendor && (vendor[0] !=
'\0')
506 && (res == 0); vendor =
strsep(&next,
":")) {
508 model =
strsep(&next,
":");
510 strflags =
strsep(&next, next_check);
511 if (!model || !strflags) {
513 " '%s'\n", __func__, vendor, model,
517 res = scsi_dev_info_list_add(0 , vendor,
536 const unsigned char *vendor,
537 const unsigned char *model)
558 const unsigned char *vendor,
559 const unsigned char *model,
565 devinfo_table = scsi_devinfo_lookup_by_key(key);
567 if (IS_ERR(devinfo_table))
568 return PTR_ERR(devinfo_table);
586 while ((max > 0) && *vendor ==
' ') {
605 while ((max > 0) && *model ==
' ') {
612 return devinfo->
flags;
615 sizeof(devinfo->
vendor)) &&
617 sizeof(devinfo->
model)))
618 return devinfo->
flags;
629 return scsi_default_dev_flags;
633 #ifdef CONFIG_SCSI_PROC_FS
639 static int devinfo_seq_show(
struct seq_file *
m,
void *
v)
641 struct double_list *
dl =
v;
657 static void *devinfo_seq_start(
struct seq_file *m, loff_t *ppos)
678 static
void *devinfo_seq_next(
struct seq_file *m,
void *v, loff_t *ppos)
680 struct double_list *dl =
v;
685 dl->bottom = dl->bottom->next;
687 dl->top = dl->top->next;
701 static void devinfo_seq_stop(
struct seq_file *m,
void *v)
707 .
start = devinfo_seq_start,
708 .next = devinfo_seq_next,
709 .stop = devinfo_seq_stop,
710 .show = devinfo_seq_show,
715 return seq_open(file, &scsi_devinfo_seq_ops);
726 const char __user *
buf,
727 size_t length, loff_t *ppos)
748 scsi_dev_info_list_add_str(buffer);
757 .open = proc_scsi_devinfo_open,
759 .write = proc_scsi_devinfo_write,
767 "Given scsi_dev_flags=vendor:model:flags[,v:m:f] add black/white"
768 " list entries for vendor and model with an integer value of flags"
769 " to the scsi device info list");
773 "scsi default device flag integer value");
780 #ifdef CONFIG_SCSI_PROC_FS
798 scsi_devinfo_lookup_by_key(key);
800 if (!IS_ERR(devinfo_table))
809 INIT_LIST_HEAD(&devinfo_table->
node);
831 scsi_devinfo_lookup_by_key(key);
833 if (IS_ERR(devinfo_table))
847 kfree(devinfo_table);
862 #ifdef CONFIG_SCSI_PROC_FS
871 error = scsi_dev_info_list_add_str(scsi_dev_flags);
875 for (i = 0; scsi_static_device_list[
i].vendor; i++) {
876 error = scsi_dev_info_list_add(1 ,
877 scsi_static_device_list[i].vendor,
878 scsi_static_device_list[i].model,
880 scsi_static_device_list[i].
flags);
885 #ifdef CONFIG_SCSI_PROC_FS
886 p = proc_create(
"scsi/device_info", 0, NULL, &scsi_devinfo_proc_fops);