Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | |
| 2 | #include <linux/blkdev.h> |
| 3 | #include <linux/init.h> |
| 4 | #include <linux/kernel.h> |
| 5 | #include <linux/module.h> |
| 6 | #include <linux/moduleparam.h> |
| 7 | #include <linux/proc_fs.h> |
| 8 | #include <linux/seq_file.h> |
| 9 | |
| 10 | #include <scsi/scsi_device.h> |
| 11 | #include <scsi/scsi_devinfo.h> |
| 12 | |
| 13 | #include "scsi_priv.h" |
| 14 | |
| 15 | |
| 16 | /* |
| 17 | * scsi_dev_info_list: structure to hold black/white listed devices. |
| 18 | */ |
| 19 | struct scsi_dev_info_list { |
| 20 | struct list_head dev_info_list; |
| 21 | char vendor[8]; |
| 22 | char model[16]; |
| 23 | unsigned flags; |
| 24 | unsigned compatible; /* for use with scsi_static_device_list entries */ |
| 25 | }; |
| 26 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 27 | struct scsi_dev_info_list_table { |
| 28 | struct list_head node; /* our node for being on the master list */ |
| 29 | struct list_head scsi_dev_info_list; /* head of dev info list */ |
| 30 | const char *name; /* name of list for /proc (NULL for global) */ |
| 31 | int key; /* unique numeric identifier */ |
| 32 | }; |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | static const char spaces[] = " "; /* 16 of them */ |
| 36 | static unsigned scsi_default_dev_flags; |
| 37 | static LIST_HEAD(scsi_dev_info_list); |
| 38 | static char scsi_dev_flags[256]; |
| 39 | |
| 40 | /* |
| 41 | * scsi_static_device_list: deprecated list of devices that require |
| 42 | * settings that differ from the default, includes black-listed (broken) |
| 43 | * devices. The entries here are added to the tail of scsi_dev_info_list |
| 44 | * via scsi_dev_info_list_init. |
| 45 | * |
| 46 | * Do not add to this list, use the command line or proc interface to add |
| 47 | * to the scsi_dev_info_list. This table will eventually go away. |
| 48 | */ |
| 49 | static struct { |
| 50 | char *vendor; |
| 51 | char *model; |
| 52 | char *revision; /* revision known to be bad, unused */ |
| 53 | unsigned flags; |
| 54 | } scsi_static_device_list[] __initdata = { |
| 55 | /* |
| 56 | * The following devices are known not to tolerate a lun != 0 scan |
| 57 | * for one reason or another. Some will respond to all luns, |
| 58 | * others will lock up. |
| 59 | */ |
| 60 | {"Aashima", "IMAGERY 2400SP", "1.03", BLIST_NOLUN}, /* locks up */ |
| 61 | {"CHINON", "CD-ROM CDS-431", "H42", BLIST_NOLUN}, /* locks up */ |
| 62 | {"CHINON", "CD-ROM CDS-535", "Q14", BLIST_NOLUN}, /* locks up */ |
| 63 | {"DENON", "DRD-25X", "V", BLIST_NOLUN}, /* locks up */ |
| 64 | {"HITACHI", "DK312C", "CM81", BLIST_NOLUN}, /* responds to all lun */ |
| 65 | {"HITACHI", "DK314C", "CR21", BLIST_NOLUN}, /* responds to all lun */ |
Brian King | f2536cb | 2006-04-26 13:48:11 -0500 | [diff] [blame] | 66 | {"IBM", "2104-DU3", NULL, BLIST_NOLUN}, /* locks up */ |
| 67 | {"IBM", "2104-TU3", NULL, BLIST_NOLUN}, /* locks up */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | {"IMS", "CDD521/10", "2.06", BLIST_NOLUN}, /* locks up */ |
| 69 | {"MAXTOR", "XT-3280", "PR02", BLIST_NOLUN}, /* locks up */ |
| 70 | {"MAXTOR", "XT-4380S", "B3C", BLIST_NOLUN}, /* locks up */ |
| 71 | {"MAXTOR", "MXT-1240S", "I1.2", BLIST_NOLUN}, /* locks up */ |
| 72 | {"MAXTOR", "XT-4170S", "B5A", BLIST_NOLUN}, /* locks up */ |
| 73 | {"MAXTOR", "XT-8760S", "B7B", BLIST_NOLUN}, /* locks up */ |
| 74 | {"MEDIAVIS", "RENO CD-ROMX2A", "2.03", BLIST_NOLUN}, /* responds to all lun */ |
| 75 | {"MICROTEK", "ScanMakerIII", "2.30", BLIST_NOLUN}, /* responds to all lun */ |
| 76 | {"NEC", "CD-ROM DRIVE:841", "1.0", BLIST_NOLUN},/* locks up */ |
| 77 | {"PHILIPS", "PCA80SC", "V4-2", BLIST_NOLUN}, /* responds to all lun */ |
| 78 | {"RODIME", "RO3000S", "2.33", BLIST_NOLUN}, /* locks up */ |
| 79 | {"SUN", "SENA", NULL, BLIST_NOLUN}, /* responds to all luns */ |
| 80 | /* |
| 81 | * The following causes a failed REQUEST SENSE on lun 1 for |
| 82 | * aha152x controller, which causes SCSI code to reset bus. |
| 83 | */ |
| 84 | {"SANYO", "CRD-250S", "1.20", BLIST_NOLUN}, |
| 85 | /* |
| 86 | * The following causes a failed REQUEST SENSE on lun 1 for |
| 87 | * aha152x controller, which causes SCSI code to reset bus. |
| 88 | */ |
| 89 | {"SEAGATE", "ST157N", "\004|j", BLIST_NOLUN}, |
| 90 | {"SEAGATE", "ST296", "921", BLIST_NOLUN}, /* responds to all lun */ |
| 91 | {"SEAGATE", "ST1581", "6538", BLIST_NOLUN}, /* responds to all lun */ |
| 92 | {"SONY", "CD-ROM CDU-541", "4.3d", BLIST_NOLUN}, |
| 93 | {"SONY", "CD-ROM CDU-55S", "1.0i", BLIST_NOLUN}, |
| 94 | {"SONY", "CD-ROM CDU-561", "1.7x", BLIST_NOLUN}, |
| 95 | {"SONY", "CD-ROM CDU-8012", NULL, BLIST_NOLUN}, |
| 96 | {"SONY", "SDT-5000", "3.17", BLIST_SELECT_NO_ATN}, |
| 97 | {"TANDBERG", "TDC 3600", "U07", BLIST_NOLUN}, /* locks up */ |
| 98 | {"TEAC", "CD-R55S", "1.0H", BLIST_NOLUN}, /* locks up */ |
| 99 | /* |
| 100 | * The following causes a failed REQUEST SENSE on lun 1 for |
| 101 | * seagate controller, which causes SCSI code to reset bus. |
| 102 | */ |
| 103 | {"TEAC", "CD-ROM", "1.06", BLIST_NOLUN}, |
| 104 | {"TEAC", "MT-2ST/45S2-27", "RV M", BLIST_NOLUN}, /* responds to all lun */ |
| 105 | /* |
| 106 | * The following causes a failed REQUEST SENSE on lun 1 for |
| 107 | * seagate controller, which causes SCSI code to reset bus. |
| 108 | */ |
| 109 | {"HP", "C1750A", "3226", BLIST_NOLUN}, /* scanjet iic */ |
| 110 | {"HP", "C1790A", "", BLIST_NOLUN}, /* scanjet iip */ |
| 111 | {"HP", "C2500A", "", BLIST_NOLUN}, /* scanjet iicx */ |
| 112 | {"MEDIAVIS", "CDR-H93MV", "1.31", BLIST_NOLUN}, /* locks up */ |
| 113 | {"MICROTEK", "ScanMaker II", "5.61", BLIST_NOLUN}, /* responds to all lun */ |
| 114 | {"MITSUMI", "CD-R CR-2201CS", "6119", BLIST_NOLUN}, /* locks up */ |
| 115 | {"NEC", "D3856", "0009", BLIST_NOLUN}, |
| 116 | {"QUANTUM", "LPS525S", "3110", BLIST_NOLUN}, /* locks up */ |
| 117 | {"QUANTUM", "PD1225S", "3110", BLIST_NOLUN}, /* locks up */ |
| 118 | {"QUANTUM", "FIREBALL ST4.3S", "0F0C", BLIST_NOLUN}, /* locks up */ |
| 119 | {"RELISYS", "Scorpio", NULL, BLIST_NOLUN}, /* responds to all lun */ |
| 120 | {"SANKYO", "CP525", "6.64", BLIST_NOLUN}, /* causes failed REQ SENSE, extra reset */ |
| 121 | {"TEXEL", "CD-ROM", "1.06", BLIST_NOLUN}, |
James Bottomley | 1c53631 | 2005-09-12 09:15:14 -0500 | [diff] [blame] | 122 | {"transtec", "T5008", "0001", BLIST_NOREPORTLUN }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | {"YAMAHA", "CDR100", "1.00", BLIST_NOLUN}, /* locks up */ |
| 124 | {"YAMAHA", "CDR102", "1.00", BLIST_NOLUN}, /* locks up */ |
| 125 | {"YAMAHA", "CRW8424S", "1.0", BLIST_NOLUN}, /* locks up */ |
| 126 | {"YAMAHA", "CRW6416S", "1.0c", BLIST_NOLUN}, /* locks up */ |
Dave Jones | 0d7323c | 2005-08-08 19:01:43 -0400 | [diff] [blame] | 127 | {"", "Scanner", "1.80", BLIST_NOLUN}, /* responds to all lun */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | |
| 129 | /* |
| 130 | * Other types of devices that have special flags. |
| 131 | * Note that all USB devices should have the BLIST_INQUIRY_36 flag. |
| 132 | */ |
| 133 | {"3PARdata", "VV", NULL, BLIST_REPORTLUN2}, |
| 134 | {"ADAPTEC", "AACRAID", NULL, BLIST_FORCELUN}, |
| 135 | {"ADAPTEC", "Adaptec 5400S", NULL, BLIST_FORCELUN}, |
| 136 | {"AFT PRO", "-IX CF", "0.0>", BLIST_FORCELUN}, |
| 137 | {"BELKIN", "USB 2 HS-CF", "1.95", BLIST_FORCELUN | BLIST_INQUIRY_36}, |
Matthew Wilcox | 80dc3e0 | 2007-07-05 08:57:50 -0600 | [diff] [blame] | 138 | {"BROWNIE", "1200U3P", NULL, BLIST_NOREPORTLUN}, |
Matthew Wilcox | 98acfc7 | 2006-03-01 12:04:46 -0700 | [diff] [blame] | 139 | {"BROWNIE", "1600U3P", NULL, BLIST_NOREPORTLUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | {"CANON", "IPUBJD", NULL, BLIST_SPARSELUN}, |
| 141 | {"CBOX3", "USB Storage-SMC", "300A", BLIST_FORCELUN | BLIST_INQUIRY_36}, |
| 142 | {"CMD", "CRA-7280", NULL, BLIST_SPARSELUN}, /* CMD RAID Controller */ |
| 143 | {"CNSI", "G7324", NULL, BLIST_SPARSELUN}, /* Chaparral G7324 RAID */ |
| 144 | {"CNSi", "G8324", NULL, BLIST_SPARSELUN}, /* Chaparral G8324 RAID */ |
James Bottomley | 4d7db04 | 2006-03-31 20:07:45 -0600 | [diff] [blame] | 145 | {"COMPAQ", "ARRAY CONTROLLER", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | |
| 146 | BLIST_MAX_512 | BLIST_REPORTLUN2}, /* Compaq RA4x00 */ |
| 147 | {"COMPAQ", "LOGICAL VOLUME", NULL, BLIST_FORCELUN | BLIST_MAX_512}, /* Compaq RA4x00 */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | {"COMPAQ", "CR3500", NULL, BLIST_FORCELUN}, |
| 149 | {"COMPAQ", "MSA1000", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD}, |
| 150 | {"COMPAQ", "MSA1000 VOLUME", NULL, BLIST_SPARSELUN | BLIST_NOSTARTONADD}, |
| 151 | {"COMPAQ", "HSV110", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, |
| 152 | {"DDN", "SAN DataDirector", "*", BLIST_SPARSELUN}, |
James Bottomley | 507caac | 2005-08-09 12:57:11 -0500 | [diff] [blame] | 153 | {"DEC", "HSG80", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | {"DELL", "PV660F", NULL, BLIST_SPARSELUN}, |
| 155 | {"DELL", "PV660F PSEUDO", NULL, BLIST_SPARSELUN}, |
| 156 | {"DELL", "PSEUDO DEVICE .", NULL, BLIST_SPARSELUN}, /* Dell PV 530F */ |
| 157 | {"DELL", "PV530F", NULL, BLIST_SPARSELUN}, |
| 158 | {"DELL", "PERCRAID", NULL, BLIST_FORCELUN}, |
| 159 | {"DGC", "RAID", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, storage on LUN 0 */ |
| 160 | {"DGC", "DISK", NULL, BLIST_SPARSELUN}, /* Dell PV 650F, no storage on LUN 0 */ |
Mike Christie | 3441afc | 2006-09-30 20:42:28 -0400 | [diff] [blame] | 161 | {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN | BLIST_FORCELUN}, |
| 163 | {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN}, |
akpm@linux-foundation.org | 80b1c7bd | 2007-07-27 13:30:02 -0700 | [diff] [blame] | 164 | {"easyRAID", "16P", NULL, BLIST_NOREPORTLUN}, |
| 165 | {"easyRAID", "X6P", NULL, BLIST_NOREPORTLUN}, |
| 166 | {"easyRAID", "F8", NULL, BLIST_NOREPORTLUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | {"FSC", "CentricStor", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 168 | {"Generic", "USB SD Reader", "1.00", BLIST_FORCELUN | BLIST_INQUIRY_36}, |
| 169 | {"Generic", "USB Storage-SMC", "0180", BLIST_FORCELUN | BLIST_INQUIRY_36}, |
| 170 | {"Generic", "USB Storage-SMC", "0207", BLIST_FORCELUN | BLIST_INQUIRY_36}, |
Takahiro Yasui | 627511e | 2009-11-10 16:22:19 -0500 | [diff] [blame] | 171 | {"HITACHI", "DF400", "*", BLIST_REPORTLUN2}, |
| 172 | {"HITACHI", "DF500", "*", BLIST_REPORTLUN2}, |
| 173 | {"HITACHI", "DISK-SUBSYSTEM", "*", BLIST_REPORTLUN2}, |
| 174 | {"HITACHI", "OPEN-", "*", BLIST_REPORTLUN2}, |
Mike Christie | f70cfa9 | 2006-09-30 20:42:31 -0400 | [diff] [blame] | 175 | {"HITACHI", "OP-C-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 176 | {"HITACHI", "3380-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 177 | {"HITACHI", "3390-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 178 | {"HITACHI", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 179 | {"HITACHI", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | {"HP", "A6189A", NULL, BLIST_SPARSELUN | BLIST_LARGELUN}, /* HP VA7400 */ |
Hannes Reinecke | 9ba0883 | 2006-06-22 09:19:51 +0200 | [diff] [blame] | 181 | {"HP", "OPEN-", "*", BLIST_REPORTLUN2}, /* HP XP Arrays */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | {"HP", "NetRAID-4M", NULL, BLIST_FORCELUN}, |
| 183 | {"HP", "HSV100", NULL, BLIST_REPORTLUN2 | BLIST_NOSTARTONADD}, |
| 184 | {"HP", "C1557A", NULL, BLIST_FORCELUN}, |
| 185 | {"HP", "C3323-300", "4269", BLIST_NOTQ}, |
Thomas Bogendoerfer | c3d8336 | 2006-05-16 06:38:29 +0200 | [diff] [blame] | 186 | {"HP", "C5713A", NULL, BLIST_NOREPORTLUN}, |
Mike Christie | f70cfa9 | 2006-09-30 20:42:31 -0400 | [diff] [blame] | 187 | {"HP", "DF400", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 188 | {"HP", "DF500", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 189 | {"HP", "DF600", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 190 | {"HP", "OP-C-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 191 | {"HP", "3380-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 192 | {"HP", "3390-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 193 | {"HP", "6586-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 194 | {"HP", "6588-", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | {"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN}, |
| 196 | {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 197 | {"IBM", "2105", NULL, BLIST_RETRY_HWERROR}, |
| 198 | {"iomega", "jaz 1GB", "J.86", BLIST_NOTQ | BLIST_NOLUN}, |
| 199 | {"IOMEGA", "Io20S *F", NULL, BLIST_KEY}, |
| 200 | {"INSITE", "Floptical F*8I", NULL, BLIST_KEY}, |
| 201 | {"INSITE", "I325VM", NULL, BLIST_KEY}, |
| 202 | {"iRiver", "iFP Mass Driver", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36}, |
| 203 | {"LASOUND", "CDX7405", "3.10", BLIST_MAX5LUN | BLIST_SINGLELUN}, |
| 204 | {"MATSHITA", "PD-1", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 205 | {"MATSHITA", "DMC-LC5", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36}, |
| 206 | {"MATSHITA", "DMC-LC40", NULL, BLIST_NOT_LOCKABLE | BLIST_INQUIRY_36}, |
| 207 | {"Medion", "Flash XL MMC/SD", "2.6D", BLIST_FORCELUN}, |
| 208 | {"MegaRAID", "LD", NULL, BLIST_FORCELUN}, |
| 209 | {"MICROP", "4110", NULL, BLIST_NOTQ}, |
| 210 | {"MYLEX", "DACARMRB", "*", BLIST_REPORTLUN2}, |
| 211 | {"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN}, |
| 212 | {"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 213 | {"NAKAMICH", "MJ-5.16S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 214 | {"NEC", "PD-1 ODX654P", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
Mike Christie | 12427d9 | 2006-09-30 20:42:30 -0400 | [diff] [blame] | 215 | {"NEC", "iStorage", NULL, BLIST_REPORTLUN2}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | {"NRC", "MBR-7", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 217 | {"NRC", "MBR-7.4", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 218 | {"PIONEER", "CD-ROM DRM-600", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 219 | {"PIONEER", "CD-ROM DRM-602X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
| 220 | {"PIONEER", "CD-ROM DRM-604X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
Karl Magnus Kolstoe | f4fd20b | 2005-10-17 10:05:42 +0200 | [diff] [blame] | 221 | {"PIONEER", "CD-ROM DRM-624X", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, |
Ed Lin | e0b2e59 | 2007-05-09 20:50:33 -0800 | [diff] [blame] | 222 | {"Promise", "", NULL, BLIST_SPARSELUN}, |
Matthew Wilcox | 2ffb45c | 2007-07-26 11:39:46 -0400 | [diff] [blame] | 223 | {"QUANTUM", "XP34301", "1071", BLIST_NOTQ}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | {"REGAL", "CDC-4X", NULL, BLIST_MAX5LUN | BLIST_SINGLELUN}, |
| 225 | {"SanDisk", "ImageMate CF-SD1", NULL, BLIST_FORCELUN}, |
| 226 | {"SEAGATE", "ST34555N", "0930", BLIST_NOTQ}, /* Chokes on tagged INQUIRY */ |
| 227 | {"SEAGATE", "ST3390N", "9546", BLIST_NOTQ}, |
| 228 | {"SGI", "RAID3", "*", BLIST_SPARSELUN}, |
| 229 | {"SGI", "RAID5", "*", BLIST_SPARSELUN}, |
| 230 | {"SGI", "TP9100", "*", BLIST_REPORTLUN2}, |
| 231 | {"SGI", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
Anton Blanchard | 4869040 | 2005-09-06 18:08:14 +1000 | [diff] [blame] | 232 | {"IBM", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
ILLES, Marton | debf477 | 2009-01-12 15:45:52 +0100 | [diff] [blame] | 233 | {"SUN", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
James Bottomley | 4aa312b | 2009-06-13 09:21:43 -0500 | [diff] [blame] | 234 | {"DELL", "Universal Xport", "*", BLIST_NO_ULD_ATTACH}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | {"SMSC", "USB 2 HS-CF", NULL, BLIST_SPARSELUN | BLIST_INQUIRY_36}, |
| 236 | {"SONY", "CD-ROM CDU-8001", NULL, BLIST_BORKEN}, |
| 237 | {"SONY", "TSL", NULL, BLIST_FORCELUN}, /* DDS3 & DDS4 autoloaders */ |
| 238 | {"ST650211", "CF", NULL, BLIST_RETRY_HWERROR}, |
| 239 | {"SUN", "T300", "*", BLIST_SPARSELUN}, |
| 240 | {"SUN", "T4", "*", BLIST_SPARSELUN}, |
| 241 | {"TEXEL", "CD-ROM", "1.06", BLIST_BORKEN}, |
Mike Christie | 5f619c5 | 2006-09-30 20:42:29 -0400 | [diff] [blame] | 242 | {"Tornado-", "F4", "*", BLIST_NOREPORTLUN}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | {"TOSHIBA", "CDROM", NULL, BLIST_ISROM}, |
| 244 | {"TOSHIBA", "CD-ROM", NULL, BLIST_ISROM}, |
| 245 | {"USB2.0", "SMARTMEDIA/XD", NULL, BLIST_FORCELUN | BLIST_INQUIRY_36}, |
| 246 | {"WangDAT", "Model 2600", "01.7", BLIST_SELECT_NO_ATN}, |
| 247 | {"WangDAT", "Model 3200", "02.2", BLIST_SELECT_NO_ATN}, |
| 248 | {"WangDAT", "Model 1300", "02.4", BLIST_SELECT_NO_ATN}, |
| 249 | {"WDC WD25", "00JB-00FUA0", NULL, BLIST_NOREPORTLUN}, |
| 250 | {"XYRATEX", "RS", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, |
| 251 | {"Zzyzx", "RocketStor 500S", NULL, BLIST_SPARSELUN}, |
| 252 | {"Zzyzx", "RocketStor 2000", NULL, BLIST_SPARSELUN}, |
| 253 | { NULL, NULL, NULL, 0 }, |
| 254 | }; |
| 255 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 256 | static struct scsi_dev_info_list_table *scsi_devinfo_lookup_by_key(int key) |
| 257 | { |
| 258 | struct scsi_dev_info_list_table *devinfo_table; |
| 259 | int found = 0; |
| 260 | |
| 261 | list_for_each_entry(devinfo_table, &scsi_dev_info_list, node) |
| 262 | if (devinfo_table->key == key) { |
| 263 | found = 1; |
| 264 | break; |
| 265 | } |
| 266 | if (!found) |
| 267 | return ERR_PTR(-EINVAL); |
| 268 | |
| 269 | return devinfo_table; |
| 270 | } |
| 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | /* |
| 273 | * scsi_strcpy_devinfo: called from scsi_dev_info_list_add to copy into |
| 274 | * devinfo vendor and model strings. |
| 275 | */ |
| 276 | static void scsi_strcpy_devinfo(char *name, char *to, size_t to_length, |
| 277 | char *from, int compatible) |
| 278 | { |
| 279 | size_t from_length; |
| 280 | |
| 281 | from_length = strlen(from); |
| 282 | strncpy(to, from, min(to_length, from_length)); |
| 283 | if (from_length < to_length) { |
| 284 | if (compatible) { |
| 285 | /* |
| 286 | * NUL terminate the string if it is short. |
| 287 | */ |
| 288 | to[from_length] = '\0'; |
| 289 | } else { |
| 290 | /* |
| 291 | * space pad the string if it is short. |
| 292 | */ |
| 293 | strncpy(&to[from_length], spaces, |
| 294 | to_length - from_length); |
| 295 | } |
| 296 | } |
| 297 | if (from_length > to_length) |
| 298 | printk(KERN_WARNING "%s: %s string '%s' is too long\n", |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 299 | __func__, name, from); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | /** |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 303 | * scsi_dev_info_list_add - add one dev_info list entry. |
| 304 | * @compatible: if true, null terminate short strings. Otherwise space pad. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | * @vendor: vendor string |
| 306 | * @model: model (product) string |
| 307 | * @strflags: integer string |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 308 | * @flags: if strflags NULL, use this flag value |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | * |
| 310 | * Description: |
| 311 | * Create and add one dev_info entry for @vendor, @model, @strflags or |
| 312 | * @flag. If @compatible, add to the tail of the list, do not space |
| 313 | * pad, and set devinfo->compatible. The scsi_static_device_list entries |
| 314 | * are added with @compatible 1 and @clfags NULL. |
| 315 | * |
| 316 | * Returns: 0 OK, -error on failure. |
| 317 | **/ |
| 318 | static int scsi_dev_info_list_add(int compatible, char *vendor, char *model, |
| 319 | char *strflags, int flags) |
| 320 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 321 | return scsi_dev_info_list_add_keyed(compatible, vendor, model, |
| 322 | strflags, flags, |
| 323 | SCSI_DEVINFO_GLOBAL); |
| 324 | } |
| 325 | |
| 326 | /** |
| 327 | * scsi_dev_info_list_add_keyed - add one dev_info list entry. |
| 328 | * @compatible: if true, null terminate short strings. Otherwise space pad. |
| 329 | * @vendor: vendor string |
| 330 | * @model: model (product) string |
| 331 | * @strflags: integer string |
| 332 | * @flags: if strflags NULL, use this flag value |
| 333 | * @key: specify list to use |
| 334 | * |
| 335 | * Description: |
| 336 | * Create and add one dev_info entry for @vendor, @model, |
| 337 | * @strflags or @flag in list specified by @key. If @compatible, |
| 338 | * add to the tail of the list, do not space pad, and set |
| 339 | * devinfo->compatible. The scsi_static_device_list entries are |
| 340 | * added with @compatible 1 and @clfags NULL. |
| 341 | * |
| 342 | * Returns: 0 OK, -error on failure. |
| 343 | **/ |
| 344 | int scsi_dev_info_list_add_keyed(int compatible, char *vendor, char *model, |
| 345 | char *strflags, int flags, int key) |
| 346 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | struct scsi_dev_info_list *devinfo; |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 348 | struct scsi_dev_info_list_table *devinfo_table = |
| 349 | scsi_devinfo_lookup_by_key(key); |
| 350 | |
| 351 | if (IS_ERR(devinfo_table)) |
| 352 | return PTR_ERR(devinfo_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
| 354 | devinfo = kmalloc(sizeof(*devinfo), GFP_KERNEL); |
| 355 | if (!devinfo) { |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 356 | printk(KERN_ERR "%s: no memory\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 357 | return -ENOMEM; |
| 358 | } |
| 359 | |
| 360 | scsi_strcpy_devinfo("vendor", devinfo->vendor, sizeof(devinfo->vendor), |
| 361 | vendor, compatible); |
| 362 | scsi_strcpy_devinfo("model", devinfo->model, sizeof(devinfo->model), |
| 363 | model, compatible); |
| 364 | |
| 365 | if (strflags) |
| 366 | devinfo->flags = simple_strtoul(strflags, NULL, 0); |
| 367 | else |
| 368 | devinfo->flags = flags; |
| 369 | |
| 370 | devinfo->compatible = compatible; |
| 371 | |
| 372 | if (compatible) |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 373 | list_add_tail(&devinfo->dev_info_list, |
| 374 | &devinfo_table->scsi_dev_info_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | else |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 376 | list_add(&devinfo->dev_info_list, |
| 377 | &devinfo_table->scsi_dev_info_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | |
| 379 | return 0; |
| 380 | } |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 381 | EXPORT_SYMBOL(scsi_dev_info_list_add_keyed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 382 | |
| 383 | /** |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 384 | * scsi_dev_info_list_add_str - parse dev_list and add to the scsi_dev_info_list. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 385 | * @dev_list: string of device flags to add |
| 386 | * |
| 387 | * Description: |
| 388 | * Parse dev_list, and add entries to the scsi_dev_info_list. |
| 389 | * dev_list is of the form "vendor:product:flag,vendor:product:flag". |
| 390 | * dev_list is modified via strsep. Can be called for command line |
| 391 | * addition, for proc or mabye a sysfs interface. |
| 392 | * |
| 393 | * Returns: 0 if OK, -error on failure. |
| 394 | **/ |
| 395 | static int scsi_dev_info_list_add_str(char *dev_list) |
| 396 | { |
| 397 | char *vendor, *model, *strflags, *next; |
| 398 | char *next_check; |
| 399 | int res = 0; |
| 400 | |
| 401 | next = dev_list; |
| 402 | if (next && next[0] == '"') { |
| 403 | /* |
| 404 | * Ignore both the leading and trailing quote. |
| 405 | */ |
| 406 | next++; |
| 407 | next_check = ",\""; |
| 408 | } else { |
| 409 | next_check = ","; |
| 410 | } |
| 411 | |
| 412 | /* |
| 413 | * For the leading and trailing '"' case, the for loop comes |
| 414 | * through the last time with vendor[0] == '\0'. |
| 415 | */ |
| 416 | for (vendor = strsep(&next, ":"); vendor && (vendor[0] != '\0') |
| 417 | && (res == 0); vendor = strsep(&next, ":")) { |
| 418 | strflags = NULL; |
| 419 | model = strsep(&next, ":"); |
| 420 | if (model) |
| 421 | strflags = strsep(&next, next_check); |
| 422 | if (!model || !strflags) { |
| 423 | printk(KERN_ERR "%s: bad dev info string '%s' '%s'" |
Harvey Harrison | cadbd4a | 2008-07-03 23:47:27 -0700 | [diff] [blame] | 424 | " '%s'\n", __func__, vendor, model, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 425 | strflags); |
| 426 | res = -EINVAL; |
| 427 | } else |
| 428 | res = scsi_dev_info_list_add(0 /* compatible */, vendor, |
| 429 | model, strflags, 0); |
| 430 | } |
| 431 | return res; |
| 432 | } |
| 433 | |
| 434 | /** |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 435 | * get_device_flags - get device specific flags from the dynamic device list. |
| 436 | * @sdev: &scsi_device to get flags for |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 437 | * @vendor: vendor name |
| 438 | * @model: model name |
| 439 | * |
| 440 | * Description: |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 441 | * Search the global scsi_dev_info_list (specified by list zero) |
| 442 | * for an entry matching @vendor and @model, if found, return the |
| 443 | * matching flags value, else return the host or global default |
| 444 | * settings. Called during scan time. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 445 | **/ |
James Bottomley | 7f23e14 | 2005-12-01 12:50:13 -0600 | [diff] [blame] | 446 | int scsi_get_device_flags(struct scsi_device *sdev, |
| 447 | const unsigned char *vendor, |
| 448 | const unsigned char *model) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 450 | return scsi_get_device_flags_keyed(sdev, vendor, model, |
| 451 | SCSI_DEVINFO_GLOBAL); |
| 452 | } |
| 453 | |
| 454 | |
| 455 | /** |
Randy Dunlap | 1acf3b0 | 2009-11-17 14:53:20 -0800 | [diff] [blame] | 456 | * scsi_get_device_flags_keyed - get device specific flags from the dynamic device list |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 457 | * @sdev: &scsi_device to get flags for |
| 458 | * @vendor: vendor name |
| 459 | * @model: model name |
| 460 | * @key: list to look up |
| 461 | * |
| 462 | * Description: |
| 463 | * Search the scsi_dev_info_list specified by @key for an entry |
| 464 | * matching @vendor and @model, if found, return the matching |
| 465 | * flags value, else return the host or global default settings. |
| 466 | * Called during scan time. |
| 467 | **/ |
| 468 | int scsi_get_device_flags_keyed(struct scsi_device *sdev, |
| 469 | const unsigned char *vendor, |
| 470 | const unsigned char *model, |
| 471 | int key) |
| 472 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | struct scsi_dev_info_list *devinfo; |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 474 | struct scsi_dev_info_list_table *devinfo_table; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 475 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 476 | devinfo_table = scsi_devinfo_lookup_by_key(key); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 478 | if (IS_ERR(devinfo_table)) |
| 479 | return PTR_ERR(devinfo_table); |
| 480 | |
| 481 | list_for_each_entry(devinfo, &devinfo_table->scsi_dev_info_list, |
| 482 | dev_info_list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 | if (devinfo->compatible) { |
| 484 | /* |
| 485 | * Behave like the older version of get_device_flags. |
| 486 | */ |
| 487 | size_t max; |
| 488 | /* |
| 489 | * XXX why skip leading spaces? If an odd INQUIRY |
| 490 | * value, that should have been part of the |
| 491 | * scsi_static_device_list[] entry, such as " FOO" |
| 492 | * rather than "FOO". Since this code is already |
| 493 | * here, and we don't know what device it is |
| 494 | * trying to work with, leave it as-is. |
| 495 | */ |
| 496 | max = 8; /* max length of vendor */ |
| 497 | while ((max > 0) && *vendor == ' ') { |
| 498 | max--; |
| 499 | vendor++; |
| 500 | } |
| 501 | /* |
| 502 | * XXX removing the following strlen() would be |
| 503 | * good, using it means that for a an entry not in |
| 504 | * the list, we scan every byte of every vendor |
| 505 | * listed in scsi_static_device_list[], and never match |
| 506 | * a single one (and still have to compare at |
| 507 | * least the first byte of each vendor). |
| 508 | */ |
| 509 | if (memcmp(devinfo->vendor, vendor, |
| 510 | min(max, strlen(devinfo->vendor)))) |
| 511 | continue; |
| 512 | /* |
| 513 | * Skip spaces again. |
| 514 | */ |
| 515 | max = 16; /* max length of model */ |
| 516 | while ((max > 0) && *model == ' ') { |
| 517 | max--; |
| 518 | model++; |
| 519 | } |
| 520 | if (memcmp(devinfo->model, model, |
| 521 | min(max, strlen(devinfo->model)))) |
| 522 | continue; |
| 523 | return devinfo->flags; |
| 524 | } else { |
| 525 | if (!memcmp(devinfo->vendor, vendor, |
| 526 | sizeof(devinfo->vendor)) && |
| 527 | !memcmp(devinfo->model, model, |
| 528 | sizeof(devinfo->model))) |
| 529 | return devinfo->flags; |
| 530 | } |
| 531 | } |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 532 | /* nothing found, return nothing */ |
| 533 | if (key != SCSI_DEVINFO_GLOBAL) |
| 534 | return 0; |
| 535 | |
| 536 | /* except for the global list, where we have an exception */ |
| 537 | if (sdev->sdev_bflags) |
| 538 | return sdev->sdev_bflags; |
| 539 | |
| 540 | return scsi_default_dev_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | } |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 542 | EXPORT_SYMBOL(scsi_get_device_flags_keyed); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 543 | |
| 544 | #ifdef CONFIG_SCSI_PROC_FS |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 545 | struct double_list { |
| 546 | struct list_head *top; |
| 547 | struct list_head *bottom; |
| 548 | }; |
| 549 | |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 550 | static int devinfo_seq_show(struct seq_file *m, void *v) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 552 | struct double_list *dl = v; |
| 553 | struct scsi_dev_info_list_table *devinfo_table = |
| 554 | list_entry(dl->top, struct scsi_dev_info_list_table, node); |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 555 | struct scsi_dev_info_list *devinfo = |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 556 | list_entry(dl->bottom, struct scsi_dev_info_list, |
| 557 | dev_info_list); |
| 558 | |
| 559 | if (devinfo_table->scsi_dev_info_list.next == dl->bottom && |
| 560 | devinfo_table->name) |
| 561 | seq_printf(m, "[%s]:\n", devinfo_table->name); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 562 | |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 563 | seq_printf(m, "'%.8s' '%.16s' 0x%x\n", |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 564 | devinfo->vendor, devinfo->model, devinfo->flags); |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 565 | return 0; |
| 566 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 567 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 568 | static void *devinfo_seq_start(struct seq_file *m, loff_t *ppos) |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 569 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 570 | struct double_list *dl = kmalloc(sizeof(*dl), GFP_KERNEL); |
| 571 | loff_t pos = *ppos; |
| 572 | |
| 573 | if (!dl) |
| 574 | return NULL; |
| 575 | |
| 576 | list_for_each(dl->top, &scsi_dev_info_list) { |
| 577 | struct scsi_dev_info_list_table *devinfo_table = |
| 578 | list_entry(dl->top, struct scsi_dev_info_list_table, |
| 579 | node); |
| 580 | list_for_each(dl->bottom, &devinfo_table->scsi_dev_info_list) |
| 581 | if (pos-- == 0) |
| 582 | return dl; |
| 583 | } |
| 584 | |
| 585 | kfree(dl); |
| 586 | return NULL; |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 587 | } |
| 588 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 589 | static void *devinfo_seq_next(struct seq_file *m, void *v, loff_t *ppos) |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 590 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 591 | struct double_list *dl = v; |
| 592 | struct scsi_dev_info_list_table *devinfo_table = |
| 593 | list_entry(dl->top, struct scsi_dev_info_list_table, node); |
| 594 | |
| 595 | ++*ppos; |
| 596 | dl->bottom = dl->bottom->next; |
| 597 | while (&devinfo_table->scsi_dev_info_list == dl->bottom) { |
| 598 | dl->top = dl->top->next; |
| 599 | if (dl->top == &scsi_dev_info_list) { |
| 600 | kfree(dl); |
| 601 | return NULL; |
| 602 | } |
| 603 | devinfo_table = list_entry(dl->top, |
| 604 | struct scsi_dev_info_list_table, |
| 605 | node); |
| 606 | dl->bottom = devinfo_table->scsi_dev_info_list.next; |
| 607 | } |
| 608 | |
| 609 | return dl; |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | static void devinfo_seq_stop(struct seq_file *m, void *v) |
| 613 | { |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 614 | kfree(v); |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 615 | } |
| 616 | |
| 617 | static const struct seq_operations scsi_devinfo_seq_ops = { |
| 618 | .start = devinfo_seq_start, |
| 619 | .next = devinfo_seq_next, |
| 620 | .stop = devinfo_seq_stop, |
| 621 | .show = devinfo_seq_show, |
| 622 | }; |
| 623 | |
| 624 | static int proc_scsi_devinfo_open(struct inode *inode, struct file *file) |
| 625 | { |
| 626 | return seq_open(file, &scsi_devinfo_seq_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | /* |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 630 | * proc_scsi_dev_info_write - allow additions to scsi_dev_info_list via /proc. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 631 | * |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 632 | * Description: Adds a black/white list entry for vendor and model with an |
| 633 | * integer value of flag to the scsi device info list. |
| 634 | * To use, echo "vendor:model:flag" > /proc/scsi/device_info |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 635 | */ |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 636 | static ssize_t proc_scsi_devinfo_write(struct file *file, |
| 637 | const char __user *buf, |
| 638 | size_t length, loff_t *ppos) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 639 | { |
| 640 | char *buffer; |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 641 | ssize_t err = length; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | |
| 643 | if (!buf || length>PAGE_SIZE) |
| 644 | return -EINVAL; |
| 645 | if (!(buffer = (char *) __get_free_page(GFP_KERNEL))) |
| 646 | return -ENOMEM; |
| 647 | if (copy_from_user(buffer, buf, length)) { |
| 648 | err =-EFAULT; |
| 649 | goto out; |
| 650 | } |
| 651 | |
| 652 | if (length < PAGE_SIZE) |
| 653 | buffer[length] = '\0'; |
| 654 | else if (buffer[PAGE_SIZE-1]) { |
| 655 | err = -EINVAL; |
| 656 | goto out; |
| 657 | } |
| 658 | |
| 659 | scsi_dev_info_list_add_str(buffer); |
| 660 | |
| 661 | out: |
| 662 | free_page((unsigned long)buffer); |
| 663 | return err; |
| 664 | } |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 665 | |
| 666 | static const struct file_operations scsi_devinfo_proc_fops = { |
| 667 | .owner = THIS_MODULE, |
| 668 | .open = proc_scsi_devinfo_open, |
| 669 | .read = seq_read, |
| 670 | .write = proc_scsi_devinfo_write, |
| 671 | .llseek = seq_lseek, |
| 672 | .release = seq_release, |
| 673 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 674 | #endif /* CONFIG_SCSI_PROC_FS */ |
| 675 | |
| 676 | module_param_string(dev_flags, scsi_dev_flags, sizeof(scsi_dev_flags), 0); |
| 677 | MODULE_PARM_DESC(dev_flags, |
| 678 | "Given scsi_dev_flags=vendor:model:flags[,v:m:f] add black/white" |
| 679 | " list entries for vendor and model with an integer value of flags" |
| 680 | " to the scsi device info list"); |
| 681 | |
| 682 | module_param_named(default_dev_flags, scsi_default_dev_flags, int, S_IRUGO|S_IWUSR); |
| 683 | MODULE_PARM_DESC(default_dev_flags, |
| 684 | "scsi default device flag integer value"); |
| 685 | |
| 686 | /** |
Randy Dunlap | 1acf3b0 | 2009-11-17 14:53:20 -0800 | [diff] [blame] | 687 | * scsi_exit_devinfo - remove /proc/scsi/device_info & the scsi_dev_info_list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | **/ |
| 689 | void scsi_exit_devinfo(void) |
| 690 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | #ifdef CONFIG_SCSI_PROC_FS |
| 692 | remove_proc_entry("scsi/device_info", NULL); |
| 693 | #endif |
| 694 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 695 | scsi_dev_info_remove_list(SCSI_DEVINFO_GLOBAL); |
| 696 | } |
| 697 | |
| 698 | /** |
| 699 | * scsi_dev_info_add_list - add a new devinfo list |
| 700 | * @key: key of the list to add |
| 701 | * @name: Name of the list to add (for /proc/scsi/device_info) |
| 702 | * |
| 703 | * Adds the requested list, returns zero on success, -EEXIST if the |
| 704 | * key is already registered to a list, or other error on failure. |
| 705 | */ |
| 706 | int scsi_dev_info_add_list(int key, const char *name) |
| 707 | { |
| 708 | struct scsi_dev_info_list_table *devinfo_table = |
| 709 | scsi_devinfo_lookup_by_key(key); |
| 710 | |
| 711 | if (!IS_ERR(devinfo_table)) |
| 712 | /* list already exists */ |
| 713 | return -EEXIST; |
| 714 | |
| 715 | devinfo_table = kmalloc(sizeof(*devinfo_table), GFP_KERNEL); |
| 716 | |
| 717 | if (!devinfo_table) |
| 718 | return -ENOMEM; |
| 719 | |
| 720 | INIT_LIST_HEAD(&devinfo_table->node); |
| 721 | INIT_LIST_HEAD(&devinfo_table->scsi_dev_info_list); |
| 722 | devinfo_table->name = name; |
| 723 | devinfo_table->key = key; |
| 724 | list_add_tail(&devinfo_table->node, &scsi_dev_info_list); |
| 725 | |
| 726 | return 0; |
| 727 | } |
| 728 | EXPORT_SYMBOL(scsi_dev_info_add_list); |
| 729 | |
| 730 | /** |
| 731 | * scsi_dev_info_remove_list - destroy an added devinfo list |
| 732 | * @key: key of the list to destroy |
| 733 | * |
| 734 | * Iterates over the entire list first, freeing all the values, then |
| 735 | * frees the list itself. Returns 0 on success or -EINVAL if the key |
| 736 | * can't be found. |
| 737 | */ |
| 738 | int scsi_dev_info_remove_list(int key) |
| 739 | { |
| 740 | struct list_head *lh, *lh_next; |
| 741 | struct scsi_dev_info_list_table *devinfo_table = |
| 742 | scsi_devinfo_lookup_by_key(key); |
| 743 | |
| 744 | if (IS_ERR(devinfo_table)) |
| 745 | /* no such list */ |
| 746 | return -EINVAL; |
| 747 | |
| 748 | /* remove from the master list */ |
| 749 | list_del(&devinfo_table->node); |
| 750 | |
| 751 | list_for_each_safe(lh, lh_next, &devinfo_table->scsi_dev_info_list) { |
| 752 | struct scsi_dev_info_list *devinfo; |
| 753 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | devinfo = list_entry(lh, struct scsi_dev_info_list, |
| 755 | dev_info_list); |
| 756 | kfree(devinfo); |
| 757 | } |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 758 | kfree(devinfo_table); |
| 759 | |
| 760 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 762 | EXPORT_SYMBOL(scsi_dev_info_remove_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 763 | |
| 764 | /** |
Randy Dunlap | c93ff97 | 2007-11-15 17:07:28 -0800 | [diff] [blame] | 765 | * scsi_init_devinfo - set up the dynamic device list. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 766 | * |
| 767 | * Description: |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 768 | * Add command line entries from scsi_dev_flags, then add |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 769 | * scsi_static_device_list entries to the scsi device info list. |
Rob Landley | eb44820 | 2007-11-03 13:30:39 -0500 | [diff] [blame] | 770 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | int __init scsi_init_devinfo(void) |
| 772 | { |
| 773 | #ifdef CONFIG_SCSI_PROC_FS |
| 774 | struct proc_dir_entry *p; |
| 775 | #endif |
| 776 | int error, i; |
| 777 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 778 | error = scsi_dev_info_add_list(SCSI_DEVINFO_GLOBAL, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | if (error) |
| 780 | return error; |
| 781 | |
James Bottomley | 598fa4b | 2009-06-17 15:01:58 -0400 | [diff] [blame] | 782 | error = scsi_dev_info_list_add_str(scsi_dev_flags); |
| 783 | if (error) |
| 784 | goto out; |
| 785 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 786 | for (i = 0; scsi_static_device_list[i].vendor; i++) { |
| 787 | error = scsi_dev_info_list_add(1 /* compatibile */, |
| 788 | scsi_static_device_list[i].vendor, |
| 789 | scsi_static_device_list[i].model, |
| 790 | NULL, |
| 791 | scsi_static_device_list[i].flags); |
| 792 | if (error) |
| 793 | goto out; |
| 794 | } |
| 795 | |
| 796 | #ifdef CONFIG_SCSI_PROC_FS |
Alexey Dobriyan | 352ced8 | 2008-04-29 01:01:55 -0700 | [diff] [blame] | 797 | p = proc_create("scsi/device_info", 0, NULL, &scsi_devinfo_proc_fops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 798 | if (!p) { |
| 799 | error = -ENOMEM; |
| 800 | goto out; |
| 801 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | #endif /* CONFIG_SCSI_PROC_FS */ |
| 803 | |
| 804 | out: |
| 805 | if (error) |
| 806 | scsi_exit_devinfo(); |
| 807 | return error; |
| 808 | } |