diff options
Diffstat (limited to 'drivers/ieee1394')
-rw-r--r-- | drivers/ieee1394/Kconfig | 23 | ||||
-rw-r--r-- | drivers/ieee1394/Makefile | 2 | ||||
-rw-r--r-- | drivers/ieee1394/csr1212.c | 11 | ||||
-rw-r--r-- | drivers/ieee1394/csr1212.h | 2 | ||||
-rw-r--r-- | drivers/ieee1394/dv1394.c | 13 | ||||
-rw-r--r-- | drivers/ieee1394/eth1394.c | 20 | ||||
-rw-r--r-- | drivers/ieee1394/highlevel.c | 18 | ||||
-rw-r--r-- | drivers/ieee1394/hosts.c | 6 | ||||
-rw-r--r-- | drivers/ieee1394/ieee1394-ioctl.h | 8 | ||||
-rw-r--r-- | drivers/ieee1394/nodemgr.c | 27 | ||||
-rw-r--r-- | drivers/ieee1394/ohci1394.c | 33 | ||||
-rw-r--r-- | drivers/ieee1394/ohci1394.h | 4 | ||||
-rw-r--r-- | drivers/ieee1394/pcilynx.c | 2 | ||||
-rw-r--r-- | drivers/ieee1394/raw1394.c | 38 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.c | 634 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.h | 23 | ||||
-rw-r--r-- | drivers/ieee1394/video1394.c | 89 |
17 files changed, 325 insertions, 628 deletions
diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig index 25103a0ef9b3..39142e2f804b 100644 --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig | |||
@@ -169,27 +169,4 @@ config IEEE1394_RAWIO | |||
169 | To compile this driver as a module, say M here: the | 169 | To compile this driver as a module, say M here: the |
170 | module will be called raw1394. | 170 | module will be called raw1394. |
171 | 171 | ||
172 | config IEEE1394_CMP | ||
173 | tristate "IEC61883-1 Plug support" | ||
174 | depends on IEEE1394 | ||
175 | help | ||
176 | This option enables the Connection Management Procedures | ||
177 | (IEC61883-1) driver, which implements input and output plugs. | ||
178 | |||
179 | To compile this driver as a module, say M here: the | ||
180 | module will be called cmp. | ||
181 | |||
182 | config IEEE1394_AMDTP | ||
183 | tristate "IEC61883-6 (Audio transmission) support" | ||
184 | depends on IEEE1394 && IEEE1394_OHCI1394 && IEEE1394_CMP | ||
185 | help | ||
186 | This option enables the Audio & Music Data Transmission Protocol | ||
187 | (IEC61883-6) driver, which implements audio transmission over | ||
188 | IEEE1394. | ||
189 | |||
190 | The userspace interface is documented in amdtp.h. | ||
191 | |||
192 | To compile this driver as a module, say M here: the | ||
193 | module will be called amdtp. | ||
194 | |||
195 | endmenu | 172 | endmenu |
diff --git a/drivers/ieee1394/Makefile b/drivers/ieee1394/Makefile index e8b4d48d376e..6f53611fe255 100644 --- a/drivers/ieee1394/Makefile +++ b/drivers/ieee1394/Makefile | |||
@@ -14,8 +14,6 @@ obj-$(CONFIG_IEEE1394_RAWIO) += raw1394.o | |||
14 | obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o | 14 | obj-$(CONFIG_IEEE1394_SBP2) += sbp2.o |
15 | obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o | 15 | obj-$(CONFIG_IEEE1394_DV1394) += dv1394.o |
16 | obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o | 16 | obj-$(CONFIG_IEEE1394_ETH1394) += eth1394.o |
17 | obj-$(CONFIG_IEEE1394_AMDTP) += amdtp.o | ||
18 | obj-$(CONFIG_IEEE1394_CMP) += cmp.o | ||
19 | 17 | ||
20 | quiet_cmd_oui2c = OUI2C $@ | 18 | quiet_cmd_oui2c = OUI2C $@ |
21 | cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@ | 19 | cmd_oui2c = $(CONFIG_SHELL) $(srctree)/$(src)/oui2c.sh < $< > $@ |
diff --git a/drivers/ieee1394/csr1212.c b/drivers/ieee1394/csr1212.c index 61ddd5d37eff..c0f8ed6fca8a 100644 --- a/drivers/ieee1394/csr1212.c +++ b/drivers/ieee1394/csr1212.c | |||
@@ -1261,7 +1261,7 @@ static int csr1212_parse_bus_info_block(struct csr1212_csr *csr) | |||
1261 | return CSR1212_EINVAL; | 1261 | return CSR1212_EINVAL; |
1262 | #endif | 1262 | #endif |
1263 | 1263 | ||
1264 | cr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1264 | cr = CSR1212_MALLOC(sizeof(*cr)); |
1265 | if (!cr) | 1265 | if (!cr) |
1266 | return CSR1212_ENOMEM; | 1266 | return CSR1212_ENOMEM; |
1267 | 1267 | ||
@@ -1393,8 +1393,7 @@ int csr1212_parse_keyval(struct csr1212_keyval *kv, | |||
1393 | case CSR1212_KV_TYPE_LEAF: | 1393 | case CSR1212_KV_TYPE_LEAF: |
1394 | if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { | 1394 | if (kv->key.id != CSR1212_KV_ID_EXTENDED_ROM) { |
1395 | kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); | 1395 | kv->value.leaf.data = CSR1212_MALLOC(quads_to_bytes(kvi_len)); |
1396 | if (!kv->value.leaf.data) | 1396 | if (!kv->value.leaf.data) { |
1397 | { | ||
1398 | ret = CSR1212_ENOMEM; | 1397 | ret = CSR1212_ENOMEM; |
1399 | goto fail; | 1398 | goto fail; |
1400 | } | 1399 | } |
@@ -1462,7 +1461,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1462 | cache->next = NULL; | 1461 | cache->next = NULL; |
1463 | csr->cache_tail = cache; | 1462 | csr->cache_tail = cache; |
1464 | cache->filled_head = | 1463 | cache->filled_head = |
1465 | CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1464 | CSR1212_MALLOC(sizeof(*cache->filled_head)); |
1466 | if (!cache->filled_head) { | 1465 | if (!cache->filled_head) { |
1467 | return CSR1212_ENOMEM; | 1466 | return CSR1212_ENOMEM; |
1468 | } | 1467 | } |
@@ -1484,7 +1483,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1484 | /* Now seach read portions of the cache to see if it is there. */ | 1483 | /* Now seach read portions of the cache to see if it is there. */ |
1485 | for (cr = cache->filled_head; cr; cr = cr->next) { | 1484 | for (cr = cache->filled_head; cr; cr = cr->next) { |
1486 | if (cache_index < cr->offset_start) { | 1485 | if (cache_index < cr->offset_start) { |
1487 | newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1486 | newcr = CSR1212_MALLOC(sizeof(*newcr)); |
1488 | if (!newcr) | 1487 | if (!newcr) |
1489 | return CSR1212_ENOMEM; | 1488 | return CSR1212_ENOMEM; |
1490 | 1489 | ||
@@ -1508,7 +1507,7 @@ int _csr1212_read_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv) | |||
1508 | 1507 | ||
1509 | if (!cr) { | 1508 | if (!cr) { |
1510 | cr = cache->filled_tail; | 1509 | cr = cache->filled_tail; |
1511 | newcr = CSR1212_MALLOC(sizeof(struct csr1212_cache_region)); | 1510 | newcr = CSR1212_MALLOC(sizeof(*newcr)); |
1512 | if (!newcr) | 1511 | if (!newcr) |
1513 | return CSR1212_ENOMEM; | 1512 | return CSR1212_ENOMEM; |
1514 | 1513 | ||
diff --git a/drivers/ieee1394/csr1212.h b/drivers/ieee1394/csr1212.h index 28c5f4b726e2..cecd5871f2de 100644 --- a/drivers/ieee1394/csr1212.h +++ b/drivers/ieee1394/csr1212.h | |||
@@ -646,7 +646,7 @@ static inline struct csr1212_csr_rom_cache *csr1212_rom_cache_malloc(u_int32_t o | |||
646 | { | 646 | { |
647 | struct csr1212_csr_rom_cache *cache; | 647 | struct csr1212_csr_rom_cache *cache; |
648 | 648 | ||
649 | cache = CSR1212_MALLOC(sizeof(struct csr1212_csr_rom_cache) + size); | 649 | cache = CSR1212_MALLOC(sizeof(*cache) + size); |
650 | if (!cache) | 650 | if (!cache) |
651 | return NULL; | 651 | return NULL; |
652 | 652 | ||
diff --git a/drivers/ieee1394/dv1394.c b/drivers/ieee1394/dv1394.c index cbbbe14b8849..196db7439272 100644 --- a/drivers/ieee1394/dv1394.c +++ b/drivers/ieee1394/dv1394.c | |||
@@ -123,15 +123,6 @@ | |||
123 | 123 | ||
124 | #include "ohci1394.h" | 124 | #include "ohci1394.h" |
125 | 125 | ||
126 | #ifndef virt_to_page | ||
127 | #define virt_to_page(x) MAP_NR(x) | ||
128 | #endif | ||
129 | |||
130 | #ifndef vmalloc_32 | ||
131 | #define vmalloc_32(x) vmalloc(x) | ||
132 | #endif | ||
133 | |||
134 | |||
135 | /* DEBUG LEVELS: | 126 | /* DEBUG LEVELS: |
136 | 0 - no debugging messages | 127 | 0 - no debugging messages |
137 | 1 - some debugging messages, but none during DMA frame transmission | 128 | 1 - some debugging messages, but none during DMA frame transmission |
@@ -2218,14 +2209,12 @@ static int dv1394_init(struct ti_ohci *ohci, enum pal_or_ntsc format, enum modes | |||
2218 | unsigned long flags; | 2209 | unsigned long flags; |
2219 | int i; | 2210 | int i; |
2220 | 2211 | ||
2221 | video = kmalloc(sizeof(struct video_card), GFP_KERNEL); | 2212 | video = kzalloc(sizeof(*video), GFP_KERNEL); |
2222 | if (!video) { | 2213 | if (!video) { |
2223 | printk(KERN_ERR "dv1394: cannot allocate video_card\n"); | 2214 | printk(KERN_ERR "dv1394: cannot allocate video_card\n"); |
2224 | goto err; | 2215 | goto err; |
2225 | } | 2216 | } |
2226 | 2217 | ||
2227 | memset(video, 0, sizeof(struct video_card)); | ||
2228 | |||
2229 | video->ohci = ohci; | 2218 | video->ohci = ohci; |
2230 | /* lower 2 bits of id indicate which of four "plugs" | 2219 | /* lower 2 bits of id indicate which of four "plugs" |
2231 | per host */ | 2220 | per host */ |
diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index c9e92d85c893..30fa0d43a43a 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c | |||
@@ -88,9 +88,6 @@ | |||
88 | printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args) | 88 | printk(KERN_ERR "%s:%s[%d]: " fmt "\n", driver_name, __FUNCTION__, __LINE__, ## args) |
89 | #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) | 89 | #define TRACE() printk(KERN_ERR "%s:%s[%d] ---- TRACE\n", driver_name, __FUNCTION__, __LINE__) |
90 | 90 | ||
91 | static char version[] __devinitdata = | ||
92 | "$Rev: 1312 $ Ben Collins <bcollins@debian.org>"; | ||
93 | |||
94 | struct fragment_info { | 91 | struct fragment_info { |
95 | struct list_head list; | 92 | struct list_head list; |
96 | int offset; | 93 | int offset; |
@@ -355,12 +352,12 @@ static int eth1394_probe(struct device *dev) | |||
355 | if (!hi) | 352 | if (!hi) |
356 | return -ENOENT; | 353 | return -ENOENT; |
357 | 354 | ||
358 | new_node = kmalloc(sizeof(struct eth1394_node_ref), | 355 | new_node = kmalloc(sizeof(*new_node), |
359 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 356 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
360 | if (!new_node) | 357 | if (!new_node) |
361 | return -ENOMEM; | 358 | return -ENOMEM; |
362 | 359 | ||
363 | node_info = kmalloc(sizeof(struct eth1394_node_info), | 360 | node_info = kmalloc(sizeof(*node_info), |
364 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 361 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
365 | if (!node_info) { | 362 | if (!node_info) { |
366 | kfree(new_node); | 363 | kfree(new_node); |
@@ -436,12 +433,12 @@ static int eth1394_update(struct unit_directory *ud) | |||
436 | node = eth1394_find_node(&priv->ip_node_list, ud); | 433 | node = eth1394_find_node(&priv->ip_node_list, ud); |
437 | 434 | ||
438 | if (!node) { | 435 | if (!node) { |
439 | node = kmalloc(sizeof(struct eth1394_node_ref), | 436 | node = kmalloc(sizeof(*node), |
440 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 437 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
441 | if (!node) | 438 | if (!node) |
442 | return -ENOMEM; | 439 | return -ENOMEM; |
443 | 440 | ||
444 | node_info = kmalloc(sizeof(struct eth1394_node_info), | 441 | node_info = kmalloc(sizeof(*node_info), |
445 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); | 442 | in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); |
446 | if (!node_info) { | 443 | if (!node_info) { |
447 | kfree(node); | 444 | kfree(node); |
@@ -566,7 +563,6 @@ static void ether1394_add_host (struct hpsb_host *host) | |||
566 | struct eth1394_host_info *hi = NULL; | 563 | struct eth1394_host_info *hi = NULL; |
567 | struct net_device *dev = NULL; | 564 | struct net_device *dev = NULL; |
568 | struct eth1394_priv *priv; | 565 | struct eth1394_priv *priv; |
569 | static int version_printed = 0; | ||
570 | u64 fifo_addr; | 566 | u64 fifo_addr; |
571 | 567 | ||
572 | if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394)) | 568 | if (!(host->config_roms & HPSB_CONFIG_ROM_ENTRY_IP1394)) |
@@ -581,9 +577,6 @@ static void ether1394_add_host (struct hpsb_host *host) | |||
581 | if (fifo_addr == ~0ULL) | 577 | if (fifo_addr == ~0ULL) |
582 | goto out; | 578 | goto out; |
583 | 579 | ||
584 | if (version_printed++ == 0) | ||
585 | ETH1394_PRINT_G (KERN_INFO, "%s\n", version); | ||
586 | |||
587 | /* We should really have our own alloc_hpsbdev() function in | 580 | /* We should really have our own alloc_hpsbdev() function in |
588 | * net_init.c instead of calling the one for ethernet then hijacking | 581 | * net_init.c instead of calling the one for ethernet then hijacking |
589 | * it for ourselves. That way we'd be a real networking device. */ | 582 | * it for ourselves. That way we'd be a real networking device. */ |
@@ -1021,7 +1014,7 @@ static inline int new_fragment(struct list_head *frag_info, int offset, int len) | |||
1021 | } | 1014 | } |
1022 | } | 1015 | } |
1023 | 1016 | ||
1024 | new = kmalloc(sizeof(struct fragment_info), GFP_ATOMIC); | 1017 | new = kmalloc(sizeof(*new), GFP_ATOMIC); |
1025 | if (!new) | 1018 | if (!new) |
1026 | return -ENOMEM; | 1019 | return -ENOMEM; |
1027 | 1020 | ||
@@ -1040,7 +1033,7 @@ static inline int new_partial_datagram(struct net_device *dev, | |||
1040 | { | 1033 | { |
1041 | struct partial_datagram *new; | 1034 | struct partial_datagram *new; |
1042 | 1035 | ||
1043 | new = kmalloc(sizeof(struct partial_datagram), GFP_ATOMIC); | 1036 | new = kmalloc(sizeof(*new), GFP_ATOMIC); |
1044 | if (!new) | 1037 | if (!new) |
1045 | return -ENOMEM; | 1038 | return -ENOMEM; |
1046 | 1039 | ||
@@ -1768,7 +1761,6 @@ fail: | |||
1768 | static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1761 | static void ether1394_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) |
1769 | { | 1762 | { |
1770 | strcpy (info->driver, driver_name); | 1763 | strcpy (info->driver, driver_name); |
1771 | strcpy (info->version, "$Rev: 1312 $"); | ||
1772 | /* FIXME XXX provide sane businfo */ | 1764 | /* FIXME XXX provide sane businfo */ |
1773 | strcpy (info->bus_info, "ieee1394"); | 1765 | strcpy (info->bus_info, "ieee1394"); |
1774 | } | 1766 | } |
diff --git a/drivers/ieee1394/highlevel.c b/drivers/ieee1394/highlevel.c index 997e1bf6297f..734b121a0554 100644 --- a/drivers/ieee1394/highlevel.c +++ b/drivers/ieee1394/highlevel.c | |||
@@ -101,12 +101,10 @@ void *hpsb_create_hostinfo(struct hpsb_highlevel *hl, struct hpsb_host *host, | |||
101 | return NULL; | 101 | return NULL; |
102 | } | 102 | } |
103 | 103 | ||
104 | hi = kmalloc(sizeof(*hi) + data_size, GFP_ATOMIC); | 104 | hi = kzalloc(sizeof(*hi) + data_size, GFP_ATOMIC); |
105 | if (!hi) | 105 | if (!hi) |
106 | return NULL; | 106 | return NULL; |
107 | 107 | ||
108 | memset(hi, 0, sizeof(*hi) + data_size); | ||
109 | |||
110 | if (data_size) { | 108 | if (data_size) { |
111 | data = hi->data = hi + 1; | 109 | data = hi->data = hi + 1; |
112 | hi->size = data_size; | 110 | hi->size = data_size; |
@@ -326,11 +324,9 @@ u64 hpsb_allocate_and_register_addrspace(struct hpsb_highlevel *hl, | |||
326 | return retval; | 324 | return retval; |
327 | } | 325 | } |
328 | 326 | ||
329 | as = (struct hpsb_address_serve *) | 327 | as = kmalloc(sizeof(*as), GFP_KERNEL); |
330 | kmalloc(sizeof(struct hpsb_address_serve), GFP_KERNEL); | 328 | if (!as) |
331 | if (as == NULL) { | ||
332 | return retval; | 329 | return retval; |
333 | } | ||
334 | 330 | ||
335 | INIT_LIST_HEAD(&as->host_list); | 331 | INIT_LIST_HEAD(&as->host_list); |
336 | INIT_LIST_HEAD(&as->hl_list); | 332 | INIT_LIST_HEAD(&as->hl_list); |
@@ -383,11 +379,9 @@ int hpsb_register_addrspace(struct hpsb_highlevel *hl, struct hpsb_host *host, | |||
383 | return 0; | 379 | return 0; |
384 | } | 380 | } |
385 | 381 | ||
386 | as = (struct hpsb_address_serve *) | 382 | as = kmalloc(sizeof(*as), GFP_ATOMIC); |
387 | kmalloc(sizeof(struct hpsb_address_serve), GFP_ATOMIC); | 383 | if (!as) |
388 | if (as == NULL) { | 384 | return 0; |
389 | return 0; | ||
390 | } | ||
391 | 385 | ||
392 | INIT_LIST_HEAD(&as->host_list); | 386 | INIT_LIST_HEAD(&as->host_list); |
393 | INIT_LIST_HEAD(&as->hl_list); | 387 | INIT_LIST_HEAD(&as->hl_list); |
diff --git a/drivers/ieee1394/hosts.c b/drivers/ieee1394/hosts.c index aeeaeb670d03..d245abe4033c 100644 --- a/drivers/ieee1394/hosts.c +++ b/drivers/ieee1394/hosts.c | |||
@@ -114,9 +114,9 @@ struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra, | |||
114 | int i; | 114 | int i; |
115 | int hostnum = 0; | 115 | int hostnum = 0; |
116 | 116 | ||
117 | h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL); | 117 | h = kzalloc(sizeof(*h) + extra, SLAB_KERNEL); |
118 | if (!h) return NULL; | 118 | if (!h) |
119 | memset(h, 0, sizeof(struct hpsb_host) + extra); | 119 | return NULL; |
120 | 120 | ||
121 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); | 121 | h->csr.rom = csr1212_create_csr(&csr_bus_ops, CSR_BUS_INFO_SIZE, h); |
122 | if (!h->csr.rom) { | 122 | if (!h->csr.rom) { |
diff --git a/drivers/ieee1394/ieee1394-ioctl.h b/drivers/ieee1394/ieee1394-ioctl.h index f92b566363d5..156703986348 100644 --- a/drivers/ieee1394/ieee1394-ioctl.h +++ b/drivers/ieee1394/ieee1394-ioctl.h | |||
@@ -7,14 +7,6 @@ | |||
7 | #include <linux/ioctl.h> | 7 | #include <linux/ioctl.h> |
8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
9 | 9 | ||
10 | |||
11 | /* AMDTP Gets 6 */ | ||
12 | #define AMDTP_IOC_CHANNEL _IOW('#', 0x00, struct amdtp_ioctl) | ||
13 | #define AMDTP_IOC_PLUG _IOW('#', 0x01, struct amdtp_ioctl) | ||
14 | #define AMDTP_IOC_PING _IOW('#', 0x02, struct amdtp_ioctl) | ||
15 | #define AMDTP_IOC_ZAP _IO ('#', 0x03) | ||
16 | |||
17 | |||
18 | /* DV1394 Gets 10 */ | 10 | /* DV1394 Gets 10 */ |
19 | 11 | ||
20 | /* Get the driver ready to transmit video. pass a struct dv1394_init* as | 12 | /* Get the driver ready to transmit video. pass a struct dv1394_init* as |
diff --git a/drivers/ieee1394/nodemgr.c b/drivers/ieee1394/nodemgr.c index 7fff5a1d2ea4..3f0917bbd7f5 100644 --- a/drivers/ieee1394/nodemgr.c +++ b/drivers/ieee1394/nodemgr.c | |||
@@ -743,21 +743,20 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr | |||
743 | unsigned int generation) | 743 | unsigned int generation) |
744 | { | 744 | { |
745 | struct hpsb_host *host = hi->host; | 745 | struct hpsb_host *host = hi->host; |
746 | struct node_entry *ne; | 746 | struct node_entry *ne; |
747 | |||
748 | ne = kmalloc(sizeof(struct node_entry), GFP_KERNEL); | ||
749 | if (!ne) return NULL; | ||
750 | 747 | ||
751 | memset(ne, 0, sizeof(struct node_entry)); | 748 | ne = kzalloc(sizeof(*ne), GFP_KERNEL); |
749 | if (!ne) | ||
750 | return NULL; | ||
752 | 751 | ||
753 | ne->tpool = &host->tpool[nodeid & NODE_MASK]; | 752 | ne->tpool = &host->tpool[nodeid & NODE_MASK]; |
754 | 753 | ||
755 | ne->host = host; | 754 | ne->host = host; |
756 | ne->nodeid = nodeid; | 755 | ne->nodeid = nodeid; |
757 | ne->generation = generation; | 756 | ne->generation = generation; |
758 | ne->needs_probe = 1; | 757 | ne->needs_probe = 1; |
759 | 758 | ||
760 | ne->guid = guid; | 759 | ne->guid = guid; |
761 | ne->guid_vendor_id = (guid >> 40) & 0xffffff; | 760 | ne->guid_vendor_id = (guid >> 40) & 0xffffff; |
762 | ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); | 761 | ne->guid_vendor_oui = nodemgr_find_oui_name(ne->guid_vendor_id); |
763 | ne->csr = csr; | 762 | ne->csr = csr; |
@@ -787,7 +786,7 @@ static struct node_entry *nodemgr_create_node(octlet_t guid, struct csr1212_csr | |||
787 | (host->node_id == nodeid) ? "Host" : "Node", | 786 | (host->node_id == nodeid) ? "Host" : "Node", |
788 | NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); | 787 | NODE_BUS_ARGS(host, nodeid), (unsigned long long)guid); |
789 | 788 | ||
790 | return ne; | 789 | return ne; |
791 | } | 790 | } |
792 | 791 | ||
793 | 792 | ||
@@ -872,12 +871,10 @@ static struct unit_directory *nodemgr_process_unit_directory | |||
872 | struct csr1212_keyval *kv; | 871 | struct csr1212_keyval *kv; |
873 | u8 last_key_id = 0; | 872 | u8 last_key_id = 0; |
874 | 873 | ||
875 | ud = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); | 874 | ud = kzalloc(sizeof(*ud), GFP_KERNEL); |
876 | if (!ud) | 875 | if (!ud) |
877 | goto unit_directory_error; | 876 | goto unit_directory_error; |
878 | 877 | ||
879 | memset (ud, 0, sizeof(struct unit_directory)); | ||
880 | |||
881 | ud->ne = ne; | 878 | ud->ne = ne; |
882 | ud->ignore_driver = ignore_drivers; | 879 | ud->ignore_driver = ignore_drivers; |
883 | ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; | 880 | ud->address = ud_kv->offset + CSR1212_CONFIG_ROM_SPACE_BASE; |
@@ -937,10 +934,10 @@ static struct unit_directory *nodemgr_process_unit_directory | |||
937 | /* Logical Unit Number */ | 934 | /* Logical Unit Number */ |
938 | if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { | 935 | if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { |
939 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { | 936 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) { |
940 | ud_child = kmalloc(sizeof(struct unit_directory), GFP_KERNEL); | 937 | ud_child = kmalloc(sizeof(*ud_child), GFP_KERNEL); |
941 | if (!ud_child) | 938 | if (!ud_child) |
942 | goto unit_directory_error; | 939 | goto unit_directory_error; |
943 | memcpy(ud_child, ud, sizeof(struct unit_directory)); | 940 | memcpy(ud_child, ud, sizeof(*ud_child)); |
944 | nodemgr_register_device(ne, ud_child, &ne->device); | 941 | nodemgr_register_device(ne, ud_child, &ne->device); |
945 | ud_child = NULL; | 942 | ud_child = NULL; |
946 | 943 | ||
@@ -1200,7 +1197,7 @@ static void nodemgr_node_scan_one(struct host_info *hi, | |||
1200 | struct csr1212_csr *csr; | 1197 | struct csr1212_csr *csr; |
1201 | struct nodemgr_csr_info *ci; | 1198 | struct nodemgr_csr_info *ci; |
1202 | 1199 | ||
1203 | ci = kmalloc(sizeof(struct nodemgr_csr_info), GFP_KERNEL); | 1200 | ci = kmalloc(sizeof(*ci), GFP_KERNEL); |
1204 | if (!ci) | 1201 | if (!ci) |
1205 | return; | 1202 | return; |
1206 | 1203 | ||
diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 4cf9b8f3e336..97b6f48033c4 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c | |||
@@ -161,9 +161,6 @@ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args) | |||
161 | #define PRINT(level, fmt, args...) \ | 161 | #define PRINT(level, fmt, args...) \ |
162 | printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) | 162 | printk(level "%s: fw-host%d: " fmt "\n" , OHCI1394_DRIVER_NAME, ohci->host->id , ## args) |
163 | 163 | ||
164 | static char version[] __devinitdata = | ||
165 | "$Rev: 1313 $ Ben Collins <bcollins@debian.org>"; | ||
166 | |||
167 | /* Module Parameters */ | 164 | /* Module Parameters */ |
168 | static int phys_dma = 1; | 165 | static int phys_dma = 1; |
169 | module_param(phys_dma, int, 0644); | 166 | module_param(phys_dma, int, 0644); |
@@ -2960,28 +2957,23 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, struct dma_rcv_ctx *d, | |||
2960 | d->ctrlClear = 0; | 2957 | d->ctrlClear = 0; |
2961 | d->cmdPtr = 0; | 2958 | d->cmdPtr = 0; |
2962 | 2959 | ||
2963 | d->buf_cpu = kmalloc(d->num_desc * sizeof(quadlet_t*), GFP_ATOMIC); | 2960 | d->buf_cpu = kzalloc(d->num_desc * sizeof(*d->buf_cpu), GFP_ATOMIC); |
2964 | d->buf_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); | 2961 | d->buf_bus = kzalloc(d->num_desc * sizeof(*d->buf_bus), GFP_ATOMIC); |
2965 | 2962 | ||
2966 | if (d->buf_cpu == NULL || d->buf_bus == NULL) { | 2963 | if (d->buf_cpu == NULL || d->buf_bus == NULL) { |
2967 | PRINT(KERN_ERR, "Failed to allocate dma buffer"); | 2964 | PRINT(KERN_ERR, "Failed to allocate dma buffer"); |
2968 | free_dma_rcv_ctx(d); | 2965 | free_dma_rcv_ctx(d); |
2969 | return -ENOMEM; | 2966 | return -ENOMEM; |
2970 | } | 2967 | } |
2971 | memset(d->buf_cpu, 0, d->num_desc * sizeof(quadlet_t*)); | ||
2972 | memset(d->buf_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
2973 | 2968 | ||
2974 | d->prg_cpu = kmalloc(d->num_desc * sizeof(struct dma_cmd*), | 2969 | d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_ATOMIC); |
2975 | GFP_ATOMIC); | 2970 | d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_ATOMIC); |
2976 | d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_ATOMIC); | ||
2977 | 2971 | ||
2978 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { | 2972 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { |
2979 | PRINT(KERN_ERR, "Failed to allocate dma prg"); | 2973 | PRINT(KERN_ERR, "Failed to allocate dma prg"); |
2980 | free_dma_rcv_ctx(d); | 2974 | free_dma_rcv_ctx(d); |
2981 | return -ENOMEM; | 2975 | return -ENOMEM; |
2982 | } | 2976 | } |
2983 | memset(d->prg_cpu, 0, d->num_desc * sizeof(struct dma_cmd*)); | ||
2984 | memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
2985 | 2977 | ||
2986 | d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); | 2978 | d->spb = kmalloc(d->split_buf_size, GFP_ATOMIC); |
2987 | 2979 | ||
@@ -3093,17 +3085,14 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, struct dma_trm_ctx *d, | |||
3093 | d->ctrlClear = 0; | 3085 | d->ctrlClear = 0; |
3094 | d->cmdPtr = 0; | 3086 | d->cmdPtr = 0; |
3095 | 3087 | ||
3096 | d->prg_cpu = kmalloc(d->num_desc * sizeof(struct at_dma_prg*), | 3088 | d->prg_cpu = kzalloc(d->num_desc * sizeof(*d->prg_cpu), GFP_KERNEL); |
3097 | GFP_KERNEL); | 3089 | d->prg_bus = kzalloc(d->num_desc * sizeof(*d->prg_bus), GFP_KERNEL); |
3098 | d->prg_bus = kmalloc(d->num_desc * sizeof(dma_addr_t), GFP_KERNEL); | ||
3099 | 3090 | ||
3100 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { | 3091 | if (d->prg_cpu == NULL || d->prg_bus == NULL) { |
3101 | PRINT(KERN_ERR, "Failed to allocate at dma prg"); | 3092 | PRINT(KERN_ERR, "Failed to allocate at dma prg"); |
3102 | free_dma_trm_ctx(d); | 3093 | free_dma_trm_ctx(d); |
3103 | return -ENOMEM; | 3094 | return -ENOMEM; |
3104 | } | 3095 | } |
3105 | memset(d->prg_cpu, 0, d->num_desc * sizeof(struct at_dma_prg*)); | ||
3106 | memset(d->prg_bus, 0, d->num_desc * sizeof(dma_addr_t)); | ||
3107 | 3096 | ||
3108 | len = sprintf(pool_name, "ohci1394_trm_prg"); | 3097 | len = sprintf(pool_name, "ohci1394_trm_prg"); |
3109 | sprintf(pool_name+len, "%d", num_allocs); | 3098 | sprintf(pool_name+len, "%d", num_allocs); |
@@ -3201,8 +3190,6 @@ static struct hpsb_host_driver ohci1394_driver = { | |||
3201 | .hw_csr_reg = ohci_hw_csr_reg, | 3190 | .hw_csr_reg = ohci_hw_csr_reg, |
3202 | }; | 3191 | }; |
3203 | 3192 | ||
3204 | |||
3205 | |||
3206 | /*********************************** | 3193 | /*********************************** |
3207 | * PCI Driver Interface functions * | 3194 | * PCI Driver Interface functions * |
3208 | ***********************************/ | 3195 | ***********************************/ |
@@ -3217,15 +3204,10 @@ do { \ | |||
3217 | static int __devinit ohci1394_pci_probe(struct pci_dev *dev, | 3204 | static int __devinit ohci1394_pci_probe(struct pci_dev *dev, |
3218 | const struct pci_device_id *ent) | 3205 | const struct pci_device_id *ent) |
3219 | { | 3206 | { |
3220 | static int version_printed = 0; | ||
3221 | |||
3222 | struct hpsb_host *host; | 3207 | struct hpsb_host *host; |
3223 | struct ti_ohci *ohci; /* shortcut to currently handled device */ | 3208 | struct ti_ohci *ohci; /* shortcut to currently handled device */ |
3224 | unsigned long ohci_base; | 3209 | unsigned long ohci_base; |
3225 | 3210 | ||
3226 | if (version_printed++ == 0) | ||
3227 | PRINT_G(KERN_INFO, "%s", version); | ||
3228 | |||
3229 | if (pci_enable_device(dev)) | 3211 | if (pci_enable_device(dev)) |
3230 | FAIL(-ENXIO, "Failed to enable OHCI hardware"); | 3212 | FAIL(-ENXIO, "Failed to enable OHCI hardware"); |
3231 | pci_set_master(dev); | 3213 | pci_set_master(dev); |
@@ -3606,8 +3588,6 @@ static struct pci_driver ohci1394_pci_driver = { | |||
3606 | .suspend = ohci1394_pci_suspend, | 3588 | .suspend = ohci1394_pci_suspend, |
3607 | }; | 3589 | }; |
3608 | 3590 | ||
3609 | |||
3610 | |||
3611 | /*********************************** | 3591 | /*********************************** |
3612 | * OHCI1394 Video Interface * | 3592 | * OHCI1394 Video Interface * |
3613 | ***********************************/ | 3593 | ***********************************/ |
@@ -3714,7 +3694,6 @@ EXPORT_SYMBOL(ohci1394_init_iso_tasklet); | |||
3714 | EXPORT_SYMBOL(ohci1394_register_iso_tasklet); | 3694 | EXPORT_SYMBOL(ohci1394_register_iso_tasklet); |
3715 | EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); | 3695 | EXPORT_SYMBOL(ohci1394_unregister_iso_tasklet); |
3716 | 3696 | ||
3717 | |||
3718 | /*********************************** | 3697 | /*********************************** |
3719 | * General module initialization * | 3698 | * General module initialization * |
3720 | ***********************************/ | 3699 | ***********************************/ |
diff --git a/drivers/ieee1394/ohci1394.h b/drivers/ieee1394/ohci1394.h index cc66c1cae250..7df0962144e3 100644 --- a/drivers/ieee1394/ohci1394.h +++ b/drivers/ieee1394/ohci1394.h | |||
@@ -219,8 +219,8 @@ struct ti_ohci { | |||
219 | 219 | ||
220 | int self_id_errors; | 220 | int self_id_errors; |
221 | 221 | ||
222 | /* Tasklets for iso receive and transmit, used by video1394, | 222 | /* Tasklets for iso receive and transmit, used by video1394 |
223 | * amdtp and dv1394 */ | 223 | * and dv1394 */ |
224 | 224 | ||
225 | struct list_head iso_tasklet_list; | 225 | struct list_head iso_tasklet_list; |
226 | spinlock_t iso_tasklet_list_lock; | 226 | spinlock_t iso_tasklet_list_lock; |
diff --git a/drivers/ieee1394/pcilynx.c b/drivers/ieee1394/pcilynx.c index 6b1ab875333b..e2edc41e1b6f 100644 --- a/drivers/ieee1394/pcilynx.c +++ b/drivers/ieee1394/pcilynx.c | |||
@@ -1435,7 +1435,7 @@ static int __devinit add_card(struct pci_dev *dev, | |||
1435 | struct i2c_algo_bit_data i2c_adapter_data; | 1435 | struct i2c_algo_bit_data i2c_adapter_data; |
1436 | 1436 | ||
1437 | error = -ENOMEM; | 1437 | error = -ENOMEM; |
1438 | i2c_ad = kmalloc(sizeof(struct i2c_adapter), SLAB_KERNEL); | 1438 | i2c_ad = kmalloc(sizeof(*i2c_ad), SLAB_KERNEL); |
1439 | if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); | 1439 | if (!i2c_ad) FAIL("failed to allocate I2C adapter memory"); |
1440 | 1440 | ||
1441 | memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); | 1441 | memcpy(i2c_ad, &bit_ops, sizeof(struct i2c_adapter)); |
diff --git a/drivers/ieee1394/raw1394.c b/drivers/ieee1394/raw1394.c index 24411e666b21..0278dc5d5ef9 100644 --- a/drivers/ieee1394/raw1394.c +++ b/drivers/ieee1394/raw1394.c | |||
@@ -102,12 +102,9 @@ static struct pending_request *__alloc_pending_request(gfp_t flags) | |||
102 | { | 102 | { |
103 | struct pending_request *req; | 103 | struct pending_request *req; |
104 | 104 | ||
105 | req = (struct pending_request *)kmalloc(sizeof(struct pending_request), | 105 | req = kzalloc(sizeof(*req), flags); |
106 | flags); | 106 | if (req) |
107 | if (req != NULL) { | ||
108 | memset(req, 0, sizeof(struct pending_request)); | ||
109 | INIT_LIST_HEAD(&req->list); | 107 | INIT_LIST_HEAD(&req->list); |
110 | } | ||
111 | 108 | ||
112 | return req; | 109 | return req; |
113 | } | 110 | } |
@@ -192,9 +189,9 @@ static void add_host(struct hpsb_host *host) | |||
192 | struct host_info *hi; | 189 | struct host_info *hi; |
193 | unsigned long flags; | 190 | unsigned long flags; |
194 | 191 | ||
195 | hi = (struct host_info *)kmalloc(sizeof(struct host_info), GFP_KERNEL); | 192 | hi = kmalloc(sizeof(*hi), GFP_KERNEL); |
196 | 193 | ||
197 | if (hi != NULL) { | 194 | if (hi) { |
198 | INIT_LIST_HEAD(&hi->list); | 195 | INIT_LIST_HEAD(&hi->list); |
199 | hi->host = host; | 196 | hi->host = host; |
200 | INIT_LIST_HEAD(&hi->file_info_list); | 197 | INIT_LIST_HEAD(&hi->file_info_list); |
@@ -315,8 +312,8 @@ static void iso_receive(struct hpsb_host *host, int channel, quadlet_t * data, | |||
315 | break; | 312 | break; |
316 | 313 | ||
317 | if (!ibs) { | 314 | if (!ibs) { |
318 | ibs = kmalloc(sizeof(struct iso_block_store) | 315 | ibs = kmalloc(sizeof(*ibs) + length, |
319 | + length, SLAB_ATOMIC); | 316 | SLAB_ATOMIC); |
320 | if (!ibs) { | 317 | if (!ibs) { |
321 | kfree(req); | 318 | kfree(req); |
322 | break; | 319 | break; |
@@ -376,8 +373,8 @@ static void fcp_request(struct hpsb_host *host, int nodeid, int direction, | |||
376 | break; | 373 | break; |
377 | 374 | ||
378 | if (!ibs) { | 375 | if (!ibs) { |
379 | ibs = kmalloc(sizeof(struct iso_block_store) | 376 | ibs = kmalloc(sizeof(*ibs) + length, |
380 | + length, SLAB_ATOMIC); | 377 | SLAB_ATOMIC); |
381 | if (!ibs) { | 378 | if (!ibs) { |
382 | kfree(req); | 379 | kfree(req); |
383 | break; | 380 | break; |
@@ -502,10 +499,9 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
502 | switch (req->req.type) { | 499 | switch (req->req.type) { |
503 | case RAW1394_REQ_LIST_CARDS: | 500 | case RAW1394_REQ_LIST_CARDS: |
504 | spin_lock_irqsave(&host_info_lock, flags); | 501 | spin_lock_irqsave(&host_info_lock, flags); |
505 | khl = kmalloc(sizeof(struct raw1394_khost_list) * host_count, | 502 | khl = kmalloc(sizeof(*khl) * host_count, SLAB_ATOMIC); |
506 | SLAB_ATOMIC); | ||
507 | 503 | ||
508 | if (khl != NULL) { | 504 | if (khl) { |
509 | req->req.misc = host_count; | 505 | req->req.misc = host_count; |
510 | req->data = (quadlet_t *) khl; | 506 | req->data = (quadlet_t *) khl; |
511 | 507 | ||
@@ -517,7 +513,7 @@ static int state_initialized(struct file_info *fi, struct pending_request *req) | |||
517 | } | 513 | } |
518 | spin_unlock_irqrestore(&host_info_lock, flags); | 514 | spin_unlock_irqrestore(&host_info_lock, flags); |
519 | 515 | ||
520 | if (khl != NULL) { | 516 | if (khl) { |
521 | req->req.error = RAW1394_ERROR_NONE; | 517 | req->req.error = RAW1394_ERROR_NONE; |
522 | req->req.length = min(req->req.length, | 518 | req->req.length = min(req->req.length, |
523 | (u32) (sizeof | 519 | (u32) (sizeof |
@@ -1647,13 +1643,13 @@ static int arm_register(struct file_info *fi, struct pending_request *req) | |||
1647 | return (-EINVAL); | 1643 | return (-EINVAL); |
1648 | } | 1644 | } |
1649 | /* addr-list-entry for fileinfo */ | 1645 | /* addr-list-entry for fileinfo */ |
1650 | addr = (struct arm_addr *)kmalloc(sizeof(struct arm_addr), SLAB_KERNEL); | 1646 | addr = kmalloc(sizeof(*addr), SLAB_KERNEL); |
1651 | if (!addr) { | 1647 | if (!addr) { |
1652 | req->req.length = 0; | 1648 | req->req.length = 0; |
1653 | return (-ENOMEM); | 1649 | return (-ENOMEM); |
1654 | } | 1650 | } |
1655 | /* allocation of addr_space_buffer */ | 1651 | /* allocation of addr_space_buffer */ |
1656 | addr->addr_space_buffer = (u8 *) vmalloc(req->req.length); | 1652 | addr->addr_space_buffer = vmalloc(req->req.length); |
1657 | if (!(addr->addr_space_buffer)) { | 1653 | if (!(addr->addr_space_buffer)) { |
1658 | kfree(addr); | 1654 | kfree(addr); |
1659 | req->req.length = 0; | 1655 | req->req.length = 0; |
@@ -2122,8 +2118,7 @@ static int modify_config_rom(struct file_info *fi, struct pending_request *req) | |||
2122 | return -ENOMEM; | 2118 | return -ENOMEM; |
2123 | } | 2119 | } |
2124 | 2120 | ||
2125 | cache->filled_head = | 2121 | cache->filled_head = kmalloc(sizeof(*cache->filled_head), GFP_KERNEL); |
2126 | kmalloc(sizeof(struct csr1212_cache_region), GFP_KERNEL); | ||
2127 | if (!cache->filled_head) { | 2122 | if (!cache->filled_head) { |
2128 | csr1212_release_keyval(fi->csr1212_dirs[dr]); | 2123 | csr1212_release_keyval(fi->csr1212_dirs[dr]); |
2129 | fi->csr1212_dirs[dr] = NULL; | 2124 | fi->csr1212_dirs[dr] = NULL; |
@@ -2684,11 +2679,10 @@ static int raw1394_open(struct inode *inode, struct file *file) | |||
2684 | { | 2679 | { |
2685 | struct file_info *fi; | 2680 | struct file_info *fi; |
2686 | 2681 | ||
2687 | fi = kmalloc(sizeof(struct file_info), SLAB_KERNEL); | 2682 | fi = kzalloc(sizeof(*fi), SLAB_KERNEL); |
2688 | if (fi == NULL) | 2683 | if (!fi) |
2689 | return -ENOMEM; | 2684 | return -ENOMEM; |
2690 | 2685 | ||
2691 | memset(fi, 0, sizeof(struct file_info)); | ||
2692 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ | 2686 | fi->notification = (u8) RAW1394_NOTIFY_ON; /* busreset notification */ |
2693 | 2687 | ||
2694 | INIT_LIST_HEAD(&fi->list); | 2688 | INIT_LIST_HEAD(&fi->list); |
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 12cec7c4a342..84875cd5a70d 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c | |||
@@ -80,9 +80,6 @@ | |||
80 | #include "ieee1394_transactions.h" | 80 | #include "ieee1394_transactions.h" |
81 | #include "sbp2.h" | 81 | #include "sbp2.h" |
82 | 82 | ||
83 | static char version[] __devinitdata = | ||
84 | "$Rev: 1306 $ Ben Collins <bcollins@debian.org>"; | ||
85 | |||
86 | /* | 83 | /* |
87 | * Module load parameter definitions | 84 | * Module load parameter definitions |
88 | */ | 85 | */ |
@@ -151,18 +148,15 @@ static int force_inquiry_hack; | |||
151 | module_param(force_inquiry_hack, int, 0444); | 148 | module_param(force_inquiry_hack, int, 0444); |
152 | MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); | 149 | MODULE_PARM_DESC(force_inquiry_hack, "Force SCSI inquiry hack (default = 0)"); |
153 | 150 | ||
154 | |||
155 | /* | 151 | /* |
156 | * Export information about protocols/devices supported by this driver. | 152 | * Export information about protocols/devices supported by this driver. |
157 | */ | 153 | */ |
158 | static struct ieee1394_device_id sbp2_id_table[] = { | 154 | static struct ieee1394_device_id sbp2_id_table[] = { |
159 | { | 155 | { |
160 | .match_flags =IEEE1394_MATCH_SPECIFIER_ID | | 156 | .match_flags = IEEE1394_MATCH_SPECIFIER_ID | IEEE1394_MATCH_VERSION, |
161 | IEEE1394_MATCH_VERSION, | 157 | .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, |
162 | .specifier_id = SBP2_UNIT_SPEC_ID_ENTRY & 0xffffff, | 158 | .version = SBP2_SW_VERSION_ENTRY & 0xffffff}, |
163 | .version = SBP2_SW_VERSION_ENTRY & 0xffffff | 159 | {} |
164 | }, | ||
165 | { } | ||
166 | }; | 160 | }; |
167 | 161 | ||
168 | MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); | 162 | MODULE_DEVICE_TABLE(ieee1394, sbp2_id_table); |
@@ -221,7 +215,6 @@ static u32 global_outstanding_dmas = 0; | |||
221 | 215 | ||
222 | #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) | 216 | #define SBP2_ERR(fmt, args...) HPSB_ERR("sbp2: "fmt, ## args) |
223 | 217 | ||
224 | |||
225 | /* | 218 | /* |
226 | * Globals | 219 | * Globals |
227 | */ | 220 | */ |
@@ -254,8 +247,8 @@ static struct hpsb_address_ops sbp2_ops = { | |||
254 | 247 | ||
255 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA | 248 | #ifdef CONFIG_IEEE1394_SBP2_PHYS_DMA |
256 | static struct hpsb_address_ops sbp2_physdma_ops = { | 249 | static struct hpsb_address_ops sbp2_physdma_ops = { |
257 | .read = sbp2_handle_physdma_read, | 250 | .read = sbp2_handle_physdma_read, |
258 | .write = sbp2_handle_physdma_write, | 251 | .write = sbp2_handle_physdma_write, |
259 | }; | 252 | }; |
260 | #endif | 253 | #endif |
261 | 254 | ||
@@ -287,7 +280,6 @@ static u32 sbp2_broken_inquiry_list[] = { | |||
287 | * General utility functions | 280 | * General utility functions |
288 | **************************************/ | 281 | **************************************/ |
289 | 282 | ||
290 | |||
291 | #ifndef __BIG_ENDIAN | 283 | #ifndef __BIG_ENDIAN |
292 | /* | 284 | /* |
293 | * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. | 285 | * Converts a buffer from be32 to cpu byte ordering. Length is in bytes. |
@@ -324,7 +316,8 @@ static __inline__ void sbp2util_cpu_to_be32_buffer(void *buffer, int length) | |||
324 | /* | 316 | /* |
325 | * Debug packet dump routine. Length is in bytes. | 317 | * Debug packet dump routine. Length is in bytes. |
326 | */ | 318 | */ |
327 | static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 dump_phys_addr) | 319 | static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, |
320 | u32 dump_phys_addr) | ||
328 | { | 321 | { |
329 | int i; | 322 | int i; |
330 | unsigned char *dump = buffer; | 323 | unsigned char *dump = buffer; |
@@ -345,7 +338,7 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, u32 | |||
345 | printk(" "); | 338 | printk(" "); |
346 | if ((i & 0xf) == 0) | 339 | if ((i & 0xf) == 0) |
347 | printk("\n "); | 340 | printk("\n "); |
348 | printk("%02x ", (int) dump[i]); | 341 | printk("%02x ", (int)dump[i]); |
349 | } | 342 | } |
350 | printk("\n"); | 343 | printk("\n"); |
351 | 344 | ||
@@ -364,9 +357,9 @@ static int sbp2util_down_timeout(atomic_t *done, int timeout) | |||
364 | 357 | ||
365 | for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { | 358 | for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { |
366 | if (msleep_interruptible(100)) /* 100ms */ | 359 | if (msleep_interruptible(100)) /* 100ms */ |
367 | return(1); | 360 | return 1; |
368 | } | 361 | } |
369 | return ((i > 0) ? 0:1); | 362 | return (i > 0) ? 0 : 1; |
370 | } | 363 | } |
371 | 364 | ||
372 | /* Free's an allocated packet */ | 365 | /* Free's an allocated packet */ |
@@ -380,21 +373,22 @@ static void sbp2_free_packet(struct hpsb_packet *packet) | |||
380 | * subaction and returns immediately. Can be used from interrupts. | 373 | * subaction and returns immediately. Can be used from interrupts. |
381 | */ | 374 | */ |
382 | static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, | 375 | static int sbp2util_node_write_no_wait(struct node_entry *ne, u64 addr, |
383 | quadlet_t *buffer, size_t length) | 376 | quadlet_t *buffer, size_t length) |
384 | { | 377 | { |
385 | struct hpsb_packet *packet; | 378 | struct hpsb_packet *packet; |
386 | 379 | ||
387 | packet = hpsb_make_writepacket(ne->host, ne->nodeid, | 380 | packet = hpsb_make_writepacket(ne->host, ne->nodeid, |
388 | addr, buffer, length); | 381 | addr, buffer, length); |
389 | if (!packet) | 382 | if (!packet) |
390 | return -ENOMEM; | 383 | return -ENOMEM; |
391 | 384 | ||
392 | hpsb_set_packet_complete_task(packet, (void (*)(void*))sbp2_free_packet, | 385 | hpsb_set_packet_complete_task(packet, |
386 | (void (*)(void *))sbp2_free_packet, | ||
393 | packet); | 387 | packet); |
394 | 388 | ||
395 | hpsb_node_fill_packet(ne, packet); | 389 | hpsb_node_fill_packet(ne, packet); |
396 | 390 | ||
397 | if (hpsb_send_packet(packet) < 0) { | 391 | if (hpsb_send_packet(packet) < 0) { |
398 | sbp2_free_packet(packet); | 392 | sbp2_free_packet(packet); |
399 | return -EIO; | 393 | return -EIO; |
400 | } | 394 | } |
@@ -417,22 +411,22 @@ static int sbp2util_create_command_orb_pool(struct scsi_id_instance_data *scsi_i | |||
417 | 411 | ||
418 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); | 412 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); |
419 | for (i = 0; i < orbs; i++) { | 413 | for (i = 0; i < orbs; i++) { |
420 | command = (struct sbp2_command_info *) | 414 | command = kzalloc(sizeof(*command), GFP_ATOMIC); |
421 | kmalloc(sizeof(struct sbp2_command_info), GFP_ATOMIC); | ||
422 | if (!command) { | 415 | if (!command) { |
423 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | 416 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, |
424 | return(-ENOMEM); | 417 | flags); |
418 | return -ENOMEM; | ||
425 | } | 419 | } |
426 | memset(command, '\0', sizeof(struct sbp2_command_info)); | ||
427 | command->command_orb_dma = | 420 | command->command_orb_dma = |
428 | pci_map_single (hi->host->pdev, &command->command_orb, | 421 | pci_map_single(hi->host->pdev, &command->command_orb, |
429 | sizeof(struct sbp2_command_orb), | 422 | sizeof(struct sbp2_command_orb), |
430 | PCI_DMA_BIDIRECTIONAL); | 423 | PCI_DMA_BIDIRECTIONAL); |
431 | SBP2_DMA_ALLOC("single command orb DMA"); | 424 | SBP2_DMA_ALLOC("single command orb DMA"); |
432 | command->sge_dma = | 425 | command->sge_dma = |
433 | pci_map_single (hi->host->pdev, &command->scatter_gather_element, | 426 | pci_map_single(hi->host->pdev, |
434 | sizeof(command->scatter_gather_element), | 427 | &command->scatter_gather_element, |
435 | PCI_DMA_BIDIRECTIONAL); | 428 | sizeof(command->scatter_gather_element), |
429 | PCI_DMA_BIDIRECTIONAL); | ||
436 | SBP2_DMA_ALLOC("scatter_gather_element"); | 430 | SBP2_DMA_ALLOC("scatter_gather_element"); |
437 | INIT_LIST_HEAD(&command->list); | 431 | INIT_LIST_HEAD(&command->list); |
438 | list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); | 432 | list_add_tail(&command->list, &scsi_id->sbp2_command_orb_completed); |
@@ -488,7 +482,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( | |||
488 | list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { | 482 | list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { |
489 | if (command->command_orb_dma == orb) { | 483 | if (command->command_orb_dma == orb) { |
490 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | 484 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); |
491 | return (command); | 485 | return command; |
492 | } | 486 | } |
493 | } | 487 | } |
494 | } | 488 | } |
@@ -496,7 +490,7 @@ static struct sbp2_command_info *sbp2util_find_command_for_orb( | |||
496 | 490 | ||
497 | SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); | 491 | SBP2_ORB_DEBUG("could not match command orb %x", (unsigned int)orb); |
498 | 492 | ||
499 | return(NULL); | 493 | return NULL; |
500 | } | 494 | } |
501 | 495 | ||
502 | /* | 496 | /* |
@@ -513,12 +507,12 @@ static struct sbp2_command_info *sbp2util_find_command_for_SCpnt(struct scsi_id_ | |||
513 | list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { | 507 | list_for_each_entry(command, &scsi_id->sbp2_command_orb_inuse, list) { |
514 | if (command->Current_SCpnt == SCpnt) { | 508 | if (command->Current_SCpnt == SCpnt) { |
515 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | 509 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); |
516 | return (command); | 510 | return command; |
517 | } | 511 | } |
518 | } | 512 | } |
519 | } | 513 | } |
520 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | 514 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); |
521 | return(NULL); | 515 | return NULL; |
522 | } | 516 | } |
523 | 517 | ||
524 | /* | 518 | /* |
@@ -545,7 +539,7 @@ static struct sbp2_command_info *sbp2util_allocate_command_orb( | |||
545 | SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); | 539 | SBP2_ERR("sbp2util_allocate_command_orb - No orbs available!"); |
546 | } | 540 | } |
547 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | 541 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); |
548 | return (command); | 542 | return command; |
549 | } | 543 | } |
550 | 544 | ||
551 | /* Free our DMA's */ | 545 | /* Free our DMA's */ |
@@ -587,7 +581,8 @@ static void sbp2util_free_command_dma(struct sbp2_command_info *command) | |||
587 | /* | 581 | /* |
588 | * This function moves a command to the completed orb list. | 582 | * This function moves a command to the completed orb list. |
589 | */ | 583 | */ |
590 | static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, struct sbp2_command_info *command) | 584 | static void sbp2util_mark_command_completed(struct scsi_id_instance_data *scsi_id, |
585 | struct sbp2_command_info *command) | ||
591 | { | 586 | { |
592 | unsigned long flags; | 587 | unsigned long flags; |
593 | 588 | ||
@@ -606,8 +601,6 @@ static inline int sbp2util_node_is_available(struct scsi_id_instance_data *scsi_ | |||
606 | return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; | 601 | return scsi_id && scsi_id->ne && !scsi_id->ne->in_limbo; |
607 | } | 602 | } |
608 | 603 | ||
609 | |||
610 | |||
611 | /********************************************* | 604 | /********************************************* |
612 | * IEEE-1394 core driver stack related section | 605 | * IEEE-1394 core driver stack related section |
613 | *********************************************/ | 606 | *********************************************/ |
@@ -627,14 +620,14 @@ static int sbp2_probe(struct device *dev) | |||
627 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) | 620 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN_DIRECTORY) |
628 | return -ENODEV; | 621 | return -ENODEV; |
629 | 622 | ||
630 | scsi_id = sbp2_alloc_device(ud); | 623 | scsi_id = sbp2_alloc_device(ud); |
631 | 624 | ||
632 | if (!scsi_id) | 625 | if (!scsi_id) |
633 | return -ENOMEM; | 626 | return -ENOMEM; |
634 | 627 | ||
635 | sbp2_parse_unit_directory(scsi_id, ud); | 628 | sbp2_parse_unit_directory(scsi_id, ud); |
636 | 629 | ||
637 | return sbp2_start_device(scsi_id); | 630 | return sbp2_start_device(scsi_id); |
638 | } | 631 | } |
639 | 632 | ||
640 | static int sbp2_remove(struct device *dev) | 633 | static int sbp2_remove(struct device *dev) |
@@ -719,12 +712,11 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
719 | 712 | ||
720 | SBP2_DEBUG("sbp2_alloc_device"); | 713 | SBP2_DEBUG("sbp2_alloc_device"); |
721 | 714 | ||
722 | scsi_id = kmalloc(sizeof(*scsi_id), GFP_KERNEL); | 715 | scsi_id = kzalloc(sizeof(*scsi_id), GFP_KERNEL); |
723 | if (!scsi_id) { | 716 | if (!scsi_id) { |
724 | SBP2_ERR("failed to create scsi_id"); | 717 | SBP2_ERR("failed to create scsi_id"); |
725 | goto failed_alloc; | 718 | goto failed_alloc; |
726 | } | 719 | } |
727 | memset(scsi_id, 0, sizeof(*scsi_id)); | ||
728 | 720 | ||
729 | scsi_id->ne = ud->ne; | 721 | scsi_id->ne = ud->ne; |
730 | scsi_id->ud = ud; | 722 | scsi_id->ud = ud; |
@@ -735,7 +727,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
735 | INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); | 727 | INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); |
736 | INIT_LIST_HEAD(&scsi_id->scsi_list); | 728 | INIT_LIST_HEAD(&scsi_id->scsi_list); |
737 | spin_lock_init(&scsi_id->sbp2_command_orb_lock); | 729 | spin_lock_init(&scsi_id->sbp2_command_orb_lock); |
738 | scsi_id->sbp2_device_type_and_lun = SBP2_DEVICE_TYPE_LUN_UNINITIALIZED; | 730 | scsi_id->sbp2_lun = 0; |
739 | 731 | ||
740 | ud->device.driver_data = scsi_id; | 732 | ud->device.driver_data = scsi_id; |
741 | 733 | ||
@@ -769,7 +761,7 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud | |||
769 | 761 | ||
770 | /* Register our host with the SCSI stack. */ | 762 | /* Register our host with the SCSI stack. */ |
771 | scsi_host = scsi_host_alloc(&scsi_driver_template, | 763 | scsi_host = scsi_host_alloc(&scsi_driver_template, |
772 | sizeof (unsigned long)); | 764 | sizeof(unsigned long)); |
773 | if (!scsi_host) { | 765 | if (!scsi_host) { |
774 | SBP2_ERR("failed to register scsi host"); | 766 | SBP2_ERR("failed to register scsi host"); |
775 | goto failed_alloc; | 767 | goto failed_alloc; |
@@ -790,7 +782,6 @@ failed_alloc: | |||
790 | return NULL; | 782 | return NULL; |
791 | } | 783 | } |
792 | 784 | ||
793 | |||
794 | static void sbp2_host_reset(struct hpsb_host *host) | 785 | static void sbp2_host_reset(struct hpsb_host *host) |
795 | { | 786 | { |
796 | struct sbp2scsi_host_info *hi; | 787 | struct sbp2scsi_host_info *hi; |
@@ -804,7 +795,6 @@ static void sbp2_host_reset(struct hpsb_host *host) | |||
804 | } | 795 | } |
805 | } | 796 | } |
806 | 797 | ||
807 | |||
808 | /* | 798 | /* |
809 | * This function is where we first pull the node unique ids, and then | 799 | * This function is where we first pull the node unique ids, and then |
810 | * allocate memory and register a SBP-2 device. | 800 | * allocate memory and register a SBP-2 device. |
@@ -818,7 +808,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
818 | 808 | ||
819 | /* Login FIFO DMA */ | 809 | /* Login FIFO DMA */ |
820 | scsi_id->login_response = | 810 | scsi_id->login_response = |
821 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_response), | 811 | pci_alloc_consistent(hi->host->pdev, |
812 | sizeof(struct sbp2_login_response), | ||
822 | &scsi_id->login_response_dma); | 813 | &scsi_id->login_response_dma); |
823 | if (!scsi_id->login_response) | 814 | if (!scsi_id->login_response) |
824 | goto alloc_fail; | 815 | goto alloc_fail; |
@@ -826,7 +817,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
826 | 817 | ||
827 | /* Query logins ORB DMA */ | 818 | /* Query logins ORB DMA */ |
828 | scsi_id->query_logins_orb = | 819 | scsi_id->query_logins_orb = |
829 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_orb), | 820 | pci_alloc_consistent(hi->host->pdev, |
821 | sizeof(struct sbp2_query_logins_orb), | ||
830 | &scsi_id->query_logins_orb_dma); | 822 | &scsi_id->query_logins_orb_dma); |
831 | if (!scsi_id->query_logins_orb) | 823 | if (!scsi_id->query_logins_orb) |
832 | goto alloc_fail; | 824 | goto alloc_fail; |
@@ -834,7 +826,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
834 | 826 | ||
835 | /* Query logins response DMA */ | 827 | /* Query logins response DMA */ |
836 | scsi_id->query_logins_response = | 828 | scsi_id->query_logins_response = |
837 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_query_logins_response), | 829 | pci_alloc_consistent(hi->host->pdev, |
830 | sizeof(struct sbp2_query_logins_response), | ||
838 | &scsi_id->query_logins_response_dma); | 831 | &scsi_id->query_logins_response_dma); |
839 | if (!scsi_id->query_logins_response) | 832 | if (!scsi_id->query_logins_response) |
840 | goto alloc_fail; | 833 | goto alloc_fail; |
@@ -842,7 +835,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
842 | 835 | ||
843 | /* Reconnect ORB DMA */ | 836 | /* Reconnect ORB DMA */ |
844 | scsi_id->reconnect_orb = | 837 | scsi_id->reconnect_orb = |
845 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_reconnect_orb), | 838 | pci_alloc_consistent(hi->host->pdev, |
839 | sizeof(struct sbp2_reconnect_orb), | ||
846 | &scsi_id->reconnect_orb_dma); | 840 | &scsi_id->reconnect_orb_dma); |
847 | if (!scsi_id->reconnect_orb) | 841 | if (!scsi_id->reconnect_orb) |
848 | goto alloc_fail; | 842 | goto alloc_fail; |
@@ -850,7 +844,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
850 | 844 | ||
851 | /* Logout ORB DMA */ | 845 | /* Logout ORB DMA */ |
852 | scsi_id->logout_orb = | 846 | scsi_id->logout_orb = |
853 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_logout_orb), | 847 | pci_alloc_consistent(hi->host->pdev, |
848 | sizeof(struct sbp2_logout_orb), | ||
854 | &scsi_id->logout_orb_dma); | 849 | &scsi_id->logout_orb_dma); |
855 | if (!scsi_id->logout_orb) | 850 | if (!scsi_id->logout_orb) |
856 | goto alloc_fail; | 851 | goto alloc_fail; |
@@ -858,7 +853,8 @@ static int sbp2_start_device(struct scsi_id_instance_data *scsi_id) | |||
858 | 853 | ||
859 | /* Login ORB DMA */ | 854 | /* Login ORB DMA */ |
860 | scsi_id->login_orb = | 855 | scsi_id->login_orb = |
861 | pci_alloc_consistent(hi->host->pdev, sizeof(struct sbp2_login_orb), | 856 | pci_alloc_consistent(hi->host->pdev, |
857 | sizeof(struct sbp2_login_orb), | ||
862 | &scsi_id->login_orb_dma); | 858 | &scsi_id->login_orb_dma); |
863 | if (!scsi_id->login_orb) { | 859 | if (!scsi_id->login_orb) { |
864 | alloc_fail: | 860 | alloc_fail: |
@@ -880,25 +876,25 @@ alloc_fail: | |||
880 | 876 | ||
881 | if (scsi_id->logout_orb) { | 877 | if (scsi_id->logout_orb) { |
882 | pci_free_consistent(hi->host->pdev, | 878 | pci_free_consistent(hi->host->pdev, |
883 | sizeof(struct sbp2_logout_orb), | 879 | sizeof(struct sbp2_logout_orb), |
884 | scsi_id->logout_orb, | 880 | scsi_id->logout_orb, |
885 | scsi_id->logout_orb_dma); | 881 | scsi_id->logout_orb_dma); |
886 | SBP2_DMA_FREE("logout ORB DMA"); | 882 | SBP2_DMA_FREE("logout ORB DMA"); |
887 | } | 883 | } |
888 | 884 | ||
889 | if (scsi_id->reconnect_orb) { | 885 | if (scsi_id->reconnect_orb) { |
890 | pci_free_consistent(hi->host->pdev, | 886 | pci_free_consistent(hi->host->pdev, |
891 | sizeof(struct sbp2_reconnect_orb), | 887 | sizeof(struct sbp2_reconnect_orb), |
892 | scsi_id->reconnect_orb, | 888 | scsi_id->reconnect_orb, |
893 | scsi_id->reconnect_orb_dma); | 889 | scsi_id->reconnect_orb_dma); |
894 | SBP2_DMA_FREE("reconnect ORB DMA"); | 890 | SBP2_DMA_FREE("reconnect ORB DMA"); |
895 | } | 891 | } |
896 | 892 | ||
897 | if (scsi_id->login_response) { | 893 | if (scsi_id->login_response) { |
898 | pci_free_consistent(hi->host->pdev, | 894 | pci_free_consistent(hi->host->pdev, |
899 | sizeof(struct sbp2_login_response), | 895 | sizeof(struct sbp2_login_response), |
900 | scsi_id->login_response, | 896 | scsi_id->login_response, |
901 | scsi_id->login_response_dma); | 897 | scsi_id->login_response_dma); |
902 | SBP2_DMA_FREE("login FIFO DMA"); | 898 | SBP2_DMA_FREE("login FIFO DMA"); |
903 | } | 899 | } |
904 | 900 | ||
@@ -906,7 +902,7 @@ alloc_fail: | |||
906 | 902 | ||
907 | kfree(scsi_id); | 903 | kfree(scsi_id); |
908 | 904 | ||
909 | SBP2_ERR ("Could not allocate memory for scsi_id"); | 905 | SBP2_ERR("Could not allocate memory for scsi_id"); |
910 | 906 | ||
911 | return -ENOMEM; | 907 | return -ENOMEM; |
912 | } | 908 | } |
@@ -935,7 +931,7 @@ alloc_fail: | |||
935 | sbp2_remove_device(scsi_id); | 931 | sbp2_remove_device(scsi_id); |
936 | return -EINTR; | 932 | return -EINTR; |
937 | } | 933 | } |
938 | 934 | ||
939 | /* | 935 | /* |
940 | * Login to the sbp-2 device | 936 | * Login to the sbp-2 device |
941 | */ | 937 | */ |
@@ -1054,51 +1050,44 @@ static void sbp2_remove_device(struct scsi_id_instance_data *scsi_id) | |||
1054 | * This function deals with physical dma write requests (for adapters that do not support | 1050 | * This function deals with physical dma write requests (for adapters that do not support |
1055 | * physical dma in hardware). Mostly just here for debugging... | 1051 | * physical dma in hardware). Mostly just here for debugging... |
1056 | */ | 1052 | */ |
1057 | static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, int destid, quadlet_t *data, | 1053 | static int sbp2_handle_physdma_write(struct hpsb_host *host, int nodeid, |
1058 | u64 addr, size_t length, u16 flags) | 1054 | int destid, quadlet_t *data, u64 addr, |
1055 | size_t length, u16 flags) | ||
1059 | { | 1056 | { |
1060 | 1057 | ||
1061 | /* | 1058 | /* |
1062 | * Manually put the data in the right place. | 1059 | * Manually put the data in the right place. |
1063 | */ | 1060 | */ |
1064 | memcpy(bus_to_virt((u32)addr), data, length); | 1061 | memcpy(bus_to_virt((u32) addr), data, length); |
1065 | sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", (u32)addr); | 1062 | sbp2util_packet_dump(data, length, "sbp2 phys dma write by device", |
1066 | return(RCODE_COMPLETE); | 1063 | (u32) addr); |
1064 | return RCODE_COMPLETE; | ||
1067 | } | 1065 | } |
1068 | 1066 | ||
1069 | /* | 1067 | /* |
1070 | * This function deals with physical dma read requests (for adapters that do not support | 1068 | * This function deals with physical dma read requests (for adapters that do not support |
1071 | * physical dma in hardware). Mostly just here for debugging... | 1069 | * physical dma in hardware). Mostly just here for debugging... |
1072 | */ | 1070 | */ |
1073 | static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, quadlet_t *data, | 1071 | static int sbp2_handle_physdma_read(struct hpsb_host *host, int nodeid, |
1074 | u64 addr, size_t length, u16 flags) | 1072 | quadlet_t *data, u64 addr, size_t length, |
1073 | u16 flags) | ||
1075 | { | 1074 | { |
1076 | 1075 | ||
1077 | /* | 1076 | /* |
1078 | * Grab data from memory and send a read response. | 1077 | * Grab data from memory and send a read response. |
1079 | */ | 1078 | */ |
1080 | memcpy(data, bus_to_virt((u32)addr), length); | 1079 | memcpy(data, bus_to_virt((u32) addr), length); |
1081 | sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", (u32)addr); | 1080 | sbp2util_packet_dump(data, length, "sbp2 phys dma read by device", |
1082 | return(RCODE_COMPLETE); | 1081 | (u32) addr); |
1082 | return RCODE_COMPLETE; | ||
1083 | } | 1083 | } |
1084 | #endif | 1084 | #endif |
1085 | 1085 | ||
1086 | |||
1087 | /************************************** | 1086 | /************************************** |
1088 | * SBP-2 protocol related section | 1087 | * SBP-2 protocol related section |
1089 | **************************************/ | 1088 | **************************************/ |
1090 | 1089 | ||
1091 | /* | 1090 | /* |
1092 | * This function determines if we should convert scsi commands for a particular sbp2 device type | ||
1093 | */ | ||
1094 | static __inline__ int sbp2_command_conversion_device_type(u8 device_type) | ||
1095 | { | ||
1096 | return (((device_type == TYPE_DISK) || | ||
1097 | (device_type == TYPE_RBC) || | ||
1098 | (device_type == TYPE_ROM)) ? 1:0); | ||
1099 | } | ||
1100 | |||
1101 | /* | ||
1102 | * This function queries the device for the maximum concurrent logins it | 1091 | * This function queries the device for the maximum concurrent logins it |
1103 | * supports. | 1092 | * supports. |
1104 | */ | 1093 | */ |
@@ -1120,11 +1109,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) | |||
1120 | 1109 | ||
1121 | scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); | 1110 | scsi_id->query_logins_orb->lun_misc = ORB_SET_FUNCTION(SBP2_QUERY_LOGINS_REQUEST); |
1122 | scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); | 1111 | scsi_id->query_logins_orb->lun_misc |= ORB_SET_NOTIFY(1); |
1123 | if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { | 1112 | scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); |
1124 | scsi_id->query_logins_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); | ||
1125 | SBP2_DEBUG("sbp2_query_logins: set lun to %d", | ||
1126 | ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun)); | ||
1127 | } | ||
1128 | SBP2_DEBUG("sbp2_query_logins: lun_misc initialized"); | 1113 | SBP2_DEBUG("sbp2_query_logins: lun_misc initialized"); |
1129 | 1114 | ||
1130 | scsi_id->query_logins_orb->reserved_resp_length = | 1115 | scsi_id->query_logins_orb->reserved_resp_length = |
@@ -1161,12 +1146,12 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) | |||
1161 | 1146 | ||
1162 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { | 1147 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { |
1163 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); | 1148 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); |
1164 | return(-EIO); | 1149 | return -EIO; |
1165 | } | 1150 | } |
1166 | 1151 | ||
1167 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { | 1152 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->query_logins_orb_dma) { |
1168 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); | 1153 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); |
1169 | return(-EIO); | 1154 | return -EIO; |
1170 | } | 1155 | } |
1171 | 1156 | ||
1172 | if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || | 1157 | if (STATUS_GET_RESP(scsi_id->status_block.ORB_offset_hi_misc) || |
@@ -1174,7 +1159,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) | |||
1174 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { | 1159 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { |
1175 | 1160 | ||
1176 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); | 1161 | SBP2_INFO("Error querying logins to SBP-2 device - timed out"); |
1177 | return(-EIO); | 1162 | return -EIO; |
1178 | } | 1163 | } |
1179 | 1164 | ||
1180 | sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); | 1165 | sbp2util_cpu_to_be32_buffer(scsi_id->query_logins_response, sizeof(struct sbp2_query_logins_response)); |
@@ -1191,7 +1176,7 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) | |||
1191 | SBP2_DEBUG("Number of active logins: %d", active_logins); | 1176 | SBP2_DEBUG("Number of active logins: %d", active_logins); |
1192 | 1177 | ||
1193 | if (active_logins >= max_logins) { | 1178 | if (active_logins >= max_logins) { |
1194 | return(-EIO); | 1179 | return -EIO; |
1195 | } | 1180 | } |
1196 | 1181 | ||
1197 | return 0; | 1182 | return 0; |
@@ -1210,13 +1195,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1210 | 1195 | ||
1211 | if (!scsi_id->login_orb) { | 1196 | if (!scsi_id->login_orb) { |
1212 | SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); | 1197 | SBP2_DEBUG("sbp2_login_device: login_orb not alloc'd!"); |
1213 | return(-EIO); | 1198 | return -EIO; |
1214 | } | 1199 | } |
1215 | 1200 | ||
1216 | if (!exclusive_login) { | 1201 | if (!exclusive_login) { |
1217 | if (sbp2_query_logins(scsi_id)) { | 1202 | if (sbp2_query_logins(scsi_id)) { |
1218 | SBP2_INFO("Device does not support any more concurrent logins"); | 1203 | SBP2_INFO("Device does not support any more concurrent logins"); |
1219 | return(-EIO); | 1204 | return -EIO; |
1220 | } | 1205 | } |
1221 | } | 1206 | } |
1222 | 1207 | ||
@@ -1233,12 +1218,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1233 | scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ | 1218 | scsi_id->login_orb->lun_misc |= ORB_SET_RECONNECT(0); /* One second reconnect time */ |
1234 | scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ | 1219 | scsi_id->login_orb->lun_misc |= ORB_SET_EXCLUSIVE(exclusive_login); /* Exclusive access to device */ |
1235 | scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ | 1220 | scsi_id->login_orb->lun_misc |= ORB_SET_NOTIFY(1); /* Notify us of login complete */ |
1236 | /* Set the lun if we were able to pull it from the device's unit directory */ | 1221 | scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_lun); |
1237 | if (scsi_id->sbp2_device_type_and_lun != SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { | ||
1238 | scsi_id->login_orb->lun_misc |= ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); | ||
1239 | SBP2_DEBUG("sbp2_query_logins: set lun to %d", | ||
1240 | ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun)); | ||
1241 | } | ||
1242 | SBP2_DEBUG("sbp2_login_device: lun_misc initialized"); | 1222 | SBP2_DEBUG("sbp2_login_device: lun_misc initialized"); |
1243 | 1223 | ||
1244 | scsi_id->login_orb->passwd_resp_lengths = | 1224 | scsi_id->login_orb->passwd_resp_lengths = |
@@ -1288,7 +1268,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1288 | */ | 1268 | */ |
1289 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { | 1269 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { |
1290 | SBP2_ERR("Error logging into SBP-2 device - login timed-out"); | 1270 | SBP2_ERR("Error logging into SBP-2 device - login timed-out"); |
1291 | return(-EIO); | 1271 | return -EIO; |
1292 | } | 1272 | } |
1293 | 1273 | ||
1294 | /* | 1274 | /* |
@@ -1296,7 +1276,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1296 | */ | 1276 | */ |
1297 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { | 1277 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->login_orb_dma) { |
1298 | SBP2_ERR("Error logging into SBP-2 device - login timed-out"); | 1278 | SBP2_ERR("Error logging into SBP-2 device - login timed-out"); |
1299 | return(-EIO); | 1279 | return -EIO; |
1300 | } | 1280 | } |
1301 | 1281 | ||
1302 | /* | 1282 | /* |
@@ -1307,7 +1287,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1307 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { | 1287 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { |
1308 | 1288 | ||
1309 | SBP2_ERR("Error logging into SBP-2 device - login failed"); | 1289 | SBP2_ERR("Error logging into SBP-2 device - login failed"); |
1310 | return(-EIO); | 1290 | return -EIO; |
1311 | } | 1291 | } |
1312 | 1292 | ||
1313 | /* | 1293 | /* |
@@ -1331,7 +1311,7 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) | |||
1331 | 1311 | ||
1332 | SBP2_INFO("Logged into SBP-2 device"); | 1312 | SBP2_INFO("Logged into SBP-2 device"); |
1333 | 1313 | ||
1334 | return(0); | 1314 | return 0; |
1335 | 1315 | ||
1336 | } | 1316 | } |
1337 | 1317 | ||
@@ -1385,8 +1365,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) | |||
1385 | atomic_set(&scsi_id->sbp2_login_complete, 0); | 1365 | atomic_set(&scsi_id->sbp2_login_complete, 0); |
1386 | 1366 | ||
1387 | error = hpsb_node_write(scsi_id->ne, | 1367 | error = hpsb_node_write(scsi_id->ne, |
1388 | scsi_id->sbp2_management_agent_addr, | 1368 | scsi_id->sbp2_management_agent_addr, data, 8); |
1389 | data, 8); | ||
1390 | if (error) | 1369 | if (error) |
1391 | return error; | 1370 | return error; |
1392 | 1371 | ||
@@ -1396,7 +1375,7 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) | |||
1396 | 1375 | ||
1397 | SBP2_INFO("Logged out of SBP-2 device"); | 1376 | SBP2_INFO("Logged out of SBP-2 device"); |
1398 | 1377 | ||
1399 | return(0); | 1378 | return 0; |
1400 | 1379 | ||
1401 | } | 1380 | } |
1402 | 1381 | ||
@@ -1456,8 +1435,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) | |||
1456 | atomic_set(&scsi_id->sbp2_login_complete, 0); | 1435 | atomic_set(&scsi_id->sbp2_login_complete, 0); |
1457 | 1436 | ||
1458 | error = hpsb_node_write(scsi_id->ne, | 1437 | error = hpsb_node_write(scsi_id->ne, |
1459 | scsi_id->sbp2_management_agent_addr, | 1438 | scsi_id->sbp2_management_agent_addr, data, 8); |
1460 | data, 8); | ||
1461 | if (error) | 1439 | if (error) |
1462 | return error; | 1440 | return error; |
1463 | 1441 | ||
@@ -1466,7 +1444,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) | |||
1466 | */ | 1444 | */ |
1467 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { | 1445 | if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { |
1468 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); | 1446 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); |
1469 | return(-EIO); | 1447 | return -EIO; |
1470 | } | 1448 | } |
1471 | 1449 | ||
1472 | /* | 1450 | /* |
@@ -1474,7 +1452,7 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) | |||
1474 | */ | 1452 | */ |
1475 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { | 1453 | if (scsi_id->status_block.ORB_offset_lo != scsi_id->reconnect_orb_dma) { |
1476 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); | 1454 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); |
1477 | return(-EIO); | 1455 | return -EIO; |
1478 | } | 1456 | } |
1479 | 1457 | ||
1480 | /* | 1458 | /* |
@@ -1485,12 +1463,12 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) | |||
1485 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { | 1463 | STATUS_GET_SBP_STATUS(scsi_id->status_block.ORB_offset_hi_misc)) { |
1486 | 1464 | ||
1487 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); | 1465 | SBP2_ERR("Error reconnecting to SBP-2 device - reconnect failed"); |
1488 | return(-EIO); | 1466 | return -EIO; |
1489 | } | 1467 | } |
1490 | 1468 | ||
1491 | HPSB_DEBUG("Reconnected to SBP-2 device"); | 1469 | HPSB_DEBUG("Reconnected to SBP-2 device"); |
1492 | 1470 | ||
1493 | return(0); | 1471 | return 0; |
1494 | 1472 | ||
1495 | } | 1473 | } |
1496 | 1474 | ||
@@ -1513,10 +1491,9 @@ static int sbp2_set_busy_timeout(struct scsi_id_instance_data *scsi_id) | |||
1513 | SBP2_ERR("sbp2_set_busy_timeout error"); | 1491 | SBP2_ERR("sbp2_set_busy_timeout error"); |
1514 | } | 1492 | } |
1515 | 1493 | ||
1516 | return(0); | 1494 | return 0; |
1517 | } | 1495 | } |
1518 | 1496 | ||
1519 | |||
1520 | /* | 1497 | /* |
1521 | * This function is called to parse sbp2 device's config rom unit | 1498 | * This function is called to parse sbp2 device's config rom unit |
1522 | * directory. Used to determine things like sbp2 management agent offset, | 1499 | * directory. Used to determine things like sbp2 management agent offset, |
@@ -1529,7 +1506,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1529 | struct csr1212_dentry *dentry; | 1506 | struct csr1212_dentry *dentry; |
1530 | u64 management_agent_addr; | 1507 | u64 management_agent_addr; |
1531 | u32 command_set_spec_id, command_set, unit_characteristics, | 1508 | u32 command_set_spec_id, command_set, unit_characteristics, |
1532 | firmware_revision, workarounds; | 1509 | firmware_revision, workarounds; |
1533 | int i; | 1510 | int i; |
1534 | 1511 | ||
1535 | SBP2_DEBUG("sbp2_parse_unit_directory"); | 1512 | SBP2_DEBUG("sbp2_parse_unit_directory"); |
@@ -1547,13 +1524,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1547 | if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { | 1524 | if (kv->key.type == CSR1212_KV_TYPE_CSR_OFFSET) { |
1548 | /* Save off the management agent address */ | 1525 | /* Save off the management agent address */ |
1549 | management_agent_addr = | 1526 | management_agent_addr = |
1550 | CSR1212_REGISTER_SPACE_BASE + | 1527 | CSR1212_REGISTER_SPACE_BASE + |
1551 | (kv->value.csr_offset << 2); | 1528 | (kv->value.csr_offset << 2); |
1552 | 1529 | ||
1553 | SBP2_DEBUG("sbp2_management_agent_addr = %x", | 1530 | SBP2_DEBUG("sbp2_management_agent_addr = %x", |
1554 | (unsigned int) management_agent_addr); | 1531 | (unsigned int)management_agent_addr); |
1555 | } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { | 1532 | } else if (kv->key.type == CSR1212_KV_TYPE_IMMEDIATE) { |
1556 | scsi_id->sbp2_device_type_and_lun = kv->value.immediate; | 1533 | scsi_id->sbp2_lun = |
1534 | ORB_SET_LUN(kv->value.immediate); | ||
1557 | } | 1535 | } |
1558 | break; | 1536 | break; |
1559 | 1537 | ||
@@ -1561,14 +1539,14 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1561 | /* Command spec organization */ | 1539 | /* Command spec organization */ |
1562 | command_set_spec_id = kv->value.immediate; | 1540 | command_set_spec_id = kv->value.immediate; |
1563 | SBP2_DEBUG("sbp2_command_set_spec_id = %x", | 1541 | SBP2_DEBUG("sbp2_command_set_spec_id = %x", |
1564 | (unsigned int) command_set_spec_id); | 1542 | (unsigned int)command_set_spec_id); |
1565 | break; | 1543 | break; |
1566 | 1544 | ||
1567 | case SBP2_COMMAND_SET_KEY: | 1545 | case SBP2_COMMAND_SET_KEY: |
1568 | /* Command set used by sbp2 device */ | 1546 | /* Command set used by sbp2 device */ |
1569 | command_set = kv->value.immediate; | 1547 | command_set = kv->value.immediate; |
1570 | SBP2_DEBUG("sbp2_command_set = %x", | 1548 | SBP2_DEBUG("sbp2_command_set = %x", |
1571 | (unsigned int) command_set); | 1549 | (unsigned int)command_set); |
1572 | break; | 1550 | break; |
1573 | 1551 | ||
1574 | case SBP2_UNIT_CHARACTERISTICS_KEY: | 1552 | case SBP2_UNIT_CHARACTERISTICS_KEY: |
@@ -1578,7 +1556,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1578 | */ | 1556 | */ |
1579 | unit_characteristics = kv->value.immediate; | 1557 | unit_characteristics = kv->value.immediate; |
1580 | SBP2_DEBUG("sbp2_unit_characteristics = %x", | 1558 | SBP2_DEBUG("sbp2_unit_characteristics = %x", |
1581 | (unsigned int) unit_characteristics); | 1559 | (unsigned int)unit_characteristics); |
1582 | break; | 1560 | break; |
1583 | 1561 | ||
1584 | case SBP2_FIRMWARE_REVISION_KEY: | 1562 | case SBP2_FIRMWARE_REVISION_KEY: |
@@ -1586,9 +1564,10 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1586 | firmware_revision = kv->value.immediate; | 1564 | firmware_revision = kv->value.immediate; |
1587 | if (force_inquiry_hack) | 1565 | if (force_inquiry_hack) |
1588 | SBP2_INFO("sbp2_firmware_revision = %x", | 1566 | SBP2_INFO("sbp2_firmware_revision = %x", |
1589 | (unsigned int) firmware_revision); | 1567 | (unsigned int)firmware_revision); |
1590 | else SBP2_DEBUG("sbp2_firmware_revision = %x", | 1568 | else |
1591 | (unsigned int) firmware_revision); | 1569 | SBP2_DEBUG("sbp2_firmware_revision = %x", |
1570 | (unsigned int)firmware_revision); | ||
1592 | break; | 1571 | break; |
1593 | 1572 | ||
1594 | default: | 1573 | default: |
@@ -1646,7 +1625,7 @@ static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | |||
1646 | scsi_id->sbp2_firmware_revision = firmware_revision; | 1625 | scsi_id->sbp2_firmware_revision = firmware_revision; |
1647 | scsi_id->workarounds = workarounds; | 1626 | scsi_id->workarounds = workarounds; |
1648 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) | 1627 | if (ud->flags & UNIT_DIRECTORY_HAS_LUN) |
1649 | scsi_id->sbp2_device_type_and_lun = ud->lun; | 1628 | scsi_id->sbp2_lun = ORB_SET_LUN(ud->lun); |
1650 | } | 1629 | } |
1651 | } | 1630 | } |
1652 | 1631 | ||
@@ -1666,8 +1645,9 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) | |||
1666 | SBP2_DEBUG("sbp2_max_speed_and_size"); | 1645 | SBP2_DEBUG("sbp2_max_speed_and_size"); |
1667 | 1646 | ||
1668 | /* Initial setting comes from the hosts speed map */ | 1647 | /* Initial setting comes from the hosts speed map */ |
1669 | scsi_id->speed_code = hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 | 1648 | scsi_id->speed_code = |
1670 | + NODEID_TO_NODE(scsi_id->ne->nodeid)]; | 1649 | hi->host->speed_map[NODEID_TO_NODE(hi->host->node_id) * 64 + |
1650 | NODEID_TO_NODE(scsi_id->ne->nodeid)]; | ||
1671 | 1651 | ||
1672 | /* Bump down our speed if the user requested it */ | 1652 | /* Bump down our speed if the user requested it */ |
1673 | if (scsi_id->speed_code > max_speed) { | 1653 | if (scsi_id->speed_code > max_speed) { |
@@ -1678,15 +1658,16 @@ static int sbp2_max_speed_and_size(struct scsi_id_instance_data *scsi_id) | |||
1678 | 1658 | ||
1679 | /* Payload size is the lesser of what our speed supports and what | 1659 | /* Payload size is the lesser of what our speed supports and what |
1680 | * our host supports. */ | 1660 | * our host supports. */ |
1681 | scsi_id->max_payload_size = min(sbp2_speedto_max_payload[scsi_id->speed_code], | 1661 | scsi_id->max_payload_size = |
1682 | (u8)(hi->host->csr.max_rec - 1)); | 1662 | min(sbp2_speedto_max_payload[scsi_id->speed_code], |
1663 | (u8) (hi->host->csr.max_rec - 1)); | ||
1683 | 1664 | ||
1684 | HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", | 1665 | HPSB_DEBUG("Node " NODE_BUS_FMT ": Max speed [%s] - Max payload [%u]", |
1685 | NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), | 1666 | NODE_BUS_ARGS(hi->host, scsi_id->ne->nodeid), |
1686 | hpsb_speedto_str[scsi_id->speed_code], | 1667 | hpsb_speedto_str[scsi_id->speed_code], |
1687 | 1 << ((u32)scsi_id->max_payload_size + 2)); | 1668 | 1 << ((u32) scsi_id->max_payload_size + 2)); |
1688 | 1669 | ||
1689 | return(0); | 1670 | return 0; |
1690 | } | 1671 | } |
1691 | 1672 | ||
1692 | /* | 1673 | /* |
@@ -1721,7 +1702,7 @@ static int sbp2_agent_reset(struct scsi_id_instance_data *scsi_id, int wait) | |||
1721 | */ | 1702 | */ |
1722 | scsi_id->last_orb = NULL; | 1703 | scsi_id->last_orb = NULL; |
1723 | 1704 | ||
1724 | return(0); | 1705 | return 0; |
1725 | } | 1706 | } |
1726 | 1707 | ||
1727 | /* | 1708 | /* |
@@ -1735,10 +1716,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, | |||
1735 | unsigned int scsi_request_bufflen, | 1716 | unsigned int scsi_request_bufflen, |
1736 | void *scsi_request_buffer, | 1717 | void *scsi_request_buffer, |
1737 | enum dma_data_direction dma_dir) | 1718 | enum dma_data_direction dma_dir) |
1738 | |||
1739 | { | 1719 | { |
1740 | struct sbp2scsi_host_info *hi = scsi_id->hi; | 1720 | struct sbp2scsi_host_info *hi = scsi_id->hi; |
1741 | struct scatterlist *sgpnt = (struct scatterlist *) scsi_request_buffer; | 1721 | struct scatterlist *sgpnt = (struct scatterlist *)scsi_request_buffer; |
1742 | struct sbp2_command_orb *command_orb = &command->command_orb; | 1722 | struct sbp2_command_orb *command_orb = &command->command_orb; |
1743 | struct sbp2_unrestricted_page_table *scatter_gather_element = | 1723 | struct sbp2_unrestricted_page_table *scatter_gather_element = |
1744 | &command->scatter_gather_element[0]; | 1724 | &command->scatter_gather_element[0]; |
@@ -1758,30 +1738,30 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, | |||
1758 | command_orb->next_ORB_lo = 0x0; | 1738 | command_orb->next_ORB_lo = 0x0; |
1759 | command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); | 1739 | command_orb->misc = ORB_SET_MAX_PAYLOAD(scsi_id->max_payload_size); |
1760 | command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); | 1740 | command_orb->misc |= ORB_SET_SPEED(scsi_id->speed_code); |
1761 | command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ | 1741 | command_orb->misc |= ORB_SET_NOTIFY(1); /* Notify us when complete */ |
1762 | 1742 | ||
1763 | /* | 1743 | /* |
1764 | * Get the direction of the transfer. If the direction is unknown, then use our | 1744 | * Get the direction of the transfer. If the direction is unknown, then use our |
1765 | * goofy table as a back-up. | 1745 | * goofy table as a back-up. |
1766 | */ | 1746 | */ |
1767 | switch (dma_dir) { | 1747 | switch (dma_dir) { |
1768 | case DMA_NONE: | 1748 | case DMA_NONE: |
1769 | orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; | 1749 | orb_direction = ORB_DIRECTION_NO_DATA_TRANSFER; |
1770 | break; | 1750 | break; |
1771 | case DMA_TO_DEVICE: | 1751 | case DMA_TO_DEVICE: |
1772 | orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; | 1752 | orb_direction = ORB_DIRECTION_WRITE_TO_MEDIA; |
1773 | break; | 1753 | break; |
1774 | case DMA_FROM_DEVICE: | 1754 | case DMA_FROM_DEVICE: |
1775 | orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; | 1755 | orb_direction = ORB_DIRECTION_READ_FROM_MEDIA; |
1776 | break; | 1756 | break; |
1777 | case DMA_BIDIRECTIONAL: | 1757 | case DMA_BIDIRECTIONAL: |
1778 | default: | 1758 | default: |
1779 | SBP2_ERR("SCSI data transfer direction not specified. " | 1759 | SBP2_ERR("SCSI data transfer direction not specified. " |
1780 | "Update the SBP2 direction table in sbp2.h if " | 1760 | "Update the SBP2 direction table in sbp2.h if " |
1781 | "necessary for your application"); | 1761 | "necessary for your application"); |
1782 | __scsi_print_command(scsi_cmd); | 1762 | __scsi_print_command(scsi_cmd); |
1783 | orb_direction = sbp2scsi_direction_table[*scsi_cmd]; | 1763 | orb_direction = sbp2scsi_direction_table[*scsi_cmd]; |
1784 | break; | 1764 | break; |
1785 | } | 1765 | } |
1786 | 1766 | ||
1787 | /* | 1767 | /* |
@@ -1884,9 +1864,9 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, | |||
1884 | command->dma_dir = dma_dir; | 1864 | command->dma_dir = dma_dir; |
1885 | command->dma_size = scsi_request_bufflen; | 1865 | command->dma_size = scsi_request_bufflen; |
1886 | command->dma_type = CMD_DMA_SINGLE; | 1866 | command->dma_type = CMD_DMA_SINGLE; |
1887 | command->cmd_dma = pci_map_single (hi->host->pdev, scsi_request_buffer, | 1867 | command->cmd_dma = |
1888 | command->dma_size, | 1868 | pci_map_single(hi->host->pdev, scsi_request_buffer, |
1889 | command->dma_dir); | 1869 | command->dma_size, command->dma_dir); |
1890 | SBP2_DMA_ALLOC("single bulk"); | 1870 | SBP2_DMA_ALLOC("single bulk"); |
1891 | 1871 | ||
1892 | /* | 1872 | /* |
@@ -1973,7 +1953,7 @@ static int sbp2_create_command_orb(struct scsi_id_instance_data *scsi_id, | |||
1973 | memset(command_orb->cdb, 0, 12); | 1953 | memset(command_orb->cdb, 0, 12); |
1974 | memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); | 1954 | memcpy(command_orb->cdb, scsi_cmd, COMMAND_SIZE(*scsi_cmd)); |
1975 | 1955 | ||
1976 | return(0); | 1956 | return 0; |
1977 | } | 1957 | } |
1978 | 1958 | ||
1979 | /* | 1959 | /* |
@@ -1989,7 +1969,7 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, | |||
1989 | 1969 | ||
1990 | outstanding_orb_incr; | 1970 | outstanding_orb_incr; |
1991 | SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", | 1971 | SBP2_ORB_DEBUG("sending command orb %p, total orbs = %x", |
1992 | command_orb, global_outstanding_command_orbs); | 1972 | command_orb, global_outstanding_command_orbs); |
1993 | 1973 | ||
1994 | pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, | 1974 | pci_dma_sync_single_for_device(hi->host->pdev, command->command_orb_dma, |
1995 | sizeof(struct sbp2_command_orb), | 1975 | sizeof(struct sbp2_command_orb), |
@@ -2034,10 +2014,11 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, | |||
2034 | * both by the sbp2 device and us. | 2014 | * both by the sbp2 device and us. |
2035 | */ | 2015 | */ |
2036 | scsi_id->last_orb->next_ORB_lo = | 2016 | scsi_id->last_orb->next_ORB_lo = |
2037 | cpu_to_be32(command->command_orb_dma); | 2017 | cpu_to_be32(command->command_orb_dma); |
2038 | /* Tells hardware that this pointer is valid */ | 2018 | /* Tells hardware that this pointer is valid */ |
2039 | scsi_id->last_orb->next_ORB_hi = 0x0; | 2019 | scsi_id->last_orb->next_ORB_hi = 0x0; |
2040 | pci_dma_sync_single_for_device(hi->host->pdev, scsi_id->last_orb_dma, | 2020 | pci_dma_sync_single_for_device(hi->host->pdev, |
2021 | scsi_id->last_orb_dma, | ||
2041 | sizeof(struct sbp2_command_orb), | 2022 | sizeof(struct sbp2_command_orb), |
2042 | PCI_DMA_BIDIRECTIONAL); | 2023 | PCI_DMA_BIDIRECTIONAL); |
2043 | 2024 | ||
@@ -2051,14 +2032,14 @@ static int sbp2_link_orb_command(struct scsi_id_instance_data *scsi_id, | |||
2051 | 2032 | ||
2052 | if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { | 2033 | if (sbp2util_node_write_no_wait(ne, addr, &data, 4) < 0) { |
2053 | SBP2_ERR("sbp2util_node_write_no_wait failed"); | 2034 | SBP2_ERR("sbp2util_node_write_no_wait failed"); |
2054 | return(-EIO); | 2035 | return -EIO; |
2055 | } | 2036 | } |
2056 | 2037 | ||
2057 | scsi_id->last_orb = command_orb; | 2038 | scsi_id->last_orb = command_orb; |
2058 | scsi_id->last_orb_dma = command->command_orb_dma; | 2039 | scsi_id->last_orb_dma = command->command_orb_dma; |
2059 | 2040 | ||
2060 | } | 2041 | } |
2061 | return(0); | 2042 | return 0; |
2062 | } | 2043 | } |
2063 | 2044 | ||
2064 | /* | 2045 | /* |
@@ -2085,7 +2066,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, | |||
2085 | */ | 2066 | */ |
2086 | command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); | 2067 | command = sbp2util_allocate_command_orb(scsi_id, SCpnt, done); |
2087 | if (!command) { | 2068 | if (!command) { |
2088 | return(-EIO); | 2069 | return -EIO; |
2089 | } | 2070 | } |
2090 | 2071 | ||
2091 | /* | 2072 | /* |
@@ -2106,11 +2087,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, | |||
2106 | sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, | 2087 | sbp2_create_command_orb(scsi_id, command, cmd, SCpnt->use_sg, |
2107 | request_bufflen, SCpnt->request_buffer, | 2088 | request_bufflen, SCpnt->request_buffer, |
2108 | SCpnt->sc_data_direction); | 2089 | SCpnt->sc_data_direction); |
2109 | /* | ||
2110 | * Update our cdb if necessary (to handle sbp2 RBC command set | ||
2111 | * differences). This is where the command set hacks go! =) | ||
2112 | */ | ||
2113 | sbp2_check_sbp2_command(scsi_id, command->command_orb.cdb); | ||
2114 | 2090 | ||
2115 | sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb), | 2091 | sbp2util_packet_dump(&command->command_orb, sizeof(struct sbp2_command_orb), |
2116 | "sbp2 command orb", command->command_orb_dma); | 2092 | "sbp2 command orb", command->command_orb_dma); |
@@ -2125,112 +2101,7 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, | |||
2125 | */ | 2101 | */ |
2126 | sbp2_link_orb_command(scsi_id, command); | 2102 | sbp2_link_orb_command(scsi_id, command); |
2127 | 2103 | ||
2128 | return(0); | 2104 | return 0; |
2129 | } | ||
2130 | |||
2131 | |||
2132 | /* | ||
2133 | * This function deals with command set differences between Linux scsi | ||
2134 | * command set and sbp2 RBC command set. | ||
2135 | */ | ||
2136 | static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd) | ||
2137 | { | ||
2138 | unchar new_cmd[16]; | ||
2139 | u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); | ||
2140 | |||
2141 | SBP2_DEBUG("sbp2_check_sbp2_command"); | ||
2142 | |||
2143 | switch (*cmd) { | ||
2144 | |||
2145 | case READ_6: | ||
2146 | |||
2147 | if (sbp2_command_conversion_device_type(device_type)) { | ||
2148 | |||
2149 | SBP2_DEBUG("Convert READ_6 to READ_10"); | ||
2150 | |||
2151 | /* | ||
2152 | * Need to turn read_6 into read_10 | ||
2153 | */ | ||
2154 | new_cmd[0] = 0x28; | ||
2155 | new_cmd[1] = (cmd[1] & 0xe0); | ||
2156 | new_cmd[2] = 0x0; | ||
2157 | new_cmd[3] = (cmd[1] & 0x1f); | ||
2158 | new_cmd[4] = cmd[2]; | ||
2159 | new_cmd[5] = cmd[3]; | ||
2160 | new_cmd[6] = 0x0; | ||
2161 | new_cmd[7] = 0x0; | ||
2162 | new_cmd[8] = cmd[4]; | ||
2163 | new_cmd[9] = cmd[5]; | ||
2164 | |||
2165 | memcpy(cmd, new_cmd, 10); | ||
2166 | |||
2167 | } | ||
2168 | |||
2169 | break; | ||
2170 | |||
2171 | case WRITE_6: | ||
2172 | |||
2173 | if (sbp2_command_conversion_device_type(device_type)) { | ||
2174 | |||
2175 | SBP2_DEBUG("Convert WRITE_6 to WRITE_10"); | ||
2176 | |||
2177 | /* | ||
2178 | * Need to turn write_6 into write_10 | ||
2179 | */ | ||
2180 | new_cmd[0] = 0x2a; | ||
2181 | new_cmd[1] = (cmd[1] & 0xe0); | ||
2182 | new_cmd[2] = 0x0; | ||
2183 | new_cmd[3] = (cmd[1] & 0x1f); | ||
2184 | new_cmd[4] = cmd[2]; | ||
2185 | new_cmd[5] = cmd[3]; | ||
2186 | new_cmd[6] = 0x0; | ||
2187 | new_cmd[7] = 0x0; | ||
2188 | new_cmd[8] = cmd[4]; | ||
2189 | new_cmd[9] = cmd[5]; | ||
2190 | |||
2191 | memcpy(cmd, new_cmd, 10); | ||
2192 | |||
2193 | } | ||
2194 | |||
2195 | break; | ||
2196 | |||
2197 | case MODE_SENSE: | ||
2198 | |||
2199 | if (sbp2_command_conversion_device_type(device_type)) { | ||
2200 | |||
2201 | SBP2_DEBUG("Convert MODE_SENSE_6 to MODE_SENSE_10"); | ||
2202 | |||
2203 | /* | ||
2204 | * Need to turn mode_sense_6 into mode_sense_10 | ||
2205 | */ | ||
2206 | new_cmd[0] = 0x5a; | ||
2207 | new_cmd[1] = cmd[1]; | ||
2208 | new_cmd[2] = cmd[2]; | ||
2209 | new_cmd[3] = 0x0; | ||
2210 | new_cmd[4] = 0x0; | ||
2211 | new_cmd[5] = 0x0; | ||
2212 | new_cmd[6] = 0x0; | ||
2213 | new_cmd[7] = 0x0; | ||
2214 | new_cmd[8] = cmd[4]; | ||
2215 | new_cmd[9] = cmd[5]; | ||
2216 | |||
2217 | memcpy(cmd, new_cmd, 10); | ||
2218 | |||
2219 | } | ||
2220 | |||
2221 | break; | ||
2222 | |||
2223 | case MODE_SELECT: | ||
2224 | |||
2225 | /* | ||
2226 | * TODO. Probably need to change mode select to 10 byte version | ||
2227 | */ | ||
2228 | |||
2229 | default: | ||
2230 | break; | ||
2231 | } | ||
2232 | |||
2233 | return; | ||
2234 | } | 2105 | } |
2235 | 2106 | ||
2236 | /* | 2107 | /* |
@@ -2260,80 +2131,40 @@ static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense | |||
2260 | sense_data[14] = sbp2_status[20]; | 2131 | sense_data[14] = sbp2_status[20]; |
2261 | sense_data[15] = sbp2_status[21]; | 2132 | sense_data[15] = sbp2_status[21]; |
2262 | 2133 | ||
2263 | return(sbp2_status[8] & 0x3f); /* return scsi status */ | 2134 | return sbp2_status[8] & 0x3f; /* return scsi status */ |
2264 | } | 2135 | } |
2265 | 2136 | ||
2266 | /* | 2137 | /* |
2267 | * This function is called after a command is completed, in order to do any necessary SBP-2 | 2138 | * This function is called after a command is completed, in order to do any necessary SBP-2 |
2268 | * response data translations for the SCSI stack | 2139 | * response data translations for the SCSI stack |
2269 | */ | 2140 | */ |
2270 | static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, | 2141 | static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, |
2271 | struct scsi_cmnd *SCpnt) | 2142 | struct scsi_cmnd *SCpnt) |
2272 | { | 2143 | { |
2273 | u8 *scsi_buf = SCpnt->request_buffer; | 2144 | u8 *scsi_buf = SCpnt->request_buffer; |
2274 | u8 device_type = SBP2_DEVICE_TYPE (scsi_id->sbp2_device_type_and_lun); | ||
2275 | 2145 | ||
2276 | SBP2_DEBUG("sbp2_check_sbp2_response"); | 2146 | SBP2_DEBUG("sbp2_check_sbp2_response"); |
2277 | 2147 | ||
2278 | switch (SCpnt->cmnd[0]) { | 2148 | switch (SCpnt->cmnd[0]) { |
2279 | 2149 | ||
2280 | case INQUIRY: | 2150 | case INQUIRY: |
2281 | 2151 | /* | |
2282 | /* | 2152 | * Make sure data length is ok. Minimum length is 36 bytes |
2283 | * If scsi_id->sbp2_device_type_and_lun is uninitialized, then fill | 2153 | */ |
2284 | * this information in from the inquiry response data. Lun is set to zero. | 2154 | if (scsi_buf[4] == 0) { |
2285 | */ | 2155 | scsi_buf[4] = 36 - 5; |
2286 | if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) { | 2156 | } |
2287 | SBP2_DEBUG("Creating sbp2_device_type_and_lun from scsi inquiry data"); | ||
2288 | scsi_id->sbp2_device_type_and_lun = (scsi_buf[0] & 0x1f) << 16; | ||
2289 | } | ||
2290 | |||
2291 | /* | ||
2292 | * Make sure data length is ok. Minimum length is 36 bytes | ||
2293 | */ | ||
2294 | if (scsi_buf[4] == 0) { | ||
2295 | scsi_buf[4] = 36 - 5; | ||
2296 | } | ||
2297 | |||
2298 | /* | ||
2299 | * Check for Simple Direct Access Device and change it to TYPE_DISK | ||
2300 | */ | ||
2301 | if ((scsi_buf[0] & 0x1f) == TYPE_RBC) { | ||
2302 | SBP2_DEBUG("Changing TYPE_RBC to TYPE_DISK"); | ||
2303 | scsi_buf[0] &= 0xe0; | ||
2304 | } | ||
2305 | |||
2306 | /* | ||
2307 | * Fix ansi revision and response data format | ||
2308 | */ | ||
2309 | scsi_buf[2] |= 2; | ||
2310 | scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; | ||
2311 | |||
2312 | break; | ||
2313 | |||
2314 | case MODE_SENSE: | ||
2315 | |||
2316 | if (sbp2_command_conversion_device_type(device_type)) { | ||
2317 | |||
2318 | SBP2_DEBUG("Modify mode sense response (10 byte version)"); | ||
2319 | |||
2320 | scsi_buf[0] = scsi_buf[1]; /* Mode data length */ | ||
2321 | scsi_buf[1] = scsi_buf[2]; /* Medium type */ | ||
2322 | scsi_buf[2] = scsi_buf[3]; /* Device specific parameter */ | ||
2323 | scsi_buf[3] = scsi_buf[7]; /* Block descriptor length */ | ||
2324 | memcpy(scsi_buf + 4, scsi_buf + 8, scsi_buf[0]); | ||
2325 | } | ||
2326 | 2157 | ||
2327 | break; | 2158 | /* |
2159 | * Fix ansi revision and response data format | ||
2160 | */ | ||
2161 | scsi_buf[2] |= 2; | ||
2162 | scsi_buf[3] = (scsi_buf[3] & 0xf0) | 2; | ||
2328 | 2163 | ||
2329 | case MODE_SELECT: | 2164 | break; |
2330 | 2165 | ||
2331 | /* | 2166 | default: |
2332 | * TODO. Probably need to change mode select to 10 byte version | 2167 | break; |
2333 | */ | ||
2334 | |||
2335 | default: | ||
2336 | break; | ||
2337 | } | 2168 | } |
2338 | return; | 2169 | return; |
2339 | } | 2170 | } |
@@ -2350,6 +2181,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2350 | struct scsi_cmnd *SCpnt = NULL; | 2181 | struct scsi_cmnd *SCpnt = NULL; |
2351 | u32 scsi_status = SBP2_SCSI_STATUS_GOOD; | 2182 | u32 scsi_status = SBP2_SCSI_STATUS_GOOD; |
2352 | struct sbp2_command_info *command; | 2183 | struct sbp2_command_info *command; |
2184 | unsigned long flags; | ||
2353 | 2185 | ||
2354 | SBP2_DEBUG("sbp2_handle_status_write"); | 2186 | SBP2_DEBUG("sbp2_handle_status_write"); |
2355 | 2187 | ||
@@ -2357,14 +2189,14 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2357 | 2189 | ||
2358 | if (!host) { | 2190 | if (!host) { |
2359 | SBP2_ERR("host is NULL - this is bad!"); | 2191 | SBP2_ERR("host is NULL - this is bad!"); |
2360 | return(RCODE_ADDRESS_ERROR); | 2192 | return RCODE_ADDRESS_ERROR; |
2361 | } | 2193 | } |
2362 | 2194 | ||
2363 | hi = hpsb_get_hostinfo(&sbp2_highlevel, host); | 2195 | hi = hpsb_get_hostinfo(&sbp2_highlevel, host); |
2364 | 2196 | ||
2365 | if (!hi) { | 2197 | if (!hi) { |
2366 | SBP2_ERR("host info is NULL - this is bad!"); | 2198 | SBP2_ERR("host info is NULL - this is bad!"); |
2367 | return(RCODE_ADDRESS_ERROR); | 2199 | return RCODE_ADDRESS_ERROR; |
2368 | } | 2200 | } |
2369 | 2201 | ||
2370 | /* | 2202 | /* |
@@ -2381,7 +2213,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2381 | 2213 | ||
2382 | if (!scsi_id) { | 2214 | if (!scsi_id) { |
2383 | SBP2_ERR("scsi_id is NULL - device is gone?"); | 2215 | SBP2_ERR("scsi_id is NULL - device is gone?"); |
2384 | return(RCODE_ADDRESS_ERROR); | 2216 | return RCODE_ADDRESS_ERROR; |
2385 | } | 2217 | } |
2386 | 2218 | ||
2387 | /* | 2219 | /* |
@@ -2451,9 +2283,11 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2451 | * null out last orb so that next time around we write directly to the orb pointer... | 2283 | * null out last orb so that next time around we write directly to the orb pointer... |
2452 | * Quick start saves one 1394 bus transaction. | 2284 | * Quick start saves one 1394 bus transaction. |
2453 | */ | 2285 | */ |
2286 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); | ||
2454 | if (list_empty(&scsi_id->sbp2_command_orb_inuse)) { | 2287 | if (list_empty(&scsi_id->sbp2_command_orb_inuse)) { |
2455 | scsi_id->last_orb = NULL; | 2288 | scsi_id->last_orb = NULL; |
2456 | } | 2289 | } |
2290 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | ||
2457 | 2291 | ||
2458 | } else { | 2292 | } else { |
2459 | 2293 | ||
@@ -2477,10 +2311,9 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, int dest | |||
2477 | SBP2_ORB_DEBUG("command orb completed"); | 2311 | SBP2_ORB_DEBUG("command orb completed"); |
2478 | } | 2312 | } |
2479 | 2313 | ||
2480 | return(RCODE_COMPLETE); | 2314 | return RCODE_COMPLETE; |
2481 | } | 2315 | } |
2482 | 2316 | ||
2483 | |||
2484 | /************************************** | 2317 | /************************************** |
2485 | * SCSI interface related section | 2318 | * SCSI interface related section |
2486 | **************************************/ | 2319 | **************************************/ |
@@ -2563,9 +2396,11 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id | |||
2563 | struct sbp2scsi_host_info *hi = scsi_id->hi; | 2396 | struct sbp2scsi_host_info *hi = scsi_id->hi; |
2564 | struct list_head *lh; | 2397 | struct list_head *lh; |
2565 | struct sbp2_command_info *command; | 2398 | struct sbp2_command_info *command; |
2399 | unsigned long flags; | ||
2566 | 2400 | ||
2567 | SBP2_DEBUG("sbp2scsi_complete_all_commands"); | 2401 | SBP2_DEBUG("sbp2scsi_complete_all_commands"); |
2568 | 2402 | ||
2403 | spin_lock_irqsave(&scsi_id->sbp2_command_orb_lock, flags); | ||
2569 | while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { | 2404 | while (!list_empty(&scsi_id->sbp2_command_orb_inuse)) { |
2570 | SBP2_DEBUG("Found pending command to complete"); | 2405 | SBP2_DEBUG("Found pending command to complete"); |
2571 | lh = scsi_id->sbp2_command_orb_inuse.next; | 2406 | lh = scsi_id->sbp2_command_orb_inuse.next; |
@@ -2582,6 +2417,7 @@ static void sbp2scsi_complete_all_commands(struct scsi_id_instance_data *scsi_id | |||
2582 | command->Current_done(command->Current_SCpnt); | 2417 | command->Current_done(command->Current_SCpnt); |
2583 | } | 2418 | } |
2584 | } | 2419 | } |
2420 | spin_unlock_irqrestore(&scsi_id->sbp2_command_orb_lock, flags); | ||
2585 | 2421 | ||
2586 | return; | 2422 | return; |
2587 | } | 2423 | } |
@@ -2610,55 +2446,56 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, | |||
2610 | * complete the command, just let it get retried at the end of the | 2446 | * complete the command, just let it get retried at the end of the |
2611 | * bus reset. | 2447 | * bus reset. |
2612 | */ | 2448 | */ |
2613 | if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { | 2449 | if (!hpsb_node_entry_valid(scsi_id->ne) |
2450 | && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { | ||
2614 | SBP2_ERR("Bus reset in progress - retry command later"); | 2451 | SBP2_ERR("Bus reset in progress - retry command later"); |
2615 | return; | 2452 | return; |
2616 | } | 2453 | } |
2617 | 2454 | ||
2618 | /* | 2455 | /* |
2619 | * Switch on scsi status | 2456 | * Switch on scsi status |
2620 | */ | 2457 | */ |
2621 | switch (scsi_status) { | 2458 | switch (scsi_status) { |
2622 | case SBP2_SCSI_STATUS_GOOD: | 2459 | case SBP2_SCSI_STATUS_GOOD: |
2623 | SCpnt->result = DID_OK; | 2460 | SCpnt->result = DID_OK; |
2624 | break; | 2461 | break; |
2625 | 2462 | ||
2626 | case SBP2_SCSI_STATUS_BUSY: | 2463 | case SBP2_SCSI_STATUS_BUSY: |
2627 | SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); | 2464 | SBP2_ERR("SBP2_SCSI_STATUS_BUSY"); |
2628 | SCpnt->result = DID_BUS_BUSY << 16; | 2465 | SCpnt->result = DID_BUS_BUSY << 16; |
2629 | break; | 2466 | break; |
2630 | 2467 | ||
2631 | case SBP2_SCSI_STATUS_CHECK_CONDITION: | 2468 | case SBP2_SCSI_STATUS_CHECK_CONDITION: |
2632 | SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); | 2469 | SBP2_DEBUG("SBP2_SCSI_STATUS_CHECK_CONDITION"); |
2633 | SCpnt->result = CHECK_CONDITION << 1; | 2470 | SCpnt->result = CHECK_CONDITION << 1; |
2634 | 2471 | ||
2635 | /* | 2472 | /* |
2636 | * Debug stuff | 2473 | * Debug stuff |
2637 | */ | 2474 | */ |
2638 | #if CONFIG_IEEE1394_SBP2_DEBUG >= 1 | 2475 | #if CONFIG_IEEE1394_SBP2_DEBUG >= 1 |
2639 | scsi_print_command(SCpnt); | 2476 | scsi_print_command(SCpnt); |
2640 | scsi_print_sense("bh", SCpnt); | 2477 | scsi_print_sense("bh", SCpnt); |
2641 | #endif | 2478 | #endif |
2642 | 2479 | ||
2643 | break; | 2480 | break; |
2644 | 2481 | ||
2645 | case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: | 2482 | case SBP2_SCSI_STATUS_SELECTION_TIMEOUT: |
2646 | SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); | 2483 | SBP2_ERR("SBP2_SCSI_STATUS_SELECTION_TIMEOUT"); |
2647 | SCpnt->result = DID_NO_CONNECT << 16; | 2484 | SCpnt->result = DID_NO_CONNECT << 16; |
2648 | scsi_print_command(SCpnt); | 2485 | scsi_print_command(SCpnt); |
2649 | break; | 2486 | break; |
2650 | 2487 | ||
2651 | case SBP2_SCSI_STATUS_CONDITION_MET: | 2488 | case SBP2_SCSI_STATUS_CONDITION_MET: |
2652 | case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: | 2489 | case SBP2_SCSI_STATUS_RESERVATION_CONFLICT: |
2653 | case SBP2_SCSI_STATUS_COMMAND_TERMINATED: | 2490 | case SBP2_SCSI_STATUS_COMMAND_TERMINATED: |
2654 | SBP2_ERR("Bad SCSI status = %x", scsi_status); | 2491 | SBP2_ERR("Bad SCSI status = %x", scsi_status); |
2655 | SCpnt->result = DID_ERROR << 16; | 2492 | SCpnt->result = DID_ERROR << 16; |
2656 | scsi_print_command(SCpnt); | 2493 | scsi_print_command(SCpnt); |
2657 | break; | 2494 | break; |
2658 | 2495 | ||
2659 | default: | 2496 | default: |
2660 | SBP2_ERR("Unsupported SCSI status = %x", scsi_status); | 2497 | SBP2_ERR("Unsupported SCSI status = %x", scsi_status); |
2661 | SCpnt->result = DID_ERROR << 16; | 2498 | SCpnt->result = DID_ERROR << 16; |
2662 | } | 2499 | } |
2663 | 2500 | ||
2664 | /* | 2501 | /* |
@@ -2672,7 +2509,8 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, | |||
2672 | * If a bus reset is in progress and there was an error, complete | 2509 | * If a bus reset is in progress and there was an error, complete |
2673 | * the command as busy so that it will get retried. | 2510 | * the command as busy so that it will get retried. |
2674 | */ | 2511 | */ |
2675 | if (!hpsb_node_entry_valid(scsi_id->ne) && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { | 2512 | if (!hpsb_node_entry_valid(scsi_id->ne) |
2513 | && (scsi_status != SBP2_SCSI_STATUS_GOOD)) { | ||
2676 | SBP2_ERR("Completing command with busy (bus reset)"); | 2514 | SBP2_ERR("Completing command with busy (bus reset)"); |
2677 | SCpnt->result = DID_BUS_BUSY << 16; | 2515 | SCpnt->result = DID_BUS_BUSY << 16; |
2678 | } | 2516 | } |
@@ -2693,31 +2531,29 @@ static void sbp2scsi_complete_command(struct scsi_id_instance_data *scsi_id, | |||
2693 | /* | 2531 | /* |
2694 | * Tell scsi stack that we're done with this command | 2532 | * Tell scsi stack that we're done with this command |
2695 | */ | 2533 | */ |
2696 | done (SCpnt); | 2534 | done(SCpnt); |
2697 | } | 2535 | } |
2698 | 2536 | ||
2699 | |||
2700 | static int sbp2scsi_slave_alloc(struct scsi_device *sdev) | 2537 | static int sbp2scsi_slave_alloc(struct scsi_device *sdev) |
2701 | { | 2538 | { |
2702 | ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; | 2539 | ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = sdev; |
2703 | return 0; | 2540 | return 0; |
2704 | } | 2541 | } |
2705 | 2542 | ||
2706 | |||
2707 | static int sbp2scsi_slave_configure(struct scsi_device *sdev) | 2543 | static int sbp2scsi_slave_configure(struct scsi_device *sdev) |
2708 | { | 2544 | { |
2709 | blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); | 2545 | blk_queue_dma_alignment(sdev->request_queue, (512 - 1)); |
2546 | sdev->use_10_for_rw = 1; | ||
2547 | sdev->use_10_for_ms = 1; | ||
2710 | return 0; | 2548 | return 0; |
2711 | } | 2549 | } |
2712 | 2550 | ||
2713 | |||
2714 | static void sbp2scsi_slave_destroy(struct scsi_device *sdev) | 2551 | static void sbp2scsi_slave_destroy(struct scsi_device *sdev) |
2715 | { | 2552 | { |
2716 | ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; | 2553 | ((struct scsi_id_instance_data *)sdev->host->hostdata[0])->sdev = NULL; |
2717 | return; | 2554 | return; |
2718 | } | 2555 | } |
2719 | 2556 | ||
2720 | |||
2721 | /* | 2557 | /* |
2722 | * Called by scsi stack when something has really gone wrong. Usually | 2558 | * Called by scsi stack when something has really gone wrong. Usually |
2723 | * called when a command has timed-out for some reason. | 2559 | * called when a command has timed-out for some reason. |
@@ -2763,7 +2599,7 @@ static int sbp2scsi_abort(struct scsi_cmnd *SCpnt) | |||
2763 | sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); | 2599 | sbp2scsi_complete_all_commands(scsi_id, DID_BUS_BUSY); |
2764 | } | 2600 | } |
2765 | 2601 | ||
2766 | return(SUCCESS); | 2602 | return SUCCESS; |
2767 | } | 2603 | } |
2768 | 2604 | ||
2769 | /* | 2605 | /* |
@@ -2789,12 +2625,14 @@ static int sbp2scsi_reset(struct scsi_cmnd *SCpnt) | |||
2789 | return SUCCESS; | 2625 | return SUCCESS; |
2790 | } | 2626 | } |
2791 | 2627 | ||
2792 | static const char *sbp2scsi_info (struct Scsi_Host *host) | 2628 | static const char *sbp2scsi_info(struct Scsi_Host *host) |
2793 | { | 2629 | { |
2794 | return "SCSI emulation for IEEE-1394 SBP-2 Devices"; | 2630 | return "SCSI emulation for IEEE-1394 SBP-2 Devices"; |
2795 | } | 2631 | } |
2796 | 2632 | ||
2797 | static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_attribute *attr, char *buf) | 2633 | static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, |
2634 | struct device_attribute *attr, | ||
2635 | char *buf) | ||
2798 | { | 2636 | { |
2799 | struct scsi_device *sdev; | 2637 | struct scsi_device *sdev; |
2800 | struct scsi_id_instance_data *scsi_id; | 2638 | struct scsi_id_instance_data *scsi_id; |
@@ -2806,10 +2644,7 @@ static ssize_t sbp2_sysfs_ieee1394_id_show(struct device *dev, struct device_att | |||
2806 | if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0])) | 2644 | if (!(scsi_id = (struct scsi_id_instance_data *)sdev->host->hostdata[0])) |
2807 | return 0; | 2645 | return 0; |
2808 | 2646 | ||
2809 | if (scsi_id->sbp2_device_type_and_lun == SBP2_DEVICE_TYPE_LUN_UNINITIALIZED) | 2647 | lun = ORB_SET_LUN(scsi_id->sbp2_lun); |
2810 | lun = 0; | ||
2811 | else | ||
2812 | lun = ORB_SET_LUN(scsi_id->sbp2_device_type_and_lun); | ||
2813 | 2648 | ||
2814 | return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, | 2649 | return sprintf(buf, "%016Lx:%d:%d\n", (unsigned long long)scsi_id->ne->guid, |
2815 | scsi_id->ud->id, lun); | 2650 | scsi_id->ud->id, lun); |
@@ -2855,8 +2690,6 @@ static int sbp2_module_init(void) | |||
2855 | 2690 | ||
2856 | SBP2_DEBUG("sbp2_module_init"); | 2691 | SBP2_DEBUG("sbp2_module_init"); |
2857 | 2692 | ||
2858 | printk(KERN_INFO "sbp2: %s\n", version); | ||
2859 | |||
2860 | /* Module load debug option to force one command at a time (serializing I/O) */ | 2693 | /* Module load debug option to force one command at a time (serializing I/O) */ |
2861 | if (serialize_io) { | 2694 | if (serialize_io) { |
2862 | SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)"); | 2695 | SBP2_INFO("Driver forced to serialize I/O (serialize_io=1)"); |
@@ -2868,7 +2701,6 @@ static int sbp2_module_init(void) | |||
2868 | /* Set max sectors (module load option). Default is 255 sectors. */ | 2701 | /* Set max sectors (module load option). Default is 255 sectors. */ |
2869 | scsi_driver_template.max_sectors = max_sectors; | 2702 | scsi_driver_template.max_sectors = max_sectors; |
2870 | 2703 | ||
2871 | |||
2872 | /* Register our high level driver with 1394 stack */ | 2704 | /* Register our high level driver with 1394 stack */ |
2873 | hpsb_register_highlevel(&sbp2_highlevel); | 2705 | hpsb_register_highlevel(&sbp2_highlevel); |
2874 | 2706 | ||
diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index cd425be74841..abc647bae5b1 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h | |||
@@ -119,8 +119,8 @@ struct sbp2_query_logins_response { | |||
119 | struct sbp2_reconnect_orb { | 119 | struct sbp2_reconnect_orb { |
120 | u32 reserved1; | 120 | u32 reserved1; |
121 | u32 reserved2; | 121 | u32 reserved2; |
122 | u32 reserved3; | 122 | u32 reserved3; |
123 | u32 reserved4; | 123 | u32 reserved4; |
124 | u32 login_ID_misc; | 124 | u32 login_ID_misc; |
125 | u32 reserved5; | 125 | u32 reserved5; |
126 | u32 status_FIFO_hi; | 126 | u32 status_FIFO_hi; |
@@ -130,8 +130,8 @@ struct sbp2_reconnect_orb { | |||
130 | struct sbp2_logout_orb { | 130 | struct sbp2_logout_orb { |
131 | u32 reserved1; | 131 | u32 reserved1; |
132 | u32 reserved2; | 132 | u32 reserved2; |
133 | u32 reserved3; | 133 | u32 reserved3; |
134 | u32 reserved4; | 134 | u32 reserved4; |
135 | u32 login_ID_misc; | 135 | u32 login_ID_misc; |
136 | u32 reserved5; | 136 | u32 reserved5; |
137 | u32 status_FIFO_hi; | 137 | u32 status_FIFO_hi; |
@@ -188,7 +188,7 @@ struct sbp2_unrestricted_page_table { | |||
188 | struct sbp2_status_block { | 188 | struct sbp2_status_block { |
189 | u32 ORB_offset_hi_misc; | 189 | u32 ORB_offset_hi_misc; |
190 | u32 ORB_offset_lo; | 190 | u32 ORB_offset_lo; |
191 | u8 command_set_dependent[24]; | 191 | u8 command_set_dependent[24]; |
192 | }; | 192 | }; |
193 | 193 | ||
194 | /* | 194 | /* |
@@ -211,7 +211,7 @@ struct sbp2_status_block { | |||
211 | * specified for write posting, where the ohci controller will | 211 | * specified for write posting, where the ohci controller will |
212 | * automatically send an ack_complete when the status is written by the | 212 | * automatically send an ack_complete when the status is written by the |
213 | * sbp2 device... saving a split transaction. =) | 213 | * sbp2 device... saving a split transaction. =) |
214 | */ | 214 | */ |
215 | #define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL | 215 | #define SBP2_STATUS_FIFO_ADDRESS 0xfffe00000000ULL |
216 | #define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe | 216 | #define SBP2_STATUS_FIFO_ADDRESS_HI 0xfffe |
217 | #define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 | 217 | #define SBP2_STATUS_FIFO_ADDRESS_LO 0x0 |
@@ -229,9 +229,6 @@ struct sbp2_status_block { | |||
229 | #define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14 | 229 | #define SBP2_DEVICE_TYPE_AND_LUN_KEY 0x14 |
230 | #define SBP2_FIRMWARE_REVISION_KEY 0x3c | 230 | #define SBP2_FIRMWARE_REVISION_KEY 0x3c |
231 | 231 | ||
232 | #define SBP2_DEVICE_TYPE(q) (((q) >> 16) & 0x1f) | ||
233 | #define SBP2_DEVICE_LUN(q) ((q) & 0xffff) | ||
234 | |||
235 | #define SBP2_AGENT_STATE_OFFSET 0x00ULL | 232 | #define SBP2_AGENT_STATE_OFFSET 0x00ULL |
236 | #define SBP2_AGENT_RESET_OFFSET 0x04ULL | 233 | #define SBP2_AGENT_RESET_OFFSET 0x04ULL |
237 | #define SBP2_ORB_POINTER_OFFSET 0x08ULL | 234 | #define SBP2_ORB_POINTER_OFFSET 0x08ULL |
@@ -256,8 +253,6 @@ struct sbp2_status_block { | |||
256 | */ | 253 | */ |
257 | #define SBP2_128KB_BROKEN_FIRMWARE 0xa0b800 | 254 | #define SBP2_128KB_BROKEN_FIRMWARE 0xa0b800 |
258 | 255 | ||
259 | #define SBP2_DEVICE_TYPE_LUN_UNINITIALIZED 0xffffffff | ||
260 | |||
261 | /* | 256 | /* |
262 | * SCSI specific stuff | 257 | * SCSI specific stuff |
263 | */ | 258 | */ |
@@ -338,10 +333,8 @@ struct sbp2_command_info { | |||
338 | #define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 | 333 | #define SBP2_BREAKAGE_128K_MAX_TRANSFER 0x1 |
339 | #define SBP2_BREAKAGE_INQUIRY_HACK 0x2 | 334 | #define SBP2_BREAKAGE_INQUIRY_HACK 0x2 |
340 | 335 | ||
341 | |||
342 | struct sbp2scsi_host_info; | 336 | struct sbp2scsi_host_info; |
343 | 337 | ||
344 | |||
345 | /* | 338 | /* |
346 | * Information needed on a per scsi id basis (one for each sbp2 device) | 339 | * Information needed on a per scsi id basis (one for each sbp2 device) |
347 | */ | 340 | */ |
@@ -379,7 +372,7 @@ struct scsi_id_instance_data { | |||
379 | u32 sbp2_command_set_spec_id; | 372 | u32 sbp2_command_set_spec_id; |
380 | u32 sbp2_command_set; | 373 | u32 sbp2_command_set; |
381 | u32 sbp2_unit_characteristics; | 374 | u32 sbp2_unit_characteristics; |
382 | u32 sbp2_device_type_and_lun; | 375 | u32 sbp2_lun; |
383 | u32 sbp2_firmware_revision; | 376 | u32 sbp2_firmware_revision; |
384 | 377 | ||
385 | /* | 378 | /* |
@@ -411,7 +404,6 @@ struct scsi_id_instance_data { | |||
411 | u32 workarounds; | 404 | u32 workarounds; |
412 | }; | 405 | }; |
413 | 406 | ||
414 | |||
415 | /* Sbp2 host data structure (one per IEEE1394 host) */ | 407 | /* Sbp2 host data structure (one per IEEE1394 host) */ |
416 | struct sbp2scsi_host_info { | 408 | struct sbp2scsi_host_info { |
417 | struct hpsb_host *host; /* IEEE1394 host */ | 409 | struct hpsb_host *host; /* IEEE1394 host */ |
@@ -469,7 +461,6 @@ static int sbp2_send_command(struct scsi_id_instance_data *scsi_id, | |||
469 | struct scsi_cmnd *SCpnt, | 461 | struct scsi_cmnd *SCpnt, |
470 | void (*done)(struct scsi_cmnd *)); | 462 | void (*done)(struct scsi_cmnd *)); |
471 | static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data); | 463 | static unsigned int sbp2_status_to_sense_data(unchar *sbp2_status, unchar *sense_data); |
472 | static void sbp2_check_sbp2_command(struct scsi_id_instance_data *scsi_id, unchar *cmd); | ||
473 | static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, | 464 | static void sbp2_check_sbp2_response(struct scsi_id_instance_data *scsi_id, |
474 | struct scsi_cmnd *SCpnt); | 465 | struct scsi_cmnd *SCpnt); |
475 | static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, | 466 | static void sbp2_parse_unit_directory(struct scsi_id_instance_data *scsi_id, |
diff --git a/drivers/ieee1394/video1394.c b/drivers/ieee1394/video1394.c index 23911da50154..07050f0e4098 100644 --- a/drivers/ieee1394/video1394.c +++ b/drivers/ieee1394/video1394.c | |||
@@ -77,14 +77,6 @@ | |||
77 | 77 | ||
78 | #define ISO_CHANNELS 64 | 78 | #define ISO_CHANNELS 64 |
79 | 79 | ||
80 | #ifndef virt_to_page | ||
81 | #define virt_to_page(x) MAP_NR(x) | ||
82 | #endif | ||
83 | |||
84 | #ifndef vmalloc_32 | ||
85 | #define vmalloc_32(x) vmalloc(x) | ||
86 | #endif | ||
87 | |||
88 | struct it_dma_prg { | 80 | struct it_dma_prg { |
89 | struct dma_cmd begin; | 81 | struct dma_cmd begin; |
90 | quadlet_t data[4]; | 82 | quadlet_t data[4]; |
@@ -206,14 +198,12 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
206 | struct dma_iso_ctx *d; | 198 | struct dma_iso_ctx *d; |
207 | int i; | 199 | int i; |
208 | 200 | ||
209 | d = kmalloc(sizeof(struct dma_iso_ctx), GFP_KERNEL); | 201 | d = kzalloc(sizeof(*d), GFP_KERNEL); |
210 | if (d == NULL) { | 202 | if (!d) { |
211 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); | 203 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma_iso_ctx"); |
212 | return NULL; | 204 | return NULL; |
213 | } | 205 | } |
214 | 206 | ||
215 | memset(d, 0, sizeof *d); | ||
216 | |||
217 | d->ohci = ohci; | 207 | d->ohci = ohci; |
218 | d->type = type; | 208 | d->type = type; |
219 | d->channel = channel; | 209 | d->channel = channel; |
@@ -251,9 +241,8 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
251 | } | 241 | } |
252 | d->ctx = d->iso_tasklet.context; | 242 | d->ctx = d->iso_tasklet.context; |
253 | 243 | ||
254 | d->prg_reg = kmalloc(d->num_desc * sizeof(struct dma_prog_region), | 244 | d->prg_reg = kmalloc(d->num_desc * sizeof(*d->prg_reg), GFP_KERNEL); |
255 | GFP_KERNEL); | 245 | if (!d->prg_reg) { |
256 | if (d->prg_reg == NULL) { | ||
257 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); | 246 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate ir prg regs"); |
258 | free_dma_iso_ctx(d); | 247 | free_dma_iso_ctx(d); |
259 | return NULL; | 248 | return NULL; |
@@ -268,15 +257,14 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
268 | d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; | 257 | d->cmdPtr = OHCI1394_IsoRcvCommandPtr+32*d->ctx; |
269 | d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; | 258 | d->ctxMatch = OHCI1394_IsoRcvContextMatch+32*d->ctx; |
270 | 259 | ||
271 | d->ir_prg = kmalloc(d->num_desc * sizeof(struct dma_cmd *), | 260 | d->ir_prg = kzalloc(d->num_desc * sizeof(*d->ir_prg), |
272 | GFP_KERNEL); | 261 | GFP_KERNEL); |
273 | 262 | ||
274 | if (d->ir_prg == NULL) { | 263 | if (!d->ir_prg) { |
275 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); | 264 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate dma ir prg"); |
276 | free_dma_iso_ctx(d); | 265 | free_dma_iso_ctx(d); |
277 | return NULL; | 266 | return NULL; |
278 | } | 267 | } |
279 | memset(d->ir_prg, 0, d->num_desc * sizeof(struct dma_cmd *)); | ||
280 | 268 | ||
281 | d->nb_cmd = d->buf_size / PAGE_SIZE + 1; | 269 | d->nb_cmd = d->buf_size / PAGE_SIZE + 1; |
282 | d->left_size = (d->frame_size % PAGE_SIZE) ? | 270 | d->left_size = (d->frame_size % PAGE_SIZE) ? |
@@ -297,16 +285,15 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
297 | d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; | 285 | d->ctrlClear = OHCI1394_IsoXmitContextControlClear+16*d->ctx; |
298 | d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; | 286 | d->cmdPtr = OHCI1394_IsoXmitCommandPtr+16*d->ctx; |
299 | 287 | ||
300 | d->it_prg = kmalloc(d->num_desc * sizeof(struct it_dma_prg *), | 288 | d->it_prg = kzalloc(d->num_desc * sizeof(*d->it_prg), |
301 | GFP_KERNEL); | 289 | GFP_KERNEL); |
302 | 290 | ||
303 | if (d->it_prg == NULL) { | 291 | if (!d->it_prg) { |
304 | PRINT(KERN_ERR, ohci->host->id, | 292 | PRINT(KERN_ERR, ohci->host->id, |
305 | "Failed to allocate dma it prg"); | 293 | "Failed to allocate dma it prg"); |
306 | free_dma_iso_ctx(d); | 294 | free_dma_iso_ctx(d); |
307 | return NULL; | 295 | return NULL; |
308 | } | 296 | } |
309 | memset(d->it_prg, 0, d->num_desc*sizeof(struct it_dma_prg *)); | ||
310 | 297 | ||
311 | d->packet_size = packet_size; | 298 | d->packet_size = packet_size; |
312 | 299 | ||
@@ -337,47 +324,24 @@ alloc_dma_iso_ctx(struct ti_ohci *ohci, int type, int num_desc, | |||
337 | } | 324 | } |
338 | } | 325 | } |
339 | 326 | ||
340 | d->buffer_status = kmalloc(d->num_desc * sizeof(unsigned int), | 327 | d->buffer_status = |
341 | GFP_KERNEL); | 328 | kzalloc(d->num_desc * sizeof(*d->buffer_status), GFP_KERNEL); |
342 | d->buffer_prg_assignment = kmalloc(d->num_desc * sizeof(unsigned int), | 329 | d->buffer_prg_assignment = |
343 | GFP_KERNEL); | 330 | kzalloc(d->num_desc * sizeof(*d->buffer_prg_assignment), GFP_KERNEL); |
344 | d->buffer_time = kmalloc(d->num_desc * sizeof(struct timeval), | 331 | d->buffer_time = |
345 | GFP_KERNEL); | 332 | kzalloc(d->num_desc * sizeof(*d->buffer_time), GFP_KERNEL); |
346 | d->last_used_cmd = kmalloc(d->num_desc * sizeof(unsigned int), | 333 | d->last_used_cmd = |
347 | GFP_KERNEL); | 334 | kzalloc(d->num_desc * sizeof(*d->last_used_cmd), GFP_KERNEL); |
348 | d->next_buffer = kmalloc(d->num_desc * sizeof(int), | 335 | d->next_buffer = |
349 | GFP_KERNEL); | 336 | kzalloc(d->num_desc * sizeof(*d->next_buffer), GFP_KERNEL); |
350 | 337 | ||
351 | if (d->buffer_status == NULL) { | 338 | if (!d->buffer_status || !d->buffer_prg_assignment || !d->buffer_time || |
352 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_status"); | 339 | !d->last_used_cmd || !d->next_buffer) { |
353 | free_dma_iso_ctx(d); | 340 | PRINT(KERN_ERR, ohci->host->id, |
354 | return NULL; | 341 | "Failed to allocate dma_iso_ctx member"); |
355 | } | ||
356 | if (d->buffer_prg_assignment == NULL) { | ||
357 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_prg_assignment"); | ||
358 | free_dma_iso_ctx(d); | ||
359 | return NULL; | ||
360 | } | ||
361 | if (d->buffer_time == NULL) { | ||
362 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate buffer_time"); | ||
363 | free_dma_iso_ctx(d); | ||
364 | return NULL; | ||
365 | } | ||
366 | if (d->last_used_cmd == NULL) { | ||
367 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate last_used_cmd"); | ||
368 | free_dma_iso_ctx(d); | ||
369 | return NULL; | ||
370 | } | ||
371 | if (d->next_buffer == NULL) { | ||
372 | PRINT(KERN_ERR, ohci->host->id, "Failed to allocate next_buffer"); | ||
373 | free_dma_iso_ctx(d); | 342 | free_dma_iso_ctx(d); |
374 | return NULL; | 343 | return NULL; |
375 | } | 344 | } |
376 | memset(d->buffer_status, 0, d->num_desc * sizeof(unsigned int)); | ||
377 | memset(d->buffer_prg_assignment, 0, d->num_desc * sizeof(unsigned int)); | ||
378 | memset(d->buffer_time, 0, d->num_desc * sizeof(struct timeval)); | ||
379 | memset(d->last_used_cmd, 0, d->num_desc * sizeof(unsigned int)); | ||
380 | memset(d->next_buffer, -1, d->num_desc * sizeof(int)); | ||
381 | 345 | ||
382 | spin_lock_init(&d->lock); | 346 | spin_lock_init(&d->lock); |
383 | 347 | ||
@@ -1085,7 +1049,7 @@ static int __video1394_ioctl(struct file *file, | |||
1085 | } | 1049 | } |
1086 | 1050 | ||
1087 | if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { | 1051 | if (d->flags & VIDEO1394_VARIABLE_PACKET_SIZE) { |
1088 | int buf_size = d->nb_cmd * sizeof(unsigned int); | 1052 | int buf_size = d->nb_cmd * sizeof(*psizes); |
1089 | struct video1394_queue_variable __user *p = argp; | 1053 | struct video1394_queue_variable __user *p = argp; |
1090 | unsigned int __user *qv; | 1054 | unsigned int __user *qv; |
1091 | 1055 | ||
@@ -1251,13 +1215,12 @@ static int video1394_open(struct inode *inode, struct file *file) | |||
1251 | if (ohci == NULL) | 1215 | if (ohci == NULL) |
1252 | return -EIO; | 1216 | return -EIO; |
1253 | 1217 | ||
1254 | ctx = kmalloc(sizeof(struct file_ctx), GFP_KERNEL); | 1218 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); |
1255 | if (ctx == NULL) { | 1219 | if (!ctx) { |
1256 | PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); | 1220 | PRINT(KERN_ERR, ohci->host->id, "Cannot malloc file_ctx"); |
1257 | return -ENOMEM; | 1221 | return -ENOMEM; |
1258 | } | 1222 | } |
1259 | 1223 | ||
1260 | memset(ctx, 0, sizeof(struct file_ctx)); | ||
1261 | ctx->ohci = ohci; | 1224 | ctx->ohci = ohci; |
1262 | INIT_LIST_HEAD(&ctx->context_list); | 1225 | INIT_LIST_HEAD(&ctx->context_list); |
1263 | ctx->current_ctx = NULL; | 1226 | ctx->current_ctx = NULL; |