diff options
author | David Woodhouse <dwmw2@infradead.org> | 2006-05-03 08:30:35 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@infradead.org> | 2006-05-03 08:30:35 -0400 |
commit | edc4ff7c08e9885c40e60c4fb39fa42cc91a0602 (patch) | |
tree | f375d28043dd4457428a841167dc93d760ba9a46 /drivers | |
parent | cbb9a56177b16294ed347ba7fcb1c66c8adb5dc4 (diff) | |
parent | e17df688f7064dae1417ce425dd1e4b71d24d63b (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'drivers')
170 files changed, 4440 insertions, 3843 deletions
diff --git a/drivers/Kconfig b/drivers/Kconfig index 5c91d6afb117..aeb5ab2391e4 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig | |||
@@ -68,8 +68,6 @@ source "drivers/leds/Kconfig" | |||
68 | 68 | ||
69 | source "drivers/infiniband/Kconfig" | 69 | source "drivers/infiniband/Kconfig" |
70 | 70 | ||
71 | source "drivers/sn/Kconfig" | ||
72 | |||
73 | source "drivers/edac/Kconfig" | 71 | source "drivers/edac/Kconfig" |
74 | 72 | ||
75 | source "drivers/rtc/Kconfig" | 73 | source "drivers/rtc/Kconfig" |
diff --git a/drivers/base/topology.c b/drivers/base/topology.c index 915810f6237e..8c52421cbc54 100644 --- a/drivers/base/topology.c +++ b/drivers/base/topology.c | |||
@@ -107,7 +107,7 @@ static int __cpuinit topology_remove_dev(struct sys_device * sys_dev) | |||
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | static int __cpuinit topology_cpu_callback(struct notifier_block *nfb, | 110 | static int topology_cpu_callback(struct notifier_block *nfb, |
111 | unsigned long action, void *hcpu) | 111 | unsigned long action, void *hcpu) |
112 | { | 112 | { |
113 | unsigned int cpu = (unsigned long)hcpu; | 113 | unsigned int cpu = (unsigned long)hcpu; |
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 1b0fd31c57c3..1319d8f20640 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -1180,6 +1180,53 @@ static int revalidate_allvol(ctlr_info_t *host) | |||
1180 | return 0; | 1180 | return 0; |
1181 | } | 1181 | } |
1182 | 1182 | ||
1183 | static inline void complete_buffers(struct bio *bio, int status) | ||
1184 | { | ||
1185 | while (bio) { | ||
1186 | struct bio *xbh = bio->bi_next; | ||
1187 | int nr_sectors = bio_sectors(bio); | ||
1188 | |||
1189 | bio->bi_next = NULL; | ||
1190 | blk_finished_io(len); | ||
1191 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); | ||
1192 | bio = xbh; | ||
1193 | } | ||
1194 | |||
1195 | } | ||
1196 | |||
1197 | static void cciss_softirq_done(struct request *rq) | ||
1198 | { | ||
1199 | CommandList_struct *cmd = rq->completion_data; | ||
1200 | ctlr_info_t *h = hba[cmd->ctlr]; | ||
1201 | unsigned long flags; | ||
1202 | u64bit temp64; | ||
1203 | int i, ddir; | ||
1204 | |||
1205 | if (cmd->Request.Type.Direction == XFER_READ) | ||
1206 | ddir = PCI_DMA_FROMDEVICE; | ||
1207 | else | ||
1208 | ddir = PCI_DMA_TODEVICE; | ||
1209 | |||
1210 | /* command did not need to be retried */ | ||
1211 | /* unmap the DMA mapping for all the scatter gather elements */ | ||
1212 | for(i=0; i<cmd->Header.SGList; i++) { | ||
1213 | temp64.val32.lower = cmd->SG[i].Addr.lower; | ||
1214 | temp64.val32.upper = cmd->SG[i].Addr.upper; | ||
1215 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); | ||
1216 | } | ||
1217 | |||
1218 | complete_buffers(rq->bio, rq->errors); | ||
1219 | |||
1220 | #ifdef CCISS_DEBUG | ||
1221 | printk("Done with %p\n", rq); | ||
1222 | #endif /* CCISS_DEBUG */ | ||
1223 | |||
1224 | spin_lock_irqsave(&h->lock, flags); | ||
1225 | end_that_request_last(rq, rq->errors); | ||
1226 | cmd_free(h, cmd,1); | ||
1227 | spin_unlock_irqrestore(&h->lock, flags); | ||
1228 | } | ||
1229 | |||
1183 | /* This function will check the usage_count of the drive to be updated/added. | 1230 | /* This function will check the usage_count of the drive to be updated/added. |
1184 | * If the usage_count is zero then the drive information will be updated and | 1231 | * If the usage_count is zero then the drive information will be updated and |
1185 | * the disk will be re-registered with the kernel. If not then it will be | 1232 | * the disk will be re-registered with the kernel. If not then it will be |
@@ -1248,6 +1295,8 @@ static void cciss_update_drive_info(int ctlr, int drv_index) | |||
1248 | 1295 | ||
1249 | blk_queue_max_sectors(disk->queue, 512); | 1296 | blk_queue_max_sectors(disk->queue, 512); |
1250 | 1297 | ||
1298 | blk_queue_softirq_done(disk->queue, cciss_softirq_done); | ||
1299 | |||
1251 | disk->queue->queuedata = hba[ctlr]; | 1300 | disk->queue->queuedata = hba[ctlr]; |
1252 | 1301 | ||
1253 | blk_queue_hardsect_size(disk->queue, | 1302 | blk_queue_hardsect_size(disk->queue, |
@@ -2147,20 +2196,6 @@ static void start_io( ctlr_info_t *h) | |||
2147 | addQ (&(h->cmpQ), c); | 2196 | addQ (&(h->cmpQ), c); |
2148 | } | 2197 | } |
2149 | } | 2198 | } |
2150 | |||
2151 | static inline void complete_buffers(struct bio *bio, int status) | ||
2152 | { | ||
2153 | while (bio) { | ||
2154 | struct bio *xbh = bio->bi_next; | ||
2155 | int nr_sectors = bio_sectors(bio); | ||
2156 | |||
2157 | bio->bi_next = NULL; | ||
2158 | blk_finished_io(len); | ||
2159 | bio_endio(bio, nr_sectors << 9, status ? 0 : -EIO); | ||
2160 | bio = xbh; | ||
2161 | } | ||
2162 | |||
2163 | } | ||
2164 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ | 2199 | /* Assumes that CCISS_LOCK(h->ctlr) is held. */ |
2165 | /* Zeros out the error record and then resends the command back */ | 2200 | /* Zeros out the error record and then resends the command back */ |
2166 | /* to the controller */ | 2201 | /* to the controller */ |
@@ -2178,39 +2213,6 @@ static inline void resend_cciss_cmd( ctlr_info_t *h, CommandList_struct *c) | |||
2178 | start_io(h); | 2213 | start_io(h); |
2179 | } | 2214 | } |
2180 | 2215 | ||
2181 | static void cciss_softirq_done(struct request *rq) | ||
2182 | { | ||
2183 | CommandList_struct *cmd = rq->completion_data; | ||
2184 | ctlr_info_t *h = hba[cmd->ctlr]; | ||
2185 | unsigned long flags; | ||
2186 | u64bit temp64; | ||
2187 | int i, ddir; | ||
2188 | |||
2189 | if (cmd->Request.Type.Direction == XFER_READ) | ||
2190 | ddir = PCI_DMA_FROMDEVICE; | ||
2191 | else | ||
2192 | ddir = PCI_DMA_TODEVICE; | ||
2193 | |||
2194 | /* command did not need to be retried */ | ||
2195 | /* unmap the DMA mapping for all the scatter gather elements */ | ||
2196 | for(i=0; i<cmd->Header.SGList; i++) { | ||
2197 | temp64.val32.lower = cmd->SG[i].Addr.lower; | ||
2198 | temp64.val32.upper = cmd->SG[i].Addr.upper; | ||
2199 | pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir); | ||
2200 | } | ||
2201 | |||
2202 | complete_buffers(rq->bio, rq->errors); | ||
2203 | |||
2204 | #ifdef CCISS_DEBUG | ||
2205 | printk("Done with %p\n", rq); | ||
2206 | #endif /* CCISS_DEBUG */ | ||
2207 | |||
2208 | spin_lock_irqsave(&h->lock, flags); | ||
2209 | end_that_request_last(rq, rq->errors); | ||
2210 | cmd_free(h, cmd,1); | ||
2211 | spin_unlock_irqrestore(&h->lock, flags); | ||
2212 | } | ||
2213 | |||
2214 | /* checks the status of the job and calls complete buffers to mark all | 2216 | /* checks the status of the job and calls complete buffers to mark all |
2215 | * buffers for the completed job. Note that this function does not need | 2217 | * buffers for the completed job. Note that this function does not need |
2216 | * to hold the hba/queue lock. | 2218 | * to hold the hba/queue lock. |
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index bedb689b051f..dff1e67b1dd4 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c | |||
@@ -4301,7 +4301,7 @@ static int __init floppy_init(void) | |||
4301 | } | 4301 | } |
4302 | 4302 | ||
4303 | use_virtual_dma = can_use_virtual_dma & 1; | 4303 | use_virtual_dma = can_use_virtual_dma & 1; |
4304 | #if defined(CONFIG_PPC64) | 4304 | #if defined(CONFIG_PPC_MERGE) |
4305 | if (check_legacy_ioport(FDC1)) { | 4305 | if (check_legacy_ioport(FDC1)) { |
4306 | del_timer(&fd_timeout); | 4306 | del_timer(&fd_timeout); |
4307 | err = -ENODEV; | 4307 | err = -ENODEV; |
diff --git a/drivers/char/cs5535_gpio.c b/drivers/char/cs5535_gpio.c index 5d72f50de1ac..46d66037b917 100644 --- a/drivers/char/cs5535_gpio.c +++ b/drivers/char/cs5535_gpio.c | |||
@@ -241,9 +241,10 @@ static int __init cs5535_gpio_init(void) | |||
241 | static void __exit cs5535_gpio_cleanup(void) | 241 | static void __exit cs5535_gpio_cleanup(void) |
242 | { | 242 | { |
243 | dev_t dev_id = MKDEV(major, 0); | 243 | dev_t dev_id = MKDEV(major, 0); |
244 | |||
245 | cdev_del(&cs5535_gpio_cdev); | ||
244 | unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT); | 246 | unregister_chrdev_region(dev_id, CS5535_GPIO_COUNT); |
245 | if (gpio_base != 0) | 247 | release_region(gpio_base, CS5535_GPIO_SIZE); |
246 | release_region(gpio_base, CS5535_GPIO_SIZE); | ||
247 | } | 248 | } |
248 | 249 | ||
249 | module_init(cs5535_gpio_init); | 250 | module_init(cs5535_gpio_init); |
diff --git a/drivers/char/drm/drmP.h b/drivers/char/drm/drmP.h index edc72a6348a7..cb76e5ca9a23 100644 --- a/drivers/char/drm/drmP.h +++ b/drivers/char/drm/drmP.h | |||
@@ -815,8 +815,6 @@ extern int drm_mem_info(char *buf, char **start, off_t offset, | |||
815 | extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); | 815 | extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area); |
816 | extern void *drm_ioremap(unsigned long offset, unsigned long size, | 816 | extern void *drm_ioremap(unsigned long offset, unsigned long size, |
817 | drm_device_t * dev); | 817 | drm_device_t * dev); |
818 | extern void *drm_ioremap_nocache(unsigned long offset, unsigned long size, | ||
819 | drm_device_t * dev); | ||
820 | extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev); | 818 | extern void drm_ioremapfree(void *pt, unsigned long size, drm_device_t * dev); |
821 | 819 | ||
822 | extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type); | 820 | extern DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type); |
@@ -891,7 +889,6 @@ extern int drm_lock_free(drm_device_t * dev, | |||
891 | /* Buffer management support (drm_bufs.h) */ | 889 | /* Buffer management support (drm_bufs.h) */ |
892 | extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request); | 890 | extern int drm_addbufs_agp(drm_device_t * dev, drm_buf_desc_t * request); |
893 | extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request); | 891 | extern int drm_addbufs_pci(drm_device_t * dev, drm_buf_desc_t * request); |
894 | extern int drm_addbufs_fb(drm_device_t *dev, drm_buf_desc_t *request); | ||
895 | extern int drm_addmap(drm_device_t * dev, unsigned int offset, | 892 | extern int drm_addmap(drm_device_t * dev, unsigned int offset, |
896 | unsigned int size, drm_map_type_t type, | 893 | unsigned int size, drm_map_type_t type, |
897 | drm_map_flags_t flags, drm_local_map_t ** map_ptr); | 894 | drm_map_flags_t flags, drm_local_map_t ** map_ptr); |
@@ -1022,11 +1019,13 @@ static __inline__ void drm_core_ioremap(struct drm_map *map, | |||
1022 | map->handle = drm_ioremap(map->offset, map->size, dev); | 1019 | map->handle = drm_ioremap(map->offset, map->size, dev); |
1023 | } | 1020 | } |
1024 | 1021 | ||
1022 | #if 0 | ||
1025 | static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, | 1023 | static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, |
1026 | struct drm_device *dev) | 1024 | struct drm_device *dev) |
1027 | { | 1025 | { |
1028 | map->handle = drm_ioremap_nocache(map->offset, map->size, dev); | 1026 | map->handle = drm_ioremap_nocache(map->offset, map->size, dev); |
1029 | } | 1027 | } |
1028 | #endif /* 0 */ | ||
1030 | 1029 | ||
1031 | static __inline__ void drm_core_ioremapfree(struct drm_map *map, | 1030 | static __inline__ void drm_core_ioremapfree(struct drm_map *map, |
1032 | struct drm_device *dev) | 1031 | struct drm_device *dev) |
diff --git a/drivers/char/drm/drm_agpsupport.c b/drivers/char/drm/drm_agpsupport.c index fabc930c67a2..40bfd9b01e39 100644 --- a/drivers/char/drm/drm_agpsupport.c +++ b/drivers/char/drm/drm_agpsupport.c | |||
@@ -503,8 +503,6 @@ int drm_agp_bind_memory(DRM_AGP_MEM * handle, off_t start) | |||
503 | return agp_bind_memory(handle, start); | 503 | return agp_bind_memory(handle, start); |
504 | } | 504 | } |
505 | 505 | ||
506 | EXPORT_SYMBOL(drm_agp_bind_memory); | ||
507 | |||
508 | /** Calls agp_unbind_memory() */ | 506 | /** Calls agp_unbind_memory() */ |
509 | int drm_agp_unbind_memory(DRM_AGP_MEM * handle) | 507 | int drm_agp_unbind_memory(DRM_AGP_MEM * handle) |
510 | { | 508 | { |
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c index 8a9cf12e6183..006b06d29727 100644 --- a/drivers/char/drm/drm_bufs.c +++ b/drivers/char/drm/drm_bufs.c | |||
@@ -386,7 +386,6 @@ int drm_rmmap_locked(drm_device_t *dev, drm_local_map_t *map) | |||
386 | 386 | ||
387 | return 0; | 387 | return 0; |
388 | } | 388 | } |
389 | EXPORT_SYMBOL(drm_rmmap_locked); | ||
390 | 389 | ||
391 | int drm_rmmap(drm_device_t *dev, drm_local_map_t *map) | 390 | int drm_rmmap(drm_device_t *dev, drm_local_map_t *map) |
392 | { | 391 | { |
@@ -398,7 +397,6 @@ int drm_rmmap(drm_device_t *dev, drm_local_map_t *map) | |||
398 | 397 | ||
399 | return ret; | 398 | return ret; |
400 | } | 399 | } |
401 | EXPORT_SYMBOL(drm_rmmap); | ||
402 | 400 | ||
403 | /* The rmmap ioctl appears to be unnecessary. All mappings are torn down on | 401 | /* The rmmap ioctl appears to be unnecessary. All mappings are torn down on |
404 | * the last close of the device, and this is necessary for cleanup when things | 402 | * the last close of the device, and this is necessary for cleanup when things |
@@ -1053,7 +1051,7 @@ static int drm_addbufs_sg(drm_device_t * dev, drm_buf_desc_t * request) | |||
1053 | return 0; | 1051 | return 0; |
1054 | } | 1052 | } |
1055 | 1053 | ||
1056 | int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) | 1054 | static int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) |
1057 | { | 1055 | { |
1058 | drm_device_dma_t *dma = dev->dma; | 1056 | drm_device_dma_t *dma = dev->dma; |
1059 | drm_buf_entry_t *entry; | 1057 | drm_buf_entry_t *entry; |
@@ -1212,7 +1210,6 @@ int drm_addbufs_fb(drm_device_t * dev, drm_buf_desc_t * request) | |||
1212 | atomic_dec(&dev->buf_alloc); | 1210 | atomic_dec(&dev->buf_alloc); |
1213 | return 0; | 1211 | return 0; |
1214 | } | 1212 | } |
1215 | EXPORT_SYMBOL(drm_addbufs_fb); | ||
1216 | 1213 | ||
1217 | 1214 | ||
1218 | /** | 1215 | /** |
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index dc6bbe8a18dc..3c0b882a8e72 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -75,8 +75,8 @@ static drm_ioctl_desc_t drm_ioctls[] = { | |||
75 | [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 75 | [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = {drm_setsareactx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
76 | [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH}, | 76 | [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = {drm_getsareactx, DRM_AUTH}, |
77 | 77 | ||
78 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 78 | [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = {drm_addctx, DRM_AUTH|DRM_ROOT_ONLY}, |
79 | [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 79 | [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = {drm_rmctx, DRM_AUTH|DRM_ROOT_ONLY}, |
80 | [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 80 | [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = {drm_modctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
81 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, | 81 | [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = {drm_getctx, DRM_AUTH}, |
82 | [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, | 82 | [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = {drm_switchctx, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY}, |
diff --git a/drivers/char/drm/drm_memory.c b/drivers/char/drm/drm_memory.c index dddf8de66143..7e3318e1d1c6 100644 --- a/drivers/char/drm/drm_memory.c +++ b/drivers/char/drm/drm_memory.c | |||
@@ -80,6 +80,71 @@ void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area) | |||
80 | } | 80 | } |
81 | 81 | ||
82 | #if __OS_HAS_AGP | 82 | #if __OS_HAS_AGP |
83 | /* | ||
84 | * Find the drm_map that covers the range [offset, offset+size). | ||
85 | */ | ||
86 | static drm_map_t *drm_lookup_map(unsigned long offset, | ||
87 | unsigned long size, drm_device_t * dev) | ||
88 | { | ||
89 | struct list_head *list; | ||
90 | drm_map_list_t *r_list; | ||
91 | drm_map_t *map; | ||
92 | |||
93 | list_for_each(list, &dev->maplist->head) { | ||
94 | r_list = (drm_map_list_t *) list; | ||
95 | map = r_list->map; | ||
96 | if (!map) | ||
97 | continue; | ||
98 | if (map->offset <= offset | ||
99 | && (offset + size) <= (map->offset + map->size)) | ||
100 | return map; | ||
101 | } | ||
102 | return NULL; | ||
103 | } | ||
104 | |||
105 | static void *agp_remap(unsigned long offset, unsigned long size, | ||
106 | drm_device_t * dev) | ||
107 | { | ||
108 | unsigned long *phys_addr_map, i, num_pages = | ||
109 | PAGE_ALIGN(size) / PAGE_SIZE; | ||
110 | struct drm_agp_mem *agpmem; | ||
111 | struct page **page_map; | ||
112 | void *addr; | ||
113 | |||
114 | size = PAGE_ALIGN(size); | ||
115 | |||
116 | #ifdef __alpha__ | ||
117 | offset -= dev->hose->mem_space->start; | ||
118 | #endif | ||
119 | |||
120 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) | ||
121 | if (agpmem->bound <= offset | ||
122 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= | ||
123 | (offset + size)) | ||
124 | break; | ||
125 | if (!agpmem) | ||
126 | return NULL; | ||
127 | |||
128 | /* | ||
129 | * OK, we're mapping AGP space on a chipset/platform on which memory accesses by | ||
130 | * the CPU do not get remapped by the GART. We fix this by using the kernel's | ||
131 | * page-table instead (that's probably faster anyhow...). | ||
132 | */ | ||
133 | /* note: use vmalloc() because num_pages could be large... */ | ||
134 | page_map = vmalloc(num_pages * sizeof(struct page *)); | ||
135 | if (!page_map) | ||
136 | return NULL; | ||
137 | |||
138 | phys_addr_map = | ||
139 | agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; | ||
140 | for (i = 0; i < num_pages; ++i) | ||
141 | page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); | ||
142 | addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); | ||
143 | vfree(page_map); | ||
144 | |||
145 | return addr; | ||
146 | } | ||
147 | |||
83 | /** Wrapper around agp_allocate_memory() */ | 148 | /** Wrapper around agp_allocate_memory() */ |
84 | DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type) | 149 | DRM_AGP_MEM *drm_alloc_agp(drm_device_t * dev, int pages, u32 type) |
85 | { | 150 | { |
@@ -103,5 +168,74 @@ int drm_unbind_agp(DRM_AGP_MEM * handle) | |||
103 | { | 168 | { |
104 | return drm_agp_unbind_memory(handle); | 169 | return drm_agp_unbind_memory(handle); |
105 | } | 170 | } |
171 | |||
172 | #else /* __OS_HAS_AGP */ | ||
173 | |||
174 | static inline drm_map_t *drm_lookup_map(unsigned long offset, | ||
175 | unsigned long size, drm_device_t * dev) | ||
176 | { | ||
177 | return NULL; | ||
178 | } | ||
179 | |||
180 | static inline void *agp_remap(unsigned long offset, unsigned long size, | ||
181 | drm_device_t * dev) | ||
182 | { | ||
183 | return NULL; | ||
184 | } | ||
185 | |||
106 | #endif /* agp */ | 186 | #endif /* agp */ |
187 | |||
188 | void *drm_ioremap(unsigned long offset, unsigned long size, | ||
189 | drm_device_t * dev) | ||
190 | { | ||
191 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | ||
192 | drm_map_t *map = drm_lookup_map(offset, size, dev); | ||
193 | |||
194 | if (map && map->type == _DRM_AGP) | ||
195 | return agp_remap(offset, size, dev); | ||
196 | } | ||
197 | return ioremap(offset, size); | ||
198 | } | ||
199 | EXPORT_SYMBOL(drm_ioremap); | ||
200 | |||
201 | #if 0 | ||
202 | void *drm_ioremap_nocache(unsigned long offset, | ||
203 | unsigned long size, drm_device_t * dev) | ||
204 | { | ||
205 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | ||
206 | drm_map_t *map = drm_lookup_map(offset, size, dev); | ||
207 | |||
208 | if (map && map->type == _DRM_AGP) | ||
209 | return agp_remap(offset, size, dev); | ||
210 | } | ||
211 | return ioremap_nocache(offset, size); | ||
212 | } | ||
213 | #endif /* 0 */ | ||
214 | |||
215 | void drm_ioremapfree(void *pt, unsigned long size, | ||
216 | drm_device_t * dev) | ||
217 | { | ||
218 | /* | ||
219 | * This is a bit ugly. It would be much cleaner if the DRM API would use separate | ||
220 | * routines for handling mappings in the AGP space. Hopefully this can be done in | ||
221 | * a future revision of the interface... | ||
222 | */ | ||
223 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture | ||
224 | && ((unsigned long)pt >= VMALLOC_START | ||
225 | && (unsigned long)pt < VMALLOC_END)) { | ||
226 | unsigned long offset; | ||
227 | drm_map_t *map; | ||
228 | |||
229 | offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK); | ||
230 | map = drm_lookup_map(offset, size, dev); | ||
231 | if (map && map->type == _DRM_AGP) { | ||
232 | vunmap(pt); | ||
233 | return; | ||
234 | } | ||
235 | } | ||
236 | |||
237 | iounmap(pt); | ||
238 | } | ||
239 | EXPORT_SYMBOL(drm_ioremapfree); | ||
240 | |||
107 | #endif /* debug_memory */ | 241 | #endif /* debug_memory */ |
diff --git a/drivers/char/drm/drm_memory.h b/drivers/char/drm/drm_memory.h index 3732a61c3762..714d9aedcff5 100644 --- a/drivers/char/drm/drm_memory.h +++ b/drivers/char/drm/drm_memory.h | |||
@@ -57,71 +57,6 @@ | |||
57 | # endif | 57 | # endif |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | /* | ||
61 | * Find the drm_map that covers the range [offset, offset+size). | ||
62 | */ | ||
63 | static inline drm_map_t *drm_lookup_map(unsigned long offset, | ||
64 | unsigned long size, drm_device_t * dev) | ||
65 | { | ||
66 | struct list_head *list; | ||
67 | drm_map_list_t *r_list; | ||
68 | drm_map_t *map; | ||
69 | |||
70 | list_for_each(list, &dev->maplist->head) { | ||
71 | r_list = (drm_map_list_t *) list; | ||
72 | map = r_list->map; | ||
73 | if (!map) | ||
74 | continue; | ||
75 | if (map->offset <= offset | ||
76 | && (offset + size) <= (map->offset + map->size)) | ||
77 | return map; | ||
78 | } | ||
79 | return NULL; | ||
80 | } | ||
81 | |||
82 | static inline void *agp_remap(unsigned long offset, unsigned long size, | ||
83 | drm_device_t * dev) | ||
84 | { | ||
85 | unsigned long *phys_addr_map, i, num_pages = | ||
86 | PAGE_ALIGN(size) / PAGE_SIZE; | ||
87 | struct drm_agp_mem *agpmem; | ||
88 | struct page **page_map; | ||
89 | void *addr; | ||
90 | |||
91 | size = PAGE_ALIGN(size); | ||
92 | |||
93 | #ifdef __alpha__ | ||
94 | offset -= dev->hose->mem_space->start; | ||
95 | #endif | ||
96 | |||
97 | for (agpmem = dev->agp->memory; agpmem; agpmem = agpmem->next) | ||
98 | if (agpmem->bound <= offset | ||
99 | && (agpmem->bound + (agpmem->pages << PAGE_SHIFT)) >= | ||
100 | (offset + size)) | ||
101 | break; | ||
102 | if (!agpmem) | ||
103 | return NULL; | ||
104 | |||
105 | /* | ||
106 | * OK, we're mapping AGP space on a chipset/platform on which memory accesses by | ||
107 | * the CPU do not get remapped by the GART. We fix this by using the kernel's | ||
108 | * page-table instead (that's probably faster anyhow...). | ||
109 | */ | ||
110 | /* note: use vmalloc() because num_pages could be large... */ | ||
111 | page_map = vmalloc(num_pages * sizeof(struct page *)); | ||
112 | if (!page_map) | ||
113 | return NULL; | ||
114 | |||
115 | phys_addr_map = | ||
116 | agpmem->memory->memory + (offset - agpmem->bound) / PAGE_SIZE; | ||
117 | for (i = 0; i < num_pages; ++i) | ||
118 | page_map[i] = pfn_to_page(phys_addr_map[i] >> PAGE_SHIFT); | ||
119 | addr = vmap(page_map, num_pages, VM_IOREMAP, PAGE_AGP); | ||
120 | vfree(page_map); | ||
121 | |||
122 | return addr; | ||
123 | } | ||
124 | |||
125 | static inline unsigned long drm_follow_page(void *vaddr) | 60 | static inline unsigned long drm_follow_page(void *vaddr) |
126 | { | 61 | { |
127 | pgd_t *pgd = pgd_offset_k((unsigned long)vaddr); | 62 | pgd_t *pgd = pgd_offset_k((unsigned long)vaddr); |
@@ -133,18 +68,6 @@ static inline unsigned long drm_follow_page(void *vaddr) | |||
133 | 68 | ||
134 | #else /* __OS_HAS_AGP */ | 69 | #else /* __OS_HAS_AGP */ |
135 | 70 | ||
136 | static inline drm_map_t *drm_lookup_map(unsigned long offset, | ||
137 | unsigned long size, drm_device_t * dev) | ||
138 | { | ||
139 | return NULL; | ||
140 | } | ||
141 | |||
142 | static inline void *agp_remap(unsigned long offset, unsigned long size, | ||
143 | drm_device_t * dev) | ||
144 | { | ||
145 | return NULL; | ||
146 | } | ||
147 | |||
148 | static inline unsigned long drm_follow_page(void *vaddr) | 71 | static inline unsigned long drm_follow_page(void *vaddr) |
149 | { | 72 | { |
150 | return 0; | 73 | return 0; |
@@ -152,51 +75,8 @@ static inline unsigned long drm_follow_page(void *vaddr) | |||
152 | 75 | ||
153 | #endif | 76 | #endif |
154 | 77 | ||
155 | static inline void *drm_ioremap(unsigned long offset, unsigned long size, | 78 | void *drm_ioremap(unsigned long offset, unsigned long size, |
156 | drm_device_t * dev) | 79 | drm_device_t * dev); |
157 | { | ||
158 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | ||
159 | drm_map_t *map = drm_lookup_map(offset, size, dev); | ||
160 | |||
161 | if (map && map->type == _DRM_AGP) | ||
162 | return agp_remap(offset, size, dev); | ||
163 | } | ||
164 | return ioremap(offset, size); | ||
165 | } | ||
166 | |||
167 | static inline void *drm_ioremap_nocache(unsigned long offset, | ||
168 | unsigned long size, drm_device_t * dev) | ||
169 | { | ||
170 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture) { | ||
171 | drm_map_t *map = drm_lookup_map(offset, size, dev); | ||
172 | |||
173 | if (map && map->type == _DRM_AGP) | ||
174 | return agp_remap(offset, size, dev); | ||
175 | } | ||
176 | return ioremap_nocache(offset, size); | ||
177 | } | ||
178 | |||
179 | static inline void drm_ioremapfree(void *pt, unsigned long size, | ||
180 | drm_device_t * dev) | ||
181 | { | ||
182 | /* | ||
183 | * This is a bit ugly. It would be much cleaner if the DRM API would use separate | ||
184 | * routines for handling mappings in the AGP space. Hopefully this can be done in | ||
185 | * a future revision of the interface... | ||
186 | */ | ||
187 | if (drm_core_has_AGP(dev) && dev->agp && dev->agp->cant_use_aperture | ||
188 | && ((unsigned long)pt >= VMALLOC_START | ||
189 | && (unsigned long)pt < VMALLOC_END)) { | ||
190 | unsigned long offset; | ||
191 | drm_map_t *map; | ||
192 | |||
193 | offset = drm_follow_page(pt) | ((unsigned long)pt & ~PAGE_MASK); | ||
194 | map = drm_lookup_map(offset, size, dev); | ||
195 | if (map && map->type == _DRM_AGP) { | ||
196 | vunmap(pt); | ||
197 | return; | ||
198 | } | ||
199 | } | ||
200 | 80 | ||
201 | iounmap(pt); | 81 | void drm_ioremapfree(void *pt, unsigned long size, |
202 | } | 82 | drm_device_t * dev); |
diff --git a/drivers/char/drm/drm_memory_debug.h b/drivers/char/drm/drm_memory_debug.h index 7868341817da..6543b9a14c42 100644 --- a/drivers/char/drm/drm_memory_debug.h +++ b/drivers/char/drm/drm_memory_debug.h | |||
@@ -229,6 +229,7 @@ void *drm_ioremap (unsigned long offset, unsigned long size, | |||
229 | return pt; | 229 | return pt; |
230 | } | 230 | } |
231 | 231 | ||
232 | #if 0 | ||
232 | void *drm_ioremap_nocache (unsigned long offset, unsigned long size, | 233 | void *drm_ioremap_nocache (unsigned long offset, unsigned long size, |
233 | drm_device_t * dev) { | 234 | drm_device_t * dev) { |
234 | void *pt; | 235 | void *pt; |
@@ -251,6 +252,7 @@ void *drm_ioremap_nocache (unsigned long offset, unsigned long size, | |||
251 | spin_unlock(&drm_mem_lock); | 252 | spin_unlock(&drm_mem_lock); |
252 | return pt; | 253 | return pt; |
253 | } | 254 | } |
255 | #endif /* 0 */ | ||
254 | 256 | ||
255 | void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) { | 257 | void drm_ioremapfree (void *pt, unsigned long size, drm_device_t * dev) { |
256 | int alloc_count; | 258 | int alloc_count; |
diff --git a/drivers/char/drm/drm_pci.c b/drivers/char/drm/drm_pci.c index b28ca9cea8a2..86a0f1c22091 100644 --- a/drivers/char/drm/drm_pci.c +++ b/drivers/char/drm/drm_pci.c | |||
@@ -37,6 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | 38 | ||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/dma-mapping.h> | ||
40 | #include "drmP.h" | 41 | #include "drmP.h" |
41 | 42 | ||
42 | /**********************************************************************/ | 43 | /**********************************************************************/ |
diff --git a/drivers/char/drm/drm_stub.c b/drivers/char/drm/drm_stub.c index 68073e14fdec..9a842a36bb27 100644 --- a/drivers/char/drm/drm_stub.c +++ b/drivers/char/drm/drm_stub.c | |||
@@ -229,8 +229,6 @@ int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent, | |||
229 | return ret; | 229 | return ret; |
230 | } | 230 | } |
231 | 231 | ||
232 | EXPORT_SYMBOL(drm_get_dev); | ||
233 | |||
234 | /** | 232 | /** |
235 | * Put a device minor number. | 233 | * Put a device minor number. |
236 | * | 234 | * |
diff --git a/drivers/char/drm/r300_cmdbuf.c b/drivers/char/drm/r300_cmdbuf.c index b108c7f913b2..26bdf2ca59d7 100644 --- a/drivers/char/drm/r300_cmdbuf.c +++ b/drivers/char/drm/r300_cmdbuf.c | |||
@@ -723,7 +723,7 @@ static int r300_scratch(drm_radeon_private_t *dev_priv, | |||
723 | 723 | ||
724 | dev_priv->scratch_ages[header.scratch.reg]++; | 724 | dev_priv->scratch_ages[header.scratch.reg]++; |
725 | 725 | ||
726 | ref_age_base = *(u32 **)cmdbuf->buf; | 726 | ref_age_base = (u32 *)(unsigned long)*((uint64_t *)cmdbuf->buf); |
727 | 727 | ||
728 | cmdbuf->buf += sizeof(u64); | 728 | cmdbuf->buf += sizeof(u64); |
729 | cmdbuf->bufsz -= sizeof(u64); | 729 | cmdbuf->bufsz -= sizeof(u64); |
diff --git a/drivers/char/drm/via_irq.c b/drivers/char/drm/via_irq.c index 6152415644e9..c33d068cde19 100644 --- a/drivers/char/drm/via_irq.c +++ b/drivers/char/drm/via_irq.c | |||
@@ -196,9 +196,9 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, | |||
196 | { | 196 | { |
197 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 197 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
198 | unsigned int cur_irq_sequence; | 198 | unsigned int cur_irq_sequence; |
199 | drm_via_irq_t *cur_irq = dev_priv->via_irqs; | 199 | drm_via_irq_t *cur_irq; |
200 | int ret = 0; | 200 | int ret = 0; |
201 | maskarray_t *masks = dev_priv->irq_masks; | 201 | maskarray_t *masks; |
202 | int real_irq; | 202 | int real_irq; |
203 | 203 | ||
204 | DRM_DEBUG("%s\n", __FUNCTION__); | 204 | DRM_DEBUG("%s\n", __FUNCTION__); |
@@ -221,8 +221,9 @@ via_driver_irq_wait(drm_device_t * dev, unsigned int irq, int force_sequence, | |||
221 | __FUNCTION__, irq); | 221 | __FUNCTION__, irq); |
222 | return DRM_ERR(EINVAL); | 222 | return DRM_ERR(EINVAL); |
223 | } | 223 | } |
224 | 224 | ||
225 | cur_irq += real_irq; | 225 | masks = dev_priv->irq_masks; |
226 | cur_irq = dev_priv->via_irqs + real_irq; | ||
226 | 227 | ||
227 | if (masks[real_irq][2] && !force_sequence) { | 228 | if (masks[real_irq][2] && !force_sequence) { |
228 | DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, | 229 | DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ, |
@@ -247,11 +248,12 @@ void via_driver_irq_preinstall(drm_device_t * dev) | |||
247 | { | 248 | { |
248 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; | 249 | drm_via_private_t *dev_priv = (drm_via_private_t *) dev->dev_private; |
249 | u32 status; | 250 | u32 status; |
250 | drm_via_irq_t *cur_irq = dev_priv->via_irqs; | 251 | drm_via_irq_t *cur_irq; |
251 | int i; | 252 | int i; |
252 | 253 | ||
253 | DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv); | 254 | DRM_DEBUG("driver_irq_preinstall: dev_priv: %p\n", dev_priv); |
254 | if (dev_priv) { | 255 | if (dev_priv) { |
256 | cur_irq = dev_priv->via_irqs; | ||
255 | 257 | ||
256 | dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE; | 258 | dev_priv->irq_enable_mask = VIA_IRQ_VBLANK_ENABLE; |
257 | dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING; | 259 | dev_priv->irq_pending_mask = VIA_IRQ_VBLANK_PENDING; |
diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c index d3a2bc36129b..588fca542a98 100644 --- a/drivers/char/genrtc.c +++ b/drivers/char/genrtc.c | |||
@@ -200,13 +200,13 @@ static ssize_t gen_rtc_read(struct file *file, char __user *buf, | |||
200 | /* first test allows optimizer to nuke this case for 32-bit machines */ | 200 | /* first test allows optimizer to nuke this case for 32-bit machines */ |
201 | if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { | 201 | if (sizeof (int) != sizeof (long) && count == sizeof (unsigned int)) { |
202 | unsigned int uidata = data; | 202 | unsigned int uidata = data; |
203 | retval = put_user(uidata, (unsigned long __user *)buf); | 203 | retval = put_user(uidata, (unsigned int __user *)buf) ?: |
204 | sizeof(unsigned int); | ||
204 | } | 205 | } |
205 | else { | 206 | else { |
206 | retval = put_user(data, (unsigned long __user *)buf); | 207 | retval = put_user(data, (unsigned long __user *)buf) ?: |
208 | sizeof(unsigned long); | ||
207 | } | 209 | } |
208 | if (!retval) | ||
209 | retval = sizeof(unsigned long); | ||
210 | out: | 210 | out: |
211 | current->state = TASK_RUNNING; | 211 | current->state = TASK_RUNNING; |
212 | remove_wait_queue(&gen_rtc_wait, &wait); | 212 | remove_wait_queue(&gen_rtc_wait, &wait); |
diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c index 58dcdee1cd71..0030cd8e2e95 100644 --- a/drivers/char/ipmi/ipmi_bt_sm.c +++ b/drivers/char/ipmi/ipmi_bt_sm.c | |||
@@ -165,7 +165,7 @@ static int bt_start_transaction(struct si_sm_data *bt, | |||
165 | { | 165 | { |
166 | unsigned int i; | 166 | unsigned int i; |
167 | 167 | ||
168 | if ((size < 2) || (size > IPMI_MAX_MSG_LENGTH)) | 168 | if ((size < 2) || (size > (IPMI_MAX_MSG_LENGTH - 2))) |
169 | return -1; | 169 | return -1; |
170 | 170 | ||
171 | if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) | 171 | if ((bt->state != BT_STATE_IDLE) && (bt->state != BT_STATE_HOSED)) |
diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index a86c0f29953e..b36eef0e9d19 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c | |||
@@ -2198,11 +2198,11 @@ static inline void wait_for_timer_and_thread(struct smi_info *smi_info) | |||
2198 | } | 2198 | } |
2199 | } | 2199 | } |
2200 | 2200 | ||
2201 | static struct ipmi_default_vals | 2201 | static __devinitdata struct ipmi_default_vals |
2202 | { | 2202 | { |
2203 | int type; | 2203 | int type; |
2204 | int port; | 2204 | int port; |
2205 | } __devinit ipmi_defaults[] = | 2205 | } ipmi_defaults[] = |
2206 | { | 2206 | { |
2207 | { .type = SI_KCS, .port = 0xca2 }, | 2207 | { .type = SI_KCS, .port = 0xca2 }, |
2208 | { .type = SI_SMIC, .port = 0xca9 }, | 2208 | { .type = SI_SMIC, .port = 0xca9 }, |
diff --git a/drivers/char/keyboard.c b/drivers/char/keyboard.c index 935670a3cd98..5755b7e5f187 100644 --- a/drivers/char/keyboard.c +++ b/drivers/char/keyboard.c | |||
@@ -860,9 +860,32 @@ static void k_slock(struct vc_data *vc, unsigned char value, char up_flag, struc | |||
860 | } | 860 | } |
861 | 861 | ||
862 | /* by default, 300ms interval for combination release */ | 862 | /* by default, 300ms interval for combination release */ |
863 | static long brl_timeout = 300; | 863 | static unsigned brl_timeout = 300; |
864 | MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for combination on first release, < 0 for dead characters)"); | 864 | MODULE_PARM_DESC(brl_timeout, "Braille keys release delay in ms (0 for commit on first key release)"); |
865 | module_param(brl_timeout, long, 0644); | 865 | module_param(brl_timeout, uint, 0644); |
866 | |||
867 | static unsigned brl_nbchords = 1; | ||
868 | MODULE_PARM_DESC(brl_nbchords, "Number of chords that produce a braille pattern (0 for dead chords)"); | ||
869 | module_param(brl_nbchords, uint, 0644); | ||
870 | |||
871 | static void k_brlcommit(struct vc_data *vc, unsigned int pattern, char up_flag, struct pt_regs *regs) | ||
872 | { | ||
873 | static unsigned long chords; | ||
874 | static unsigned committed; | ||
875 | |||
876 | if (!brl_nbchords) | ||
877 | k_deadunicode(vc, BRL_UC_ROW | pattern, up_flag, regs); | ||
878 | else { | ||
879 | committed |= pattern; | ||
880 | chords++; | ||
881 | if (chords == brl_nbchords) { | ||
882 | k_unicode(vc, BRL_UC_ROW | committed, up_flag, regs); | ||
883 | chords = 0; | ||
884 | committed = 0; | ||
885 | } | ||
886 | } | ||
887 | } | ||
888 | |||
866 | static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) | 889 | static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct pt_regs *regs) |
867 | { | 890 | { |
868 | static unsigned pressed,committing; | 891 | static unsigned pressed,committing; |
@@ -882,11 +905,6 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct | |||
882 | if (value > 8) | 905 | if (value > 8) |
883 | return; | 906 | return; |
884 | 907 | ||
885 | if (brl_timeout < 0) { | ||
886 | k_deadunicode(vc, BRL_UC_ROW | (1 << (value - 1)), up_flag, regs); | ||
887 | return; | ||
888 | } | ||
889 | |||
890 | if (up_flag) { | 908 | if (up_flag) { |
891 | if (brl_timeout) { | 909 | if (brl_timeout) { |
892 | if (!committing || | 910 | if (!committing || |
@@ -897,13 +915,13 @@ static void k_brl(struct vc_data *vc, unsigned char value, char up_flag, struct | |||
897 | pressed &= ~(1 << (value - 1)); | 915 | pressed &= ~(1 << (value - 1)); |
898 | if (!pressed) { | 916 | if (!pressed) { |
899 | if (committing) { | 917 | if (committing) { |
900 | k_unicode(vc, BRL_UC_ROW | committing, 0, regs); | 918 | k_brlcommit(vc, committing, 0, regs); |
901 | committing = 0; | 919 | committing = 0; |
902 | } | 920 | } |
903 | } | 921 | } |
904 | } else { | 922 | } else { |
905 | if (committing) { | 923 | if (committing) { |
906 | k_unicode(vc, BRL_UC_ROW | committing, 0, regs); | 924 | k_brlcommit(vc, committing, 0, regs); |
907 | committing = 0; | 925 | committing = 0; |
908 | } | 926 | } |
909 | pressed &= ~(1 << (value - 1)); | 927 | pressed &= ~(1 << (value - 1)); |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 66719f9d294c..1fa9fa157c12 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/crash_dump.h> | 27 | #include <linux/crash_dump.h> |
28 | #include <linux/backing-dev.h> | 28 | #include <linux/backing-dev.h> |
29 | #include <linux/bootmem.h> | 29 | #include <linux/bootmem.h> |
30 | #include <linux/pipe_fs_i.h> | ||
30 | 31 | ||
31 | #include <asm/uaccess.h> | 32 | #include <asm/uaccess.h> |
32 | #include <asm/io.h> | 33 | #include <asm/io.h> |
@@ -578,6 +579,18 @@ static ssize_t write_null(struct file * file, const char __user * buf, | |||
578 | return count; | 579 | return count; |
579 | } | 580 | } |
580 | 581 | ||
582 | static int pipe_to_null(struct pipe_inode_info *info, struct pipe_buffer *buf, | ||
583 | struct splice_desc *sd) | ||
584 | { | ||
585 | return sd->len; | ||
586 | } | ||
587 | |||
588 | static ssize_t splice_write_null(struct pipe_inode_info *pipe,struct file *out, | ||
589 | loff_t *ppos, size_t len, unsigned int flags) | ||
590 | { | ||
591 | return splice_from_pipe(pipe, out, ppos, len, flags, pipe_to_null); | ||
592 | } | ||
593 | |||
581 | #ifdef CONFIG_MMU | 594 | #ifdef CONFIG_MMU |
582 | /* | 595 | /* |
583 | * For fun, we are using the MMU for this. | 596 | * For fun, we are using the MMU for this. |
@@ -785,6 +798,7 @@ static struct file_operations null_fops = { | |||
785 | .llseek = null_lseek, | 798 | .llseek = null_lseek, |
786 | .read = read_null, | 799 | .read = read_null, |
787 | .write = write_null, | 800 | .write = write_null, |
801 | .splice_write = splice_write_null, | ||
788 | }; | 802 | }; |
789 | 803 | ||
790 | #if defined(CONFIG_ISA) || !defined(__mc68000__) | 804 | #if defined(CONFIG_ISA) || !defined(__mc68000__) |
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index 8666171e187b..d3ba2f860ef0 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c | |||
@@ -271,7 +271,7 @@ static int mwave_ioctl(struct inode *inode, struct file *file, | |||
271 | ipcnum, | 271 | ipcnum, |
272 | pDrvData->IPCs[ipcnum].usIntCount); | 272 | pDrvData->IPCs[ipcnum].usIntCount); |
273 | 273 | ||
274 | if (ipcnum > ARRAY_SIZE(pDrvData->IPCs)) { | 274 | if (ipcnum >= ARRAY_SIZE(pDrvData->IPCs)) { |
275 | PRINTK_ERROR(KERN_ERR_MWAVE | 275 | PRINTK_ERROR(KERN_ERR_MWAVE |
276 | "mwavedd::mwave_ioctl:" | 276 | "mwavedd::mwave_ioctl:" |
277 | " IOCTL_MW_REGISTER_IPC:" | 277 | " IOCTL_MW_REGISTER_IPC:" |
diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index b543821d8cb4..56c8243cdb73 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c | |||
@@ -390,7 +390,8 @@ scdrv_init(void) | |||
390 | format_module_id(devnamep, geo_module(geoid), | 390 | format_module_id(devnamep, geo_module(geoid), |
391 | MODULE_FORMAT_BRIEF); | 391 | MODULE_FORMAT_BRIEF); |
392 | devnamep = devname + strlen(devname); | 392 | devnamep = devname + strlen(devname); |
393 | sprintf(devnamep, "#%d", geo_slab(geoid)); | 393 | sprintf(devnamep, "^%d#%d", geo_slot(geoid), |
394 | geo_slab(geoid)); | ||
394 | 395 | ||
395 | /* allocate sysctl device data */ | 396 | /* allocate sysctl device data */ |
396 | scd = kzalloc(sizeof (struct sysctl_data_s), | 397 | scd = kzalloc(sizeof (struct sysctl_data_s), |
diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c index f8dd8527c6aa..a90f5d97df35 100644 --- a/drivers/char/sonypi.c +++ b/drivers/char/sonypi.c | |||
@@ -1341,6 +1341,9 @@ static int __devinit sonypi_probe(struct platform_device *dev) | |||
1341 | else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, | 1341 | else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, |
1342 | PCI_DEVICE_ID_INTEL_ICH6_1, NULL))) | 1342 | PCI_DEVICE_ID_INTEL_ICH6_1, NULL))) |
1343 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3; | 1343 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3; |
1344 | else if ((pcidev = pci_get_device(PCI_VENDOR_ID_INTEL, | ||
1345 | PCI_DEVICE_ID_INTEL_ICH7_1, NULL))) | ||
1346 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE3; | ||
1344 | else | 1347 | else |
1345 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2; | 1348 | sonypi_device.model = SONYPI_DEVICE_MODEL_TYPE2; |
1346 | 1349 | ||
diff --git a/drivers/char/tipar.c b/drivers/char/tipar.c index eb2eb3e12d6a..079db5a935a1 100644 --- a/drivers/char/tipar.c +++ b/drivers/char/tipar.c | |||
@@ -515,7 +515,7 @@ tipar_init_module(void) | |||
515 | err = PTR_ERR(tipar_class); | 515 | err = PTR_ERR(tipar_class); |
516 | goto out_chrdev; | 516 | goto out_chrdev; |
517 | } | 517 | } |
518 | if (parport_register_driver(&tipar_driver) || tp_count == 0) { | 518 | if (parport_register_driver(&tipar_driver)) { |
519 | printk(KERN_ERR "tipar: unable to register with parport\n"); | 519 | printk(KERN_ERR "tipar: unable to register with parport\n"); |
520 | err = -EIO; | 520 | err = -EIO; |
521 | goto out_class; | 521 | goto out_class; |
diff --git a/drivers/char/tpm/Kconfig b/drivers/char/tpm/Kconfig index a6873bf89ffa..1efde3b27619 100644 --- a/drivers/char/tpm/Kconfig +++ b/drivers/char/tpm/Kconfig | |||
@@ -20,9 +20,18 @@ config TCG_TPM | |||
20 | Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI | 20 | Note: For more TPM drivers enable CONFIG_PNP, CONFIG_ACPI |
21 | and CONFIG_PNPACPI. | 21 | and CONFIG_PNPACPI. |
22 | 22 | ||
23 | config TCG_TIS | ||
24 | tristate "TPM Interface Specification 1.2 Interface" | ||
25 | depends on TCG_TPM | ||
26 | ---help--- | ||
27 | If you have a TPM security chip that is compliant with the | ||
28 | TCG TIS 1.2 TPM specification say Yes and it will be accessible | ||
29 | from within Linux. To compile this driver as a module, choose | ||
30 | M here; the module will be called tpm_tis. | ||
31 | |||
23 | config TCG_NSC | 32 | config TCG_NSC |
24 | tristate "National Semiconductor TPM Interface" | 33 | tristate "National Semiconductor TPM Interface" |
25 | depends on TCG_TPM | 34 | depends on TCG_TPM && PNPACPI |
26 | ---help--- | 35 | ---help--- |
27 | If you have a TPM security chip from National Semicondutor | 36 | If you have a TPM security chip from National Semicondutor |
28 | say Yes and it will be accessible from within Linux. To | 37 | say Yes and it will be accessible from within Linux. To |
diff --git a/drivers/char/tpm/Makefile b/drivers/char/tpm/Makefile index ba4582d160fd..ea3a1e02a824 100644 --- a/drivers/char/tpm/Makefile +++ b/drivers/char/tpm/Makefile | |||
@@ -5,6 +5,7 @@ obj-$(CONFIG_TCG_TPM) += tpm.o | |||
5 | ifdef CONFIG_ACPI | 5 | ifdef CONFIG_ACPI |
6 | obj-$(CONFIG_TCG_TPM) += tpm_bios.o | 6 | obj-$(CONFIG_TCG_TPM) += tpm_bios.o |
7 | endif | 7 | endif |
8 | obj-$(CONFIG_TCG_TIS) += tpm_tis.o | ||
8 | obj-$(CONFIG_TCG_NSC) += tpm_nsc.o | 9 | obj-$(CONFIG_TCG_NSC) += tpm_nsc.o |
9 | obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o | 10 | obj-$(CONFIG_TCG_ATMEL) += tpm_atmel.o |
10 | obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o | 11 | obj-$(CONFIG_TCG_INFINEON) += tpm_infineon.o |
diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c index 5a3870477ef1..6889e7db3aff 100644 --- a/drivers/char/tpm/tpm.c +++ b/drivers/char/tpm/tpm.c | |||
@@ -32,12 +32,291 @@ enum tpm_const { | |||
32 | TPM_MINOR = 224, /* officially assigned */ | 32 | TPM_MINOR = 224, /* officially assigned */ |
33 | TPM_BUFSIZE = 2048, | 33 | TPM_BUFSIZE = 2048, |
34 | TPM_NUM_DEVICES = 256, | 34 | TPM_NUM_DEVICES = 256, |
35 | TPM_NUM_MASK_ENTRIES = TPM_NUM_DEVICES / (8 * sizeof(int)) | ||
36 | }; | 35 | }; |
37 | 36 | ||
37 | enum tpm_duration { | ||
38 | TPM_SHORT = 0, | ||
39 | TPM_MEDIUM = 1, | ||
40 | TPM_LONG = 2, | ||
41 | TPM_UNDEFINED, | ||
42 | }; | ||
43 | |||
44 | #define TPM_MAX_ORDINAL 243 | ||
45 | #define TPM_MAX_PROTECTED_ORDINAL 12 | ||
46 | #define TPM_PROTECTED_ORDINAL_MASK 0xFF | ||
47 | |||
38 | static LIST_HEAD(tpm_chip_list); | 48 | static LIST_HEAD(tpm_chip_list); |
39 | static DEFINE_SPINLOCK(driver_lock); | 49 | static DEFINE_SPINLOCK(driver_lock); |
40 | static int dev_mask[TPM_NUM_MASK_ENTRIES]; | 50 | static DECLARE_BITMAP(dev_mask, TPM_NUM_DEVICES); |
51 | |||
52 | /* | ||
53 | * Array with one entry per ordinal defining the maximum amount | ||
54 | * of time the chip could take to return the result. The ordinal | ||
55 | * designation of short, medium or long is defined in a table in | ||
56 | * TCG Specification TPM Main Part 2 TPM Structures Section 17. The | ||
57 | * values of the SHORT, MEDIUM, and LONG durations are retrieved | ||
58 | * from the chip during initialization with a call to tpm_get_timeouts. | ||
59 | */ | ||
60 | static const u8 tpm_protected_ordinal_duration[TPM_MAX_PROTECTED_ORDINAL] = { | ||
61 | TPM_UNDEFINED, /* 0 */ | ||
62 | TPM_UNDEFINED, | ||
63 | TPM_UNDEFINED, | ||
64 | TPM_UNDEFINED, | ||
65 | TPM_UNDEFINED, | ||
66 | TPM_UNDEFINED, /* 5 */ | ||
67 | TPM_UNDEFINED, | ||
68 | TPM_UNDEFINED, | ||
69 | TPM_UNDEFINED, | ||
70 | TPM_UNDEFINED, | ||
71 | TPM_SHORT, /* 10 */ | ||
72 | TPM_SHORT, | ||
73 | }; | ||
74 | |||
75 | static const u8 tpm_ordinal_duration[TPM_MAX_ORDINAL] = { | ||
76 | TPM_UNDEFINED, /* 0 */ | ||
77 | TPM_UNDEFINED, | ||
78 | TPM_UNDEFINED, | ||
79 | TPM_UNDEFINED, | ||
80 | TPM_UNDEFINED, | ||
81 | TPM_UNDEFINED, /* 5 */ | ||
82 | TPM_UNDEFINED, | ||
83 | TPM_UNDEFINED, | ||
84 | TPM_UNDEFINED, | ||
85 | TPM_UNDEFINED, | ||
86 | TPM_SHORT, /* 10 */ | ||
87 | TPM_SHORT, | ||
88 | TPM_MEDIUM, | ||
89 | TPM_LONG, | ||
90 | TPM_LONG, | ||
91 | TPM_MEDIUM, /* 15 */ | ||
92 | TPM_SHORT, | ||
93 | TPM_SHORT, | ||
94 | TPM_MEDIUM, | ||
95 | TPM_LONG, | ||
96 | TPM_SHORT, /* 20 */ | ||
97 | TPM_SHORT, | ||
98 | TPM_MEDIUM, | ||
99 | TPM_MEDIUM, | ||
100 | TPM_MEDIUM, | ||
101 | TPM_SHORT, /* 25 */ | ||
102 | TPM_SHORT, | ||
103 | TPM_MEDIUM, | ||
104 | TPM_SHORT, | ||
105 | TPM_SHORT, | ||
106 | TPM_MEDIUM, /* 30 */ | ||
107 | TPM_LONG, | ||
108 | TPM_MEDIUM, | ||
109 | TPM_SHORT, | ||
110 | TPM_SHORT, | ||
111 | TPM_SHORT, /* 35 */ | ||
112 | TPM_MEDIUM, | ||
113 | TPM_MEDIUM, | ||
114 | TPM_UNDEFINED, | ||
115 | TPM_UNDEFINED, | ||
116 | TPM_MEDIUM, /* 40 */ | ||
117 | TPM_LONG, | ||
118 | TPM_MEDIUM, | ||
119 | TPM_SHORT, | ||
120 | TPM_SHORT, | ||
121 | TPM_SHORT, /* 45 */ | ||
122 | TPM_SHORT, | ||
123 | TPM_SHORT, | ||
124 | TPM_SHORT, | ||
125 | TPM_LONG, | ||
126 | TPM_MEDIUM, /* 50 */ | ||
127 | TPM_MEDIUM, | ||
128 | TPM_UNDEFINED, | ||
129 | TPM_UNDEFINED, | ||
130 | TPM_UNDEFINED, | ||
131 | TPM_UNDEFINED, /* 55 */ | ||
132 | TPM_UNDEFINED, | ||
133 | TPM_UNDEFINED, | ||
134 | TPM_UNDEFINED, | ||
135 | TPM_UNDEFINED, | ||
136 | TPM_MEDIUM, /* 60 */ | ||
137 | TPM_MEDIUM, | ||
138 | TPM_MEDIUM, | ||
139 | TPM_SHORT, | ||
140 | TPM_SHORT, | ||
141 | TPM_MEDIUM, /* 65 */ | ||
142 | TPM_UNDEFINED, | ||
143 | TPM_UNDEFINED, | ||
144 | TPM_UNDEFINED, | ||
145 | TPM_UNDEFINED, | ||
146 | TPM_SHORT, /* 70 */ | ||
147 | TPM_SHORT, | ||
148 | TPM_UNDEFINED, | ||
149 | TPM_UNDEFINED, | ||
150 | TPM_UNDEFINED, | ||
151 | TPM_UNDEFINED, /* 75 */ | ||
152 | TPM_UNDEFINED, | ||
153 | TPM_UNDEFINED, | ||
154 | TPM_UNDEFINED, | ||
155 | TPM_UNDEFINED, | ||
156 | TPM_LONG, /* 80 */ | ||
157 | TPM_UNDEFINED, | ||
158 | TPM_MEDIUM, | ||
159 | TPM_LONG, | ||
160 | TPM_SHORT, | ||
161 | TPM_UNDEFINED, /* 85 */ | ||
162 | TPM_UNDEFINED, | ||
163 | TPM_UNDEFINED, | ||
164 | TPM_UNDEFINED, | ||
165 | TPM_UNDEFINED, | ||
166 | TPM_SHORT, /* 90 */ | ||
167 | TPM_SHORT, | ||
168 | TPM_SHORT, | ||
169 | TPM_SHORT, | ||
170 | TPM_SHORT, | ||
171 | TPM_UNDEFINED, /* 95 */ | ||
172 | TPM_UNDEFINED, | ||
173 | TPM_UNDEFINED, | ||
174 | TPM_UNDEFINED, | ||
175 | TPM_UNDEFINED, | ||
176 | TPM_MEDIUM, /* 100 */ | ||
177 | TPM_SHORT, | ||
178 | TPM_SHORT, | ||
179 | TPM_UNDEFINED, | ||
180 | TPM_UNDEFINED, | ||
181 | TPM_UNDEFINED, /* 105 */ | ||
182 | TPM_UNDEFINED, | ||
183 | TPM_UNDEFINED, | ||
184 | TPM_UNDEFINED, | ||
185 | TPM_UNDEFINED, | ||
186 | TPM_SHORT, /* 110 */ | ||
187 | TPM_SHORT, | ||
188 | TPM_SHORT, | ||
189 | TPM_SHORT, | ||
190 | TPM_SHORT, | ||
191 | TPM_SHORT, /* 115 */ | ||
192 | TPM_SHORT, | ||
193 | TPM_SHORT, | ||
194 | TPM_UNDEFINED, | ||
195 | TPM_UNDEFINED, | ||
196 | TPM_LONG, /* 120 */ | ||
197 | TPM_LONG, | ||
198 | TPM_MEDIUM, | ||
199 | TPM_UNDEFINED, | ||
200 | TPM_SHORT, | ||
201 | TPM_SHORT, /* 125 */ | ||
202 | TPM_SHORT, | ||
203 | TPM_LONG, | ||
204 | TPM_SHORT, | ||
205 | TPM_SHORT, | ||
206 | TPM_SHORT, /* 130 */ | ||
207 | TPM_MEDIUM, | ||
208 | TPM_UNDEFINED, | ||
209 | TPM_SHORT, | ||
210 | TPM_MEDIUM, | ||
211 | TPM_UNDEFINED, /* 135 */ | ||
212 | TPM_UNDEFINED, | ||
213 | TPM_UNDEFINED, | ||
214 | TPM_UNDEFINED, | ||
215 | TPM_UNDEFINED, | ||
216 | TPM_SHORT, /* 140 */ | ||
217 | TPM_SHORT, | ||
218 | TPM_UNDEFINED, | ||
219 | TPM_UNDEFINED, | ||
220 | TPM_UNDEFINED, | ||
221 | TPM_UNDEFINED, /* 145 */ | ||
222 | TPM_UNDEFINED, | ||
223 | TPM_UNDEFINED, | ||
224 | TPM_UNDEFINED, | ||
225 | TPM_UNDEFINED, | ||
226 | TPM_SHORT, /* 150 */ | ||
227 | TPM_MEDIUM, | ||
228 | TPM_MEDIUM, | ||
229 | TPM_SHORT, | ||
230 | TPM_SHORT, | ||
231 | TPM_UNDEFINED, /* 155 */ | ||
232 | TPM_UNDEFINED, | ||
233 | TPM_UNDEFINED, | ||
234 | TPM_UNDEFINED, | ||
235 | TPM_UNDEFINED, | ||
236 | TPM_SHORT, /* 160 */ | ||
237 | TPM_SHORT, | ||
238 | TPM_SHORT, | ||
239 | TPM_SHORT, | ||
240 | TPM_UNDEFINED, | ||
241 | TPM_UNDEFINED, /* 165 */ | ||
242 | TPM_UNDEFINED, | ||
243 | TPM_UNDEFINED, | ||
244 | TPM_UNDEFINED, | ||
245 | TPM_UNDEFINED, | ||
246 | TPM_LONG, /* 170 */ | ||
247 | TPM_UNDEFINED, | ||
248 | TPM_UNDEFINED, | ||
249 | TPM_UNDEFINED, | ||
250 | TPM_UNDEFINED, | ||
251 | TPM_UNDEFINED, /* 175 */ | ||
252 | TPM_UNDEFINED, | ||
253 | TPM_UNDEFINED, | ||
254 | TPM_UNDEFINED, | ||
255 | TPM_UNDEFINED, | ||
256 | TPM_MEDIUM, /* 180 */ | ||
257 | TPM_SHORT, | ||
258 | TPM_MEDIUM, | ||
259 | TPM_MEDIUM, | ||
260 | TPM_MEDIUM, | ||
261 | TPM_MEDIUM, /* 185 */ | ||
262 | TPM_SHORT, | ||
263 | TPM_UNDEFINED, | ||
264 | TPM_UNDEFINED, | ||
265 | TPM_UNDEFINED, | ||
266 | TPM_UNDEFINED, /* 190 */ | ||
267 | TPM_UNDEFINED, | ||
268 | TPM_UNDEFINED, | ||
269 | TPM_UNDEFINED, | ||
270 | TPM_UNDEFINED, | ||
271 | TPM_UNDEFINED, /* 195 */ | ||
272 | TPM_UNDEFINED, | ||
273 | TPM_UNDEFINED, | ||
274 | TPM_UNDEFINED, | ||
275 | TPM_UNDEFINED, | ||
276 | TPM_SHORT, /* 200 */ | ||
277 | TPM_UNDEFINED, | ||
278 | TPM_UNDEFINED, | ||
279 | TPM_UNDEFINED, | ||
280 | TPM_SHORT, | ||
281 | TPM_SHORT, /* 205 */ | ||
282 | TPM_SHORT, | ||
283 | TPM_SHORT, | ||
284 | TPM_SHORT, | ||
285 | TPM_SHORT, | ||
286 | TPM_MEDIUM, /* 210 */ | ||
287 | TPM_UNDEFINED, | ||
288 | TPM_MEDIUM, | ||
289 | TPM_MEDIUM, | ||
290 | TPM_MEDIUM, | ||
291 | TPM_UNDEFINED, /* 215 */ | ||
292 | TPM_MEDIUM, | ||
293 | TPM_UNDEFINED, | ||
294 | TPM_UNDEFINED, | ||
295 | TPM_SHORT, | ||
296 | TPM_SHORT, /* 220 */ | ||
297 | TPM_SHORT, | ||
298 | TPM_SHORT, | ||
299 | TPM_SHORT, | ||
300 | TPM_SHORT, | ||
301 | TPM_UNDEFINED, /* 225 */ | ||
302 | TPM_UNDEFINED, | ||
303 | TPM_UNDEFINED, | ||
304 | TPM_UNDEFINED, | ||
305 | TPM_UNDEFINED, | ||
306 | TPM_SHORT, /* 230 */ | ||
307 | TPM_LONG, | ||
308 | TPM_MEDIUM, | ||
309 | TPM_UNDEFINED, | ||
310 | TPM_UNDEFINED, | ||
311 | TPM_UNDEFINED, /* 235 */ | ||
312 | TPM_UNDEFINED, | ||
313 | TPM_UNDEFINED, | ||
314 | TPM_UNDEFINED, | ||
315 | TPM_UNDEFINED, | ||
316 | TPM_SHORT, /* 240 */ | ||
317 | TPM_UNDEFINED, | ||
318 | TPM_MEDIUM, | ||
319 | }; | ||
41 | 320 | ||
42 | static void user_reader_timeout(unsigned long ptr) | 321 | static void user_reader_timeout(unsigned long ptr) |
43 | { | 322 | { |
@@ -46,7 +325,7 @@ static void user_reader_timeout(unsigned long ptr) | |||
46 | schedule_work(&chip->work); | 325 | schedule_work(&chip->work); |
47 | } | 326 | } |
48 | 327 | ||
49 | static void timeout_work(void * ptr) | 328 | static void timeout_work(void *ptr) |
50 | { | 329 | { |
51 | struct tpm_chip *chip = ptr; | 330 | struct tpm_chip *chip = ptr; |
52 | 331 | ||
@@ -57,17 +336,43 @@ static void timeout_work(void * ptr) | |||
57 | } | 336 | } |
58 | 337 | ||
59 | /* | 338 | /* |
339 | * Returns max number of jiffies to wait | ||
340 | */ | ||
341 | unsigned long tpm_calc_ordinal_duration(struct tpm_chip *chip, | ||
342 | u32 ordinal) | ||
343 | { | ||
344 | int duration_idx = TPM_UNDEFINED; | ||
345 | int duration = 0; | ||
346 | |||
347 | if (ordinal < TPM_MAX_ORDINAL) | ||
348 | duration_idx = tpm_ordinal_duration[ordinal]; | ||
349 | else if ((ordinal & TPM_PROTECTED_ORDINAL_MASK) < | ||
350 | TPM_MAX_PROTECTED_ORDINAL) | ||
351 | duration_idx = | ||
352 | tpm_protected_ordinal_duration[ordinal & | ||
353 | TPM_PROTECTED_ORDINAL_MASK]; | ||
354 | |||
355 | if (duration_idx != TPM_UNDEFINED) | ||
356 | duration = chip->vendor.duration[duration_idx]; | ||
357 | if (duration <= 0) | ||
358 | return 2 * 60 * HZ; | ||
359 | else | ||
360 | return duration; | ||
361 | } | ||
362 | EXPORT_SYMBOL_GPL(tpm_calc_ordinal_duration); | ||
363 | |||
364 | /* | ||
60 | * Internal kernel interface to transmit TPM commands | 365 | * Internal kernel interface to transmit TPM commands |
61 | */ | 366 | */ |
62 | static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | 367 | static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, |
63 | size_t bufsiz) | 368 | size_t bufsiz) |
64 | { | 369 | { |
65 | ssize_t rc; | 370 | ssize_t rc; |
66 | u32 count; | 371 | u32 count, ordinal; |
67 | unsigned long stop; | 372 | unsigned long stop; |
68 | 373 | ||
69 | count = be32_to_cpu(*((__be32 *) (buf + 2))); | 374 | count = be32_to_cpu(*((__be32 *) (buf + 2))); |
70 | 375 | ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); | |
71 | if (count == 0) | 376 | if (count == 0) |
72 | return -ENODATA; | 377 | return -ENODATA; |
73 | if (count > bufsiz) { | 378 | if (count > bufsiz) { |
@@ -78,21 +383,23 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
78 | 383 | ||
79 | down(&chip->tpm_mutex); | 384 | down(&chip->tpm_mutex); |
80 | 385 | ||
81 | if ((rc = chip->vendor->send(chip, (u8 *) buf, count)) < 0) { | 386 | if ((rc = chip->vendor.send(chip, (u8 *) buf, count)) < 0) { |
82 | dev_err(chip->dev, | 387 | dev_err(chip->dev, |
83 | "tpm_transmit: tpm_send: error %zd\n", rc); | 388 | "tpm_transmit: tpm_send: error %zd\n", rc); |
84 | goto out; | 389 | goto out; |
85 | } | 390 | } |
86 | 391 | ||
87 | stop = jiffies + 2 * 60 * HZ; | 392 | if (chip->vendor.irq) |
393 | goto out_recv; | ||
394 | |||
395 | stop = jiffies + tpm_calc_ordinal_duration(chip, ordinal); | ||
88 | do { | 396 | do { |
89 | u8 status = chip->vendor->status(chip); | 397 | u8 status = chip->vendor.status(chip); |
90 | if ((status & chip->vendor->req_complete_mask) == | 398 | if ((status & chip->vendor.req_complete_mask) == |
91 | chip->vendor->req_complete_val) { | 399 | chip->vendor.req_complete_val) |
92 | goto out_recv; | 400 | goto out_recv; |
93 | } | ||
94 | 401 | ||
95 | if ((status == chip->vendor->req_canceled)) { | 402 | if ((status == chip->vendor.req_canceled)) { |
96 | dev_err(chip->dev, "Operation Canceled\n"); | 403 | dev_err(chip->dev, "Operation Canceled\n"); |
97 | rc = -ECANCELED; | 404 | rc = -ECANCELED; |
98 | goto out; | 405 | goto out; |
@@ -102,14 +409,13 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf, | |||
102 | rmb(); | 409 | rmb(); |
103 | } while (time_before(jiffies, stop)); | 410 | } while (time_before(jiffies, stop)); |
104 | 411 | ||
105 | 412 | chip->vendor.cancel(chip); | |
106 | chip->vendor->cancel(chip); | ||
107 | dev_err(chip->dev, "Operation Timed out\n"); | 413 | dev_err(chip->dev, "Operation Timed out\n"); |
108 | rc = -ETIME; | 414 | rc = -ETIME; |
109 | goto out; | 415 | goto out; |
110 | 416 | ||
111 | out_recv: | 417 | out_recv: |
112 | rc = chip->vendor->recv(chip, (u8 *) buf, bufsiz); | 418 | rc = chip->vendor.recv(chip, (u8 *) buf, bufsiz); |
113 | if (rc < 0) | 419 | if (rc < 0) |
114 | dev_err(chip->dev, | 420 | dev_err(chip->dev, |
115 | "tpm_transmit: tpm_recv: error %zd\n", rc); | 421 | "tpm_transmit: tpm_recv: error %zd\n", rc); |
@@ -119,17 +425,247 @@ out: | |||
119 | } | 425 | } |
120 | 426 | ||
121 | #define TPM_DIGEST_SIZE 20 | 427 | #define TPM_DIGEST_SIZE 20 |
122 | #define CAP_PCR_RESULT_SIZE 18 | 428 | #define TPM_ERROR_SIZE 10 |
123 | static const u8 cap_pcr[] = { | 429 | #define TPM_RET_CODE_IDX 6 |
430 | #define TPM_GET_CAP_RET_SIZE_IDX 10 | ||
431 | #define TPM_GET_CAP_RET_UINT32_1_IDX 14 | ||
432 | #define TPM_GET_CAP_RET_UINT32_2_IDX 18 | ||
433 | #define TPM_GET_CAP_RET_UINT32_3_IDX 22 | ||
434 | #define TPM_GET_CAP_RET_UINT32_4_IDX 26 | ||
435 | #define TPM_GET_CAP_PERM_DISABLE_IDX 16 | ||
436 | #define TPM_GET_CAP_PERM_INACTIVE_IDX 18 | ||
437 | #define TPM_GET_CAP_RET_BOOL_1_IDX 14 | ||
438 | #define TPM_GET_CAP_TEMP_INACTIVE_IDX 16 | ||
439 | |||
440 | #define TPM_CAP_IDX 13 | ||
441 | #define TPM_CAP_SUBCAP_IDX 21 | ||
442 | |||
443 | enum tpm_capabilities { | ||
444 | TPM_CAP_FLAG = 4, | ||
445 | TPM_CAP_PROP = 5, | ||
446 | }; | ||
447 | |||
448 | enum tpm_sub_capabilities { | ||
449 | TPM_CAP_PROP_PCR = 0x1, | ||
450 | TPM_CAP_PROP_MANUFACTURER = 0x3, | ||
451 | TPM_CAP_FLAG_PERM = 0x8, | ||
452 | TPM_CAP_FLAG_VOL = 0x9, | ||
453 | TPM_CAP_PROP_OWNER = 0x11, | ||
454 | TPM_CAP_PROP_TIS_TIMEOUT = 0x15, | ||
455 | TPM_CAP_PROP_TIS_DURATION = 0x20, | ||
456 | }; | ||
457 | |||
458 | /* | ||
459 | * This is a semi generic GetCapability command for use | ||
460 | * with the capability type TPM_CAP_PROP or TPM_CAP_FLAG | ||
461 | * and their associated sub_capabilities. | ||
462 | */ | ||
463 | |||
464 | static const u8 tpm_cap[] = { | ||
124 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | 465 | 0, 193, /* TPM_TAG_RQU_COMMAND */ |
125 | 0, 0, 0, 22, /* length */ | 466 | 0, 0, 0, 22, /* length */ |
126 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ | 467 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ |
127 | 0, 0, 0, 5, | 468 | 0, 0, 0, 0, /* TPM_CAP_<TYPE> */ |
128 | 0, 0, 0, 4, | 469 | 0, 0, 0, 4, /* TPM_CAP_SUB_<TYPE> size */ |
129 | 0, 0, 1, 1 | 470 | 0, 0, 1, 0 /* TPM_CAP_SUB_<TYPE> */ |
130 | }; | 471 | }; |
131 | 472 | ||
132 | #define READ_PCR_RESULT_SIZE 30 | 473 | static ssize_t transmit_cmd(struct tpm_chip *chip, u8 *data, int len, |
474 | char *desc) | ||
475 | { | ||
476 | int err; | ||
477 | |||
478 | len = tpm_transmit(chip, data, len); | ||
479 | if (len < 0) | ||
480 | return len; | ||
481 | if (len == TPM_ERROR_SIZE) { | ||
482 | err = be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX))); | ||
483 | dev_dbg(chip->dev, "A TPM error (%d) occurred %s\n", err, desc); | ||
484 | return err; | ||
485 | } | ||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | void tpm_gen_interrupt(struct tpm_chip *chip) | ||
490 | { | ||
491 | u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)]; | ||
492 | ssize_t rc; | ||
493 | |||
494 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
495 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
496 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT; | ||
497 | |||
498 | rc = transmit_cmd(chip, data, sizeof(data), | ||
499 | "attempting to determine the timeouts"); | ||
500 | } | ||
501 | EXPORT_SYMBOL_GPL(tpm_gen_interrupt); | ||
502 | |||
503 | void tpm_get_timeouts(struct tpm_chip *chip) | ||
504 | { | ||
505 | u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 30)]; | ||
506 | ssize_t rc; | ||
507 | u32 timeout; | ||
508 | |||
509 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
510 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
511 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_TIMEOUT; | ||
512 | |||
513 | rc = transmit_cmd(chip, data, sizeof(data), | ||
514 | "attempting to determine the timeouts"); | ||
515 | if (rc) | ||
516 | goto duration; | ||
517 | |||
518 | if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX))) | ||
519 | != 4 * sizeof(u32)) | ||
520 | goto duration; | ||
521 | |||
522 | /* Don't overwrite default if value is 0 */ | ||
523 | timeout = | ||
524 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX))); | ||
525 | if (timeout) | ||
526 | chip->vendor.timeout_a = msecs_to_jiffies(timeout); | ||
527 | timeout = | ||
528 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_2_IDX))); | ||
529 | if (timeout) | ||
530 | chip->vendor.timeout_b = msecs_to_jiffies(timeout); | ||
531 | timeout = | ||
532 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_3_IDX))); | ||
533 | if (timeout) | ||
534 | chip->vendor.timeout_c = msecs_to_jiffies(timeout); | ||
535 | timeout = | ||
536 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_4_IDX))); | ||
537 | if (timeout) | ||
538 | chip->vendor.timeout_d = msecs_to_jiffies(timeout); | ||
539 | |||
540 | duration: | ||
541 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
542 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
543 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_TIS_DURATION; | ||
544 | |||
545 | rc = transmit_cmd(chip, data, sizeof(data), | ||
546 | "attempting to determine the durations"); | ||
547 | if (rc) | ||
548 | return; | ||
549 | |||
550 | if (be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_SIZE_IDX))) | ||
551 | != 3 * sizeof(u32)) | ||
552 | return; | ||
553 | |||
554 | chip->vendor.duration[TPM_SHORT] = | ||
555 | msecs_to_jiffies(be32_to_cpu | ||
556 | (*((__be32 *) (data + | ||
557 | TPM_GET_CAP_RET_UINT32_1_IDX)))); | ||
558 | chip->vendor.duration[TPM_MEDIUM] = | ||
559 | msecs_to_jiffies(be32_to_cpu | ||
560 | (*((__be32 *) (data + | ||
561 | TPM_GET_CAP_RET_UINT32_2_IDX)))); | ||
562 | chip->vendor.duration[TPM_LONG] = | ||
563 | msecs_to_jiffies(be32_to_cpu | ||
564 | (*((__be32 *) (data + | ||
565 | TPM_GET_CAP_RET_UINT32_3_IDX)))); | ||
566 | } | ||
567 | EXPORT_SYMBOL_GPL(tpm_get_timeouts); | ||
568 | |||
569 | void tpm_continue_selftest(struct tpm_chip *chip) | ||
570 | { | ||
571 | u8 data[] = { | ||
572 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | ||
573 | 0, 0, 0, 10, /* length */ | ||
574 | 0, 0, 0, 83, /* TPM_ORD_GetCapability */ | ||
575 | }; | ||
576 | |||
577 | tpm_transmit(chip, data, sizeof(data)); | ||
578 | } | ||
579 | EXPORT_SYMBOL_GPL(tpm_continue_selftest); | ||
580 | |||
581 | ssize_t tpm_show_enabled(struct device * dev, struct device_attribute * attr, | ||
582 | char *buf) | ||
583 | { | ||
584 | u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)]; | ||
585 | ssize_t rc; | ||
586 | |||
587 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
588 | if (chip == NULL) | ||
589 | return -ENODEV; | ||
590 | |||
591 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
592 | data[TPM_CAP_IDX] = TPM_CAP_FLAG; | ||
593 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM; | ||
594 | |||
595 | rc = transmit_cmd(chip, data, sizeof(data), | ||
596 | "attemtping to determine the permanent state"); | ||
597 | if (rc) | ||
598 | return 0; | ||
599 | return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_DISABLE_IDX]); | ||
600 | } | ||
601 | EXPORT_SYMBOL_GPL(tpm_show_enabled); | ||
602 | |||
603 | ssize_t tpm_show_active(struct device * dev, struct device_attribute * attr, | ||
604 | char *buf) | ||
605 | { | ||
606 | u8 data[max_t(int, ARRAY_SIZE(tpm_cap), 35)]; | ||
607 | ssize_t rc; | ||
608 | |||
609 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
610 | if (chip == NULL) | ||
611 | return -ENODEV; | ||
612 | |||
613 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
614 | data[TPM_CAP_IDX] = TPM_CAP_FLAG; | ||
615 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_PERM; | ||
616 | |||
617 | rc = transmit_cmd(chip, data, sizeof(data), | ||
618 | "attemtping to determine the permanent state"); | ||
619 | if (rc) | ||
620 | return 0; | ||
621 | return sprintf(buf, "%d\n", !data[TPM_GET_CAP_PERM_INACTIVE_IDX]); | ||
622 | } | ||
623 | EXPORT_SYMBOL_GPL(tpm_show_active); | ||
624 | |||
625 | ssize_t tpm_show_owned(struct device * dev, struct device_attribute * attr, | ||
626 | char *buf) | ||
627 | { | ||
628 | u8 data[sizeof(tpm_cap)]; | ||
629 | ssize_t rc; | ||
630 | |||
631 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
632 | if (chip == NULL) | ||
633 | return -ENODEV; | ||
634 | |||
635 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
636 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
637 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_OWNER; | ||
638 | |||
639 | rc = transmit_cmd(chip, data, sizeof(data), | ||
640 | "attempting to determine the owner state"); | ||
641 | if (rc) | ||
642 | return 0; | ||
643 | return sprintf(buf, "%d\n", data[TPM_GET_CAP_RET_BOOL_1_IDX]); | ||
644 | } | ||
645 | EXPORT_SYMBOL_GPL(tpm_show_owned); | ||
646 | |||
647 | ssize_t tpm_show_temp_deactivated(struct device * dev, | ||
648 | struct device_attribute * attr, char *buf) | ||
649 | { | ||
650 | u8 data[sizeof(tpm_cap)]; | ||
651 | ssize_t rc; | ||
652 | |||
653 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
654 | if (chip == NULL) | ||
655 | return -ENODEV; | ||
656 | |||
657 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
658 | data[TPM_CAP_IDX] = TPM_CAP_FLAG; | ||
659 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_FLAG_VOL; | ||
660 | |||
661 | rc = transmit_cmd(chip, data, sizeof(data), | ||
662 | "attempting to determine the temporary state"); | ||
663 | if (rc) | ||
664 | return 0; | ||
665 | return sprintf(buf, "%d\n", data[TPM_GET_CAP_TEMP_INACTIVE_IDX]); | ||
666 | } | ||
667 | EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); | ||
668 | |||
133 | static const u8 pcrread[] = { | 669 | static const u8 pcrread[] = { |
134 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | 670 | 0, 193, /* TPM_TAG_RQU_COMMAND */ |
135 | 0, 0, 0, 14, /* length */ | 671 | 0, 0, 0, 14, /* length */ |
@@ -140,8 +676,8 @@ static const u8 pcrread[] = { | |||
140 | ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, | 676 | ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, |
141 | char *buf) | 677 | char *buf) |
142 | { | 678 | { |
143 | u8 data[READ_PCR_RESULT_SIZE]; | 679 | u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(pcrread)), 30)]; |
144 | ssize_t len; | 680 | ssize_t rc; |
145 | int i, j, num_pcrs; | 681 | int i, j, num_pcrs; |
146 | __be32 index; | 682 | __be32 index; |
147 | char *str = buf; | 683 | char *str = buf; |
@@ -150,29 +686,24 @@ ssize_t tpm_show_pcrs(struct device *dev, struct device_attribute *attr, | |||
150 | if (chip == NULL) | 686 | if (chip == NULL) |
151 | return -ENODEV; | 687 | return -ENODEV; |
152 | 688 | ||
153 | memcpy(data, cap_pcr, sizeof(cap_pcr)); | 689 | memcpy(data, tpm_cap, sizeof(tpm_cap)); |
154 | if ((len = tpm_transmit(chip, data, sizeof(data))) | 690 | data[TPM_CAP_IDX] = TPM_CAP_PROP; |
155 | < CAP_PCR_RESULT_SIZE) { | 691 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_PCR; |
156 | dev_dbg(chip->dev, "A TPM error (%d) occurred " | 692 | |
157 | "attempting to determine the number of PCRS\n", | 693 | rc = transmit_cmd(chip, data, sizeof(data), |
158 | be32_to_cpu(*((__be32 *) (data + 6)))); | 694 | "attempting to determine the number of PCRS"); |
695 | if (rc) | ||
159 | return 0; | 696 | return 0; |
160 | } | ||
161 | 697 | ||
162 | num_pcrs = be32_to_cpu(*((__be32 *) (data + 14))); | 698 | num_pcrs = be32_to_cpu(*((__be32 *) (data + 14))); |
163 | |||
164 | for (i = 0; i < num_pcrs; i++) { | 699 | for (i = 0; i < num_pcrs; i++) { |
165 | memcpy(data, pcrread, sizeof(pcrread)); | 700 | memcpy(data, pcrread, sizeof(pcrread)); |
166 | index = cpu_to_be32(i); | 701 | index = cpu_to_be32(i); |
167 | memcpy(data + 10, &index, 4); | 702 | memcpy(data + 10, &index, 4); |
168 | if ((len = tpm_transmit(chip, data, sizeof(data))) | 703 | rc = transmit_cmd(chip, data, sizeof(data), |
169 | < READ_PCR_RESULT_SIZE){ | 704 | "attempting to read a PCR"); |
170 | dev_dbg(chip->dev, "A TPM error (%d) occurred" | 705 | if (rc) |
171 | " attempting to read PCR %d of %d\n", | ||
172 | be32_to_cpu(*((__be32 *) (data + 6))), | ||
173 | i, num_pcrs); | ||
174 | goto out; | 706 | goto out; |
175 | } | ||
176 | str += sprintf(str, "PCR-%02d: ", i); | 707 | str += sprintf(str, "PCR-%02d: ", i); |
177 | for (j = 0; j < TPM_DIGEST_SIZE; j++) | 708 | for (j = 0; j < TPM_DIGEST_SIZE; j++) |
178 | str += sprintf(str, "%02X ", *(data + 10 + j)); | 709 | str += sprintf(str, "%02X ", *(data + 10 + j)); |
@@ -194,7 +725,7 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, | |||
194 | char *buf) | 725 | char *buf) |
195 | { | 726 | { |
196 | u8 *data; | 727 | u8 *data; |
197 | ssize_t len; | 728 | ssize_t err; |
198 | int i, rc; | 729 | int i, rc; |
199 | char *str = buf; | 730 | char *str = buf; |
200 | 731 | ||
@@ -208,14 +739,10 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, | |||
208 | 739 | ||
209 | memcpy(data, readpubek, sizeof(readpubek)); | 740 | memcpy(data, readpubek, sizeof(readpubek)); |
210 | 741 | ||
211 | if ((len = tpm_transmit(chip, data, READ_PUBEK_RESULT_SIZE)) < | 742 | err = transmit_cmd(chip, data, READ_PUBEK_RESULT_SIZE, |
212 | READ_PUBEK_RESULT_SIZE) { | 743 | "attempting to read the PUBEK"); |
213 | dev_dbg(chip->dev, "A TPM error (%d) occurred " | 744 | if (err) |
214 | "attempting to read the PUBEK\n", | ||
215 | be32_to_cpu(*((__be32 *) (data + 6)))); | ||
216 | rc = 0; | ||
217 | goto out; | 745 | goto out; |
218 | } | ||
219 | 746 | ||
220 | /* | 747 | /* |
221 | ignore header 10 bytes | 748 | ignore header 10 bytes |
@@ -245,67 +772,110 @@ ssize_t tpm_show_pubek(struct device *dev, struct device_attribute *attr, | |||
245 | if ((i + 1) % 16 == 0) | 772 | if ((i + 1) % 16 == 0) |
246 | str += sprintf(str, "\n"); | 773 | str += sprintf(str, "\n"); |
247 | } | 774 | } |
248 | rc = str - buf; | ||
249 | out: | 775 | out: |
776 | rc = str - buf; | ||
250 | kfree(data); | 777 | kfree(data); |
251 | return rc; | 778 | return rc; |
252 | } | 779 | } |
253 | EXPORT_SYMBOL_GPL(tpm_show_pubek); | 780 | EXPORT_SYMBOL_GPL(tpm_show_pubek); |
254 | 781 | ||
255 | #define CAP_VER_RESULT_SIZE 18 | 782 | #define CAP_VERSION_1_1 6 |
783 | #define CAP_VERSION_1_2 0x1A | ||
784 | #define CAP_VERSION_IDX 13 | ||
256 | static const u8 cap_version[] = { | 785 | static const u8 cap_version[] = { |
257 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | 786 | 0, 193, /* TPM_TAG_RQU_COMMAND */ |
258 | 0, 0, 0, 18, /* length */ | 787 | 0, 0, 0, 18, /* length */ |
259 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ | 788 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ |
260 | 0, 0, 0, 6, | 789 | 0, 0, 0, 0, |
261 | 0, 0, 0, 0 | 790 | 0, 0, 0, 0 |
262 | }; | 791 | }; |
263 | 792 | ||
264 | #define CAP_MANUFACTURER_RESULT_SIZE 18 | ||
265 | static const u8 cap_manufacturer[] = { | ||
266 | 0, 193, /* TPM_TAG_RQU_COMMAND */ | ||
267 | 0, 0, 0, 22, /* length */ | ||
268 | 0, 0, 0, 101, /* TPM_ORD_GetCapability */ | ||
269 | 0, 0, 0, 5, | ||
270 | 0, 0, 0, 4, | ||
271 | 0, 0, 1, 3 | ||
272 | }; | ||
273 | |||
274 | ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, | 793 | ssize_t tpm_show_caps(struct device *dev, struct device_attribute *attr, |
275 | char *buf) | 794 | char *buf) |
276 | { | 795 | { |
277 | u8 data[sizeof(cap_manufacturer)]; | 796 | u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)]; |
278 | ssize_t len; | 797 | ssize_t rc; |
279 | char *str = buf; | 798 | char *str = buf; |
280 | 799 | ||
281 | struct tpm_chip *chip = dev_get_drvdata(dev); | 800 | struct tpm_chip *chip = dev_get_drvdata(dev); |
282 | if (chip == NULL) | 801 | if (chip == NULL) |
283 | return -ENODEV; | 802 | return -ENODEV; |
284 | 803 | ||
285 | memcpy(data, cap_manufacturer, sizeof(cap_manufacturer)); | 804 | memcpy(data, tpm_cap, sizeof(tpm_cap)); |
805 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
806 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER; | ||
286 | 807 | ||
287 | if ((len = tpm_transmit(chip, data, sizeof(data))) < | 808 | rc = transmit_cmd(chip, data, sizeof(data), |
288 | CAP_MANUFACTURER_RESULT_SIZE) | 809 | "attempting to determine the manufacturer"); |
289 | return len; | 810 | if (rc) |
811 | return 0; | ||
290 | 812 | ||
291 | str += sprintf(str, "Manufacturer: 0x%x\n", | 813 | str += sprintf(str, "Manufacturer: 0x%x\n", |
292 | be32_to_cpu(*((__be32 *) (data + 14)))); | 814 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)))); |
293 | 815 | ||
294 | memcpy(data, cap_version, sizeof(cap_version)); | 816 | memcpy(data, cap_version, sizeof(cap_version)); |
817 | data[CAP_VERSION_IDX] = CAP_VERSION_1_1; | ||
818 | rc = transmit_cmd(chip, data, sizeof(data), | ||
819 | "attempting to determine the 1.1 version"); | ||
820 | if (rc) | ||
821 | goto out; | ||
295 | 822 | ||
296 | if ((len = tpm_transmit(chip, data, sizeof(data))) < | 823 | str += sprintf(str, |
297 | CAP_VER_RESULT_SIZE) | 824 | "TCG version: %d.%d\nFirmware version: %d.%d\n", |
298 | return len; | 825 | (int) data[14], (int) data[15], (int) data[16], |
299 | 826 | (int) data[17]); | |
300 | str += | ||
301 | sprintf(str, "TCG version: %d.%d\nFirmware version: %d.%d\n", | ||
302 | (int) data[14], (int) data[15], (int) data[16], | ||
303 | (int) data[17]); | ||
304 | 827 | ||
828 | out: | ||
305 | return str - buf; | 829 | return str - buf; |
306 | } | 830 | } |
307 | EXPORT_SYMBOL_GPL(tpm_show_caps); | 831 | EXPORT_SYMBOL_GPL(tpm_show_caps); |
308 | 832 | ||
833 | ssize_t tpm_show_caps_1_2(struct device * dev, | ||
834 | struct device_attribute * attr, char *buf) | ||
835 | { | ||
836 | u8 data[max_t(int, max(ARRAY_SIZE(tpm_cap), ARRAY_SIZE(cap_version)), 30)]; | ||
837 | ssize_t len; | ||
838 | char *str = buf; | ||
839 | |||
840 | struct tpm_chip *chip = dev_get_drvdata(dev); | ||
841 | if (chip == NULL) | ||
842 | return -ENODEV; | ||
843 | |||
844 | memcpy(data, tpm_cap, sizeof(tpm_cap)); | ||
845 | data[TPM_CAP_IDX] = TPM_CAP_PROP; | ||
846 | data[TPM_CAP_SUBCAP_IDX] = TPM_CAP_PROP_MANUFACTURER; | ||
847 | |||
848 | if ((len = tpm_transmit(chip, data, sizeof(data))) <= | ||
849 | TPM_ERROR_SIZE) { | ||
850 | dev_dbg(chip->dev, "A TPM error (%d) occurred " | ||
851 | "attempting to determine the manufacturer\n", | ||
852 | be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX)))); | ||
853 | return 0; | ||
854 | } | ||
855 | |||
856 | str += sprintf(str, "Manufacturer: 0x%x\n", | ||
857 | be32_to_cpu(*((__be32 *) (data + TPM_GET_CAP_RET_UINT32_1_IDX)))); | ||
858 | |||
859 | memcpy(data, cap_version, sizeof(cap_version)); | ||
860 | data[CAP_VERSION_IDX] = CAP_VERSION_1_2; | ||
861 | |||
862 | if ((len = tpm_transmit(chip, data, sizeof(data))) <= | ||
863 | TPM_ERROR_SIZE) { | ||
864 | dev_err(chip->dev, "A TPM error (%d) occurred " | ||
865 | "attempting to determine the 1.2 version\n", | ||
866 | be32_to_cpu(*((__be32 *) (data + TPM_RET_CODE_IDX)))); | ||
867 | goto out; | ||
868 | } | ||
869 | str += sprintf(str, | ||
870 | "TCG version: %d.%d\nFirmware version: %d.%d\n", | ||
871 | (int) data[16], (int) data[17], (int) data[18], | ||
872 | (int) data[19]); | ||
873 | |||
874 | out: | ||
875 | return str - buf; | ||
876 | } | ||
877 | EXPORT_SYMBOL_GPL(tpm_show_caps_1_2); | ||
878 | |||
309 | ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | 879 | ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, |
310 | const char *buf, size_t count) | 880 | const char *buf, size_t count) |
311 | { | 881 | { |
@@ -313,7 +883,7 @@ ssize_t tpm_store_cancel(struct device *dev, struct device_attribute *attr, | |||
313 | if (chip == NULL) | 883 | if (chip == NULL) |
314 | return 0; | 884 | return 0; |
315 | 885 | ||
316 | chip->vendor->cancel(chip); | 886 | chip->vendor.cancel(chip); |
317 | return count; | 887 | return count; |
318 | } | 888 | } |
319 | EXPORT_SYMBOL_GPL(tpm_store_cancel); | 889 | EXPORT_SYMBOL_GPL(tpm_store_cancel); |
@@ -329,7 +899,7 @@ int tpm_open(struct inode *inode, struct file *file) | |||
329 | spin_lock(&driver_lock); | 899 | spin_lock(&driver_lock); |
330 | 900 | ||
331 | list_for_each_entry(pos, &tpm_chip_list, list) { | 901 | list_for_each_entry(pos, &tpm_chip_list, list) { |
332 | if (pos->vendor->miscdev.minor == minor) { | 902 | if (pos->vendor.miscdev.minor == minor) { |
333 | chip = pos; | 903 | chip = pos; |
334 | break; | 904 | break; |
335 | } | 905 | } |
@@ -387,7 +957,7 @@ int tpm_release(struct inode *inode, struct file *file) | |||
387 | EXPORT_SYMBOL_GPL(tpm_release); | 957 | EXPORT_SYMBOL_GPL(tpm_release); |
388 | 958 | ||
389 | ssize_t tpm_write(struct file *file, const char __user *buf, | 959 | ssize_t tpm_write(struct file *file, const char __user *buf, |
390 | size_t size, loff_t * off) | 960 | size_t size, loff_t *off) |
391 | { | 961 | { |
392 | struct tpm_chip *chip = file->private_data; | 962 | struct tpm_chip *chip = file->private_data; |
393 | int in_size = size, out_size; | 963 | int in_size = size, out_size; |
@@ -419,11 +989,10 @@ ssize_t tpm_write(struct file *file, const char __user *buf, | |||
419 | 989 | ||
420 | return in_size; | 990 | return in_size; |
421 | } | 991 | } |
422 | |||
423 | EXPORT_SYMBOL_GPL(tpm_write); | 992 | EXPORT_SYMBOL_GPL(tpm_write); |
424 | 993 | ||
425 | ssize_t tpm_read(struct file * file, char __user *buf, | 994 | ssize_t tpm_read(struct file *file, char __user *buf, |
426 | size_t size, loff_t * off) | 995 | size_t size, loff_t *off) |
427 | { | 996 | { |
428 | struct tpm_chip *chip = file->private_data; | 997 | struct tpm_chip *chip = file->private_data; |
429 | int ret_size; | 998 | int ret_size; |
@@ -462,14 +1031,13 @@ void tpm_remove_hardware(struct device *dev) | |||
462 | spin_unlock(&driver_lock); | 1031 | spin_unlock(&driver_lock); |
463 | 1032 | ||
464 | dev_set_drvdata(dev, NULL); | 1033 | dev_set_drvdata(dev, NULL); |
465 | misc_deregister(&chip->vendor->miscdev); | 1034 | misc_deregister(&chip->vendor.miscdev); |
466 | kfree(chip->vendor->miscdev.name); | 1035 | kfree(chip->vendor.miscdev.name); |
467 | 1036 | ||
468 | sysfs_remove_group(&dev->kobj, chip->vendor->attr_group); | 1037 | sysfs_remove_group(&dev->kobj, chip->vendor.attr_group); |
469 | tpm_bios_log_teardown(chip->bios_dir); | 1038 | tpm_bios_log_teardown(chip->bios_dir); |
470 | 1039 | ||
471 | dev_mask[chip->dev_num / TPM_NUM_MASK_ENTRIES ] &= | 1040 | clear_bit(chip->dev_num, dev_mask); |
472 | ~(1 << (chip->dev_num % TPM_NUM_MASK_ENTRIES)); | ||
473 | 1041 | ||
474 | kfree(chip); | 1042 | kfree(chip); |
475 | 1043 | ||
@@ -520,18 +1088,18 @@ EXPORT_SYMBOL_GPL(tpm_pm_resume); | |||
520 | * upon errant exit from this function specific probe function should call | 1088 | * upon errant exit from this function specific probe function should call |
521 | * pci_disable_device | 1089 | * pci_disable_device |
522 | */ | 1090 | */ |
523 | int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry) | 1091 | struct tpm_chip *tpm_register_hardware(struct device *dev, const struct tpm_vendor_specific |
1092 | *entry) | ||
524 | { | 1093 | { |
525 | #define DEVNAME_SIZE 7 | 1094 | #define DEVNAME_SIZE 7 |
526 | 1095 | ||
527 | char *devname; | 1096 | char *devname; |
528 | struct tpm_chip *chip; | 1097 | struct tpm_chip *chip; |
529 | int i, j; | ||
530 | 1098 | ||
531 | /* Driver specific per-device data */ | 1099 | /* Driver specific per-device data */ |
532 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); | 1100 | chip = kzalloc(sizeof(*chip), GFP_KERNEL); |
533 | if (chip == NULL) | 1101 | if (chip == NULL) |
534 | return -ENOMEM; | 1102 | return NULL; |
535 | 1103 | ||
536 | init_MUTEX(&chip->buffer_mutex); | 1104 | init_MUTEX(&chip->buffer_mutex); |
537 | init_MUTEX(&chip->tpm_mutex); | 1105 | init_MUTEX(&chip->tpm_mutex); |
@@ -543,45 +1111,37 @@ int tpm_register_hardware(struct device *dev, struct tpm_vendor_specific *entry) | |||
543 | chip->user_read_timer.function = user_reader_timeout; | 1111 | chip->user_read_timer.function = user_reader_timeout; |
544 | chip->user_read_timer.data = (unsigned long) chip; | 1112 | chip->user_read_timer.data = (unsigned long) chip; |
545 | 1113 | ||
546 | chip->vendor = entry; | 1114 | memcpy(&chip->vendor, entry, sizeof(struct tpm_vendor_specific)); |
547 | |||
548 | chip->dev_num = -1; | ||
549 | 1115 | ||
550 | for (i = 0; i < TPM_NUM_MASK_ENTRIES; i++) | 1116 | chip->dev_num = find_first_zero_bit(dev_mask, TPM_NUM_DEVICES); |
551 | for (j = 0; j < 8 * sizeof(int); j++) | ||
552 | if ((dev_mask[i] & (1 << j)) == 0) { | ||
553 | chip->dev_num = | ||
554 | i * TPM_NUM_MASK_ENTRIES + j; | ||
555 | dev_mask[i] |= 1 << j; | ||
556 | goto dev_num_search_complete; | ||
557 | } | ||
558 | 1117 | ||
559 | dev_num_search_complete: | 1118 | if (chip->dev_num >= TPM_NUM_DEVICES) { |
560 | if (chip->dev_num < 0) { | ||
561 | dev_err(dev, "No available tpm device numbers\n"); | 1119 | dev_err(dev, "No available tpm device numbers\n"); |
562 | kfree(chip); | 1120 | kfree(chip); |
563 | return -ENODEV; | 1121 | return NULL; |
564 | } else if (chip->dev_num == 0) | 1122 | } else if (chip->dev_num == 0) |
565 | chip->vendor->miscdev.minor = TPM_MINOR; | 1123 | chip->vendor.miscdev.minor = TPM_MINOR; |
566 | else | 1124 | else |
567 | chip->vendor->miscdev.minor = MISC_DYNAMIC_MINOR; | 1125 | chip->vendor.miscdev.minor = MISC_DYNAMIC_MINOR; |
1126 | |||
1127 | set_bit(chip->dev_num, dev_mask); | ||
568 | 1128 | ||
569 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); | 1129 | devname = kmalloc(DEVNAME_SIZE, GFP_KERNEL); |
570 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); | 1130 | scnprintf(devname, DEVNAME_SIZE, "%s%d", "tpm", chip->dev_num); |
571 | chip->vendor->miscdev.name = devname; | 1131 | chip->vendor.miscdev.name = devname; |
572 | 1132 | ||
573 | chip->vendor->miscdev.dev = dev; | 1133 | chip->vendor.miscdev.dev = dev; |
574 | chip->dev = get_device(dev); | 1134 | chip->dev = get_device(dev); |
575 | 1135 | ||
576 | if (misc_register(&chip->vendor->miscdev)) { | 1136 | if (misc_register(&chip->vendor.miscdev)) { |
577 | dev_err(chip->dev, | 1137 | dev_err(chip->dev, |
578 | "unable to misc_register %s, minor %d\n", | 1138 | "unable to misc_register %s, minor %d\n", |
579 | chip->vendor->miscdev.name, | 1139 | chip->vendor.miscdev.name, |
580 | chip->vendor->miscdev.minor); | 1140 | chip->vendor.miscdev.minor); |
581 | put_device(dev); | 1141 | put_device(dev); |
1142 | clear_bit(chip->dev_num, dev_mask); | ||
582 | kfree(chip); | 1143 | kfree(chip); |
583 | dev_mask[i] &= !(1 << j); | 1144 | return NULL; |
584 | return -ENODEV; | ||
585 | } | 1145 | } |
586 | 1146 | ||
587 | spin_lock(&driver_lock); | 1147 | spin_lock(&driver_lock); |
@@ -592,11 +1152,11 @@ dev_num_search_complete: | |||
592 | 1152 | ||
593 | spin_unlock(&driver_lock); | 1153 | spin_unlock(&driver_lock); |
594 | 1154 | ||
595 | sysfs_create_group(&dev->kobj, chip->vendor->attr_group); | 1155 | sysfs_create_group(&dev->kobj, chip->vendor.attr_group); |
596 | 1156 | ||
597 | chip->bios_dir = tpm_bios_log_setup(devname); | 1157 | chip->bios_dir = tpm_bios_log_setup(devname); |
598 | 1158 | ||
599 | return 0; | 1159 | return chip; |
600 | } | 1160 | } |
601 | EXPORT_SYMBOL_GPL(tpm_register_hardware); | 1161 | EXPORT_SYMBOL_GPL(tpm_register_hardware); |
602 | 1162 | ||
diff --git a/drivers/char/tpm/tpm.h b/drivers/char/tpm/tpm.h index dec0224b4478..54a4c804e25f 100644 --- a/drivers/char/tpm/tpm.h +++ b/drivers/char/tpm/tpm.h | |||
@@ -42,18 +42,30 @@ extern ssize_t tpm_show_pcrs(struct device *, struct device_attribute *attr, | |||
42 | char *); | 42 | char *); |
43 | extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr, | 43 | extern ssize_t tpm_show_caps(struct device *, struct device_attribute *attr, |
44 | char *); | 44 | char *); |
45 | extern ssize_t tpm_show_caps_1_2(struct device *, struct device_attribute *attr, | ||
46 | char *); | ||
45 | extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr, | 47 | extern ssize_t tpm_store_cancel(struct device *, struct device_attribute *attr, |
46 | const char *, size_t); | 48 | const char *, size_t); |
49 | extern ssize_t tpm_show_enabled(struct device *, struct device_attribute *attr, | ||
50 | char *); | ||
51 | extern ssize_t tpm_show_active(struct device *, struct device_attribute *attr, | ||
52 | char *); | ||
53 | extern ssize_t tpm_show_owned(struct device *, struct device_attribute *attr, | ||
54 | char *); | ||
55 | extern ssize_t tpm_show_temp_deactivated(struct device *, | ||
56 | struct device_attribute *attr, char *); | ||
47 | 57 | ||
48 | struct tpm_chip; | 58 | struct tpm_chip; |
49 | 59 | ||
50 | struct tpm_vendor_specific { | 60 | struct tpm_vendor_specific { |
51 | u8 req_complete_mask; | 61 | const u8 req_complete_mask; |
52 | u8 req_complete_val; | 62 | const u8 req_complete_val; |
53 | u8 req_canceled; | 63 | const u8 req_canceled; |
54 | void __iomem *iobase; /* ioremapped address */ | 64 | void __iomem *iobase; /* ioremapped address */ |
55 | unsigned long base; /* TPM base address */ | 65 | unsigned long base; /* TPM base address */ |
56 | 66 | ||
67 | int irq; | ||
68 | |||
57 | int region_size; | 69 | int region_size; |
58 | int have_region; | 70 | int have_region; |
59 | 71 | ||
@@ -63,6 +75,13 @@ struct tpm_vendor_specific { | |||
63 | u8 (*status) (struct tpm_chip *); | 75 | u8 (*status) (struct tpm_chip *); |
64 | struct miscdevice miscdev; | 76 | struct miscdevice miscdev; |
65 | struct attribute_group *attr_group; | 77 | struct attribute_group *attr_group; |
78 | struct list_head list; | ||
79 | int locality; | ||
80 | unsigned long timeout_a, timeout_b, timeout_c, timeout_d; /* jiffies */ | ||
81 | unsigned long duration[3]; /* jiffies */ | ||
82 | |||
83 | wait_queue_head_t read_queue; | ||
84 | wait_queue_head_t int_queue; | ||
66 | }; | 85 | }; |
67 | 86 | ||
68 | struct tpm_chip { | 87 | struct tpm_chip { |
@@ -81,13 +100,15 @@ struct tpm_chip { | |||
81 | struct work_struct work; | 100 | struct work_struct work; |
82 | struct semaphore tpm_mutex; /* tpm is processing */ | 101 | struct semaphore tpm_mutex; /* tpm is processing */ |
83 | 102 | ||
84 | struct tpm_vendor_specific *vendor; | 103 | struct tpm_vendor_specific vendor; |
85 | 104 | ||
86 | struct dentry **bios_dir; | 105 | struct dentry **bios_dir; |
87 | 106 | ||
88 | struct list_head list; | 107 | struct list_head list; |
89 | }; | 108 | }; |
90 | 109 | ||
110 | #define to_tpm_chip(n) container_of(n, struct tpm_chip, vendor) | ||
111 | |||
91 | static inline int tpm_read_index(int base, int index) | 112 | static inline int tpm_read_index(int base, int index) |
92 | { | 113 | { |
93 | outb(index, base); | 114 | outb(index, base); |
@@ -100,8 +121,12 @@ static inline void tpm_write_index(int base, int index, int value) | |||
100 | outb(value & 0xFF, base+1); | 121 | outb(value & 0xFF, base+1); |
101 | } | 122 | } |
102 | 123 | ||
103 | extern int tpm_register_hardware(struct device *, | 124 | extern void tpm_get_timeouts(struct tpm_chip *); |
104 | struct tpm_vendor_specific *); | 125 | extern void tpm_gen_interrupt(struct tpm_chip *); |
126 | extern void tpm_continue_selftest(struct tpm_chip *); | ||
127 | extern unsigned long tpm_calc_ordinal_duration(struct tpm_chip *, u32); | ||
128 | extern struct tpm_chip* tpm_register_hardware(struct device *, | ||
129 | const struct tpm_vendor_specific *); | ||
105 | extern int tpm_open(struct inode *, struct file *); | 130 | extern int tpm_open(struct inode *, struct file *); |
106 | extern int tpm_release(struct inode *, struct file *); | 131 | extern int tpm_release(struct inode *, struct file *); |
107 | extern ssize_t tpm_write(struct file *, const char __user *, size_t, | 132 | extern ssize_t tpm_write(struct file *, const char __user *, size_t, |
diff --git a/drivers/char/tpm/tpm_atmel.c b/drivers/char/tpm/tpm_atmel.c index ff3654964fe3..58a258cec153 100644 --- a/drivers/char/tpm/tpm_atmel.c +++ b/drivers/char/tpm/tpm_atmel.c | |||
@@ -47,12 +47,12 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
47 | return -EIO; | 47 | return -EIO; |
48 | 48 | ||
49 | for (i = 0; i < 6; i++) { | 49 | for (i = 0; i < 6; i++) { |
50 | status = ioread8(chip->vendor->iobase + 1); | 50 | status = ioread8(chip->vendor.iobase + 1); |
51 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 51 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
52 | dev_err(chip->dev, "error reading header\n"); | 52 | dev_err(chip->dev, "error reading header\n"); |
53 | return -EIO; | 53 | return -EIO; |
54 | } | 54 | } |
55 | *buf++ = ioread8(chip->vendor->iobase); | 55 | *buf++ = ioread8(chip->vendor.iobase); |
56 | } | 56 | } |
57 | 57 | ||
58 | /* size of the data received */ | 58 | /* size of the data received */ |
@@ -63,7 +63,7 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
63 | dev_err(chip->dev, | 63 | dev_err(chip->dev, |
64 | "Recv size(%d) less than available space\n", size); | 64 | "Recv size(%d) less than available space\n", size); |
65 | for (; i < size; i++) { /* clear the waiting data anyway */ | 65 | for (; i < size; i++) { /* clear the waiting data anyway */ |
66 | status = ioread8(chip->vendor->iobase + 1); | 66 | status = ioread8(chip->vendor.iobase + 1); |
67 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 67 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
68 | dev_err(chip->dev, "error reading data\n"); | 68 | dev_err(chip->dev, "error reading data\n"); |
69 | return -EIO; | 69 | return -EIO; |
@@ -74,16 +74,16 @@ static int tpm_atml_recv(struct tpm_chip *chip, u8 *buf, size_t count) | |||
74 | 74 | ||
75 | /* read all the data available */ | 75 | /* read all the data available */ |
76 | for (; i < size; i++) { | 76 | for (; i < size; i++) { |
77 | status = ioread8(chip->vendor->iobase + 1); | 77 | status = ioread8(chip->vendor.iobase + 1); |
78 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { | 78 | if ((status & ATML_STATUS_DATA_AVAIL) == 0) { |
79 | dev_err(chip->dev, "error reading data\n"); | 79 | dev_err(chip->dev, "error reading data\n"); |
80 | return -EIO; | 80 | return -EIO; |
81 | } | 81 | } |
82 | *buf++ = ioread8(chip->vendor->iobase); | 82 | *buf++ = ioread8(chip->vendor.iobase); |
83 | } | 83 | } |
84 | 84 | ||
85 | /* make sure data available is gone */ | 85 | /* make sure data available is gone */ |
86 | status = ioread8(chip->vendor->iobase + 1); | 86 | status = ioread8(chip->vendor.iobase + 1); |
87 | 87 | ||
88 | if (status & ATML_STATUS_DATA_AVAIL) { | 88 | if (status & ATML_STATUS_DATA_AVAIL) { |
89 | dev_err(chip->dev, "data available is stuck\n"); | 89 | dev_err(chip->dev, "data available is stuck\n"); |
@@ -100,7 +100,7 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
100 | dev_dbg(chip->dev, "tpm_atml_send:\n"); | 100 | dev_dbg(chip->dev, "tpm_atml_send:\n"); |
101 | for (i = 0; i < count; i++) { | 101 | for (i = 0; i < count; i++) { |
102 | dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); | 102 | dev_dbg(chip->dev, "%d 0x%x(%d)\n", i, buf[i], buf[i]); |
103 | iowrite8(buf[i], chip->vendor->iobase); | 103 | iowrite8(buf[i], chip->vendor.iobase); |
104 | } | 104 | } |
105 | 105 | ||
106 | return count; | 106 | return count; |
@@ -108,12 +108,12 @@ static int tpm_atml_send(struct tpm_chip *chip, u8 *buf, size_t count) | |||
108 | 108 | ||
109 | static void tpm_atml_cancel(struct tpm_chip *chip) | 109 | static void tpm_atml_cancel(struct tpm_chip *chip) |
110 | { | 110 | { |
111 | iowrite8(ATML_STATUS_ABORT, chip->vendor->iobase + 1); | 111 | iowrite8(ATML_STATUS_ABORT, chip->vendor.iobase + 1); |
112 | } | 112 | } |
113 | 113 | ||
114 | static u8 tpm_atml_status(struct tpm_chip *chip) | 114 | static u8 tpm_atml_status(struct tpm_chip *chip) |
115 | { | 115 | { |
116 | return ioread8(chip->vendor->iobase + 1); | 116 | return ioread8(chip->vendor.iobase + 1); |
117 | } | 117 | } |
118 | 118 | ||
119 | static struct file_operations atmel_ops = { | 119 | static struct file_operations atmel_ops = { |
@@ -140,7 +140,7 @@ static struct attribute* atmel_attrs[] = { | |||
140 | 140 | ||
141 | static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs }; | 141 | static struct attribute_group atmel_attr_grp = { .attrs = atmel_attrs }; |
142 | 142 | ||
143 | static struct tpm_vendor_specific tpm_atmel = { | 143 | static const struct tpm_vendor_specific tpm_atmel = { |
144 | .recv = tpm_atml_recv, | 144 | .recv = tpm_atml_recv, |
145 | .send = tpm_atml_send, | 145 | .send = tpm_atml_send, |
146 | .cancel = tpm_atml_cancel, | 146 | .cancel = tpm_atml_cancel, |
@@ -159,10 +159,10 @@ static void atml_plat_remove(void) | |||
159 | struct tpm_chip *chip = dev_get_drvdata(&pdev->dev); | 159 | struct tpm_chip *chip = dev_get_drvdata(&pdev->dev); |
160 | 160 | ||
161 | if (chip) { | 161 | if (chip) { |
162 | if (chip->vendor->have_region) | 162 | if (chip->vendor.have_region) |
163 | atmel_release_region(chip->vendor->base, | 163 | atmel_release_region(chip->vendor.base, |
164 | chip->vendor->region_size); | 164 | chip->vendor.region_size); |
165 | atmel_put_base_addr(chip->vendor); | 165 | atmel_put_base_addr(chip->vendor.iobase); |
166 | tpm_remove_hardware(chip->dev); | 166 | tpm_remove_hardware(chip->dev); |
167 | platform_device_unregister(pdev); | 167 | platform_device_unregister(pdev); |
168 | } | 168 | } |
@@ -179,18 +179,22 @@ static struct device_driver atml_drv = { | |||
179 | static int __init init_atmel(void) | 179 | static int __init init_atmel(void) |
180 | { | 180 | { |
181 | int rc = 0; | 181 | int rc = 0; |
182 | void __iomem *iobase = NULL; | ||
183 | int have_region, region_size; | ||
184 | unsigned long base; | ||
185 | struct tpm_chip *chip; | ||
182 | 186 | ||
183 | driver_register(&atml_drv); | 187 | driver_register(&atml_drv); |
184 | 188 | ||
185 | if ((tpm_atmel.iobase = atmel_get_base_addr(&tpm_atmel)) == NULL) { | 189 | if ((iobase = atmel_get_base_addr(&base, ®ion_size)) == NULL) { |
186 | rc = -ENODEV; | 190 | rc = -ENODEV; |
187 | goto err_unreg_drv; | 191 | goto err_unreg_drv; |
188 | } | 192 | } |
189 | 193 | ||
190 | tpm_atmel.have_region = | 194 | have_region = |
191 | (atmel_request_region | 195 | (atmel_request_region |
192 | (tpm_atmel.base, tpm_atmel.region_size, | 196 | (tpm_atmel.base, region_size, "tpm_atmel0") == NULL) ? 0 : 1; |
193 | "tpm_atmel0") == NULL) ? 0 : 1; | 197 | |
194 | 198 | ||
195 | if (IS_ERR | 199 | if (IS_ERR |
196 | (pdev = | 200 | (pdev = |
@@ -199,17 +203,25 @@ static int __init init_atmel(void) | |||
199 | goto err_rel_reg; | 203 | goto err_rel_reg; |
200 | } | 204 | } |
201 | 205 | ||
202 | if ((rc = tpm_register_hardware(&pdev->dev, &tpm_atmel)) < 0) | 206 | if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_atmel))) { |
207 | rc = -ENODEV; | ||
203 | goto err_unreg_dev; | 208 | goto err_unreg_dev; |
209 | } | ||
210 | |||
211 | chip->vendor.iobase = iobase; | ||
212 | chip->vendor.base = base; | ||
213 | chip->vendor.have_region = have_region; | ||
214 | chip->vendor.region_size = region_size; | ||
215 | |||
204 | return 0; | 216 | return 0; |
205 | 217 | ||
206 | err_unreg_dev: | 218 | err_unreg_dev: |
207 | platform_device_unregister(pdev); | 219 | platform_device_unregister(pdev); |
208 | err_rel_reg: | 220 | err_rel_reg: |
209 | atmel_put_base_addr(&tpm_atmel); | 221 | atmel_put_base_addr(iobase); |
210 | if (tpm_atmel.have_region) | 222 | if (have_region) |
211 | atmel_release_region(tpm_atmel.base, | 223 | atmel_release_region(base, |
212 | tpm_atmel.region_size); | 224 | region_size); |
213 | err_unreg_drv: | 225 | err_unreg_drv: |
214 | driver_unregister(&atml_drv); | 226 | driver_unregister(&atml_drv); |
215 | return rc; | 227 | return rc; |
diff --git a/drivers/char/tpm/tpm_atmel.h b/drivers/char/tpm/tpm_atmel.h index d3478aaadd77..2e68eeb8a2cd 100644 --- a/drivers/char/tpm/tpm_atmel.h +++ b/drivers/char/tpm/tpm_atmel.h | |||
@@ -28,13 +28,12 @@ | |||
28 | #define atmel_request_region request_mem_region | 28 | #define atmel_request_region request_mem_region |
29 | #define atmel_release_region release_mem_region | 29 | #define atmel_release_region release_mem_region |
30 | 30 | ||
31 | static inline void atmel_put_base_addr(struct tpm_vendor_specific | 31 | static inline void atmel_put_base_addr(void __iomem *iobase) |
32 | *vendor) | ||
33 | { | 32 | { |
34 | iounmap(vendor->iobase); | 33 | iounmap(iobase); |
35 | } | 34 | } |
36 | 35 | ||
37 | static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor) | 36 | static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) |
38 | { | 37 | { |
39 | struct device_node *dn; | 38 | struct device_node *dn; |
40 | unsigned long address, size; | 39 | unsigned long address, size; |
@@ -71,9 +70,9 @@ static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific *vendor) | |||
71 | else | 70 | else |
72 | size = reg[naddrc]; | 71 | size = reg[naddrc]; |
73 | 72 | ||
74 | vendor->base = address; | 73 | *base = address; |
75 | vendor->region_size = size; | 74 | *region_size = size; |
76 | return ioremap(vendor->base, vendor->region_size); | 75 | return ioremap(*base, *region_size); |
77 | } | 76 | } |
78 | #else | 77 | #else |
79 | #define atmel_getb(chip, offset) inb(chip->vendor->base + offset) | 78 | #define atmel_getb(chip, offset) inb(chip->vendor->base + offset) |
@@ -106,14 +105,12 @@ static int atmel_verify_tpm11(void) | |||
106 | return 0; | 105 | return 0; |
107 | } | 106 | } |
108 | 107 | ||
109 | static inline void atmel_put_base_addr(struct tpm_vendor_specific | 108 | static inline void atmel_put_base_addr(void __iomem *iobase) |
110 | *vendor) | ||
111 | { | 109 | { |
112 | } | 110 | } |
113 | 111 | ||
114 | /* Determine where to talk to device */ | 112 | /* Determine where to talk to device */ |
115 | static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific | 113 | static void __iomem * atmel_get_base_addr(unsigned long *base, int *region_size) |
116 | *vendor) | ||
117 | { | 114 | { |
118 | int lo, hi; | 115 | int lo, hi; |
119 | 116 | ||
@@ -123,9 +120,9 @@ static void __iomem * atmel_get_base_addr(struct tpm_vendor_specific | |||
123 | lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); | 120 | lo = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_LO); |
124 | hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); | 121 | hi = tpm_read_index(TPM_ADDR, TPM_ATMEL_BASE_ADDR_HI); |
125 | 122 | ||
126 | vendor->base = (hi << 8) | lo; | 123 | *base = (hi << 8) | lo; |
127 | vendor->region_size = 2; | 124 | *region_size = 2; |
128 | 125 | ||
129 | return ioport_map(vendor->base, vendor->region_size); | 126 | return ioport_map(*base, *region_size); |
130 | } | 127 | } |
131 | #endif | 128 | #endif |
diff --git a/drivers/char/tpm/tpm_bios.c b/drivers/char/tpm/tpm_bios.c index 537aa45d8c67..e45f0d3d12de 100644 --- a/drivers/char/tpm/tpm_bios.c +++ b/drivers/char/tpm/tpm_bios.c | |||
@@ -29,6 +29,11 @@ | |||
29 | #define MAX_TEXT_EVENT 1000 /* Max event string length */ | 29 | #define MAX_TEXT_EVENT 1000 /* Max event string length */ |
30 | #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ | 30 | #define ACPI_TCPA_SIG "TCPA" /* 0x41504354 /'TCPA' */ |
31 | 31 | ||
32 | enum bios_platform_class { | ||
33 | BIOS_CLIENT = 0x00, | ||
34 | BIOS_SERVER = 0x01, | ||
35 | }; | ||
36 | |||
32 | struct tpm_bios_log { | 37 | struct tpm_bios_log { |
33 | void *bios_event_log; | 38 | void *bios_event_log; |
34 | void *bios_event_log_end; | 39 | void *bios_event_log_end; |
@@ -36,9 +41,18 @@ struct tpm_bios_log { | |||
36 | 41 | ||
37 | struct acpi_tcpa { | 42 | struct acpi_tcpa { |
38 | struct acpi_table_header hdr; | 43 | struct acpi_table_header hdr; |
39 | u16 reserved; | 44 | u16 platform_class; |
40 | u32 log_max_len __attribute__ ((packed)); | 45 | union { |
41 | u32 log_start_addr __attribute__ ((packed)); | 46 | struct client_hdr { |
47 | u32 log_max_len __attribute__ ((packed)); | ||
48 | u64 log_start_addr __attribute__ ((packed)); | ||
49 | } client; | ||
50 | struct server_hdr { | ||
51 | u16 reserved; | ||
52 | u64 log_max_len __attribute__ ((packed)); | ||
53 | u64 log_start_addr __attribute__ ((packed)); | ||
54 | } server; | ||
55 | }; | ||
42 | }; | 56 | }; |
43 | 57 | ||
44 | struct tcpa_event { | 58 | struct tcpa_event { |
@@ -120,6 +134,7 @@ static const char* tcpa_pc_event_id_strings[] = { | |||
120 | "S-CRTM Version", | 134 | "S-CRTM Version", |
121 | "S-CRTM Contents", | 135 | "S-CRTM Contents", |
122 | "S-CRTM POST Contents", | 136 | "S-CRTM POST Contents", |
137 | "POST Contents", | ||
123 | }; | 138 | }; |
124 | 139 | ||
125 | /* returns pointer to start of pos. entry of tcg log */ | 140 | /* returns pointer to start of pos. entry of tcg log */ |
@@ -306,6 +321,7 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) | |||
306 | /* 5th: delimiter */ | 321 | /* 5th: delimiter */ |
307 | seq_putc(m, '\0'); | 322 | seq_putc(m, '\0'); |
308 | 323 | ||
324 | kfree(eventname); | ||
309 | return 0; | 325 | return 0; |
310 | } | 326 | } |
311 | 327 | ||
@@ -353,6 +369,7 @@ static int tpm_ascii_bios_measurements_show(struct seq_file *m, void *v) | |||
353 | /* 4th: eventname <= max + \'0' delimiter */ | 369 | /* 4th: eventname <= max + \'0' delimiter */ |
354 | seq_printf(m, " %s\n", eventname); | 370 | seq_printf(m, " %s\n", eventname); |
355 | 371 | ||
372 | kfree(eventname); | ||
356 | return 0; | 373 | return 0; |
357 | } | 374 | } |
358 | 375 | ||
@@ -376,6 +393,7 @@ static int read_log(struct tpm_bios_log *log) | |||
376 | struct acpi_tcpa *buff; | 393 | struct acpi_tcpa *buff; |
377 | acpi_status status; | 394 | acpi_status status; |
378 | struct acpi_table_header *virt; | 395 | struct acpi_table_header *virt; |
396 | u64 len, start; | ||
379 | 397 | ||
380 | if (log->bios_event_log != NULL) { | 398 | if (log->bios_event_log != NULL) { |
381 | printk(KERN_ERR | 399 | printk(KERN_ERR |
@@ -396,27 +414,37 @@ static int read_log(struct tpm_bios_log *log) | |||
396 | return -EIO; | 414 | return -EIO; |
397 | } | 415 | } |
398 | 416 | ||
399 | if (buff->log_max_len == 0) { | 417 | switch(buff->platform_class) { |
418 | case BIOS_SERVER: | ||
419 | len = buff->server.log_max_len; | ||
420 | start = buff->server.log_start_addr; | ||
421 | break; | ||
422 | case BIOS_CLIENT: | ||
423 | default: | ||
424 | len = buff->client.log_max_len; | ||
425 | start = buff->client.log_start_addr; | ||
426 | break; | ||
427 | } | ||
428 | if (!len) { | ||
400 | printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__); | 429 | printk(KERN_ERR "%s: ERROR - TCPA log area empty\n", __func__); |
401 | return -EIO; | 430 | return -EIO; |
402 | } | 431 | } |
403 | 432 | ||
404 | /* malloc EventLog space */ | 433 | /* malloc EventLog space */ |
405 | log->bios_event_log = kmalloc(buff->log_max_len, GFP_KERNEL); | 434 | log->bios_event_log = kmalloc(len, GFP_KERNEL); |
406 | if (!log->bios_event_log) { | 435 | if (!log->bios_event_log) { |
407 | printk | 436 | printk("%s: ERROR - Not enough Memory for BIOS measurements\n", |
408 | ("%s: ERROR - Not enough Memory for BIOS measurements\n", | 437 | __func__); |
409 | __func__); | ||
410 | return -ENOMEM; | 438 | return -ENOMEM; |
411 | } | 439 | } |
412 | 440 | ||
413 | log->bios_event_log_end = log->bios_event_log + buff->log_max_len; | 441 | log->bios_event_log_end = log->bios_event_log + len; |
414 | 442 | ||
415 | acpi_os_map_memory(buff->log_start_addr, buff->log_max_len, (void *) &virt); | 443 | acpi_os_map_memory(start, len, (void *) &virt); |
416 | 444 | ||
417 | memcpy(log->bios_event_log, virt, buff->log_max_len); | 445 | memcpy(log->bios_event_log, virt, len); |
418 | 446 | ||
419 | acpi_os_unmap_memory(virt, buff->log_max_len); | 447 | acpi_os_unmap_memory(virt, len); |
420 | return 0; | 448 | return 0; |
421 | } | 449 | } |
422 | 450 | ||
diff --git a/drivers/char/tpm/tpm_infineon.c b/drivers/char/tpm/tpm_infineon.c index 24095f6ee6da..adfff21beb21 100644 --- a/drivers/char/tpm/tpm_infineon.c +++ b/drivers/char/tpm/tpm_infineon.c | |||
@@ -15,6 +15,7 @@ | |||
15 | * License. | 15 | * License. |
16 | */ | 16 | */ |
17 | 17 | ||
18 | #include <linux/init.h> | ||
18 | #include <linux/pnp.h> | 19 | #include <linux/pnp.h> |
19 | #include "tpm.h" | 20 | #include "tpm.h" |
20 | 21 | ||
@@ -104,7 +105,7 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) | |||
104 | 105 | ||
105 | if (clear_wrfifo) { | 106 | if (clear_wrfifo) { |
106 | for (i = 0; i < 4096; i++) { | 107 | for (i = 0; i < 4096; i++) { |
107 | status = inb(chip->vendor->base + WRFIFO); | 108 | status = inb(chip->vendor.base + WRFIFO); |
108 | if (status == 0xff) { | 109 | if (status == 0xff) { |
109 | if (check == 5) | 110 | if (check == 5) |
110 | break; | 111 | break; |
@@ -124,8 +125,8 @@ static int empty_fifo(struct tpm_chip *chip, int clear_wrfifo) | |||
124 | */ | 125 | */ |
125 | i = 0; | 126 | i = 0; |
126 | do { | 127 | do { |
127 | status = inb(chip->vendor->base + RDFIFO); | 128 | status = inb(chip->vendor.base + RDFIFO); |
128 | status = inb(chip->vendor->base + STAT); | 129 | status = inb(chip->vendor.base + STAT); |
129 | i++; | 130 | i++; |
130 | if (i == TPM_MAX_TRIES) | 131 | if (i == TPM_MAX_TRIES) |
131 | return -EIO; | 132 | return -EIO; |
@@ -138,7 +139,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit) | |||
138 | int status; | 139 | int status; |
139 | int i; | 140 | int i; |
140 | for (i = 0; i < TPM_MAX_TRIES; i++) { | 141 | for (i = 0; i < TPM_MAX_TRIES; i++) { |
141 | status = inb(chip->vendor->base + STAT); | 142 | status = inb(chip->vendor.base + STAT); |
142 | /* check the status-register if wait_for_bit is set */ | 143 | /* check the status-register if wait_for_bit is set */ |
143 | if (status & 1 << wait_for_bit) | 144 | if (status & 1 << wait_for_bit) |
144 | break; | 145 | break; |
@@ -157,7 +158,7 @@ static int wait(struct tpm_chip *chip, int wait_for_bit) | |||
157 | static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) | 158 | static void wait_and_send(struct tpm_chip *chip, u8 sendbyte) |
158 | { | 159 | { |
159 | wait(chip, STAT_XFE); | 160 | wait(chip, STAT_XFE); |
160 | outb(sendbyte, chip->vendor->base + WRFIFO); | 161 | outb(sendbyte, chip->vendor.base + WRFIFO); |
161 | } | 162 | } |
162 | 163 | ||
163 | /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more | 164 | /* Note: WTX means Waiting-Time-Extension. Whenever the TPM needs more |
@@ -204,7 +205,7 @@ recv_begin: | |||
204 | ret = wait(chip, STAT_RDA); | 205 | ret = wait(chip, STAT_RDA); |
205 | if (ret) | 206 | if (ret) |
206 | return -EIO; | 207 | return -EIO; |
207 | buf[i] = inb(chip->vendor->base + RDFIFO); | 208 | buf[i] = inb(chip->vendor.base + RDFIFO); |
208 | } | 209 | } |
209 | 210 | ||
210 | if (buf[0] != TPM_VL_VER) { | 211 | if (buf[0] != TPM_VL_VER) { |
@@ -219,7 +220,7 @@ recv_begin: | |||
219 | 220 | ||
220 | for (i = 0; i < size; i++) { | 221 | for (i = 0; i < size; i++) { |
221 | wait(chip, STAT_RDA); | 222 | wait(chip, STAT_RDA); |
222 | buf[i] = inb(chip->vendor->base + RDFIFO); | 223 | buf[i] = inb(chip->vendor.base + RDFIFO); |
223 | } | 224 | } |
224 | 225 | ||
225 | if ((size == 0x6D00) && (buf[1] == 0x80)) { | 226 | if ((size == 0x6D00) && (buf[1] == 0x80)) { |
@@ -268,7 +269,7 @@ static int tpm_inf_send(struct tpm_chip *chip, u8 * buf, size_t count) | |||
268 | u8 count_high, count_low, count_4, count_3, count_2, count_1; | 269 | u8 count_high, count_low, count_4, count_3, count_2, count_1; |
269 | 270 | ||
270 | /* Disabling Reset, LP and IRQC */ | 271 | /* Disabling Reset, LP and IRQC */ |
271 | outb(RESET_LP_IRQC_DISABLE, chip->vendor->base + CMD); | 272 | outb(RESET_LP_IRQC_DISABLE, chip->vendor.base + CMD); |
272 | 273 | ||
273 | ret = empty_fifo(chip, 1); | 274 | ret = empty_fifo(chip, 1); |
274 | if (ret) { | 275 | if (ret) { |
@@ -319,7 +320,7 @@ static void tpm_inf_cancel(struct tpm_chip *chip) | |||
319 | 320 | ||
320 | static u8 tpm_inf_status(struct tpm_chip *chip) | 321 | static u8 tpm_inf_status(struct tpm_chip *chip) |
321 | { | 322 | { |
322 | return inb(chip->vendor->base + STAT); | 323 | return inb(chip->vendor.base + STAT); |
323 | } | 324 | } |
324 | 325 | ||
325 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | 326 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); |
@@ -346,7 +347,7 @@ static struct file_operations inf_ops = { | |||
346 | .release = tpm_release, | 347 | .release = tpm_release, |
347 | }; | 348 | }; |
348 | 349 | ||
349 | static struct tpm_vendor_specific tpm_inf = { | 350 | static const struct tpm_vendor_specific tpm_inf = { |
350 | .recv = tpm_inf_recv, | 351 | .recv = tpm_inf_recv, |
351 | .send = tpm_inf_send, | 352 | .send = tpm_inf_send, |
352 | .cancel = tpm_inf_cancel, | 353 | .cancel = tpm_inf_cancel, |
@@ -375,6 +376,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
375 | int version[2]; | 376 | int version[2]; |
376 | int productid[2]; | 377 | int productid[2]; |
377 | char chipname[20]; | 378 | char chipname[20]; |
379 | struct tpm_chip *chip; | ||
378 | 380 | ||
379 | /* read IO-ports through PnP */ | 381 | /* read IO-ports through PnP */ |
380 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && | 382 | if (pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && |
@@ -395,14 +397,13 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
395 | goto err_last; | 397 | goto err_last; |
396 | } | 398 | } |
397 | /* publish my base address and request region */ | 399 | /* publish my base address and request region */ |
398 | tpm_inf.base = TPM_INF_BASE; | ||
399 | if (request_region | 400 | if (request_region |
400 | (tpm_inf.base, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) { | 401 | (TPM_INF_BASE, TPM_INF_PORT_LEN, "tpm_infineon0") == NULL) { |
401 | rc = -EINVAL; | 402 | rc = -EINVAL; |
402 | goto err_last; | 403 | goto err_last; |
403 | } | 404 | } |
404 | if (request_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN, | 405 | if (request_region |
405 | "tpm_infineon0") == NULL) { | 406 | (TPM_INF_ADDR, TPM_INF_ADDR_LEN, "tpm_infineon0") == NULL) { |
406 | rc = -EINVAL; | 407 | rc = -EINVAL; |
407 | goto err_last; | 408 | goto err_last; |
408 | } | 409 | } |
@@ -442,9 +443,9 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
442 | 443 | ||
443 | /* configure TPM with IO-ports */ | 444 | /* configure TPM with IO-ports */ |
444 | outb(IOLIMH, TPM_INF_ADDR); | 445 | outb(IOLIMH, TPM_INF_ADDR); |
445 | outb(((tpm_inf.base >> 8) & 0xff), TPM_INF_DATA); | 446 | outb(((TPM_INF_BASE >> 8) & 0xff), TPM_INF_DATA); |
446 | outb(IOLIML, TPM_INF_ADDR); | 447 | outb(IOLIML, TPM_INF_ADDR); |
447 | outb((tpm_inf.base & 0xff), TPM_INF_DATA); | 448 | outb((TPM_INF_BASE & 0xff), TPM_INF_DATA); |
448 | 449 | ||
449 | /* control if IO-ports are set correctly */ | 450 | /* control if IO-ports are set correctly */ |
450 | outb(IOLIMH, TPM_INF_ADDR); | 451 | outb(IOLIMH, TPM_INF_ADDR); |
@@ -452,10 +453,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
452 | outb(IOLIML, TPM_INF_ADDR); | 453 | outb(IOLIML, TPM_INF_ADDR); |
453 | iol = inb(TPM_INF_DATA); | 454 | iol = inb(TPM_INF_DATA); |
454 | 455 | ||
455 | if ((ioh << 8 | iol) != tpm_inf.base) { | 456 | if ((ioh << 8 | iol) != TPM_INF_BASE) { |
456 | dev_err(&dev->dev, | 457 | dev_err(&dev->dev, |
457 | "Could not set IO-ports to 0x%lx\n", | 458 | "Could not set IO-ports to 0x%x\n", |
458 | tpm_inf.base); | 459 | TPM_INF_BASE); |
459 | rc = -EIO; | 460 | rc = -EIO; |
460 | goto err_release_region; | 461 | goto err_release_region; |
461 | } | 462 | } |
@@ -466,15 +467,15 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
466 | outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); | 467 | outb(DISABLE_REGISTER_PAIR, TPM_INF_ADDR); |
467 | 468 | ||
468 | /* disable RESET, LP and IRQC */ | 469 | /* disable RESET, LP and IRQC */ |
469 | outb(RESET_LP_IRQC_DISABLE, tpm_inf.base + CMD); | 470 | outb(RESET_LP_IRQC_DISABLE, TPM_INF_BASE + CMD); |
470 | 471 | ||
471 | /* Finally, we're done, print some infos */ | 472 | /* Finally, we're done, print some infos */ |
472 | dev_info(&dev->dev, "TPM found: " | 473 | dev_info(&dev->dev, "TPM found: " |
473 | "config base 0x%x, " | 474 | "config base 0x%x, " |
474 | "io base 0x%x, " | 475 | "io base 0x%x, " |
475 | "chip version %02x%02x, " | 476 | "chip version 0x%02x%02x, " |
476 | "vendor id %x%x (Infineon), " | 477 | "vendor id 0x%x%x (Infineon), " |
477 | "product id %02x%02x" | 478 | "product id 0x%02x%02x" |
478 | "%s\n", | 479 | "%s\n", |
479 | TPM_INF_ADDR, | 480 | TPM_INF_ADDR, |
480 | TPM_INF_BASE, | 481 | TPM_INF_BASE, |
@@ -482,11 +483,10 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
482 | vendorid[0], vendorid[1], | 483 | vendorid[0], vendorid[1], |
483 | productid[0], productid[1], chipname); | 484 | productid[0], productid[1], chipname); |
484 | 485 | ||
485 | rc = tpm_register_hardware(&dev->dev, &tpm_inf); | 486 | if (!(chip = tpm_register_hardware(&dev->dev, &tpm_inf))) { |
486 | if (rc < 0) { | ||
487 | rc = -ENODEV; | ||
488 | goto err_release_region; | 487 | goto err_release_region; |
489 | } | 488 | } |
489 | chip->vendor.base = TPM_INF_BASE; | ||
490 | return 0; | 490 | return 0; |
491 | } else { | 491 | } else { |
492 | rc = -ENODEV; | 492 | rc = -ENODEV; |
@@ -494,7 +494,7 @@ static int __devinit tpm_inf_pnp_probe(struct pnp_dev *dev, | |||
494 | } | 494 | } |
495 | 495 | ||
496 | err_release_region: | 496 | err_release_region: |
497 | release_region(tpm_inf.base, TPM_INF_PORT_LEN); | 497 | release_region(TPM_INF_BASE, TPM_INF_PORT_LEN); |
498 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); | 498 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); |
499 | 499 | ||
500 | err_last: | 500 | err_last: |
@@ -506,7 +506,8 @@ static __devexit void tpm_inf_pnp_remove(struct pnp_dev *dev) | |||
506 | struct tpm_chip *chip = pnp_get_drvdata(dev); | 506 | struct tpm_chip *chip = pnp_get_drvdata(dev); |
507 | 507 | ||
508 | if (chip) { | 508 | if (chip) { |
509 | release_region(chip->vendor->base, TPM_INF_PORT_LEN); | 509 | release_region(TPM_INF_BASE, TPM_INF_PORT_LEN); |
510 | release_region(TPM_INF_ADDR, TPM_INF_ADDR_LEN); | ||
510 | tpm_remove_hardware(chip->dev); | 511 | tpm_remove_hardware(chip->dev); |
511 | } | 512 | } |
512 | } | 513 | } |
@@ -520,7 +521,7 @@ static struct pnp_driver tpm_inf_pnp = { | |||
520 | }, | 521 | }, |
521 | .id_table = tpm_pnp_tbl, | 522 | .id_table = tpm_pnp_tbl, |
522 | .probe = tpm_inf_pnp_probe, | 523 | .probe = tpm_inf_pnp_probe, |
523 | .remove = tpm_inf_pnp_remove, | 524 | .remove = __devexit_p(tpm_inf_pnp_remove), |
524 | }; | 525 | }; |
525 | 526 | ||
526 | static int __init init_inf(void) | 527 | static int __init init_inf(void) |
@@ -538,5 +539,5 @@ module_exit(cleanup_inf); | |||
538 | 539 | ||
539 | MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); | 540 | MODULE_AUTHOR("Marcel Selhorst <selhorst@crypto.rub.de>"); |
540 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); | 541 | MODULE_DESCRIPTION("Driver for Infineon TPM SLD 9630 TT 1.1 / SLB 9635 TT 1.2"); |
541 | MODULE_VERSION("1.7"); | 542 | MODULE_VERSION("1.8"); |
542 | MODULE_LICENSE("GPL"); | 543 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index 680a8e331887..4c8bc06c7d95 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
@@ -71,7 +71,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) | |||
71 | unsigned long stop; | 71 | unsigned long stop; |
72 | 72 | ||
73 | /* status immediately available check */ | 73 | /* status immediately available check */ |
74 | *data = inb(chip->vendor->base + NSC_STATUS); | 74 | *data = inb(chip->vendor.base + NSC_STATUS); |
75 | if ((*data & mask) == val) | 75 | if ((*data & mask) == val) |
76 | return 0; | 76 | return 0; |
77 | 77 | ||
@@ -79,7 +79,7 @@ static int wait_for_stat(struct tpm_chip *chip, u8 mask, u8 val, u8 * data) | |||
79 | stop = jiffies + 10 * HZ; | 79 | stop = jiffies + 10 * HZ; |
80 | do { | 80 | do { |
81 | msleep(TPM_TIMEOUT); | 81 | msleep(TPM_TIMEOUT); |
82 | *data = inb(chip->vendor->base + 1); | 82 | *data = inb(chip->vendor.base + 1); |
83 | if ((*data & mask) == val) | 83 | if ((*data & mask) == val) |
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
@@ -94,9 +94,9 @@ static int nsc_wait_for_ready(struct tpm_chip *chip) | |||
94 | unsigned long stop; | 94 | unsigned long stop; |
95 | 95 | ||
96 | /* status immediately available check */ | 96 | /* status immediately available check */ |
97 | status = inb(chip->vendor->base + NSC_STATUS); | 97 | status = inb(chip->vendor.base + NSC_STATUS); |
98 | if (status & NSC_STATUS_OBF) | 98 | if (status & NSC_STATUS_OBF) |
99 | status = inb(chip->vendor->base + NSC_DATA); | 99 | status = inb(chip->vendor.base + NSC_DATA); |
100 | if (status & NSC_STATUS_RDY) | 100 | if (status & NSC_STATUS_RDY) |
101 | return 0; | 101 | return 0; |
102 | 102 | ||
@@ -104,9 +104,9 @@ static int nsc_wait_for_ready(struct tpm_chip *chip) | |||
104 | stop = jiffies + 100; | 104 | stop = jiffies + 100; |
105 | do { | 105 | do { |
106 | msleep(TPM_TIMEOUT); | 106 | msleep(TPM_TIMEOUT); |
107 | status = inb(chip->vendor->base + NSC_STATUS); | 107 | status = inb(chip->vendor.base + NSC_STATUS); |
108 | if (status & NSC_STATUS_OBF) | 108 | if (status & NSC_STATUS_OBF) |
109 | status = inb(chip->vendor->base + NSC_DATA); | 109 | status = inb(chip->vendor.base + NSC_DATA); |
110 | if (status & NSC_STATUS_RDY) | 110 | if (status & NSC_STATUS_RDY) |
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
@@ -132,7 +132,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) | |||
132 | return -EIO; | 132 | return -EIO; |
133 | } | 133 | } |
134 | if ((data = | 134 | if ((data = |
135 | inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_NORMAL) { | 135 | inb(chip->vendor.base + NSC_DATA)) != NSC_COMMAND_NORMAL) { |
136 | dev_err(chip->dev, "not in normal mode (0x%x)\n", | 136 | dev_err(chip->dev, "not in normal mode (0x%x)\n", |
137 | data); | 137 | data); |
138 | return -EIO; | 138 | return -EIO; |
@@ -148,7 +148,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) | |||
148 | } | 148 | } |
149 | if (data & NSC_STATUS_F0) | 149 | if (data & NSC_STATUS_F0) |
150 | break; | 150 | break; |
151 | *p = inb(chip->vendor->base + NSC_DATA); | 151 | *p = inb(chip->vendor.base + NSC_DATA); |
152 | } | 152 | } |
153 | 153 | ||
154 | if ((data & NSC_STATUS_F0) == 0 && | 154 | if ((data & NSC_STATUS_F0) == 0 && |
@@ -156,7 +156,7 @@ static int tpm_nsc_recv(struct tpm_chip *chip, u8 * buf, size_t count) | |||
156 | dev_err(chip->dev, "F0 not set\n"); | 156 | dev_err(chip->dev, "F0 not set\n"); |
157 | return -EIO; | 157 | return -EIO; |
158 | } | 158 | } |
159 | if ((data = inb(chip->vendor->base + NSC_DATA)) != NSC_COMMAND_EOC) { | 159 | if ((data = inb(chip->vendor.base + NSC_DATA)) != NSC_COMMAND_EOC) { |
160 | dev_err(chip->dev, | 160 | dev_err(chip->dev, |
161 | "expected end of command(0x%x)\n", data); | 161 | "expected end of command(0x%x)\n", data); |
162 | return -EIO; | 162 | return -EIO; |
@@ -182,7 +182,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) | |||
182 | * fix it. Not sure why this is needed, we followed the flow | 182 | * fix it. Not sure why this is needed, we followed the flow |
183 | * chart in the manual to the letter. | 183 | * chart in the manual to the letter. |
184 | */ | 184 | */ |
185 | outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND); | 185 | outb(NSC_COMMAND_CANCEL, chip->vendor.base + NSC_COMMAND); |
186 | 186 | ||
187 | if (nsc_wait_for_ready(chip) != 0) | 187 | if (nsc_wait_for_ready(chip) != 0) |
188 | return -EIO; | 188 | return -EIO; |
@@ -192,7 +192,7 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) | |||
192 | return -EIO; | 192 | return -EIO; |
193 | } | 193 | } |
194 | 194 | ||
195 | outb(NSC_COMMAND_NORMAL, chip->vendor->base + NSC_COMMAND); | 195 | outb(NSC_COMMAND_NORMAL, chip->vendor.base + NSC_COMMAND); |
196 | if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) { | 196 | if (wait_for_stat(chip, NSC_STATUS_IBR, NSC_STATUS_IBR, &data) < 0) { |
197 | dev_err(chip->dev, "IBR timeout\n"); | 197 | dev_err(chip->dev, "IBR timeout\n"); |
198 | return -EIO; | 198 | return -EIO; |
@@ -204,26 +204,26 @@ static int tpm_nsc_send(struct tpm_chip *chip, u8 * buf, size_t count) | |||
204 | "IBF timeout (while writing data)\n"); | 204 | "IBF timeout (while writing data)\n"); |
205 | return -EIO; | 205 | return -EIO; |
206 | } | 206 | } |
207 | outb(buf[i], chip->vendor->base + NSC_DATA); | 207 | outb(buf[i], chip->vendor.base + NSC_DATA); |
208 | } | 208 | } |
209 | 209 | ||
210 | if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { | 210 | if (wait_for_stat(chip, NSC_STATUS_IBF, 0, &data) < 0) { |
211 | dev_err(chip->dev, "IBF timeout\n"); | 211 | dev_err(chip->dev, "IBF timeout\n"); |
212 | return -EIO; | 212 | return -EIO; |
213 | } | 213 | } |
214 | outb(NSC_COMMAND_EOC, chip->vendor->base + NSC_COMMAND); | 214 | outb(NSC_COMMAND_EOC, chip->vendor.base + NSC_COMMAND); |
215 | 215 | ||
216 | return count; | 216 | return count; |
217 | } | 217 | } |
218 | 218 | ||
219 | static void tpm_nsc_cancel(struct tpm_chip *chip) | 219 | static void tpm_nsc_cancel(struct tpm_chip *chip) |
220 | { | 220 | { |
221 | outb(NSC_COMMAND_CANCEL, chip->vendor->base + NSC_COMMAND); | 221 | outb(NSC_COMMAND_CANCEL, chip->vendor.base + NSC_COMMAND); |
222 | } | 222 | } |
223 | 223 | ||
224 | static u8 tpm_nsc_status(struct tpm_chip *chip) | 224 | static u8 tpm_nsc_status(struct tpm_chip *chip) |
225 | { | 225 | { |
226 | return inb(chip->vendor->base + NSC_STATUS); | 226 | return inb(chip->vendor.base + NSC_STATUS); |
227 | } | 227 | } |
228 | 228 | ||
229 | static struct file_operations nsc_ops = { | 229 | static struct file_operations nsc_ops = { |
@@ -250,7 +250,7 @@ static struct attribute * nsc_attrs[] = { | |||
250 | 250 | ||
251 | static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs }; | 251 | static struct attribute_group nsc_attr_grp = { .attrs = nsc_attrs }; |
252 | 252 | ||
253 | static struct tpm_vendor_specific tpm_nsc = { | 253 | static const struct tpm_vendor_specific tpm_nsc = { |
254 | .recv = tpm_nsc_recv, | 254 | .recv = tpm_nsc_recv, |
255 | .send = tpm_nsc_send, | 255 | .send = tpm_nsc_send, |
256 | .cancel = tpm_nsc_cancel, | 256 | .cancel = tpm_nsc_cancel, |
@@ -268,7 +268,7 @@ static void __devexit tpm_nsc_remove(struct device *dev) | |||
268 | { | 268 | { |
269 | struct tpm_chip *chip = dev_get_drvdata(dev); | 269 | struct tpm_chip *chip = dev_get_drvdata(dev); |
270 | if ( chip ) { | 270 | if ( chip ) { |
271 | release_region(chip->vendor->base, 2); | 271 | release_region(chip->vendor.base, 2); |
272 | tpm_remove_hardware(chip->dev); | 272 | tpm_remove_hardware(chip->dev); |
273 | } | 273 | } |
274 | } | 274 | } |
@@ -286,7 +286,8 @@ static int __init init_nsc(void) | |||
286 | int rc = 0; | 286 | int rc = 0; |
287 | int lo, hi; | 287 | int lo, hi; |
288 | int nscAddrBase = TPM_ADDR; | 288 | int nscAddrBase = TPM_ADDR; |
289 | 289 | struct tpm_chip *chip; | |
290 | unsigned long base; | ||
290 | 291 | ||
291 | /* verify that it is a National part (SID) */ | 292 | /* verify that it is a National part (SID) */ |
292 | if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) { | 293 | if (tpm_read_index(TPM_ADDR, NSC_SID_INDEX) != 0xEF) { |
@@ -300,7 +301,7 @@ static int __init init_nsc(void) | |||
300 | 301 | ||
301 | hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); | 302 | hi = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_HI); |
302 | lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); | 303 | lo = tpm_read_index(nscAddrBase, TPM_NSC_BASE0_LO); |
303 | tpm_nsc.base = (hi<<8) | lo; | 304 | base = (hi<<8) | lo; |
304 | 305 | ||
305 | /* enable the DPM module */ | 306 | /* enable the DPM module */ |
306 | tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); | 307 | tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); |
@@ -320,13 +321,15 @@ static int __init init_nsc(void) | |||
320 | if ((rc = platform_device_register(pdev)) < 0) | 321 | if ((rc = platform_device_register(pdev)) < 0) |
321 | goto err_free_dev; | 322 | goto err_free_dev; |
322 | 323 | ||
323 | if (request_region(tpm_nsc.base, 2, "tpm_nsc0") == NULL ) { | 324 | if (request_region(base, 2, "tpm_nsc0") == NULL ) { |
324 | rc = -EBUSY; | 325 | rc = -EBUSY; |
325 | goto err_unreg_dev; | 326 | goto err_unreg_dev; |
326 | } | 327 | } |
327 | 328 | ||
328 | if ((rc = tpm_register_hardware(&pdev->dev, &tpm_nsc)) < 0) | 329 | if (!(chip = tpm_register_hardware(&pdev->dev, &tpm_nsc))) { |
330 | rc = -ENODEV; | ||
329 | goto err_rel_reg; | 331 | goto err_rel_reg; |
332 | } | ||
330 | 333 | ||
331 | dev_dbg(&pdev->dev, "NSC TPM detected\n"); | 334 | dev_dbg(&pdev->dev, "NSC TPM detected\n"); |
332 | dev_dbg(&pdev->dev, | 335 | dev_dbg(&pdev->dev, |
@@ -361,10 +364,12 @@ static int __init init_nsc(void) | |||
361 | "NSC TPM revision %d\n", | 364 | "NSC TPM revision %d\n", |
362 | tpm_read_index(nscAddrBase, 0x27) & 0x1F); | 365 | tpm_read_index(nscAddrBase, 0x27) & 0x1F); |
363 | 366 | ||
367 | chip->vendor.base = base; | ||
368 | |||
364 | return 0; | 369 | return 0; |
365 | 370 | ||
366 | err_rel_reg: | 371 | err_rel_reg: |
367 | release_region(tpm_nsc.base, 2); | 372 | release_region(base, 2); |
368 | err_unreg_dev: | 373 | err_unreg_dev: |
369 | platform_device_unregister(pdev); | 374 | platform_device_unregister(pdev); |
370 | err_free_dev: | 375 | err_free_dev: |
diff --git a/drivers/char/tpm/tpm_tis.c b/drivers/char/tpm/tpm_tis.c new file mode 100644 index 000000000000..b9cae9a238bb --- /dev/null +++ b/drivers/char/tpm/tpm_tis.c | |||
@@ -0,0 +1,669 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2005, 2006 IBM Corporation | ||
3 | * | ||
4 | * Authors: | ||
5 | * Leendert van Doorn <leendert@watson.ibm.com> | ||
6 | * Kylene Hall <kjhall@us.ibm.com> | ||
7 | * | ||
8 | * Device driver for TCG/TCPA TPM (trusted platform module). | ||
9 | * Specifications at www.trustedcomputinggroup.org | ||
10 | * | ||
11 | * This device driver implements the TPM interface as defined in | ||
12 | * the TCG TPM Interface Spec version 1.2, revision 1.0. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or | ||
15 | * modify it under the terms of the GNU General Public License as | ||
16 | * published by the Free Software Foundation, version 2 of the | ||
17 | * License. | ||
18 | */ | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/moduleparam.h> | ||
22 | #include <linux/pnp.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/wait.h> | ||
25 | #include "tpm.h" | ||
26 | |||
27 | #define TPM_HEADER_SIZE 10 | ||
28 | |||
29 | enum tis_access { | ||
30 | TPM_ACCESS_VALID = 0x80, | ||
31 | TPM_ACCESS_ACTIVE_LOCALITY = 0x20, | ||
32 | TPM_ACCESS_REQUEST_PENDING = 0x04, | ||
33 | TPM_ACCESS_REQUEST_USE = 0x02, | ||
34 | }; | ||
35 | |||
36 | enum tis_status { | ||
37 | TPM_STS_VALID = 0x80, | ||
38 | TPM_STS_COMMAND_READY = 0x40, | ||
39 | TPM_STS_GO = 0x20, | ||
40 | TPM_STS_DATA_AVAIL = 0x10, | ||
41 | TPM_STS_DATA_EXPECT = 0x08, | ||
42 | }; | ||
43 | |||
44 | enum tis_int_flags { | ||
45 | TPM_GLOBAL_INT_ENABLE = 0x80000000, | ||
46 | TPM_INTF_BURST_COUNT_STATIC = 0x100, | ||
47 | TPM_INTF_CMD_READY_INT = 0x080, | ||
48 | TPM_INTF_INT_EDGE_FALLING = 0x040, | ||
49 | TPM_INTF_INT_EDGE_RISING = 0x020, | ||
50 | TPM_INTF_INT_LEVEL_LOW = 0x010, | ||
51 | TPM_INTF_INT_LEVEL_HIGH = 0x008, | ||
52 | TPM_INTF_LOCALITY_CHANGE_INT = 0x004, | ||
53 | TPM_INTF_STS_VALID_INT = 0x002, | ||
54 | TPM_INTF_DATA_AVAIL_INT = 0x001, | ||
55 | }; | ||
56 | |||
57 | enum tis_defaults { | ||
58 | TIS_MEM_BASE = 0xFED4000, | ||
59 | TIS_MEM_LEN = 0x5000, | ||
60 | TIS_SHORT_TIMEOUT = 750, /* ms */ | ||
61 | TIS_LONG_TIMEOUT = 2000, /* 2 sec */ | ||
62 | }; | ||
63 | |||
64 | #define TPM_ACCESS(l) (0x0000 | ((l) << 12)) | ||
65 | #define TPM_INT_ENABLE(l) (0x0008 | ((l) << 12)) | ||
66 | #define TPM_INT_VECTOR(l) (0x000C | ((l) << 12)) | ||
67 | #define TPM_INT_STATUS(l) (0x0010 | ((l) << 12)) | ||
68 | #define TPM_INTF_CAPS(l) (0x0014 | ((l) << 12)) | ||
69 | #define TPM_STS(l) (0x0018 | ((l) << 12)) | ||
70 | #define TPM_DATA_FIFO(l) (0x0024 | ((l) << 12)) | ||
71 | |||
72 | #define TPM_DID_VID(l) (0x0F00 | ((l) << 12)) | ||
73 | #define TPM_RID(l) (0x0F04 | ((l) << 12)) | ||
74 | |||
75 | static LIST_HEAD(tis_chips); | ||
76 | static DEFINE_SPINLOCK(tis_lock); | ||
77 | |||
78 | static int check_locality(struct tpm_chip *chip, int l) | ||
79 | { | ||
80 | if ((ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & | ||
81 | (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == | ||
82 | (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) | ||
83 | return chip->vendor.locality = l; | ||
84 | |||
85 | return -1; | ||
86 | } | ||
87 | |||
88 | static void release_locality(struct tpm_chip *chip, int l, int force) | ||
89 | { | ||
90 | if (force || (ioread8(chip->vendor.iobase + TPM_ACCESS(l)) & | ||
91 | (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) == | ||
92 | (TPM_ACCESS_REQUEST_PENDING | TPM_ACCESS_VALID)) | ||
93 | iowrite8(TPM_ACCESS_ACTIVE_LOCALITY, | ||
94 | chip->vendor.iobase + TPM_ACCESS(l)); | ||
95 | } | ||
96 | |||
97 | static int request_locality(struct tpm_chip *chip, int l) | ||
98 | { | ||
99 | unsigned long stop; | ||
100 | long rc; | ||
101 | |||
102 | if (check_locality(chip, l) >= 0) | ||
103 | return l; | ||
104 | |||
105 | iowrite8(TPM_ACCESS_REQUEST_USE, | ||
106 | chip->vendor.iobase + TPM_ACCESS(l)); | ||
107 | |||
108 | if (chip->vendor.irq) { | ||
109 | rc = wait_event_interruptible_timeout(chip->vendor.int_queue, | ||
110 | (check_locality | ||
111 | (chip, l) >= 0), | ||
112 | chip->vendor.timeout_a); | ||
113 | if (rc > 0) | ||
114 | return l; | ||
115 | |||
116 | } else { | ||
117 | /* wait for burstcount */ | ||
118 | stop = jiffies + chip->vendor.timeout_a; | ||
119 | do { | ||
120 | if (check_locality(chip, l) >= 0) | ||
121 | return l; | ||
122 | msleep(TPM_TIMEOUT); | ||
123 | } | ||
124 | while (time_before(jiffies, stop)); | ||
125 | } | ||
126 | return -1; | ||
127 | } | ||
128 | |||
129 | static u8 tpm_tis_status(struct tpm_chip *chip) | ||
130 | { | ||
131 | return ioread8(chip->vendor.iobase + | ||
132 | TPM_STS(chip->vendor.locality)); | ||
133 | } | ||
134 | |||
135 | static void tpm_tis_ready(struct tpm_chip *chip) | ||
136 | { | ||
137 | /* this causes the current command to be aborted */ | ||
138 | iowrite8(TPM_STS_COMMAND_READY, | ||
139 | chip->vendor.iobase + TPM_STS(chip->vendor.locality)); | ||
140 | } | ||
141 | |||
142 | static int get_burstcount(struct tpm_chip *chip) | ||
143 | { | ||
144 | unsigned long stop; | ||
145 | int burstcnt; | ||
146 | |||
147 | /* wait for burstcount */ | ||
148 | /* which timeout value, spec has 2 answers (c & d) */ | ||
149 | stop = jiffies + chip->vendor.timeout_d; | ||
150 | do { | ||
151 | burstcnt = ioread8(chip->vendor.iobase + | ||
152 | TPM_STS(chip->vendor.locality) + 1); | ||
153 | burstcnt += ioread8(chip->vendor.iobase + | ||
154 | TPM_STS(chip->vendor.locality) + | ||
155 | 2) << 8; | ||
156 | if (burstcnt) | ||
157 | return burstcnt; | ||
158 | msleep(TPM_TIMEOUT); | ||
159 | } while (time_before(jiffies, stop)); | ||
160 | return -EBUSY; | ||
161 | } | ||
162 | |||
163 | static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout, | ||
164 | wait_queue_head_t *queue) | ||
165 | { | ||
166 | unsigned long stop; | ||
167 | long rc; | ||
168 | u8 status; | ||
169 | |||
170 | /* check current status */ | ||
171 | status = tpm_tis_status(chip); | ||
172 | if ((status & mask) == mask) | ||
173 | return 0; | ||
174 | |||
175 | if (chip->vendor.irq) { | ||
176 | rc = wait_event_interruptible_timeout(*queue, | ||
177 | ((tpm_tis_status | ||
178 | (chip) & mask) == | ||
179 | mask), timeout); | ||
180 | if (rc > 0) | ||
181 | return 0; | ||
182 | } else { | ||
183 | stop = jiffies + timeout; | ||
184 | do { | ||
185 | msleep(TPM_TIMEOUT); | ||
186 | status = tpm_tis_status(chip); | ||
187 | if ((status & mask) == mask) | ||
188 | return 0; | ||
189 | } while (time_before(jiffies, stop)); | ||
190 | } | ||
191 | return -ETIME; | ||
192 | } | ||
193 | |||
194 | static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count) | ||
195 | { | ||
196 | int size = 0, burstcnt; | ||
197 | while (size < count && | ||
198 | wait_for_stat(chip, | ||
199 | TPM_STS_DATA_AVAIL | TPM_STS_VALID, | ||
200 | chip->vendor.timeout_c, | ||
201 | &chip->vendor.read_queue) | ||
202 | == 0) { | ||
203 | burstcnt = get_burstcount(chip); | ||
204 | for (; burstcnt > 0 && size < count; burstcnt--) | ||
205 | buf[size++] = ioread8(chip->vendor.iobase + | ||
206 | TPM_DATA_FIFO(chip->vendor. | ||
207 | locality)); | ||
208 | } | ||
209 | return size; | ||
210 | } | ||
211 | |||
212 | static int tpm_tis_recv(struct tpm_chip *chip, u8 *buf, size_t count) | ||
213 | { | ||
214 | int size = 0; | ||
215 | int expected, status; | ||
216 | |||
217 | if (count < TPM_HEADER_SIZE) { | ||
218 | size = -EIO; | ||
219 | goto out; | ||
220 | } | ||
221 | |||
222 | /* read first 10 bytes, including tag, paramsize, and result */ | ||
223 | if ((size = | ||
224 | recv_data(chip, buf, TPM_HEADER_SIZE)) < TPM_HEADER_SIZE) { | ||
225 | dev_err(chip->dev, "Unable to read header\n"); | ||
226 | goto out; | ||
227 | } | ||
228 | |||
229 | expected = be32_to_cpu(*(__be32 *) (buf + 2)); | ||
230 | if (expected > count) { | ||
231 | size = -EIO; | ||
232 | goto out; | ||
233 | } | ||
234 | |||
235 | if ((size += | ||
236 | recv_data(chip, &buf[TPM_HEADER_SIZE], | ||
237 | expected - TPM_HEADER_SIZE)) < expected) { | ||
238 | dev_err(chip->dev, "Unable to read remainder of result\n"); | ||
239 | size = -ETIME; | ||
240 | goto out; | ||
241 | } | ||
242 | |||
243 | wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, | ||
244 | &chip->vendor.int_queue); | ||
245 | status = tpm_tis_status(chip); | ||
246 | if (status & TPM_STS_DATA_AVAIL) { /* retry? */ | ||
247 | dev_err(chip->dev, "Error left over data\n"); | ||
248 | size = -EIO; | ||
249 | goto out; | ||
250 | } | ||
251 | |||
252 | out: | ||
253 | tpm_tis_ready(chip); | ||
254 | release_locality(chip, chip->vendor.locality, 0); | ||
255 | return size; | ||
256 | } | ||
257 | |||
258 | /* | ||
259 | * If interrupts are used (signaled by an irq set in the vendor structure) | ||
260 | * tpm.c can skip polling for the data to be available as the interrupt is | ||
261 | * waited for here | ||
262 | */ | ||
263 | static int tpm_tis_send(struct tpm_chip *chip, u8 *buf, size_t len) | ||
264 | { | ||
265 | int rc, status, burstcnt; | ||
266 | size_t count = 0; | ||
267 | u32 ordinal; | ||
268 | |||
269 | if (request_locality(chip, 0) < 0) | ||
270 | return -EBUSY; | ||
271 | |||
272 | status = tpm_tis_status(chip); | ||
273 | if ((status & TPM_STS_COMMAND_READY) == 0) { | ||
274 | tpm_tis_ready(chip); | ||
275 | if (wait_for_stat | ||
276 | (chip, TPM_STS_COMMAND_READY, chip->vendor.timeout_b, | ||
277 | &chip->vendor.int_queue) < 0) { | ||
278 | rc = -ETIME; | ||
279 | goto out_err; | ||
280 | } | ||
281 | } | ||
282 | |||
283 | while (count < len - 1) { | ||
284 | burstcnt = get_burstcount(chip); | ||
285 | for (; burstcnt > 0 && count < len - 1; burstcnt--) { | ||
286 | iowrite8(buf[count], chip->vendor.iobase + | ||
287 | TPM_DATA_FIFO(chip->vendor.locality)); | ||
288 | count++; | ||
289 | } | ||
290 | |||
291 | wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, | ||
292 | &chip->vendor.int_queue); | ||
293 | status = tpm_tis_status(chip); | ||
294 | if ((status & TPM_STS_DATA_EXPECT) == 0) { | ||
295 | rc = -EIO; | ||
296 | goto out_err; | ||
297 | } | ||
298 | } | ||
299 | |||
300 | /* write last byte */ | ||
301 | iowrite8(buf[count], | ||
302 | chip->vendor.iobase + | ||
303 | TPM_DATA_FIFO(chip->vendor.locality)); | ||
304 | wait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, | ||
305 | &chip->vendor.int_queue); | ||
306 | status = tpm_tis_status(chip); | ||
307 | if ((status & TPM_STS_DATA_EXPECT) != 0) { | ||
308 | rc = -EIO; | ||
309 | goto out_err; | ||
310 | } | ||
311 | |||
312 | /* go and do it */ | ||
313 | iowrite8(TPM_STS_GO, | ||
314 | chip->vendor.iobase + TPM_STS(chip->vendor.locality)); | ||
315 | |||
316 | if (chip->vendor.irq) { | ||
317 | ordinal = be32_to_cpu(*((__be32 *) (buf + 6))); | ||
318 | if (wait_for_stat | ||
319 | (chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID, | ||
320 | tpm_calc_ordinal_duration(chip, ordinal), | ||
321 | &chip->vendor.read_queue) < 0) { | ||
322 | rc = -ETIME; | ||
323 | goto out_err; | ||
324 | } | ||
325 | } | ||
326 | return len; | ||
327 | out_err: | ||
328 | tpm_tis_ready(chip); | ||
329 | release_locality(chip, chip->vendor.locality, 0); | ||
330 | return rc; | ||
331 | } | ||
332 | |||
333 | static struct file_operations tis_ops = { | ||
334 | .owner = THIS_MODULE, | ||
335 | .llseek = no_llseek, | ||
336 | .open = tpm_open, | ||
337 | .read = tpm_read, | ||
338 | .write = tpm_write, | ||
339 | .release = tpm_release, | ||
340 | }; | ||
341 | |||
342 | static DEVICE_ATTR(pubek, S_IRUGO, tpm_show_pubek, NULL); | ||
343 | static DEVICE_ATTR(pcrs, S_IRUGO, tpm_show_pcrs, NULL); | ||
344 | static DEVICE_ATTR(enabled, S_IRUGO, tpm_show_enabled, NULL); | ||
345 | static DEVICE_ATTR(active, S_IRUGO, tpm_show_active, NULL); | ||
346 | static DEVICE_ATTR(owned, S_IRUGO, tpm_show_owned, NULL); | ||
347 | static DEVICE_ATTR(temp_deactivated, S_IRUGO, tpm_show_temp_deactivated, | ||
348 | NULL); | ||
349 | static DEVICE_ATTR(caps, S_IRUGO, tpm_show_caps_1_2, NULL); | ||
350 | static DEVICE_ATTR(cancel, S_IWUSR | S_IWGRP, NULL, tpm_store_cancel); | ||
351 | |||
352 | static struct attribute *tis_attrs[] = { | ||
353 | &dev_attr_pubek.attr, | ||
354 | &dev_attr_pcrs.attr, | ||
355 | &dev_attr_enabled.attr, | ||
356 | &dev_attr_active.attr, | ||
357 | &dev_attr_owned.attr, | ||
358 | &dev_attr_temp_deactivated.attr, | ||
359 | &dev_attr_caps.attr, | ||
360 | &dev_attr_cancel.attr, NULL, | ||
361 | }; | ||
362 | |||
363 | static struct attribute_group tis_attr_grp = { | ||
364 | .attrs = tis_attrs | ||
365 | }; | ||
366 | |||
367 | static struct tpm_vendor_specific tpm_tis = { | ||
368 | .status = tpm_tis_status, | ||
369 | .recv = tpm_tis_recv, | ||
370 | .send = tpm_tis_send, | ||
371 | .cancel = tpm_tis_ready, | ||
372 | .req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | ||
373 | .req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID, | ||
374 | .req_canceled = TPM_STS_COMMAND_READY, | ||
375 | .attr_group = &tis_attr_grp, | ||
376 | .miscdev = { | ||
377 | .fops = &tis_ops,}, | ||
378 | }; | ||
379 | |||
380 | static irqreturn_t tis_int_probe(int irq, void *dev_id, struct pt_regs *regs) | ||
381 | { | ||
382 | struct tpm_chip *chip = (struct tpm_chip *) dev_id; | ||
383 | u32 interrupt; | ||
384 | |||
385 | interrupt = ioread32(chip->vendor.iobase + | ||
386 | TPM_INT_STATUS(chip->vendor.locality)); | ||
387 | |||
388 | if (interrupt == 0) | ||
389 | return IRQ_NONE; | ||
390 | |||
391 | chip->vendor.irq = irq; | ||
392 | |||
393 | /* Clear interrupts handled with TPM_EOI */ | ||
394 | iowrite32(interrupt, | ||
395 | chip->vendor.iobase + | ||
396 | TPM_INT_STATUS(chip->vendor.locality)); | ||
397 | return IRQ_HANDLED; | ||
398 | } | ||
399 | |||
400 | static irqreturn_t tis_int_handler(int irq, void *dev_id, struct pt_regs *regs) | ||
401 | { | ||
402 | struct tpm_chip *chip = (struct tpm_chip *) dev_id; | ||
403 | u32 interrupt; | ||
404 | int i; | ||
405 | |||
406 | interrupt = ioread32(chip->vendor.iobase + | ||
407 | TPM_INT_STATUS(chip->vendor.locality)); | ||
408 | |||
409 | if (interrupt == 0) | ||
410 | return IRQ_NONE; | ||
411 | |||
412 | if (interrupt & TPM_INTF_DATA_AVAIL_INT) | ||
413 | wake_up_interruptible(&chip->vendor.read_queue); | ||
414 | if (interrupt & TPM_INTF_LOCALITY_CHANGE_INT) | ||
415 | for (i = 0; i < 5; i++) | ||
416 | if (check_locality(chip, i) >= 0) | ||
417 | break; | ||
418 | if (interrupt & | ||
419 | (TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_STS_VALID_INT | | ||
420 | TPM_INTF_CMD_READY_INT)) | ||
421 | wake_up_interruptible(&chip->vendor.int_queue); | ||
422 | |||
423 | /* Clear interrupts handled with TPM_EOI */ | ||
424 | iowrite32(interrupt, | ||
425 | chip->vendor.iobase + | ||
426 | TPM_INT_STATUS(chip->vendor.locality)); | ||
427 | return IRQ_HANDLED; | ||
428 | } | ||
429 | |||
430 | static int interrupts = 1; | ||
431 | module_param(interrupts, bool, 0444); | ||
432 | MODULE_PARM_DESC(interrupts, "Enable interrupts"); | ||
433 | |||
434 | static int __devinit tpm_tis_pnp_init(struct pnp_dev *pnp_dev, | ||
435 | const struct pnp_device_id *pnp_id) | ||
436 | { | ||
437 | u32 vendor, intfcaps, intmask; | ||
438 | int rc, i; | ||
439 | unsigned long start, len; | ||
440 | struct tpm_chip *chip; | ||
441 | |||
442 | start = pnp_mem_start(pnp_dev, 0); | ||
443 | len = pnp_mem_len(pnp_dev, 0); | ||
444 | |||
445 | if (!start) | ||
446 | start = TIS_MEM_BASE; | ||
447 | if (!len) | ||
448 | len = TIS_MEM_LEN; | ||
449 | |||
450 | if (!(chip = tpm_register_hardware(&pnp_dev->dev, &tpm_tis))) | ||
451 | return -ENODEV; | ||
452 | |||
453 | chip->vendor.iobase = ioremap(start, len); | ||
454 | if (!chip->vendor.iobase) { | ||
455 | rc = -EIO; | ||
456 | goto out_err; | ||
457 | } | ||
458 | |||
459 | vendor = ioread32(chip->vendor.iobase + TPM_DID_VID(0)); | ||
460 | if ((vendor & 0xFFFF) == 0xFFFF) { | ||
461 | rc = -ENODEV; | ||
462 | goto out_err; | ||
463 | } | ||
464 | |||
465 | /* Default timeouts */ | ||
466 | chip->vendor.timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT); | ||
467 | chip->vendor.timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT); | ||
468 | chip->vendor.timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT); | ||
469 | chip->vendor.timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT); | ||
470 | |||
471 | dev_info(&pnp_dev->dev, | ||
472 | "1.2 TPM (device-id 0x%X, rev-id %d)\n", | ||
473 | vendor >> 16, ioread8(chip->vendor.iobase + TPM_RID(0))); | ||
474 | |||
475 | /* Figure out the capabilities */ | ||
476 | intfcaps = | ||
477 | ioread32(chip->vendor.iobase + | ||
478 | TPM_INTF_CAPS(chip->vendor.locality)); | ||
479 | dev_dbg(&pnp_dev->dev, "TPM interface capabilities (0x%x):\n", | ||
480 | intfcaps); | ||
481 | if (intfcaps & TPM_INTF_BURST_COUNT_STATIC) | ||
482 | dev_dbg(&pnp_dev->dev, "\tBurst Count Static\n"); | ||
483 | if (intfcaps & TPM_INTF_CMD_READY_INT) | ||
484 | dev_dbg(&pnp_dev->dev, "\tCommand Ready Int Support\n"); | ||
485 | if (intfcaps & TPM_INTF_INT_EDGE_FALLING) | ||
486 | dev_dbg(&pnp_dev->dev, "\tInterrupt Edge Falling\n"); | ||
487 | if (intfcaps & TPM_INTF_INT_EDGE_RISING) | ||
488 | dev_dbg(&pnp_dev->dev, "\tInterrupt Edge Rising\n"); | ||
489 | if (intfcaps & TPM_INTF_INT_LEVEL_LOW) | ||
490 | dev_dbg(&pnp_dev->dev, "\tInterrupt Level Low\n"); | ||
491 | if (intfcaps & TPM_INTF_INT_LEVEL_HIGH) | ||
492 | dev_dbg(&pnp_dev->dev, "\tInterrupt Level High\n"); | ||
493 | if (intfcaps & TPM_INTF_LOCALITY_CHANGE_INT) | ||
494 | dev_dbg(&pnp_dev->dev, "\tLocality Change Int Support\n"); | ||
495 | if (intfcaps & TPM_INTF_STS_VALID_INT) | ||
496 | dev_dbg(&pnp_dev->dev, "\tSts Valid Int Support\n"); | ||
497 | if (intfcaps & TPM_INTF_DATA_AVAIL_INT) | ||
498 | dev_dbg(&pnp_dev->dev, "\tData Avail Int Support\n"); | ||
499 | |||
500 | if (request_locality(chip, 0) != 0) { | ||
501 | rc = -ENODEV; | ||
502 | goto out_err; | ||
503 | } | ||
504 | |||
505 | /* INTERRUPT Setup */ | ||
506 | init_waitqueue_head(&chip->vendor.read_queue); | ||
507 | init_waitqueue_head(&chip->vendor.int_queue); | ||
508 | |||
509 | intmask = | ||
510 | ioread32(chip->vendor.iobase + | ||
511 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
512 | |||
513 | intmask |= TPM_INTF_CMD_READY_INT | ||
514 | | TPM_INTF_LOCALITY_CHANGE_INT | TPM_INTF_DATA_AVAIL_INT | ||
515 | | TPM_INTF_STS_VALID_INT; | ||
516 | |||
517 | iowrite32(intmask, | ||
518 | chip->vendor.iobase + | ||
519 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
520 | if (interrupts) { | ||
521 | chip->vendor.irq = | ||
522 | ioread8(chip->vendor.iobase + | ||
523 | TPM_INT_VECTOR(chip->vendor.locality)); | ||
524 | |||
525 | for (i = 3; i < 16 && chip->vendor.irq == 0; i++) { | ||
526 | iowrite8(i, chip->vendor.iobase + | ||
527 | TPM_INT_VECTOR(chip->vendor.locality)); | ||
528 | if (request_irq | ||
529 | (i, tis_int_probe, SA_SHIRQ, | ||
530 | chip->vendor.miscdev.name, chip) != 0) { | ||
531 | dev_info(chip->dev, | ||
532 | "Unable to request irq: %d for probe\n", | ||
533 | i); | ||
534 | continue; | ||
535 | } | ||
536 | |||
537 | /* Clear all existing */ | ||
538 | iowrite32(ioread32 | ||
539 | (chip->vendor.iobase + | ||
540 | TPM_INT_STATUS(chip->vendor.locality)), | ||
541 | chip->vendor.iobase + | ||
542 | TPM_INT_STATUS(chip->vendor.locality)); | ||
543 | |||
544 | /* Turn on */ | ||
545 | iowrite32(intmask | TPM_GLOBAL_INT_ENABLE, | ||
546 | chip->vendor.iobase + | ||
547 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
548 | |||
549 | /* Generate Interrupts */ | ||
550 | tpm_gen_interrupt(chip); | ||
551 | |||
552 | /* Turn off */ | ||
553 | iowrite32(intmask, | ||
554 | chip->vendor.iobase + | ||
555 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
556 | free_irq(i, chip); | ||
557 | } | ||
558 | } | ||
559 | if (chip->vendor.irq) { | ||
560 | iowrite8(chip->vendor.irq, | ||
561 | chip->vendor.iobase + | ||
562 | TPM_INT_VECTOR(chip->vendor.locality)); | ||
563 | if (request_irq | ||
564 | (chip->vendor.irq, tis_int_handler, SA_SHIRQ, | ||
565 | chip->vendor.miscdev.name, chip) != 0) { | ||
566 | dev_info(chip->dev, | ||
567 | "Unable to request irq: %d for use\n", | ||
568 | chip->vendor.irq); | ||
569 | chip->vendor.irq = 0; | ||
570 | } else { | ||
571 | /* Clear all existing */ | ||
572 | iowrite32(ioread32 | ||
573 | (chip->vendor.iobase + | ||
574 | TPM_INT_STATUS(chip->vendor.locality)), | ||
575 | chip->vendor.iobase + | ||
576 | TPM_INT_STATUS(chip->vendor.locality)); | ||
577 | |||
578 | /* Turn on */ | ||
579 | iowrite32(intmask | TPM_GLOBAL_INT_ENABLE, | ||
580 | chip->vendor.iobase + | ||
581 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
582 | } | ||
583 | } | ||
584 | |||
585 | INIT_LIST_HEAD(&chip->vendor.list); | ||
586 | spin_lock(&tis_lock); | ||
587 | list_add(&chip->vendor.list, &tis_chips); | ||
588 | spin_unlock(&tis_lock); | ||
589 | |||
590 | tpm_get_timeouts(chip); | ||
591 | tpm_continue_selftest(chip); | ||
592 | |||
593 | return 0; | ||
594 | out_err: | ||
595 | if (chip->vendor.iobase) | ||
596 | iounmap(chip->vendor.iobase); | ||
597 | tpm_remove_hardware(chip->dev); | ||
598 | return rc; | ||
599 | } | ||
600 | |||
601 | static int tpm_tis_pnp_suspend(struct pnp_dev *dev, pm_message_t msg) | ||
602 | { | ||
603 | return tpm_pm_suspend(&dev->dev, msg); | ||
604 | } | ||
605 | |||
606 | static int tpm_tis_pnp_resume(struct pnp_dev *dev) | ||
607 | { | ||
608 | return tpm_pm_resume(&dev->dev); | ||
609 | } | ||
610 | |||
611 | static struct pnp_device_id tpm_pnp_tbl[] __devinitdata = { | ||
612 | {"PNP0C31", 0}, /* TPM */ | ||
613 | {"ATM1200", 0}, /* Atmel */ | ||
614 | {"IFX0102", 0}, /* Infineon */ | ||
615 | {"BCM0101", 0}, /* Broadcom */ | ||
616 | {"NSC1200", 0}, /* National */ | ||
617 | /* Add new here */ | ||
618 | {"", 0}, /* User Specified */ | ||
619 | {"", 0} /* Terminator */ | ||
620 | }; | ||
621 | |||
622 | static struct pnp_driver tis_pnp_driver = { | ||
623 | .name = "tpm_tis", | ||
624 | .id_table = tpm_pnp_tbl, | ||
625 | .probe = tpm_tis_pnp_init, | ||
626 | .suspend = tpm_tis_pnp_suspend, | ||
627 | .resume = tpm_tis_pnp_resume, | ||
628 | }; | ||
629 | |||
630 | #define TIS_HID_USR_IDX sizeof(tpm_pnp_tbl)/sizeof(struct pnp_device_id) -2 | ||
631 | module_param_string(hid, tpm_pnp_tbl[TIS_HID_USR_IDX].id, | ||
632 | sizeof(tpm_pnp_tbl[TIS_HID_USR_IDX].id), 0444); | ||
633 | MODULE_PARM_DESC(hid, "Set additional specific HID for this driver to probe"); | ||
634 | |||
635 | static int __init init_tis(void) | ||
636 | { | ||
637 | return pnp_register_driver(&tis_pnp_driver); | ||
638 | } | ||
639 | |||
640 | static void __exit cleanup_tis(void) | ||
641 | { | ||
642 | struct tpm_vendor_specific *i, *j; | ||
643 | struct tpm_chip *chip; | ||
644 | spin_lock(&tis_lock); | ||
645 | list_for_each_entry_safe(i, j, &tis_chips, list) { | ||
646 | chip = to_tpm_chip(i); | ||
647 | iowrite32(~TPM_GLOBAL_INT_ENABLE & | ||
648 | ioread32(chip->vendor.iobase + | ||
649 | TPM_INT_ENABLE(chip->vendor. | ||
650 | locality)), | ||
651 | chip->vendor.iobase + | ||
652 | TPM_INT_ENABLE(chip->vendor.locality)); | ||
653 | release_locality(chip, chip->vendor.locality, 1); | ||
654 | if (chip->vendor.irq) | ||
655 | free_irq(chip->vendor.irq, chip); | ||
656 | iounmap(i->iobase); | ||
657 | list_del(&i->list); | ||
658 | tpm_remove_hardware(chip->dev); | ||
659 | } | ||
660 | spin_unlock(&tis_lock); | ||
661 | pnp_unregister_driver(&tis_pnp_driver); | ||
662 | } | ||
663 | |||
664 | module_init(init_tis); | ||
665 | module_exit(cleanup_tis); | ||
666 | MODULE_AUTHOR("Leendert van Doorn (leendert@watson.ibm.com)"); | ||
667 | MODULE_DESCRIPTION("TPM Driver"); | ||
668 | MODULE_VERSION("2.0"); | ||
669 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 841f0bd3eaaf..f07637a8f88f 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -2723,7 +2723,11 @@ static void __do_SAK(void *arg) | |||
2723 | } | 2723 | } |
2724 | task_lock(p); | 2724 | task_lock(p); |
2725 | if (p->files) { | 2725 | if (p->files) { |
2726 | rcu_read_lock(); | 2726 | /* |
2727 | * We don't take a ref to the file, so we must | ||
2728 | * hold ->file_lock instead. | ||
2729 | */ | ||
2730 | spin_lock(&p->files->file_lock); | ||
2727 | fdt = files_fdtable(p->files); | 2731 | fdt = files_fdtable(p->files); |
2728 | for (i=0; i < fdt->max_fds; i++) { | 2732 | for (i=0; i < fdt->max_fds; i++) { |
2729 | filp = fcheck_files(p->files, i); | 2733 | filp = fcheck_files(p->files, i); |
@@ -2738,7 +2742,7 @@ static void __do_SAK(void *arg) | |||
2738 | break; | 2742 | break; |
2739 | } | 2743 | } |
2740 | } | 2744 | } |
2741 | rcu_read_unlock(); | 2745 | spin_unlock(&p->files->file_lock); |
2742 | } | 2746 | } |
2743 | task_unlock(p); | 2747 | task_unlock(p); |
2744 | } while_each_thread(g, p); | 2748 | } while_each_thread(g, p); |
diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig index 60c9be99c6d9..2cc71b66231e 100644 --- a/drivers/cpufreq/Kconfig +++ b/drivers/cpufreq/Kconfig | |||
@@ -99,7 +99,7 @@ config CPU_FREQ_GOV_USERSPACE | |||
99 | Enable this cpufreq governor when you either want to set the | 99 | Enable this cpufreq governor when you either want to set the |
100 | CPU frequency manually or when an userspace program shall | 100 | CPU frequency manually or when an userspace program shall |
101 | be able to set the CPU dynamically, like on LART | 101 | be able to set the CPU dynamically, like on LART |
102 | <http://www.lart.tudelft.nl/> | 102 | <http://www.lartmaker.nl/>. |
103 | 103 | ||
104 | For details, take a look at <file:Documentation/cpu-freq/>. | 104 | For details, take a look at <file:Documentation/cpu-freq/>. |
105 | 105 | ||
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 9b6ae7dc8b8a..29b2fa5534ae 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
@@ -319,7 +319,6 @@ out: | |||
319 | } | 319 | } |
320 | return -EINVAL; | 320 | return -EINVAL; |
321 | } | 321 | } |
322 | EXPORT_SYMBOL_GPL(cpufreq_parse_governor); | ||
323 | 322 | ||
324 | 323 | ||
325 | /* drivers/base/cpu.c */ | 324 | /* drivers/base/cpu.c */ |
@@ -346,6 +345,8 @@ show_one(scaling_min_freq, min); | |||
346 | show_one(scaling_max_freq, max); | 345 | show_one(scaling_max_freq, max); |
347 | show_one(scaling_cur_freq, cur); | 346 | show_one(scaling_cur_freq, cur); |
348 | 347 | ||
348 | static int __cpufreq_set_policy(struct cpufreq_policy *data, struct cpufreq_policy *policy); | ||
349 | |||
349 | /** | 350 | /** |
350 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access | 351 | * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access |
351 | */ | 352 | */ |
@@ -364,7 +365,10 @@ static ssize_t store_##file_name \ | |||
364 | if (ret != 1) \ | 365 | if (ret != 1) \ |
365 | return -EINVAL; \ | 366 | return -EINVAL; \ |
366 | \ | 367 | \ |
367 | ret = cpufreq_set_policy(&new_policy); \ | 368 | mutex_lock(&policy->lock); \ |
369 | ret = __cpufreq_set_policy(policy, &new_policy); \ | ||
370 | policy->user_policy.object = policy->object; \ | ||
371 | mutex_unlock(&policy->lock); \ | ||
368 | \ | 372 | \ |
369 | return ret ? ret : count; \ | 373 | return ret ? ret : count; \ |
370 | } | 374 | } |
@@ -420,7 +424,15 @@ static ssize_t store_scaling_governor (struct cpufreq_policy * policy, | |||
420 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) | 424 | if (cpufreq_parse_governor(str_governor, &new_policy.policy, &new_policy.governor)) |
421 | return -EINVAL; | 425 | return -EINVAL; |
422 | 426 | ||
423 | ret = cpufreq_set_policy(&new_policy); | 427 | /* Do not use cpufreq_set_policy here or the user_policy.max |
428 | will be wrongly overridden */ | ||
429 | mutex_lock(&policy->lock); | ||
430 | ret = __cpufreq_set_policy(policy, &new_policy); | ||
431 | |||
432 | policy->user_policy.policy = policy->policy; | ||
433 | policy->user_policy.governor = policy->governor; | ||
434 | mutex_unlock(&policy->lock); | ||
435 | |||
424 | return ret ? ret : count; | 436 | return ret ? ret : count; |
425 | } | 437 | } |
426 | 438 | ||
@@ -685,7 +697,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
685 | if (!cpu_online(j)) | 697 | if (!cpu_online(j)) |
686 | continue; | 698 | continue; |
687 | 699 | ||
688 | dprintk("CPU already managed, adding link\n"); | 700 | dprintk("CPU %u already managed, adding link\n", j); |
689 | cpufreq_cpu_get(cpu); | 701 | cpufreq_cpu_get(cpu); |
690 | cpu_sys_dev = get_cpu_sysdev(j); | 702 | cpu_sys_dev = get_cpu_sysdev(j); |
691 | sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, | 703 | sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj, |
@@ -695,9 +707,8 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
695 | policy->governor = NULL; /* to assure that the starting sequence is | 707 | policy->governor = NULL; /* to assure that the starting sequence is |
696 | * run in cpufreq_set_policy */ | 708 | * run in cpufreq_set_policy */ |
697 | mutex_unlock(&policy->lock); | 709 | mutex_unlock(&policy->lock); |
698 | 710 | ||
699 | /* set default policy */ | 711 | /* set default policy */ |
700 | |||
701 | ret = cpufreq_set_policy(&new_policy); | 712 | ret = cpufreq_set_policy(&new_policy); |
702 | if (ret) { | 713 | if (ret) { |
703 | dprintk("setting policy failed\n"); | 714 | dprintk("setting policy failed\n"); |
@@ -707,7 +718,7 @@ static int cpufreq_add_dev (struct sys_device * sys_dev) | |||
707 | module_put(cpufreq_driver->owner); | 718 | module_put(cpufreq_driver->owner); |
708 | dprintk("initialization complete\n"); | 719 | dprintk("initialization complete\n"); |
709 | cpufreq_debug_enable_ratelimit(); | 720 | cpufreq_debug_enable_ratelimit(); |
710 | 721 | ||
711 | return 0; | 722 | return 0; |
712 | 723 | ||
713 | 724 | ||
@@ -1486,7 +1497,7 @@ int cpufreq_update_policy(unsigned int cpu) | |||
1486 | } | 1497 | } |
1487 | EXPORT_SYMBOL(cpufreq_update_policy); | 1498 | EXPORT_SYMBOL(cpufreq_update_policy); |
1488 | 1499 | ||
1489 | static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb, | 1500 | static int cpufreq_cpu_callback(struct notifier_block *nfb, |
1490 | unsigned long action, void *hcpu) | 1501 | unsigned long action, void *hcpu) |
1491 | { | 1502 | { |
1492 | unsigned int cpu = (unsigned long)hcpu; | 1503 | unsigned int cpu = (unsigned long)hcpu; |
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c index 037f6bf4543c..e07a35487bde 100644 --- a/drivers/cpufreq/cpufreq_conservative.c +++ b/drivers/cpufreq/cpufreq_conservative.c | |||
@@ -176,8 +176,7 @@ static ssize_t store_up_threshold(struct cpufreq_policy *unused, | |||
176 | ret = sscanf (buf, "%u", &input); | 176 | ret = sscanf (buf, "%u", &input); |
177 | 177 | ||
178 | mutex_lock(&dbs_mutex); | 178 | mutex_lock(&dbs_mutex); |
179 | if (ret != 1 || input > 100 || input < 0 || | 179 | if (ret != 1 || input > 100 || input <= dbs_tuners_ins.down_threshold) { |
180 | input <= dbs_tuners_ins.down_threshold) { | ||
181 | mutex_unlock(&dbs_mutex); | 180 | mutex_unlock(&dbs_mutex); |
182 | return -EINVAL; | 181 | return -EINVAL; |
183 | } | 182 | } |
@@ -196,8 +195,7 @@ static ssize_t store_down_threshold(struct cpufreq_policy *unused, | |||
196 | ret = sscanf (buf, "%u", &input); | 195 | ret = sscanf (buf, "%u", &input); |
197 | 196 | ||
198 | mutex_lock(&dbs_mutex); | 197 | mutex_lock(&dbs_mutex); |
199 | if (ret != 1 || input > 100 || input < 0 || | 198 | if (ret != 1 || input > 100 || input >= dbs_tuners_ins.up_threshold) { |
200 | input >= dbs_tuners_ins.up_threshold) { | ||
201 | mutex_unlock(&dbs_mutex); | 199 | mutex_unlock(&dbs_mutex); |
202 | return -EINVAL; | 200 | return -EINVAL; |
203 | } | 201 | } |
diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c index 8e0f3158215f..dfca74933625 100644 --- a/drivers/i2c/busses/i2c-i801.c +++ b/drivers/i2c/busses/i2c-i801.c | |||
@@ -478,6 +478,11 @@ static s32 i801_access(struct i2c_adapter * adap, u16 addr, | |||
478 | ret = i801_transaction(); | 478 | ret = i801_transaction(); |
479 | } | 479 | } |
480 | 480 | ||
481 | /* Some BIOSes don't like it when PEC is enabled at reboot or resume | ||
482 | time, so we forcibly disable it after every transaction. */ | ||
483 | if (hwpec) | ||
484 | outb_p(0, SMBAUXCTL); | ||
485 | |||
481 | if(block) | 486 | if(block) |
482 | return ret; | 487 | return ret; |
483 | if(ret) | 488 | if(ret) |
diff --git a/drivers/i2c/chips/m41t00.c b/drivers/i2c/chips/m41t00.c index 27fc9ff2961a..99ab4ec34390 100644 --- a/drivers/i2c/chips/m41t00.c +++ b/drivers/i2c/chips/m41t00.c | |||
@@ -131,13 +131,13 @@ m41t00_set(void *arg) | |||
131 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) | 131 | if ((i2c_smbus_write_byte_data(save_client, 0, tm.tm_sec & 0x7f) < 0) |
132 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) | 132 | || (i2c_smbus_write_byte_data(save_client, 1, tm.tm_min & 0x7f) |
133 | < 0) | 133 | < 0) |
134 | || (i2c_smbus_write_byte_data(save_client, 2, tm.tm_hour & 0x7f) | 134 | || (i2c_smbus_write_byte_data(save_client, 2, tm.tm_hour & 0x3f) |
135 | < 0) | 135 | < 0) |
136 | || (i2c_smbus_write_byte_data(save_client, 4, tm.tm_mday & 0x7f) | 136 | || (i2c_smbus_write_byte_data(save_client, 4, tm.tm_mday & 0x3f) |
137 | < 0) | 137 | < 0) |
138 | || (i2c_smbus_write_byte_data(save_client, 5, tm.tm_mon & 0x7f) | 138 | || (i2c_smbus_write_byte_data(save_client, 5, tm.tm_mon & 0x1f) |
139 | < 0) | 139 | < 0) |
140 | || (i2c_smbus_write_byte_data(save_client, 6, tm.tm_year & 0x7f) | 140 | || (i2c_smbus_write_byte_data(save_client, 6, tm.tm_year & 0xff) |
141 | < 0)) | 141 | < 0)) |
142 | 142 | ||
143 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); | 143 | dev_warn(&save_client->dev,"m41t00: can't write to rtc chip\n"); |
diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c index cf84350efc55..8b24b4f2a839 100644 --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c | |||
@@ -731,6 +731,8 @@ static unsigned int __devinit ata66_ali15x3 (ide_hwif_t *hwif) | |||
731 | 731 | ||
732 | if(m5229_revision <= 0x20) | 732 | if(m5229_revision <= 0x20) |
733 | tmpbyte = (tmpbyte & (~0x02)) | 0x01; | 733 | tmpbyte = (tmpbyte & (~0x02)) | 0x01; |
734 | else if (m5229_revision == 0xc7) | ||
735 | tmpbyte |= 0x03; | ||
734 | else | 736 | else |
735 | tmpbyte |= 0x01; | 737 | tmpbyte |= 0x01; |
736 | 738 | ||
diff --git a/drivers/ide/pci/atiixp.c b/drivers/ide/pci/atiixp.c index df9ee9a78435..900efd1da587 100644 --- a/drivers/ide/pci/atiixp.c +++ b/drivers/ide/pci/atiixp.c | |||
@@ -348,6 +348,7 @@ static struct pci_device_id atiixp_pci_tbl[] = { | |||
348 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 348 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP200_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
349 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 349 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP300_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
350 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 350 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, |
351 | { PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP600_IDE, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | ||
351 | { 0, }, | 352 | { 0, }, |
352 | }; | 353 | }; |
353 | MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); | 354 | MODULE_DEVICE_TABLE(pci, atiixp_pci_tbl); |
diff --git a/drivers/ide/pci/pdc202xx_old.c b/drivers/ide/pci/pdc202xx_old.c index 6f8f8645b02c..7ce5bf783688 100644 --- a/drivers/ide/pci/pdc202xx_old.c +++ b/drivers/ide/pci/pdc202xx_old.c | |||
@@ -798,7 +798,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = { | |||
798 | .autodma = AUTODMA, | 798 | .autodma = AUTODMA, |
799 | .bootable = OFF_BOARD, | 799 | .bootable = OFF_BOARD, |
800 | .extra = 48, | 800 | .extra = 48, |
801 | .flags = IDEPCI_FLAG_FORCE_PDC, | ||
802 | },{ /* 2 */ | 801 | },{ /* 2 */ |
803 | .name = "PDC20263", | 802 | .name = "PDC20263", |
804 | .init_setup = init_setup_pdc202ata4, | 803 | .init_setup = init_setup_pdc202ata4, |
@@ -819,7 +818,6 @@ static ide_pci_device_t pdc202xx_chipsets[] __devinitdata = { | |||
819 | .autodma = AUTODMA, | 818 | .autodma = AUTODMA, |
820 | .bootable = OFF_BOARD, | 819 | .bootable = OFF_BOARD, |
821 | .extra = 48, | 820 | .extra = 48, |
822 | .flags = IDEPCI_FLAG_FORCE_PDC, | ||
823 | },{ /* 4 */ | 821 | },{ /* 4 */ |
824 | .name = "PDC20267", | 822 | .name = "PDC20267", |
825 | .init_setup = init_setup_pdc202xx, | 823 | .init_setup = init_setup_pdc202xx, |
diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c index 7ebf992e8c2f..462ed3006c30 100644 --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c | |||
@@ -580,7 +580,6 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
580 | int port; | 580 | int port; |
581 | int at_least_one_hwif_enabled = 0; | 581 | int at_least_one_hwif_enabled = 0; |
582 | ide_hwif_t *hwif, *mate = NULL; | 582 | ide_hwif_t *hwif, *mate = NULL; |
583 | static int secondpdc = 0; | ||
584 | u8 tmp; | 583 | u8 tmp; |
585 | 584 | ||
586 | index->all = 0xf0f0; | 585 | index->all = 0xf0f0; |
@@ -592,21 +591,9 @@ void ide_pci_setup_ports(struct pci_dev *dev, ide_pci_device_t *d, int pciirq, a | |||
592 | for (port = 0; port <= 1; ++port) { | 591 | for (port = 0; port <= 1; ++port) { |
593 | ide_pci_enablebit_t *e = &(d->enablebits[port]); | 592 | ide_pci_enablebit_t *e = &(d->enablebits[port]); |
594 | 593 | ||
595 | /* | ||
596 | * If this is a Promise FakeRaid controller, | ||
597 | * the 2nd controller will be marked as | ||
598 | * disabled while it is actually there and enabled | ||
599 | * by the bios for raid purposes. | ||
600 | * Skip the normal "is it enabled" test for those. | ||
601 | */ | ||
602 | if ((d->flags & IDEPCI_FLAG_FORCE_PDC) && | ||
603 | (secondpdc++==1) && (port==1)) | ||
604 | goto controller_ok; | ||
605 | |||
606 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || | 594 | if (e->reg && (pci_read_config_byte(dev, e->reg, &tmp) || |
607 | (tmp & e->mask) != e->val)) | 595 | (tmp & e->mask) != e->val)) |
608 | continue; /* port not enabled */ | 596 | continue; /* port not enabled */ |
609 | controller_ok: | ||
610 | 597 | ||
611 | if (d->channels <= port) | 598 | if (d->channels <= port) |
612 | break; | 599 | break; |
diff --git a/drivers/infiniband/core/mad.c b/drivers/infiniband/core/mad.c index 3a702da83e41..469b6923a2e2 100644 --- a/drivers/infiniband/core/mad.c +++ b/drivers/infiniband/core/mad.c | |||
@@ -228,10 +228,7 @@ struct ib_mad_agent *ib_register_mad_agent(struct ib_device *device, | |||
228 | goto error1; | 228 | goto error1; |
229 | } | 229 | } |
230 | /* Make sure class supplied is consistent with RMPP */ | 230 | /* Make sure class supplied is consistent with RMPP */ |
231 | if (ib_is_mad_class_rmpp(mad_reg_req->mgmt_class)) { | 231 | if (!ib_is_mad_class_rmpp(mad_reg_req->mgmt_class)) { |
232 | if (!rmpp_version) | ||
233 | goto error1; | ||
234 | } else { | ||
235 | if (rmpp_version) | 232 | if (rmpp_version) |
236 | goto error1; | 233 | goto error1; |
237 | } | 234 | } |
diff --git a/drivers/infiniband/hw/ipath/ipath_debug.h b/drivers/infiniband/hw/ipath/ipath_debug.h index 593e28969c69..46762387f5f8 100644 --- a/drivers/infiniband/hw/ipath/ipath_debug.h +++ b/drivers/infiniband/hw/ipath/ipath_debug.h | |||
@@ -60,11 +60,11 @@ | |||
60 | #define __IPATH_KERNEL_SEND 0x2000 /* use kernel mode send */ | 60 | #define __IPATH_KERNEL_SEND 0x2000 /* use kernel mode send */ |
61 | #define __IPATH_EPKTDBG 0x4000 /* print ethernet packet data */ | 61 | #define __IPATH_EPKTDBG 0x4000 /* print ethernet packet data */ |
62 | #define __IPATH_SMADBG 0x8000 /* sma packet debug */ | 62 | #define __IPATH_SMADBG 0x8000 /* sma packet debug */ |
63 | #define __IPATH_IPATHDBG 0x10000 /* Ethernet (IPATH) general debug on */ | 63 | #define __IPATH_IPATHDBG 0x10000 /* Ethernet (IPATH) gen debug */ |
64 | #define __IPATH_IPATHWARN 0x20000 /* Ethernet (IPATH) warnings on */ | 64 | #define __IPATH_IPATHWARN 0x20000 /* Ethernet (IPATH) warnings */ |
65 | #define __IPATH_IPATHERR 0x40000 /* Ethernet (IPATH) errors on */ | 65 | #define __IPATH_IPATHERR 0x40000 /* Ethernet (IPATH) errors */ |
66 | #define __IPATH_IPATHPD 0x80000 /* Ethernet (IPATH) packet dump on */ | 66 | #define __IPATH_IPATHPD 0x80000 /* Ethernet (IPATH) packet dump */ |
67 | #define __IPATH_IPATHTABLE 0x100000 /* Ethernet (IPATH) table dump on */ | 67 | #define __IPATH_IPATHTABLE 0x100000 /* Ethernet (IPATH) table dump */ |
68 | 68 | ||
69 | #else /* _IPATH_DEBUGGING */ | 69 | #else /* _IPATH_DEBUGGING */ |
70 | 70 | ||
@@ -79,11 +79,12 @@ | |||
79 | #define __IPATH_TRSAMPLE 0x0 /* generate trace buffer sample entries */ | 79 | #define __IPATH_TRSAMPLE 0x0 /* generate trace buffer sample entries */ |
80 | #define __IPATH_VERBDBG 0x0 /* very verbose debug */ | 80 | #define __IPATH_VERBDBG 0x0 /* very verbose debug */ |
81 | #define __IPATH_PKTDBG 0x0 /* print packet data */ | 81 | #define __IPATH_PKTDBG 0x0 /* print packet data */ |
82 | #define __IPATH_PROCDBG 0x0 /* print process startup (init)/exit messages */ | 82 | #define __IPATH_PROCDBG 0x0 /* process startup (init)/exit messages */ |
83 | /* print mmap/nopage stuff, not using VDBG any more */ | 83 | /* print mmap/nopage stuff, not using VDBG any more */ |
84 | #define __IPATH_MMDBG 0x0 | 84 | #define __IPATH_MMDBG 0x0 |
85 | #define __IPATH_EPKTDBG 0x0 /* print ethernet packet data */ | 85 | #define __IPATH_EPKTDBG 0x0 /* print ethernet packet data */ |
86 | #define __IPATH_SMADBG 0x0 /* print process startup (init)/exit messages */#define __IPATH_IPATHDBG 0x0 /* Ethernet (IPATH) table dump on */ | 86 | #define __IPATH_SMADBG 0x0 /* process startup (init)/exit messages */ |
87 | #define __IPATH_IPATHDBG 0x0 /* Ethernet (IPATH) table dump on */ | ||
87 | #define __IPATH_IPATHWARN 0x0 /* Ethernet (IPATH) warnings on */ | 88 | #define __IPATH_IPATHWARN 0x0 /* Ethernet (IPATH) warnings on */ |
88 | #define __IPATH_IPATHERR 0x0 /* Ethernet (IPATH) errors on */ | 89 | #define __IPATH_IPATHERR 0x0 /* Ethernet (IPATH) errors on */ |
89 | #define __IPATH_IPATHPD 0x0 /* Ethernet (IPATH) packet dump on */ | 90 | #define __IPATH_IPATHPD 0x0 /* Ethernet (IPATH) packet dump on */ |
diff --git a/drivers/infiniband/hw/ipath/ipath_diag.c b/drivers/infiniband/hw/ipath/ipath_diag.c index cd533cf951c2..28ddceb260e8 100644 --- a/drivers/infiniband/hw/ipath/ipath_diag.c +++ b/drivers/infiniband/hw/ipath/ipath_diag.c | |||
@@ -277,13 +277,14 @@ static int ipath_diag_open(struct inode *in, struct file *fp) | |||
277 | 277 | ||
278 | bail: | 278 | bail: |
279 | spin_unlock_irqrestore(&ipath_devs_lock, flags); | 279 | spin_unlock_irqrestore(&ipath_devs_lock, flags); |
280 | mutex_unlock(&ipath_mutex); | ||
281 | 280 | ||
282 | /* Only expose a way to reset the device if we | 281 | /* Only expose a way to reset the device if we |
283 | make it into diag mode. */ | 282 | make it into diag mode. */ |
284 | if (ret == 0) | 283 | if (ret == 0) |
285 | ipath_expose_reset(&dd->pcidev->dev); | 284 | ipath_expose_reset(&dd->pcidev->dev); |
286 | 285 | ||
286 | mutex_unlock(&ipath_mutex); | ||
287 | |||
287 | return ret; | 288 | return ret; |
288 | } | 289 | } |
289 | 290 | ||
@@ -365,15 +366,3 @@ static ssize_t ipath_diag_write(struct file *fp, const char __user *data, | |||
365 | bail: | 366 | bail: |
366 | return ret; | 367 | return ret; |
367 | } | 368 | } |
368 | |||
369 | void ipath_diag_bringup_link(struct ipath_devdata *dd) | ||
370 | { | ||
371 | if (diag_set_link || (dd->ipath_flags & IPATH_LINKACTIVE)) | ||
372 | return; | ||
373 | |||
374 | diag_set_link = 1; | ||
375 | ipath_cdbg(VERBOSE, "Trying to set to set link active for " | ||
376 | "diag pkt\n"); | ||
377 | ipath_layer_set_linkstate(dd, IPATH_IB_LINKARM); | ||
378 | ipath_layer_set_linkstate(dd, IPATH_IB_LINKACTIVE); | ||
379 | } | ||
diff --git a/drivers/infiniband/hw/ipath/ipath_driver.c b/drivers/infiniband/hw/ipath/ipath_driver.c index 58a94efb0070..398add4d4cb1 100644 --- a/drivers/infiniband/hw/ipath/ipath_driver.c +++ b/drivers/infiniband/hw/ipath/ipath_driver.c | |||
@@ -418,9 +418,19 @@ static int __devinit ipath_init_one(struct pci_dev *pdev, | |||
418 | 418 | ||
419 | ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK); | 419 | ret = pci_set_dma_mask(pdev, DMA_64BIT_MASK); |
420 | if (ret) { | 420 | if (ret) { |
421 | dev_info(&pdev->dev, "pci_set_dma_mask unit %u " | 421 | /* |
422 | "fails: %d\n", dd->ipath_unit, ret); | 422 | * if the 64 bit setup fails, try 32 bit. Some systems |
423 | goto bail_regions; | 423 | * do not setup 64 bit maps on systems with 2GB or less |
424 | * memory installed. | ||
425 | */ | ||
426 | ret = pci_set_dma_mask(pdev, DMA_32BIT_MASK); | ||
427 | if (ret) { | ||
428 | dev_info(&pdev->dev, "pci_set_dma_mask unit %u " | ||
429 | "fails: %d\n", dd->ipath_unit, ret); | ||
430 | goto bail_regions; | ||
431 | } | ||
432 | else | ||
433 | ipath_dbg("No 64bit DMA mask, used 32 bit mask\n"); | ||
424 | } | 434 | } |
425 | 435 | ||
426 | pci_set_master(pdev); | 436 | pci_set_master(pdev); |
@@ -1729,7 +1739,7 @@ void ipath_free_pddata(struct ipath_devdata *dd, u32 port, int freehdrq) | |||
1729 | } | 1739 | } |
1730 | } | 1740 | } |
1731 | 1741 | ||
1732 | int __init infinipath_init(void) | 1742 | static int __init infinipath_init(void) |
1733 | { | 1743 | { |
1734 | int ret; | 1744 | int ret; |
1735 | 1745 | ||
@@ -1949,7 +1959,7 @@ int ipath_reset_device(int unit) | |||
1949 | } | 1959 | } |
1950 | 1960 | ||
1951 | if (dd->ipath_pd) | 1961 | if (dd->ipath_pd) |
1952 | for (i = 1; i < dd->ipath_portcnt; i++) { | 1962 | for (i = 1; i < dd->ipath_cfgports; i++) { |
1953 | if (dd->ipath_pd[i] && dd->ipath_pd[i]->port_cnt) { | 1963 | if (dd->ipath_pd[i] && dd->ipath_pd[i]->port_cnt) { |
1954 | ipath_dbg("unit %u port %d is in use " | 1964 | ipath_dbg("unit %u port %d is in use " |
1955 | "(PID %u cmd %s), can't reset\n", | 1965 | "(PID %u cmd %s), can't reset\n", |
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c index 2823ff9c0c62..16f640e1c16e 100644 --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c | |||
@@ -53,13 +53,19 @@ MODULE_PARM_DESC(cfgports, "Set max number of ports to use"); | |||
53 | 53 | ||
54 | /* | 54 | /* |
55 | * Number of buffers reserved for driver (layered drivers and SMA | 55 | * Number of buffers reserved for driver (layered drivers and SMA |
56 | * send). Reserved at end of buffer list. | 56 | * send). Reserved at end of buffer list. Initialized based on |
57 | * number of PIO buffers if not set via module interface. | ||
58 | * The problem with this is that it's global, but we'll use different | ||
59 | * numbers for different chip types. So the default value is not | ||
60 | * very useful. I've redefined it for the 1.3 release so that it's | ||
61 | * zero unless set by the user to something else, in which case we | ||
62 | * try to respect it. | ||
57 | */ | 63 | */ |
58 | static ushort ipath_kpiobufs = 32; | 64 | static ushort ipath_kpiobufs; |
59 | 65 | ||
60 | static int ipath_set_kpiobufs(const char *val, struct kernel_param *kp); | 66 | static int ipath_set_kpiobufs(const char *val, struct kernel_param *kp); |
61 | 67 | ||
62 | module_param_call(kpiobufs, ipath_set_kpiobufs, param_get_uint, | 68 | module_param_call(kpiobufs, ipath_set_kpiobufs, param_get_ushort, |
63 | &ipath_kpiobufs, S_IWUSR | S_IRUGO); | 69 | &ipath_kpiobufs, S_IWUSR | S_IRUGO); |
64 | MODULE_PARM_DESC(kpiobufs, "Set number of PIO buffers for driver"); | 70 | MODULE_PARM_DESC(kpiobufs, "Set number of PIO buffers for driver"); |
65 | 71 | ||
@@ -531,8 +537,11 @@ static int init_housekeeping(struct ipath_devdata *dd, | |||
531 | * Don't clear ipath_flags as 8bit mode was set before | 537 | * Don't clear ipath_flags as 8bit mode was set before |
532 | * entering this func. However, we do set the linkstate to | 538 | * entering this func. However, we do set the linkstate to |
533 | * unknown, so we can watch for a transition. | 539 | * unknown, so we can watch for a transition. |
540 | * PRESENT is set because we want register reads to work, | ||
541 | * and the kernel infrastructure saw it in config space; | ||
542 | * We clear it if we have failures. | ||
534 | */ | 543 | */ |
535 | dd->ipath_flags |= IPATH_LINKUNK; | 544 | dd->ipath_flags |= IPATH_LINKUNK | IPATH_PRESENT; |
536 | dd->ipath_flags &= ~(IPATH_LINKACTIVE | IPATH_LINKARMED | | 545 | dd->ipath_flags &= ~(IPATH_LINKACTIVE | IPATH_LINKARMED | |
537 | IPATH_LINKDOWN | IPATH_LINKINIT); | 546 | IPATH_LINKDOWN | IPATH_LINKINIT); |
538 | 547 | ||
@@ -560,6 +569,7 @@ static int init_housekeeping(struct ipath_devdata *dd, | |||
560 | || (dd->ipath_uregbase & 0xffffffff) == 0xffffffff) { | 569 | || (dd->ipath_uregbase & 0xffffffff) == 0xffffffff) { |
561 | ipath_dev_err(dd, "Register read failures from chip, " | 570 | ipath_dev_err(dd, "Register read failures from chip, " |
562 | "giving up initialization\n"); | 571 | "giving up initialization\n"); |
572 | dd->ipath_flags &= ~IPATH_PRESENT; | ||
563 | ret = -ENODEV; | 573 | ret = -ENODEV; |
564 | goto done; | 574 | goto done; |
565 | } | 575 | } |
@@ -682,16 +692,14 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
682 | */ | 692 | */ |
683 | dd->ipath_pioavregs = ALIGN(val, sizeof(u64) * BITS_PER_BYTE / 2) | 693 | dd->ipath_pioavregs = ALIGN(val, sizeof(u64) * BITS_PER_BYTE / 2) |
684 | / (sizeof(u64) * BITS_PER_BYTE / 2); | 694 | / (sizeof(u64) * BITS_PER_BYTE / 2); |
685 | if (!ipath_kpiobufs) /* have to have at least 1, for SMA */ | 695 | if (ipath_kpiobufs == 0) { |
686 | kpiobufs = ipath_kpiobufs = 1; | 696 | /* not set by user, or set explictly to default */ |
687 | else if ((dd->ipath_piobcnt2k + dd->ipath_piobcnt4k) < | 697 | if ((dd->ipath_piobcnt2k + dd->ipath_piobcnt4k) > 128) |
688 | (dd->ipath_cfgports * IPATH_MIN_USER_PORT_BUFCNT)) { | 698 | kpiobufs = 32; |
689 | dev_info(&dd->pcidev->dev, "Too few PIO buffers (%u) " | 699 | else |
690 | "for %u ports to have %u each!\n", | 700 | kpiobufs = 16; |
691 | dd->ipath_piobcnt2k + dd->ipath_piobcnt4k, | 701 | } |
692 | dd->ipath_cfgports, IPATH_MIN_USER_PORT_BUFCNT); | 702 | else |
693 | kpiobufs = 1; /* reserve just the minimum for SMA/ether */ | ||
694 | } else | ||
695 | kpiobufs = ipath_kpiobufs; | 703 | kpiobufs = ipath_kpiobufs; |
696 | 704 | ||
697 | if (kpiobufs > | 705 | if (kpiobufs > |
diff --git a/drivers/infiniband/hw/ipath/ipath_intr.c b/drivers/infiniband/hw/ipath/ipath_intr.c index 60f5f4108069..3e72a1fe3d73 100644 --- a/drivers/infiniband/hw/ipath/ipath_intr.c +++ b/drivers/infiniband/hw/ipath/ipath_intr.c | |||
@@ -172,8 +172,8 @@ static void handle_e_ibstatuschanged(struct ipath_devdata *dd, | |||
172 | "was %s\n", dd->ipath_unit, | 172 | "was %s\n", dd->ipath_unit, |
173 | ib_linkstate(lstate), | 173 | ib_linkstate(lstate), |
174 | ib_linkstate((unsigned) | 174 | ib_linkstate((unsigned) |
175 | dd->ipath_lastibcstat | 175 | dd->ipath_lastibcstat |
176 | & IPATH_IBSTATE_MASK)); | 176 | & IPATH_IBSTATE_MASK)); |
177 | } | 177 | } |
178 | else { | 178 | else { |
179 | lstate = dd->ipath_lastibcstat & IPATH_IBSTATE_MASK; | 179 | lstate = dd->ipath_lastibcstat & IPATH_IBSTATE_MASK; |
@@ -665,14 +665,14 @@ static void handle_layer_pioavail(struct ipath_devdata *dd) | |||
665 | 665 | ||
666 | ret = __ipath_layer_intr(dd, IPATH_LAYER_INT_SEND_CONTINUE); | 666 | ret = __ipath_layer_intr(dd, IPATH_LAYER_INT_SEND_CONTINUE); |
667 | if (ret > 0) | 667 | if (ret > 0) |
668 | goto clear; | 668 | goto set; |
669 | 669 | ||
670 | ret = __ipath_verbs_piobufavail(dd); | 670 | ret = __ipath_verbs_piobufavail(dd); |
671 | if (ret > 0) | 671 | if (ret > 0) |
672 | goto clear; | 672 | goto set; |
673 | 673 | ||
674 | return; | 674 | return; |
675 | clear: | 675 | set: |
676 | set_bit(IPATH_S_PIOINTBUFAVAIL, &dd->ipath_sendctrl); | 676 | set_bit(IPATH_S_PIOINTBUFAVAIL, &dd->ipath_sendctrl); |
677 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, | 677 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, |
678 | dd->ipath_sendctrl); | 678 | dd->ipath_sendctrl); |
@@ -719,11 +719,24 @@ static void handle_rcv(struct ipath_devdata *dd, u32 istat) | |||
719 | irqreturn_t ipath_intr(int irq, void *data, struct pt_regs *regs) | 719 | irqreturn_t ipath_intr(int irq, void *data, struct pt_regs *regs) |
720 | { | 720 | { |
721 | struct ipath_devdata *dd = data; | 721 | struct ipath_devdata *dd = data; |
722 | u32 istat = ipath_read_kreg32(dd, dd->ipath_kregs->kr_intstatus); | 722 | u32 istat; |
723 | ipath_err_t estat = 0; | 723 | ipath_err_t estat = 0; |
724 | static unsigned unexpected = 0; | 724 | static unsigned unexpected = 0; |
725 | irqreturn_t ret; | 725 | irqreturn_t ret; |
726 | 726 | ||
727 | if(!(dd->ipath_flags & IPATH_PRESENT)) { | ||
728 | /* this is mostly so we don't try to touch the chip while | ||
729 | * it is being reset */ | ||
730 | /* | ||
731 | * This return value is perhaps odd, but we do not want the | ||
732 | * interrupt core code to remove our interrupt handler | ||
733 | * because we don't appear to be handling an interrupt | ||
734 | * during a chip reset. | ||
735 | */ | ||
736 | return IRQ_HANDLED; | ||
737 | } | ||
738 | |||
739 | istat = ipath_read_kreg32(dd, dd->ipath_kregs->kr_intstatus); | ||
727 | if (unlikely(!istat)) { | 740 | if (unlikely(!istat)) { |
728 | ipath_stats.sps_nullintr++; | 741 | ipath_stats.sps_nullintr++; |
729 | ret = IRQ_NONE; /* not our interrupt, or already handled */ | 742 | ret = IRQ_NONE; /* not our interrupt, or already handled */ |
diff --git a/drivers/infiniband/hw/ipath/ipath_kernel.h b/drivers/infiniband/hw/ipath/ipath_kernel.h index 159d0aed31a5..e6507f8115bc 100644 --- a/drivers/infiniband/hw/ipath/ipath_kernel.h +++ b/drivers/infiniband/hw/ipath/ipath_kernel.h | |||
@@ -528,7 +528,6 @@ extern spinlock_t ipath_devs_lock; | |||
528 | extern struct ipath_devdata *ipath_lookup(int unit); | 528 | extern struct ipath_devdata *ipath_lookup(int unit); |
529 | 529 | ||
530 | extern u16 ipath_layer_rcv_opcode; | 530 | extern u16 ipath_layer_rcv_opcode; |
531 | extern int ipath_verbs_registered; | ||
532 | extern int __ipath_layer_intr(struct ipath_devdata *, u32); | 531 | extern int __ipath_layer_intr(struct ipath_devdata *, u32); |
533 | extern int ipath_layer_intr(struct ipath_devdata *, u32); | 532 | extern int ipath_layer_intr(struct ipath_devdata *, u32); |
534 | extern int __ipath_layer_rcv(struct ipath_devdata *, void *, | 533 | extern int __ipath_layer_rcv(struct ipath_devdata *, void *, |
@@ -732,7 +731,7 @@ u64 ipath_read_kreg64_port(const struct ipath_devdata *, ipath_kreg, | |||
732 | static inline u32 ipath_read_ureg32(const struct ipath_devdata *dd, | 731 | static inline u32 ipath_read_ureg32(const struct ipath_devdata *dd, |
733 | ipath_ureg regno, int port) | 732 | ipath_ureg regno, int port) |
734 | { | 733 | { |
735 | if (!dd->ipath_kregbase) | 734 | if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT)) |
736 | return 0; | 735 | return 0; |
737 | 736 | ||
738 | return readl(regno + (u64 __iomem *) | 737 | return readl(regno + (u64 __iomem *) |
@@ -763,7 +762,7 @@ static inline void ipath_write_ureg(const struct ipath_devdata *dd, | |||
763 | static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd, | 762 | static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd, |
764 | ipath_kreg regno) | 763 | ipath_kreg regno) |
765 | { | 764 | { |
766 | if (!dd->ipath_kregbase) | 765 | if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT)) |
767 | return -1; | 766 | return -1; |
768 | return readl((u32 __iomem *) & dd->ipath_kregbase[regno]); | 767 | return readl((u32 __iomem *) & dd->ipath_kregbase[regno]); |
769 | } | 768 | } |
@@ -771,7 +770,7 @@ static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd, | |||
771 | static inline u64 ipath_read_kreg64(const struct ipath_devdata *dd, | 770 | static inline u64 ipath_read_kreg64(const struct ipath_devdata *dd, |
772 | ipath_kreg regno) | 771 | ipath_kreg regno) |
773 | { | 772 | { |
774 | if (!dd->ipath_kregbase) | 773 | if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT)) |
775 | return -1; | 774 | return -1; |
776 | 775 | ||
777 | return readq(&dd->ipath_kregbase[regno]); | 776 | return readq(&dd->ipath_kregbase[regno]); |
@@ -787,7 +786,7 @@ static inline void ipath_write_kreg(const struct ipath_devdata *dd, | |||
787 | static inline u64 ipath_read_creg(const struct ipath_devdata *dd, | 786 | static inline u64 ipath_read_creg(const struct ipath_devdata *dd, |
788 | ipath_sreg regno) | 787 | ipath_sreg regno) |
789 | { | 788 | { |
790 | if (!dd->ipath_kregbase) | 789 | if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT)) |
791 | return 0; | 790 | return 0; |
792 | 791 | ||
793 | return readq(regno + (u64 __iomem *) | 792 | return readq(regno + (u64 __iomem *) |
@@ -798,7 +797,7 @@ static inline u64 ipath_read_creg(const struct ipath_devdata *dd, | |||
798 | static inline u32 ipath_read_creg32(const struct ipath_devdata *dd, | 797 | static inline u32 ipath_read_creg32(const struct ipath_devdata *dd, |
799 | ipath_sreg regno) | 798 | ipath_sreg regno) |
800 | { | 799 | { |
801 | if (!dd->ipath_kregbase) | 800 | if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT)) |
802 | return 0; | 801 | return 0; |
803 | return readl(regno + (u64 __iomem *) | 802 | return readl(regno + (u64 __iomem *) |
804 | (dd->ipath_cregbase + | 803 | (dd->ipath_cregbase + |
diff --git a/drivers/infiniband/hw/ipath/ipath_layer.c b/drivers/infiniband/hw/ipath/ipath_layer.c index 2cabf6340572..9cb5258ffed9 100644 --- a/drivers/infiniband/hw/ipath/ipath_layer.c +++ b/drivers/infiniband/hw/ipath/ipath_layer.c | |||
@@ -46,13 +46,15 @@ | |||
46 | /* Acquire before ipath_devs_lock. */ | 46 | /* Acquire before ipath_devs_lock. */ |
47 | static DEFINE_MUTEX(ipath_layer_mutex); | 47 | static DEFINE_MUTEX(ipath_layer_mutex); |
48 | 48 | ||
49 | static int ipath_verbs_registered; | ||
50 | |||
49 | u16 ipath_layer_rcv_opcode; | 51 | u16 ipath_layer_rcv_opcode; |
52 | |||
50 | static int (*layer_intr)(void *, u32); | 53 | static int (*layer_intr)(void *, u32); |
51 | static int (*layer_rcv)(void *, void *, struct sk_buff *); | 54 | static int (*layer_rcv)(void *, void *, struct sk_buff *); |
52 | static int (*layer_rcv_lid)(void *, void *); | 55 | static int (*layer_rcv_lid)(void *, void *); |
53 | static int (*verbs_piobufavail)(void *); | 56 | static int (*verbs_piobufavail)(void *); |
54 | static void (*verbs_rcv)(void *, void *, void *, u32); | 57 | static void (*verbs_rcv)(void *, void *, void *, u32); |
55 | int ipath_verbs_registered; | ||
56 | 58 | ||
57 | static void *(*layer_add_one)(int, struct ipath_devdata *); | 59 | static void *(*layer_add_one)(int, struct ipath_devdata *); |
58 | static void (*layer_remove_one)(void *); | 60 | static void (*layer_remove_one)(void *); |
@@ -586,6 +588,8 @@ void ipath_verbs_unregister(void) | |||
586 | verbs_rcv = NULL; | 588 | verbs_rcv = NULL; |
587 | verbs_timer_cb = NULL; | 589 | verbs_timer_cb = NULL; |
588 | 590 | ||
591 | ipath_verbs_registered = 0; | ||
592 | |||
589 | mutex_unlock(&ipath_layer_mutex); | 593 | mutex_unlock(&ipath_layer_mutex); |
590 | } | 594 | } |
591 | 595 | ||
diff --git a/drivers/infiniband/hw/ipath/ipath_pe800.c b/drivers/infiniband/hw/ipath/ipath_pe800.c index e693a7a82667..6318067ab5ec 100644 --- a/drivers/infiniband/hw/ipath/ipath_pe800.c +++ b/drivers/infiniband/hw/ipath/ipath_pe800.c | |||
@@ -305,8 +305,8 @@ static const struct ipath_cregs ipath_pe_cregs = { | |||
305 | * we'll print them and continue. We reuse the same message buffer as | 305 | * we'll print them and continue. We reuse the same message buffer as |
306 | * ipath_handle_errors() to avoid excessive stack usage. | 306 | * ipath_handle_errors() to avoid excessive stack usage. |
307 | */ | 307 | */ |
308 | void ipath_pe_handle_hwerrors(struct ipath_devdata *dd, char *msg, | 308 | static void ipath_pe_handle_hwerrors(struct ipath_devdata *dd, char *msg, |
309 | size_t msgl) | 309 | size_t msgl) |
310 | { | 310 | { |
311 | ipath_err_t hwerrs; | 311 | ipath_err_t hwerrs; |
312 | u32 bits, ctrl; | 312 | u32 bits, ctrl; |
@@ -552,7 +552,7 @@ static int ipath_pe_boardname(struct ipath_devdata *dd, char *name, | |||
552 | * freeze mode), and enable hardware errors as errors (along with | 552 | * freeze mode), and enable hardware errors as errors (along with |
553 | * everything else) in errormask | 553 | * everything else) in errormask |
554 | */ | 554 | */ |
555 | void ipath_pe_init_hwerrors(struct ipath_devdata *dd) | 555 | static void ipath_pe_init_hwerrors(struct ipath_devdata *dd) |
556 | { | 556 | { |
557 | ipath_err_t val; | 557 | ipath_err_t val; |
558 | u64 extsval; | 558 | u64 extsval; |
@@ -577,7 +577,7 @@ void ipath_pe_init_hwerrors(struct ipath_devdata *dd) | |||
577 | * ipath_pe_bringup_serdes - bring up the serdes | 577 | * ipath_pe_bringup_serdes - bring up the serdes |
578 | * @dd: the infinipath device | 578 | * @dd: the infinipath device |
579 | */ | 579 | */ |
580 | int ipath_pe_bringup_serdes(struct ipath_devdata *dd) | 580 | static int ipath_pe_bringup_serdes(struct ipath_devdata *dd) |
581 | { | 581 | { |
582 | u64 val, tmp, config1; | 582 | u64 val, tmp, config1; |
583 | int ret = 0, change = 0; | 583 | int ret = 0, change = 0; |
@@ -694,7 +694,7 @@ int ipath_pe_bringup_serdes(struct ipath_devdata *dd) | |||
694 | * @dd: the infinipath device | 694 | * @dd: the infinipath device |
695 | * Called when driver is being unloaded | 695 | * Called when driver is being unloaded |
696 | */ | 696 | */ |
697 | void ipath_pe_quiet_serdes(struct ipath_devdata *dd) | 697 | static void ipath_pe_quiet_serdes(struct ipath_devdata *dd) |
698 | { | 698 | { |
699 | u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0); | 699 | u64 val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_serdesconfig0); |
700 | 700 | ||
@@ -972,6 +972,8 @@ static int ipath_setup_pe_reset(struct ipath_devdata *dd) | |||
972 | /* Use ERROR so it shows up in logs, etc. */ | 972 | /* Use ERROR so it shows up in logs, etc. */ |
973 | ipath_dev_err(dd, "Resetting PE-800 unit %u\n", | 973 | ipath_dev_err(dd, "Resetting PE-800 unit %u\n", |
974 | dd->ipath_unit); | 974 | dd->ipath_unit); |
975 | /* keep chip from being accessed in a few places */ | ||
976 | dd->ipath_flags &= ~(IPATH_INITTED|IPATH_PRESENT); | ||
975 | val = dd->ipath_control | INFINIPATH_C_RESET; | 977 | val = dd->ipath_control | INFINIPATH_C_RESET; |
976 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, val); | 978 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, val); |
977 | mb(); | 979 | mb(); |
@@ -997,6 +999,8 @@ static int ipath_setup_pe_reset(struct ipath_devdata *dd) | |||
997 | if ((r = pci_enable_device(dd->pcidev))) | 999 | if ((r = pci_enable_device(dd->pcidev))) |
998 | ipath_dev_err(dd, "pci_enable_device failed after " | 1000 | ipath_dev_err(dd, "pci_enable_device failed after " |
999 | "reset: %d\n", r); | 1001 | "reset: %d\n", r); |
1002 | /* whether it worked or not, mark as present, again */ | ||
1003 | dd->ipath_flags |= IPATH_PRESENT; | ||
1000 | val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_revision); | 1004 | val = ipath_read_kreg64(dd, dd->ipath_kregs->kr_revision); |
1001 | if (val == dd->ipath_revision) { | 1005 | if (val == dd->ipath_revision) { |
1002 | ipath_cdbg(VERBOSE, "Got matching revision " | 1006 | ipath_cdbg(VERBOSE, "Got matching revision " |
diff --git a/drivers/infiniband/hw/ipath/ipath_qp.c b/drivers/infiniband/hw/ipath/ipath_qp.c index 6058d70d7577..18890716db1e 100644 --- a/drivers/infiniband/hw/ipath/ipath_qp.c +++ b/drivers/infiniband/hw/ipath/ipath_qp.c | |||
@@ -188,8 +188,8 @@ static void free_qpn(struct ipath_qp_table *qpt, u32 qpn) | |||
188 | * Allocate the next available QPN and put the QP into the hash table. | 188 | * Allocate the next available QPN and put the QP into the hash table. |
189 | * The hash table holds a reference to the QP. | 189 | * The hash table holds a reference to the QP. |
190 | */ | 190 | */ |
191 | int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, | 191 | static int ipath_alloc_qpn(struct ipath_qp_table *qpt, struct ipath_qp *qp, |
192 | enum ib_qp_type type) | 192 | enum ib_qp_type type) |
193 | { | 193 | { |
194 | unsigned long flags; | 194 | unsigned long flags; |
195 | u32 qpn; | 195 | u32 qpn; |
@@ -232,7 +232,7 @@ bail: | |||
232 | * Remove the QP from the table so it can't be found asynchronously by | 232 | * Remove the QP from the table so it can't be found asynchronously by |
233 | * the receive interrupt routine. | 233 | * the receive interrupt routine. |
234 | */ | 234 | */ |
235 | void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp) | 235 | static void ipath_free_qp(struct ipath_qp_table *qpt, struct ipath_qp *qp) |
236 | { | 236 | { |
237 | struct ipath_qp *q, **qpp; | 237 | struct ipath_qp *q, **qpp; |
238 | unsigned long flags; | 238 | unsigned long flags; |
@@ -358,6 +358,65 @@ static void ipath_reset_qp(struct ipath_qp *qp) | |||
358 | } | 358 | } |
359 | 359 | ||
360 | /** | 360 | /** |
361 | * ipath_error_qp - put a QP into an error state | ||
362 | * @qp: the QP to put into an error state | ||
363 | * | ||
364 | * Flushes both send and receive work queues. | ||
365 | * QP r_rq.lock and s_lock should be held. | ||
366 | */ | ||
367 | |||
368 | static void ipath_error_qp(struct ipath_qp *qp) | ||
369 | { | ||
370 | struct ipath_ibdev *dev = to_idev(qp->ibqp.device); | ||
371 | struct ib_wc wc; | ||
372 | |||
373 | _VERBS_INFO("QP%d/%d in error state\n", | ||
374 | qp->ibqp.qp_num, qp->remote_qpn); | ||
375 | |||
376 | spin_lock(&dev->pending_lock); | ||
377 | /* XXX What if its already removed by the timeout code? */ | ||
378 | if (qp->timerwait.next != LIST_POISON1) | ||
379 | list_del(&qp->timerwait); | ||
380 | if (qp->piowait.next != LIST_POISON1) | ||
381 | list_del(&qp->piowait); | ||
382 | spin_unlock(&dev->pending_lock); | ||
383 | |||
384 | wc.status = IB_WC_WR_FLUSH_ERR; | ||
385 | wc.vendor_err = 0; | ||
386 | wc.byte_len = 0; | ||
387 | wc.imm_data = 0; | ||
388 | wc.qp_num = qp->ibqp.qp_num; | ||
389 | wc.src_qp = 0; | ||
390 | wc.wc_flags = 0; | ||
391 | wc.pkey_index = 0; | ||
392 | wc.slid = 0; | ||
393 | wc.sl = 0; | ||
394 | wc.dlid_path_bits = 0; | ||
395 | wc.port_num = 0; | ||
396 | |||
397 | while (qp->s_last != qp->s_head) { | ||
398 | struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last); | ||
399 | |||
400 | wc.wr_id = wqe->wr.wr_id; | ||
401 | wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; | ||
402 | if (++qp->s_last >= qp->s_size) | ||
403 | qp->s_last = 0; | ||
404 | ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1); | ||
405 | } | ||
406 | qp->s_cur = qp->s_tail = qp->s_head; | ||
407 | qp->s_hdrwords = 0; | ||
408 | qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; | ||
409 | |||
410 | wc.opcode = IB_WC_RECV; | ||
411 | while (qp->r_rq.tail != qp->r_rq.head) { | ||
412 | wc.wr_id = get_rwqe_ptr(&qp->r_rq, qp->r_rq.tail)->wr_id; | ||
413 | if (++qp->r_rq.tail >= qp->r_rq.size) | ||
414 | qp->r_rq.tail = 0; | ||
415 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); | ||
416 | } | ||
417 | } | ||
418 | |||
419 | /** | ||
361 | * ipath_modify_qp - modify the attributes of a queue pair | 420 | * ipath_modify_qp - modify the attributes of a queue pair |
362 | * @ibqp: the queue pair who's attributes we're modifying | 421 | * @ibqp: the queue pair who's attributes we're modifying |
363 | * @attr: the new attributes | 422 | * @attr: the new attributes |
@@ -821,65 +880,6 @@ void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc) | |||
821 | } | 880 | } |
822 | 881 | ||
823 | /** | 882 | /** |
824 | * ipath_error_qp - put a QP into an error state | ||
825 | * @qp: the QP to put into an error state | ||
826 | * | ||
827 | * Flushes both send and receive work queues. | ||
828 | * QP r_rq.lock and s_lock should be held. | ||
829 | */ | ||
830 | |||
831 | void ipath_error_qp(struct ipath_qp *qp) | ||
832 | { | ||
833 | struct ipath_ibdev *dev = to_idev(qp->ibqp.device); | ||
834 | struct ib_wc wc; | ||
835 | |||
836 | _VERBS_INFO("QP%d/%d in error state\n", | ||
837 | qp->ibqp.qp_num, qp->remote_qpn); | ||
838 | |||
839 | spin_lock(&dev->pending_lock); | ||
840 | /* XXX What if its already removed by the timeout code? */ | ||
841 | if (qp->timerwait.next != LIST_POISON1) | ||
842 | list_del(&qp->timerwait); | ||
843 | if (qp->piowait.next != LIST_POISON1) | ||
844 | list_del(&qp->piowait); | ||
845 | spin_unlock(&dev->pending_lock); | ||
846 | |||
847 | wc.status = IB_WC_WR_FLUSH_ERR; | ||
848 | wc.vendor_err = 0; | ||
849 | wc.byte_len = 0; | ||
850 | wc.imm_data = 0; | ||
851 | wc.qp_num = qp->ibqp.qp_num; | ||
852 | wc.src_qp = 0; | ||
853 | wc.wc_flags = 0; | ||
854 | wc.pkey_index = 0; | ||
855 | wc.slid = 0; | ||
856 | wc.sl = 0; | ||
857 | wc.dlid_path_bits = 0; | ||
858 | wc.port_num = 0; | ||
859 | |||
860 | while (qp->s_last != qp->s_head) { | ||
861 | struct ipath_swqe *wqe = get_swqe_ptr(qp, qp->s_last); | ||
862 | |||
863 | wc.wr_id = wqe->wr.wr_id; | ||
864 | wc.opcode = ib_ipath_wc_opcode[wqe->wr.opcode]; | ||
865 | if (++qp->s_last >= qp->s_size) | ||
866 | qp->s_last = 0; | ||
867 | ipath_cq_enter(to_icq(qp->ibqp.send_cq), &wc, 1); | ||
868 | } | ||
869 | qp->s_cur = qp->s_tail = qp->s_head; | ||
870 | qp->s_hdrwords = 0; | ||
871 | qp->s_ack_state = IB_OPCODE_RC_ACKNOWLEDGE; | ||
872 | |||
873 | wc.opcode = IB_WC_RECV; | ||
874 | while (qp->r_rq.tail != qp->r_rq.head) { | ||
875 | wc.wr_id = get_rwqe_ptr(&qp->r_rq, qp->r_rq.tail)->wr_id; | ||
876 | if (++qp->r_rq.tail >= qp->r_rq.size) | ||
877 | qp->r_rq.tail = 0; | ||
878 | ipath_cq_enter(to_icq(qp->ibqp.recv_cq), &wc, 1); | ||
879 | } | ||
880 | } | ||
881 | |||
882 | /** | ||
883 | * ipath_get_credit - flush the send work queue of a QP | 883 | * ipath_get_credit - flush the send work queue of a QP |
884 | * @qp: the qp who's send work queue to flush | 884 | * @qp: the qp who's send work queue to flush |
885 | * @aeth: the Acknowledge Extended Transport Header | 885 | * @aeth: the Acknowledge Extended Transport Header |
diff --git a/drivers/infiniband/hw/ipath/ipath_registers.h b/drivers/infiniband/hw/ipath/ipath_registers.h index 1e59750c5f63..402126eb79c9 100644 --- a/drivers/infiniband/hw/ipath/ipath_registers.h +++ b/drivers/infiniband/hw/ipath/ipath_registers.h | |||
@@ -34,8 +34,9 @@ | |||
34 | #define _IPATH_REGISTERS_H | 34 | #define _IPATH_REGISTERS_H |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * This file should only be included by kernel source, and by the diags. | 37 | * This file should only be included by kernel source, and by the diags. It |
38 | * It defines the registers, and their contents, for the InfiniPath HT-400 chip | 38 | * defines the registers, and their contents, for the InfiniPath HT-400 |
39 | * chip. | ||
39 | */ | 40 | */ |
40 | 41 | ||
41 | /* | 42 | /* |
@@ -156,8 +157,10 @@ | |||
156 | #define INFINIPATH_IBCC_FLOWCTRLWATERMARK_SHIFT 8 | 157 | #define INFINIPATH_IBCC_FLOWCTRLWATERMARK_SHIFT 8 |
157 | #define INFINIPATH_IBCC_LINKINITCMD_MASK 0x3ULL | 158 | #define INFINIPATH_IBCC_LINKINITCMD_MASK 0x3ULL |
158 | #define INFINIPATH_IBCC_LINKINITCMD_DISABLE 1 | 159 | #define INFINIPATH_IBCC_LINKINITCMD_DISABLE 1 |
159 | #define INFINIPATH_IBCC_LINKINITCMD_POLL 2 /* cycle through TS1/TS2 till OK */ | 160 | /* cycle through TS1/TS2 till OK */ |
160 | #define INFINIPATH_IBCC_LINKINITCMD_SLEEP 3 /* wait for TS1, then go on */ | 161 | #define INFINIPATH_IBCC_LINKINITCMD_POLL 2 |
162 | /* wait for TS1, then go on */ | ||
163 | #define INFINIPATH_IBCC_LINKINITCMD_SLEEP 3 | ||
161 | #define INFINIPATH_IBCC_LINKINITCMD_SHIFT 16 | 164 | #define INFINIPATH_IBCC_LINKINITCMD_SHIFT 16 |
162 | #define INFINIPATH_IBCC_LINKCMD_MASK 0x3ULL | 165 | #define INFINIPATH_IBCC_LINKCMD_MASK 0x3ULL |
163 | #define INFINIPATH_IBCC_LINKCMD_INIT 1 /* move to 0x11 */ | 166 | #define INFINIPATH_IBCC_LINKCMD_INIT 1 /* move to 0x11 */ |
@@ -182,7 +185,8 @@ | |||
182 | #define INFINIPATH_IBCS_LINKSTATE_SHIFT 4 | 185 | #define INFINIPATH_IBCS_LINKSTATE_SHIFT 4 |
183 | #define INFINIPATH_IBCS_TXREADY 0x40000000 | 186 | #define INFINIPATH_IBCS_TXREADY 0x40000000 |
184 | #define INFINIPATH_IBCS_TXCREDITOK 0x80000000 | 187 | #define INFINIPATH_IBCS_TXCREDITOK 0x80000000 |
185 | /* link training states (shift by INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) */ | 188 | /* link training states (shift by |
189 | INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) */ | ||
186 | #define INFINIPATH_IBCS_LT_STATE_DISABLED 0x00 | 190 | #define INFINIPATH_IBCS_LT_STATE_DISABLED 0x00 |
187 | #define INFINIPATH_IBCS_LT_STATE_LINKUP 0x01 | 191 | #define INFINIPATH_IBCS_LT_STATE_LINKUP 0x01 |
188 | #define INFINIPATH_IBCS_LT_STATE_POLLACTIVE 0x02 | 192 | #define INFINIPATH_IBCS_LT_STATE_POLLACTIVE 0x02 |
@@ -267,10 +271,12 @@ | |||
267 | /* kr_serdesconfig0 bits */ | 271 | /* kr_serdesconfig0 bits */ |
268 | #define INFINIPATH_SERDC0_RESET_MASK 0xfULL /* overal reset bits */ | 272 | #define INFINIPATH_SERDC0_RESET_MASK 0xfULL /* overal reset bits */ |
269 | #define INFINIPATH_SERDC0_RESET_PLL 0x10000000ULL /* pll reset */ | 273 | #define INFINIPATH_SERDC0_RESET_PLL 0x10000000ULL /* pll reset */ |
270 | #define INFINIPATH_SERDC0_TXIDLE 0xF000ULL /* tx idle enables (per lane) */ | 274 | /* tx idle enables (per lane) */ |
271 | #define INFINIPATH_SERDC0_RXDETECT_EN 0xF0000ULL /* rx detect enables (per lane) */ | 275 | #define INFINIPATH_SERDC0_TXIDLE 0xF000ULL |
272 | #define INFINIPATH_SERDC0_L1PWR_DN 0xF0ULL /* L1 Power down; use with RXDETECT, | 276 | /* rx detect enables (per lane) */ |
273 | Otherwise not used on IB side */ | 277 | #define INFINIPATH_SERDC0_RXDETECT_EN 0xF0000ULL |
278 | /* L1 Power down; use with RXDETECT, Otherwise not used on IB side */ | ||
279 | #define INFINIPATH_SERDC0_L1PWR_DN 0xF0ULL | ||
274 | 280 | ||
275 | /* kr_xgxsconfig bits */ | 281 | /* kr_xgxsconfig bits */ |
276 | #define INFINIPATH_XGXS_RESET 0x7ULL | 282 | #define INFINIPATH_XGXS_RESET 0x7ULL |
@@ -390,12 +396,13 @@ struct ipath_kregs { | |||
390 | ipath_kreg kr_txintmemsize; | 396 | ipath_kreg kr_txintmemsize; |
391 | ipath_kreg kr_xgxsconfig; | 397 | ipath_kreg kr_xgxsconfig; |
392 | ipath_kreg kr_ibpllcfg; | 398 | ipath_kreg kr_ibpllcfg; |
393 | /* use these two (and the following N ports) only with ipath_k*_kreg64_port(); | 399 | /* use these two (and the following N ports) only with |
394 | * not *kreg64() */ | 400 | * ipath_k*_kreg64_port(); not *kreg64() */ |
395 | ipath_kreg kr_rcvhdraddr; | 401 | ipath_kreg kr_rcvhdraddr; |
396 | ipath_kreg kr_rcvhdrtailaddr; | 402 | ipath_kreg kr_rcvhdrtailaddr; |
397 | 403 | ||
398 | /* remaining registers are not present on all types of infinipath chips */ | 404 | /* remaining registers are not present on all types of infinipath |
405 | chips */ | ||
399 | ipath_kreg kr_rcvpktledcnt; | 406 | ipath_kreg kr_rcvpktledcnt; |
400 | ipath_kreg kr_pcierbuftestreg0; | 407 | ipath_kreg kr_pcierbuftestreg0; |
401 | ipath_kreg kr_pcierbuftestreg1; | 408 | ipath_kreg kr_pcierbuftestreg1; |
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c index f232e77b78ee..eb81424b3c5b 100644 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c | |||
@@ -531,19 +531,12 @@ int ipath_post_rc_send(struct ipath_qp *qp, struct ib_send_wr *wr) | |||
531 | } | 531 | } |
532 | wqe->wr.num_sge = j; | 532 | wqe->wr.num_sge = j; |
533 | qp->s_head = next; | 533 | qp->s_head = next; |
534 | /* | ||
535 | * Wake up the send tasklet if the QP is not waiting | ||
536 | * for an RNR timeout. | ||
537 | */ | ||
538 | next = qp->s_rnr_timeout; | ||
539 | spin_unlock_irqrestore(&qp->s_lock, flags); | 534 | spin_unlock_irqrestore(&qp->s_lock, flags); |
540 | 535 | ||
541 | if (next == 0) { | 536 | if (qp->ibqp.qp_type == IB_QPT_UC) |
542 | if (qp->ibqp.qp_type == IB_QPT_UC) | 537 | ipath_do_uc_send((unsigned long) qp); |
543 | ipath_do_uc_send((unsigned long) qp); | 538 | else |
544 | else | 539 | ipath_do_rc_send((unsigned long) qp); |
545 | ipath_do_rc_send((unsigned long) qp); | ||
546 | } | ||
547 | 540 | ||
548 | ret = 0; | 541 | ret = 0; |
549 | 542 | ||
diff --git a/drivers/infiniband/hw/ipath/ipath_sysfs.c b/drivers/infiniband/hw/ipath/ipath_sysfs.c index 32acd8048b49..f323791cc495 100644 --- a/drivers/infiniband/hw/ipath/ipath_sysfs.c +++ b/drivers/infiniband/hw/ipath/ipath_sysfs.c | |||
@@ -711,10 +711,22 @@ static struct attribute_group dev_attr_group = { | |||
711 | * enters diag mode. A device reset is quite likely to crash the | 711 | * enters diag mode. A device reset is quite likely to crash the |
712 | * machine entirely, so we don't want to normally make it | 712 | * machine entirely, so we don't want to normally make it |
713 | * available. | 713 | * available. |
714 | * | ||
715 | * Called with ipath_mutex held. | ||
714 | */ | 716 | */ |
715 | int ipath_expose_reset(struct device *dev) | 717 | int ipath_expose_reset(struct device *dev) |
716 | { | 718 | { |
717 | return device_create_file(dev, &dev_attr_reset); | 719 | static int exposed; |
720 | int ret; | ||
721 | |||
722 | if (!exposed) { | ||
723 | ret = device_create_file(dev, &dev_attr_reset); | ||
724 | exposed = 1; | ||
725 | } | ||
726 | else | ||
727 | ret = 0; | ||
728 | |||
729 | return ret; | ||
718 | } | 730 | } |
719 | 731 | ||
720 | int ipath_driver_create_group(struct device_driver *drv) | 732 | int ipath_driver_create_group(struct device_driver *drv) |
diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c index 5ff3de6128b2..e606daf83210 100644 --- a/drivers/infiniband/hw/ipath/ipath_ud.c +++ b/drivers/infiniband/hw/ipath/ipath_ud.c | |||
@@ -46,8 +46,10 @@ | |||
46 | * This is called from ipath_post_ud_send() to forward a WQE addressed | 46 | * This is called from ipath_post_ud_send() to forward a WQE addressed |
47 | * to the same HCA. | 47 | * to the same HCA. |
48 | */ | 48 | */ |
49 | void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_sge_state *ss, | 49 | static void ipath_ud_loopback(struct ipath_qp *sqp, |
50 | u32 length, struct ib_send_wr *wr, struct ib_wc *wc) | 50 | struct ipath_sge_state *ss, |
51 | u32 length, struct ib_send_wr *wr, | ||
52 | struct ib_wc *wc) | ||
51 | { | 53 | { |
52 | struct ipath_ibdev *dev = to_idev(sqp->ibqp.device); | 54 | struct ipath_ibdev *dev = to_idev(sqp->ibqp.device); |
53 | struct ipath_qp *qp; | 55 | struct ipath_qp *qp; |
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c index 9f27fd35cdbb..cb9e387c301f 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.c +++ b/drivers/infiniband/hw/ipath/ipath_verbs.c | |||
@@ -41,7 +41,7 @@ | |||
41 | /* Not static, because we don't want the compiler removing it */ | 41 | /* Not static, because we don't want the compiler removing it */ |
42 | const char ipath_verbs_version[] = "ipath_verbs " IPATH_IDSTR; | 42 | const char ipath_verbs_version[] = "ipath_verbs " IPATH_IDSTR; |
43 | 43 | ||
44 | unsigned int ib_ipath_qp_table_size = 251; | 44 | static unsigned int ib_ipath_qp_table_size = 251; |
45 | module_param_named(qp_table_size, ib_ipath_qp_table_size, uint, S_IRUGO); | 45 | module_param_named(qp_table_size, ib_ipath_qp_table_size, uint, S_IRUGO); |
46 | MODULE_PARM_DESC(qp_table_size, "QP table size"); | 46 | MODULE_PARM_DESC(qp_table_size, "QP table size"); |
47 | 47 | ||
@@ -87,7 +87,7 @@ const enum ib_wc_opcode ib_ipath_wc_opcode[] = { | |||
87 | /* | 87 | /* |
88 | * System image GUID. | 88 | * System image GUID. |
89 | */ | 89 | */ |
90 | __be64 sys_image_guid; | 90 | static __be64 sys_image_guid; |
91 | 91 | ||
92 | /** | 92 | /** |
93 | * ipath_copy_sge - copy data to SGE memory | 93 | * ipath_copy_sge - copy data to SGE memory |
@@ -449,7 +449,6 @@ static void ipath_ib_timer(void *arg) | |||
449 | { | 449 | { |
450 | struct ipath_ibdev *dev = (struct ipath_ibdev *) arg; | 450 | struct ipath_ibdev *dev = (struct ipath_ibdev *) arg; |
451 | struct ipath_qp *resend = NULL; | 451 | struct ipath_qp *resend = NULL; |
452 | struct ipath_qp *rnr = NULL; | ||
453 | struct list_head *last; | 452 | struct list_head *last; |
454 | struct ipath_qp *qp; | 453 | struct ipath_qp *qp; |
455 | unsigned long flags; | 454 | unsigned long flags; |
@@ -465,32 +464,18 @@ static void ipath_ib_timer(void *arg) | |||
465 | last = &dev->pending[dev->pending_index]; | 464 | last = &dev->pending[dev->pending_index]; |
466 | while (!list_empty(last)) { | 465 | while (!list_empty(last)) { |
467 | qp = list_entry(last->next, struct ipath_qp, timerwait); | 466 | qp = list_entry(last->next, struct ipath_qp, timerwait); |
468 | if (last->next == LIST_POISON1 || | 467 | list_del(&qp->timerwait); |
469 | last->next != &qp->timerwait || | 468 | qp->timer_next = resend; |
470 | qp->timerwait.prev != last) { | 469 | resend = qp; |
471 | INIT_LIST_HEAD(last); | 470 | atomic_inc(&qp->refcount); |
472 | } else { | ||
473 | list_del(&qp->timerwait); | ||
474 | qp->timerwait.prev = (struct list_head *) resend; | ||
475 | resend = qp; | ||
476 | atomic_inc(&qp->refcount); | ||
477 | } | ||
478 | } | 471 | } |
479 | last = &dev->rnrwait; | 472 | last = &dev->rnrwait; |
480 | if (!list_empty(last)) { | 473 | if (!list_empty(last)) { |
481 | qp = list_entry(last->next, struct ipath_qp, timerwait); | 474 | qp = list_entry(last->next, struct ipath_qp, timerwait); |
482 | if (--qp->s_rnr_timeout == 0) { | 475 | if (--qp->s_rnr_timeout == 0) { |
483 | do { | 476 | do { |
484 | if (last->next == LIST_POISON1 || | ||
485 | last->next != &qp->timerwait || | ||
486 | qp->timerwait.prev != last) { | ||
487 | INIT_LIST_HEAD(last); | ||
488 | break; | ||
489 | } | ||
490 | list_del(&qp->timerwait); | 477 | list_del(&qp->timerwait); |
491 | qp->timerwait.prev = | 478 | tasklet_hi_schedule(&qp->s_task); |
492 | (struct list_head *) rnr; | ||
493 | rnr = qp; | ||
494 | if (list_empty(last)) | 479 | if (list_empty(last)) |
495 | break; | 480 | break; |
496 | qp = list_entry(last->next, struct ipath_qp, | 481 | qp = list_entry(last->next, struct ipath_qp, |
@@ -530,8 +515,7 @@ static void ipath_ib_timer(void *arg) | |||
530 | spin_unlock_irqrestore(&dev->pending_lock, flags); | 515 | spin_unlock_irqrestore(&dev->pending_lock, flags); |
531 | 516 | ||
532 | /* XXX What if timer fires again while this is running? */ | 517 | /* XXX What if timer fires again while this is running? */ |
533 | for (qp = resend; qp != NULL; | 518 | for (qp = resend; qp != NULL; qp = qp->timer_next) { |
534 | qp = (struct ipath_qp *) qp->timerwait.prev) { | ||
535 | struct ib_wc wc; | 519 | struct ib_wc wc; |
536 | 520 | ||
537 | spin_lock_irqsave(&qp->s_lock, flags); | 521 | spin_lock_irqsave(&qp->s_lock, flags); |
@@ -545,9 +529,6 @@ static void ipath_ib_timer(void *arg) | |||
545 | if (atomic_dec_and_test(&qp->refcount)) | 529 | if (atomic_dec_and_test(&qp->refcount)) |
546 | wake_up(&qp->wait); | 530 | wake_up(&qp->wait); |
547 | } | 531 | } |
548 | for (qp = rnr; qp != NULL; | ||
549 | qp = (struct ipath_qp *) qp->timerwait.prev) | ||
550 | tasklet_hi_schedule(&qp->s_task); | ||
551 | } | 532 | } |
552 | 533 | ||
553 | /** | 534 | /** |
@@ -556,9 +537,9 @@ static void ipath_ib_timer(void *arg) | |||
556 | * | 537 | * |
557 | * This is called from ipath_intr() at interrupt level when a PIO buffer is | 538 | * This is called from ipath_intr() at interrupt level when a PIO buffer is |
558 | * available after ipath_verbs_send() returned an error that no buffers were | 539 | * available after ipath_verbs_send() returned an error that no buffers were |
559 | * available. Return 0 if we consumed all the PIO buffers and we still have | 540 | * available. Return 1 if we consumed all the PIO buffers and we still have |
560 | * QPs waiting for buffers (for now, just do a tasklet_hi_schedule and | 541 | * QPs waiting for buffers (for now, just do a tasklet_hi_schedule and |
561 | * return one). | 542 | * return zero). |
562 | */ | 543 | */ |
563 | static int ipath_ib_piobufavail(void *arg) | 544 | static int ipath_ib_piobufavail(void *arg) |
564 | { | 545 | { |
@@ -579,7 +560,7 @@ static int ipath_ib_piobufavail(void *arg) | |||
579 | spin_unlock_irqrestore(&dev->pending_lock, flags); | 560 | spin_unlock_irqrestore(&dev->pending_lock, flags); |
580 | 561 | ||
581 | bail: | 562 | bail: |
582 | return 1; | 563 | return 0; |
583 | } | 564 | } |
584 | 565 | ||
585 | static int ipath_query_device(struct ib_device *ibdev, | 566 | static int ipath_query_device(struct ib_device *ibdev, |
@@ -1110,7 +1091,7 @@ static void ipath_unregister_ib_device(void *arg) | |||
1110 | ib_dealloc_device(ibdev); | 1091 | ib_dealloc_device(ibdev); |
1111 | } | 1092 | } |
1112 | 1093 | ||
1113 | int __init ipath_verbs_init(void) | 1094 | static int __init ipath_verbs_init(void) |
1114 | { | 1095 | { |
1115 | return ipath_verbs_register(ipath_register_ib_device, | 1096 | return ipath_verbs_register(ipath_register_ib_device, |
1116 | ipath_unregister_ib_device, | 1097 | ipath_unregister_ib_device, |
@@ -1118,33 +1099,33 @@ int __init ipath_verbs_init(void) | |||
1118 | ipath_ib_timer); | 1099 | ipath_ib_timer); |
1119 | } | 1100 | } |
1120 | 1101 | ||
1121 | void __exit ipath_verbs_cleanup(void) | 1102 | static void __exit ipath_verbs_cleanup(void) |
1122 | { | 1103 | { |
1123 | ipath_verbs_unregister(); | 1104 | ipath_verbs_unregister(); |
1124 | } | 1105 | } |
1125 | 1106 | ||
1126 | static ssize_t show_rev(struct class_device *cdev, char *buf) | 1107 | static ssize_t show_rev(struct class_device *cdev, char *buf) |
1127 | { | 1108 | { |
1128 | struct ipath_ibdev *dev = | 1109 | struct ipath_ibdev *dev = |
1129 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 1110 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); |
1130 | int vendor, boardrev, majrev, minrev; | 1111 | int vendor, boardrev, majrev, minrev; |
1131 | 1112 | ||
1132 | ipath_layer_query_device(dev->dd, &vendor, &boardrev, | 1113 | ipath_layer_query_device(dev->dd, &vendor, &boardrev, |
1133 | &majrev, &minrev); | 1114 | &majrev, &minrev); |
1134 | return sprintf(buf, "%d.%d\n", majrev, minrev); | 1115 | return sprintf(buf, "%d.%d\n", majrev, minrev); |
1135 | } | 1116 | } |
1136 | 1117 | ||
1137 | static ssize_t show_hca(struct class_device *cdev, char *buf) | 1118 | static ssize_t show_hca(struct class_device *cdev, char *buf) |
1138 | { | 1119 | { |
1139 | struct ipath_ibdev *dev = | 1120 | struct ipath_ibdev *dev = |
1140 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 1121 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); |
1141 | int ret; | 1122 | int ret; |
1142 | 1123 | ||
1143 | ret = ipath_layer_get_boardname(dev->dd, buf, 128); | 1124 | ret = ipath_layer_get_boardname(dev->dd, buf, 128); |
1144 | if (ret < 0) | 1125 | if (ret < 0) |
1145 | goto bail; | 1126 | goto bail; |
1146 | strcat(buf, "\n"); | 1127 | strcat(buf, "\n"); |
1147 | ret = strlen(buf); | 1128 | ret = strlen(buf); |
1148 | 1129 | ||
1149 | bail: | 1130 | bail: |
1150 | return ret; | 1131 | return ret; |
@@ -1152,40 +1133,40 @@ bail: | |||
1152 | 1133 | ||
1153 | static ssize_t show_stats(struct class_device *cdev, char *buf) | 1134 | static ssize_t show_stats(struct class_device *cdev, char *buf) |
1154 | { | 1135 | { |
1155 | struct ipath_ibdev *dev = | 1136 | struct ipath_ibdev *dev = |
1156 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); | 1137 | container_of(cdev, struct ipath_ibdev, ibdev.class_dev); |
1157 | int i; | 1138 | int i; |
1158 | int len; | 1139 | int len; |
1159 | 1140 | ||
1160 | len = sprintf(buf, | 1141 | len = sprintf(buf, |
1161 | "RC resends %d\n" | 1142 | "RC resends %d\n" |
1162 | "RC QACKs %d\n" | 1143 | "RC no QACK %d\n" |
1163 | "RC ACKs %d\n" | 1144 | "RC ACKs %d\n" |
1164 | "RC SEQ NAKs %d\n" | 1145 | "RC SEQ NAKs %d\n" |
1165 | "RC RDMA seq %d\n" | 1146 | "RC RDMA seq %d\n" |
1166 | "RC RNR NAKs %d\n" | 1147 | "RC RNR NAKs %d\n" |
1167 | "RC OTH NAKs %d\n" | 1148 | "RC OTH NAKs %d\n" |
1168 | "RC timeouts %d\n" | 1149 | "RC timeouts %d\n" |
1169 | "RC RDMA dup %d\n" | 1150 | "RC RDMA dup %d\n" |
1170 | "piobuf wait %d\n" | 1151 | "piobuf wait %d\n" |
1171 | "no piobuf %d\n" | 1152 | "no piobuf %d\n" |
1172 | "PKT drops %d\n" | 1153 | "PKT drops %d\n" |
1173 | "WQE errs %d\n", | 1154 | "WQE errs %d\n", |
1174 | dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks, | 1155 | dev->n_rc_resends, dev->n_rc_qacks, dev->n_rc_acks, |
1175 | dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks, | 1156 | dev->n_seq_naks, dev->n_rdma_seq, dev->n_rnr_naks, |
1176 | dev->n_other_naks, dev->n_timeouts, | 1157 | dev->n_other_naks, dev->n_timeouts, |
1177 | dev->n_rdma_dup_busy, dev->n_piowait, | 1158 | dev->n_rdma_dup_busy, dev->n_piowait, |
1178 | dev->n_no_piobuf, dev->n_pkt_drops, dev->n_wqe_errs); | 1159 | dev->n_no_piobuf, dev->n_pkt_drops, dev->n_wqe_errs); |
1179 | for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) { | 1160 | for (i = 0; i < ARRAY_SIZE(dev->opstats); i++) { |
1180 | const struct ipath_opcode_stats *si = &dev->opstats[i]; | 1161 | const struct ipath_opcode_stats *si = &dev->opstats[i]; |
1181 | 1162 | ||
1182 | if (!si->n_packets && !si->n_bytes) | 1163 | if (!si->n_packets && !si->n_bytes) |
1183 | continue; | 1164 | continue; |
1184 | len += sprintf(buf + len, "%02x %llu/%llu\n", i, | 1165 | len += sprintf(buf + len, "%02x %llu/%llu\n", i, |
1185 | (unsigned long long) si->n_packets, | 1166 | (unsigned long long) si->n_packets, |
1186 | (unsigned long long) si->n_bytes); | 1167 | (unsigned long long) si->n_bytes); |
1187 | } | 1168 | } |
1188 | return len; | 1169 | return len; |
1189 | } | 1170 | } |
1190 | 1171 | ||
1191 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); | 1172 | static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); |
@@ -1194,25 +1175,25 @@ static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_hca, NULL); | |||
1194 | static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); | 1175 | static CLASS_DEVICE_ATTR(stats, S_IRUGO, show_stats, NULL); |
1195 | 1176 | ||
1196 | static struct class_device_attribute *ipath_class_attributes[] = { | 1177 | static struct class_device_attribute *ipath_class_attributes[] = { |
1197 | &class_device_attr_hw_rev, | 1178 | &class_device_attr_hw_rev, |
1198 | &class_device_attr_hca_type, | 1179 | &class_device_attr_hca_type, |
1199 | &class_device_attr_board_id, | 1180 | &class_device_attr_board_id, |
1200 | &class_device_attr_stats | 1181 | &class_device_attr_stats |
1201 | }; | 1182 | }; |
1202 | 1183 | ||
1203 | static int ipath_verbs_register_sysfs(struct ib_device *dev) | 1184 | static int ipath_verbs_register_sysfs(struct ib_device *dev) |
1204 | { | 1185 | { |
1205 | int i; | 1186 | int i; |
1206 | int ret; | 1187 | int ret; |
1207 | 1188 | ||
1208 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) | 1189 | for (i = 0; i < ARRAY_SIZE(ipath_class_attributes); ++i) |
1209 | if (class_device_create_file(&dev->class_dev, | 1190 | if (class_device_create_file(&dev->class_dev, |
1210 | ipath_class_attributes[i])) { | 1191 | ipath_class_attributes[i])) { |
1211 | ret = 1; | 1192 | ret = 1; |
1212 | goto bail; | 1193 | goto bail; |
1213 | } | 1194 | } |
1214 | 1195 | ||
1215 | ret = 0; | 1196 | ret = 0; |
1216 | 1197 | ||
1217 | bail: | 1198 | bail: |
1218 | return ret; | 1199 | return ret; |
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.h b/drivers/infiniband/hw/ipath/ipath_verbs.h index b824632b2a8c..4f8d59300e9b 100644 --- a/drivers/infiniband/hw/ipath/ipath_verbs.h +++ b/drivers/infiniband/hw/ipath/ipath_verbs.h | |||
@@ -282,7 +282,8 @@ struct ipath_srq { | |||
282 | */ | 282 | */ |
283 | struct ipath_qp { | 283 | struct ipath_qp { |
284 | struct ib_qp ibqp; | 284 | struct ib_qp ibqp; |
285 | struct ipath_qp *next; /* link list for QPN hash table */ | 285 | struct ipath_qp *next; /* link list for QPN hash table */ |
286 | struct ipath_qp *timer_next; /* link list for ipath_ib_timer() */ | ||
286 | struct list_head piowait; /* link for wait PIO buf */ | 287 | struct list_head piowait; /* link for wait PIO buf */ |
287 | struct list_head timerwait; /* link for waiting for timeouts */ | 288 | struct list_head timerwait; /* link for waiting for timeouts */ |
288 | struct ib_ah_attr remote_ah_attr; | 289 | struct ib_ah_attr remote_ah_attr; |
@@ -577,8 +578,6 @@ int ipath_init_qp_table(struct ipath_ibdev *idev, int size); | |||
577 | 578 | ||
578 | void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc); | 579 | void ipath_sqerror_qp(struct ipath_qp *qp, struct ib_wc *wc); |
579 | 580 | ||
580 | void ipath_error_qp(struct ipath_qp *qp); | ||
581 | |||
582 | void ipath_get_credit(struct ipath_qp *qp, u32 aeth); | 581 | void ipath_get_credit(struct ipath_qp *qp, u32 aeth); |
583 | 582 | ||
584 | void ipath_do_rc_send(unsigned long data); | 583 | void ipath_do_rc_send(unsigned long data); |
@@ -607,9 +606,6 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | |||
607 | 606 | ||
608 | void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc); | 607 | void ipath_restart_rc(struct ipath_qp *qp, u32 psn, struct ib_wc *wc); |
609 | 608 | ||
610 | void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_sge_state *ss, | ||
611 | u32 length, struct ib_send_wr *wr, struct ib_wc *wc); | ||
612 | |||
613 | int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr); | 609 | int ipath_post_ud_send(struct ipath_qp *qp, struct ib_send_wr *wr); |
614 | 610 | ||
615 | void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, | 611 | void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr, |
diff --git a/drivers/infiniband/hw/ipath/ips_common.h b/drivers/infiniband/hw/ipath/ips_common.h index 410a764dfcef..ab7cbbbfd03a 100644 --- a/drivers/infiniband/hw/ipath/ips_common.h +++ b/drivers/infiniband/hw/ipath/ips_common.h | |||
@@ -95,7 +95,7 @@ struct ether_header { | |||
95 | __u8 seq_num; | 95 | __u8 seq_num; |
96 | __le32 len; | 96 | __le32 len; |
97 | /* MUST be of word size due to PIO write requirements */ | 97 | /* MUST be of word size due to PIO write requirements */ |
98 | __u32 csum; | 98 | __le32 csum; |
99 | __le16 csum_offset; | 99 | __le16 csum_offset; |
100 | __le16 flags; | 100 | __le16 flags; |
101 | __u16 first_2_bytes; | 101 | __u16 first_2_bytes; |
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c index f235c7ea42f0..4730863ece9a 100644 --- a/drivers/infiniband/hw/mthca/mthca_mad.c +++ b/drivers/infiniband/hw/mthca/mthca_mad.c | |||
@@ -49,7 +49,7 @@ enum { | |||
49 | MTHCA_VENDOR_CLASS2 = 0xa | 49 | MTHCA_VENDOR_CLASS2 = 0xa |
50 | }; | 50 | }; |
51 | 51 | ||
52 | int mthca_update_rate(struct mthca_dev *dev, u8 port_num) | 52 | static int mthca_update_rate(struct mthca_dev *dev, u8 port_num) |
53 | { | 53 | { |
54 | struct ib_port_attr *tprops = NULL; | 54 | struct ib_port_attr *tprops = NULL; |
55 | int ret; | 55 | int ret; |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 565a24b1756f..a2eae8a30167 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -306,7 +306,7 @@ static int mthca_query_gid(struct ib_device *ibdev, u8 port, | |||
306 | goto out; | 306 | goto out; |
307 | } | 307 | } |
308 | 308 | ||
309 | memcpy(gid->raw + 8, out_mad->data + (index % 8) * 16, 8); | 309 | memcpy(gid->raw + 8, out_mad->data + (index % 8) * 8, 8); |
310 | 310 | ||
311 | out: | 311 | out: |
312 | kfree(in_mad); | 312 | kfree(in_mad); |
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 5f2b3f6e4c47..5bb55742ada6 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
@@ -617,6 +617,14 @@ static void srp_unmap_data(struct scsi_cmnd *scmnd, | |||
617 | scmnd->sc_data_direction); | 617 | scmnd->sc_data_direction); |
618 | } | 618 | } |
619 | 619 | ||
620 | static void srp_remove_req(struct srp_target_port *target, struct srp_request *req, | ||
621 | int index) | ||
622 | { | ||
623 | list_del(&req->list); | ||
624 | req->next = target->req_head; | ||
625 | target->req_head = index; | ||
626 | } | ||
627 | |||
620 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | 628 | static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) |
621 | { | 629 | { |
622 | struct srp_request *req; | 630 | struct srp_request *req; |
@@ -664,9 +672,7 @@ static void srp_process_rsp(struct srp_target_port *target, struct srp_rsp *rsp) | |||
664 | scmnd->host_scribble = (void *) -1L; | 672 | scmnd->host_scribble = (void *) -1L; |
665 | scmnd->scsi_done(scmnd); | 673 | scmnd->scsi_done(scmnd); |
666 | 674 | ||
667 | list_del(&req->list); | 675 | srp_remove_req(target, req, rsp->tag & ~SRP_TAG_TSK_MGMT); |
668 | req->next = target->req_head; | ||
669 | target->req_head = rsp->tag & ~SRP_TAG_TSK_MGMT; | ||
670 | } else | 676 | } else |
671 | req->cmd_done = 1; | 677 | req->cmd_done = 1; |
672 | } | 678 | } |
@@ -1188,12 +1194,10 @@ static int srp_send_tsk_mgmt(struct scsi_cmnd *scmnd, u8 func) | |||
1188 | spin_lock_irq(target->scsi_host->host_lock); | 1194 | spin_lock_irq(target->scsi_host->host_lock); |
1189 | 1195 | ||
1190 | if (req->cmd_done) { | 1196 | if (req->cmd_done) { |
1191 | list_del(&req->list); | 1197 | srp_remove_req(target, req, req_index); |
1192 | req->next = target->req_head; | ||
1193 | target->req_head = req_index; | ||
1194 | |||
1195 | scmnd->scsi_done(scmnd); | 1198 | scmnd->scsi_done(scmnd); |
1196 | } else if (!req->tsk_status) { | 1199 | } else if (!req->tsk_status) { |
1200 | srp_remove_req(target, req, req_index); | ||
1197 | scmnd->result = DID_ABORT << 16; | 1201 | scmnd->result = DID_ABORT << 16; |
1198 | ret = SUCCESS; | 1202 | ret = SUCCESS; |
1199 | } | 1203 | } |
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index a34e3d91d9ed..ba325f16d077 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -403,6 +403,27 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd, | |||
403 | case EVIOCGID: | 403 | case EVIOCGID: |
404 | if (copy_to_user(p, &dev->id, sizeof(struct input_id))) | 404 | if (copy_to_user(p, &dev->id, sizeof(struct input_id))) |
405 | return -EFAULT; | 405 | return -EFAULT; |
406 | return 0; | ||
407 | |||
408 | case EVIOCGREP: | ||
409 | if (!test_bit(EV_REP, dev->evbit)) | ||
410 | return -ENOSYS; | ||
411 | if (put_user(dev->rep[REP_DELAY], ip)) | ||
412 | return -EFAULT; | ||
413 | if (put_user(dev->rep[REP_PERIOD], ip + 1)) | ||
414 | return -EFAULT; | ||
415 | return 0; | ||
416 | |||
417 | case EVIOCSREP: | ||
418 | if (!test_bit(EV_REP, dev->evbit)) | ||
419 | return -ENOSYS; | ||
420 | if (get_user(u, ip)) | ||
421 | return -EFAULT; | ||
422 | if (get_user(v, ip + 1)) | ||
423 | return -EFAULT; | ||
424 | |||
425 | input_event(dev, EV_REP, REP_DELAY, u); | ||
426 | input_event(dev, EV_REP, REP_PERIOD, v); | ||
406 | 427 | ||
407 | return 0; | 428 | return 0; |
408 | 429 | ||
diff --git a/drivers/input/input.c b/drivers/input/input.c index a935abeffffc..3038c268917d 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -155,6 +155,9 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
155 | if (code > SND_MAX || !test_bit(code, dev->sndbit)) | 155 | if (code > SND_MAX || !test_bit(code, dev->sndbit)) |
156 | return; | 156 | return; |
157 | 157 | ||
158 | if (!!test_bit(code, dev->snd) != !!value) | ||
159 | change_bit(code, dev->snd); | ||
160 | |||
158 | if (dev->event) dev->event(dev, type, code, value); | 161 | if (dev->event) dev->event(dev, type, code, value); |
159 | 162 | ||
160 | break; | 163 | break; |
@@ -286,19 +289,19 @@ static struct input_device_id *input_match_device(struct input_device_id *id, st | |||
286 | for (; id->flags || id->driver_info; id++) { | 289 | for (; id->flags || id->driver_info; id++) { |
287 | 290 | ||
288 | if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) | 291 | if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) |
289 | if (id->id.bustype != dev->id.bustype) | 292 | if (id->bustype != dev->id.bustype) |
290 | continue; | 293 | continue; |
291 | 294 | ||
292 | if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) | 295 | if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) |
293 | if (id->id.vendor != dev->id.vendor) | 296 | if (id->vendor != dev->id.vendor) |
294 | continue; | 297 | continue; |
295 | 298 | ||
296 | if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) | 299 | if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) |
297 | if (id->id.product != dev->id.product) | 300 | if (id->product != dev->id.product) |
298 | continue; | 301 | continue; |
299 | 302 | ||
300 | if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) | 303 | if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) |
301 | if (id->id.version != dev->id.version) | 304 | if (id->version != dev->id.version) |
302 | continue; | 305 | continue; |
303 | 306 | ||
304 | MATCH_BIT(evbit, EV_MAX); | 307 | MATCH_BIT(evbit, EV_MAX); |
diff --git a/drivers/input/keyboard/hil_kbd.c b/drivers/input/keyboard/hil_kbd.c index 1dca3cf42a54..2e4abdc26367 100644 --- a/drivers/input/keyboard/hil_kbd.c +++ b/drivers/input/keyboard/hil_kbd.c | |||
@@ -350,11 +350,11 @@ static int hil_kbd_connect(struct serio *serio, struct serio_driver *drv) | |||
350 | return 0; | 350 | return 0; |
351 | bail2: | 351 | bail2: |
352 | serio_close(serio); | 352 | serio_close(serio); |
353 | serio_set_drvdata(serio, NULL); | ||
353 | bail1: | 354 | bail1: |
354 | input_free_device(kbd->dev); | 355 | input_free_device(kbd->dev); |
355 | bail0: | 356 | bail0: |
356 | kfree(kbd); | 357 | kfree(kbd); |
357 | serio_set_drvdata(serio, NULL); | ||
358 | return -EIO; | 358 | return -EIO; |
359 | } | 359 | } |
360 | 360 | ||
diff --git a/drivers/input/keyboard/spitzkbd.c b/drivers/input/keyboard/spitzkbd.c index bc61cf8cfc65..1d238a9d52d6 100644 --- a/drivers/input/keyboard/spitzkbd.c +++ b/drivers/input/keyboard/spitzkbd.c | |||
@@ -53,8 +53,8 @@ static unsigned char spitzkbd_keycode[NR_SCANCODES] = { | |||
53 | KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */ | 53 | KEY_LEFTCTRL, KEY_1, KEY_3, KEY_5, KEY_6, KEY_7, KEY_9, KEY_0, KEY_BACKSPACE, SPITZ_KEY_EXOK, SPITZ_KEY_EXCANCEL, 0, 0, 0, 0, 0, /* 1-16 */ |
54 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */ | 54 | 0, KEY_2, KEY_4, KEY_R, KEY_Y, KEY_8, KEY_I, KEY_O, KEY_P, SPITZ_KEY_EXJOGDOWN, SPITZ_KEY_EXJOGUP, 0, 0, 0, 0, 0, /* 17-32 */ |
55 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ | 55 | KEY_TAB, KEY_Q, KEY_E, KEY_T, KEY_G, KEY_U, KEY_J, KEY_K, 0, 0, 0, 0, 0, 0, 0, 0, /* 33-48 */ |
56 | SPITZ_KEY_CALENDER, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ | 56 | SPITZ_KEY_ADDRESS, KEY_W, KEY_S, KEY_F, KEY_V, KEY_H, KEY_M, KEY_L, 0, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, 0, /* 49-64 */ |
57 | SPITZ_KEY_ADDRESS, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */ | 57 | SPITZ_KEY_CALENDER, KEY_A, KEY_D, KEY_C, KEY_B, KEY_N, KEY_DOT, 0, KEY_ENTER, KEY_LEFTSHIFT, 0, 0, 0, 0, 0, 0, /* 65-80 */ |
58 | SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */ | 58 | SPITZ_KEY_MAIL, KEY_Z, KEY_X, KEY_MINUS, KEY_SPACE, KEY_COMMA, 0, KEY_UP, 0, 0, SPITZ_KEY_FN, 0, 0, 0, 0, 0, /* 81-96 */ |
59 | KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */ | 59 | KEY_SYSRQ, SPITZ_KEY_JAP1, SPITZ_KEY_JAP2, SPITZ_KEY_CANCEL, SPITZ_KEY_OK, SPITZ_KEY_MENU, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, 0, 0, 0, 0 /* 97-112 */ |
60 | }; | 60 | }; |
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c index 4b415d9b0123..36cd2e07fce8 100644 --- a/drivers/input/misc/wistron_btns.c +++ b/drivers/input/misc/wistron_btns.c | |||
@@ -273,6 +273,18 @@ static struct key_entry keymap_fs_amilo_pro_v2000[] = { | |||
273 | { KE_END, 0 } | 273 | { KE_END, 0 } |
274 | }; | 274 | }; |
275 | 275 | ||
276 | static struct key_entry keymap_fujitsu_n3510[] = { | ||
277 | { KE_KEY, 0x11, KEY_PROG1 }, | ||
278 | { KE_KEY, 0x12, KEY_PROG2 }, | ||
279 | { KE_KEY, 0x36, KEY_WWW }, | ||
280 | { KE_KEY, 0x31, KEY_MAIL }, | ||
281 | { KE_KEY, 0x71, KEY_STOPCD }, | ||
282 | { KE_KEY, 0x72, KEY_PLAYPAUSE }, | ||
283 | { KE_KEY, 0x74, KEY_REWIND }, | ||
284 | { KE_KEY, 0x78, KEY_FORWARD }, | ||
285 | { KE_END, 0 } | ||
286 | }; | ||
287 | |||
276 | static struct key_entry keymap_wistron_ms2141[] = { | 288 | static struct key_entry keymap_wistron_ms2141[] = { |
277 | { KE_KEY, 0x11, KEY_PROG1 }, | 289 | { KE_KEY, 0x11, KEY_PROG1 }, |
278 | { KE_KEY, 0x12, KEY_PROG2 }, | 290 | { KE_KEY, 0x12, KEY_PROG2 }, |
@@ -323,6 +335,24 @@ static struct dmi_system_id dmi_ids[] = { | |||
323 | }, | 335 | }, |
324 | { | 336 | { |
325 | .callback = dmi_matched, | 337 | .callback = dmi_matched, |
338 | .ident = "Fujitsu-Siemens Amilo M7400", | ||
339 | .matches = { | ||
340 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU SIEMENS"), | ||
341 | DMI_MATCH(DMI_PRODUCT_NAME, "AMILO M "), | ||
342 | }, | ||
343 | .driver_data = keymap_fs_amilo_pro_v2000 | ||
344 | }, | ||
345 | { | ||
346 | .callback = dmi_matched, | ||
347 | .ident = "Fujitsu N3510", | ||
348 | .matches = { | ||
349 | DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), | ||
350 | DMI_MATCH(DMI_PRODUCT_NAME, "N3510"), | ||
351 | }, | ||
352 | .driver_data = keymap_fujitsu_n3510 | ||
353 | }, | ||
354 | { | ||
355 | .callback = dmi_matched, | ||
326 | .ident = "Acer Aspire 1500", | 356 | .ident = "Acer Aspire 1500", |
327 | .matches = { | 357 | .matches = { |
328 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | 358 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), |
diff --git a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c index 32d70ed8f41d..136321a2cfdb 100644 --- a/drivers/input/mouse/psmouse-base.c +++ b/drivers/input/mouse/psmouse-base.c | |||
@@ -302,8 +302,10 @@ static irqreturn_t psmouse_interrupt(struct serio *serio, | |||
302 | * Check if this is a new device announcement (0xAA 0x00) | 302 | * Check if this is a new device announcement (0xAA 0x00) |
303 | */ | 303 | */ |
304 | if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt <= 2)) { | 304 | if (unlikely(psmouse->packet[0] == PSMOUSE_RET_BAT && psmouse->pktcnt <= 2)) { |
305 | if (psmouse->pktcnt == 1) | 305 | if (psmouse->pktcnt == 1) { |
306 | psmouse->last = jiffies; | ||
306 | goto out; | 307 | goto out; |
308 | } | ||
307 | 309 | ||
308 | if (psmouse->packet[1] == PSMOUSE_RET_ID) { | 310 | if (psmouse->packet[1] == PSMOUSE_RET_ID) { |
309 | __psmouse_set_state(psmouse, PSMOUSE_IGNORE); | 311 | __psmouse_set_state(psmouse, PSMOUSE_IGNORE); |
diff --git a/drivers/input/serio/i8042-io.h b/drivers/input/serio/i8042-io.h index 9a9221644250..cc21914fbc72 100644 --- a/drivers/input/serio/i8042-io.h +++ b/drivers/input/serio/i8042-io.h | |||
@@ -67,14 +67,14 @@ static inline int i8042_platform_init(void) | |||
67 | * On some platforms touching the i8042 data register region can do really | 67 | * On some platforms touching the i8042 data register region can do really |
68 | * bad things. Because of this the region is always reserved on such boxes. | 68 | * bad things. Because of this the region is always reserved on such boxes. |
69 | */ | 69 | */ |
70 | #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC64) | 70 | #if !defined(__sh__) && !defined(__alpha__) && !defined(__mips__) && !defined(CONFIG_PPC_MERGE) |
71 | if (!request_region(I8042_DATA_REG, 16, "i8042")) | 71 | if (!request_region(I8042_DATA_REG, 16, "i8042")) |
72 | return -EBUSY; | 72 | return -EBUSY; |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | i8042_reset = 1; | 75 | i8042_reset = 1; |
76 | 76 | ||
77 | #if defined(CONFIG_PPC64) | 77 | #if defined(CONFIG_PPC_MERGE) |
78 | if (check_legacy_ioport(I8042_DATA_REG)) | 78 | if (check_legacy_ioport(I8042_DATA_REG)) |
79 | return -EBUSY; | 79 | return -EBUSY; |
80 | if (!request_region(I8042_DATA_REG, 16, "i8042")) | 80 | if (!request_region(I8042_DATA_REG, 16, "i8042")) |
diff --git a/drivers/input/touchscreen/ads7846.c b/drivers/input/touchscreen/ads7846.c index 46d1fec2cfd8..1494175ac6fe 100644 --- a/drivers/input/touchscreen/ads7846.c +++ b/drivers/input/touchscreen/ads7846.c | |||
@@ -2,6 +2,8 @@ | |||
2 | * ADS7846 based touchscreen and sensor driver | 2 | * ADS7846 based touchscreen and sensor driver |
3 | * | 3 | * |
4 | * Copyright (c) 2005 David Brownell | 4 | * Copyright (c) 2005 David Brownell |
5 | * Copyright (c) 2006 Nokia Corporation | ||
6 | * Various changes: Imre Deak <imre.deak@nokia.com> | ||
5 | * | 7 | * |
6 | * Using code from: | 8 | * Using code from: |
7 | * - corgi_ts.c | 9 | * - corgi_ts.c |
@@ -34,17 +36,25 @@ | |||
34 | 36 | ||
35 | 37 | ||
36 | /* | 38 | /* |
37 | * This code has been lightly tested on an ads7846. | 39 | * This code has been tested on an ads7846 / N770 device. |
38 | * Support for ads7843 and ads7845 has only been stubbed in. | 40 | * Support for ads7843 and ads7845 has only been stubbed in. |
39 | * | 41 | * |
40 | * Not yet done: investigate the values reported. Are x/y/pressure | 42 | * Not yet done: How accurate are the temperature and voltage |
41 | * event values sane enough for X11? How accurate are the temperature | 43 | * readings? (System-specific calibration should support |
42 | * and voltage readings? (System-specific calibration should support | ||
43 | * accuracy of 0.3 degrees C; otherwise it's 2.0 degrees.) | 44 | * accuracy of 0.3 degrees C; otherwise it's 2.0 degrees.) |
44 | * | 45 | * |
46 | * IRQ handling needs a workaround because of a shortcoming in handling | ||
47 | * edge triggered IRQs on some platforms like the OMAP1/2. These | ||
48 | * platforms don't handle the ARM lazy IRQ disabling properly, thus we | ||
49 | * have to maintain our own SW IRQ disabled status. This should be | ||
50 | * removed as soon as the affected platform's IRQ handling is fixed. | ||
51 | * | ||
45 | * app note sbaa036 talks in more detail about accurate sampling... | 52 | * app note sbaa036 talks in more detail about accurate sampling... |
46 | * that ought to help in situations like LCDs inducing noise (which | 53 | * that ought to help in situations like LCDs inducing noise (which |
47 | * can also be helped by using synch signals) and more generally. | 54 | * can also be helped by using synch signals) and more generally. |
55 | * This driver tries to utilize the measures described in the app | ||
56 | * note. The strength of filtering can be set in the board-* specific | ||
57 | * files. | ||
48 | */ | 58 | */ |
49 | 59 | ||
50 | #define TS_POLL_PERIOD msecs_to_jiffies(10) | 60 | #define TS_POLL_PERIOD msecs_to_jiffies(10) |
@@ -61,6 +71,7 @@ struct ts_event { | |||
61 | __be16 x; | 71 | __be16 x; |
62 | __be16 y; | 72 | __be16 y; |
63 | __be16 z1, z2; | 73 | __be16 z1, z2; |
74 | int ignore; | ||
64 | }; | 75 | }; |
65 | 76 | ||
66 | struct ads7846 { | 77 | struct ads7846 { |
@@ -71,12 +82,23 @@ struct ads7846 { | |||
71 | u16 model; | 82 | u16 model; |
72 | u16 vref_delay_usecs; | 83 | u16 vref_delay_usecs; |
73 | u16 x_plate_ohms; | 84 | u16 x_plate_ohms; |
85 | u16 pressure_max; | ||
74 | 86 | ||
75 | u8 read_x, read_y, read_z1, read_z2; | 87 | u8 read_x, read_y, read_z1, read_z2, pwrdown; |
88 | u16 dummy; /* for the pwrdown read */ | ||
76 | struct ts_event tc; | 89 | struct ts_event tc; |
77 | 90 | ||
78 | struct spi_transfer xfer[8]; | 91 | struct spi_transfer xfer[10]; |
79 | struct spi_message msg; | 92 | struct spi_message msg[5]; |
93 | struct spi_message *last_msg; | ||
94 | int msg_idx; | ||
95 | int read_cnt; | ||
96 | int read_rep; | ||
97 | int last_read; | ||
98 | |||
99 | u16 debounce_max; | ||
100 | u16 debounce_tol; | ||
101 | u16 debounce_rep; | ||
80 | 102 | ||
81 | spinlock_t lock; | 103 | spinlock_t lock; |
82 | struct timer_list timer; /* P: lock */ | 104 | struct timer_list timer; /* P: lock */ |
@@ -84,6 +106,9 @@ struct ads7846 { | |||
84 | unsigned pending:1; /* P: lock */ | 106 | unsigned pending:1; /* P: lock */ |
85 | // FIXME remove "irq_disabled" | 107 | // FIXME remove "irq_disabled" |
86 | unsigned irq_disabled:1; /* P: lock */ | 108 | unsigned irq_disabled:1; /* P: lock */ |
109 | unsigned disabled:1; | ||
110 | |||
111 | int (*get_pendown_state)(void); | ||
87 | }; | 112 | }; |
88 | 113 | ||
89 | /* leave chip selected when we're done, for quicker re-select? */ | 114 | /* leave chip selected when we're done, for quicker re-select? */ |
@@ -125,7 +150,9 @@ struct ads7846 { | |||
125 | #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) | 150 | #define READ_Y (READ_12BIT_DFR(y) | ADS_PD10_ADC_ON) |
126 | #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) | 151 | #define READ_Z1 (READ_12BIT_DFR(z1) | ADS_PD10_ADC_ON) |
127 | #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) | 152 | #define READ_Z2 (READ_12BIT_DFR(z2) | ADS_PD10_ADC_ON) |
128 | #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_PDOWN) /* LAST */ | 153 | |
154 | #define READ_X (READ_12BIT_DFR(x) | ADS_PD10_ADC_ON) | ||
155 | #define PWRDOWN (READ_12BIT_DFR(y) | ADS_PD10_PDOWN) /* LAST */ | ||
129 | 156 | ||
130 | /* single-ended samples need to first power up reference voltage; | 157 | /* single-ended samples need to first power up reference voltage; |
131 | * we leave both ADC and VREF powered | 158 | * we leave both ADC and VREF powered |
@@ -152,6 +179,15 @@ struct ser_req { | |||
152 | struct spi_transfer xfer[6]; | 179 | struct spi_transfer xfer[6]; |
153 | }; | 180 | }; |
154 | 181 | ||
182 | static void ads7846_enable(struct ads7846 *ts); | ||
183 | static void ads7846_disable(struct ads7846 *ts); | ||
184 | |||
185 | static int device_suspended(struct device *dev) | ||
186 | { | ||
187 | struct ads7846 *ts = dev_get_drvdata(dev); | ||
188 | return dev->power.power_state.event != PM_EVENT_ON || ts->disabled; | ||
189 | } | ||
190 | |||
155 | static int ads7846_read12_ser(struct device *dev, unsigned command) | 191 | static int ads7846_read12_ser(struct device *dev, unsigned command) |
156 | { | 192 | { |
157 | struct spi_device *spi = to_spi_device(dev); | 193 | struct spi_device *spi = to_spi_device(dev); |
@@ -164,7 +200,7 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
164 | if (!req) | 200 | if (!req) |
165 | return -ENOMEM; | 201 | return -ENOMEM; |
166 | 202 | ||
167 | INIT_LIST_HEAD(&req->msg.transfers); | 203 | spi_message_init(&req->msg); |
168 | 204 | ||
169 | /* activate reference, so it has time to settle; */ | 205 | /* activate reference, so it has time to settle; */ |
170 | req->ref_on = REF_ON; | 206 | req->ref_on = REF_ON; |
@@ -204,8 +240,10 @@ static int ads7846_read12_ser(struct device *dev, unsigned command) | |||
204 | for (i = 0; i < 6; i++) | 240 | for (i = 0; i < 6; i++) |
205 | spi_message_add_tail(&req->xfer[i], &req->msg); | 241 | spi_message_add_tail(&req->xfer[i], &req->msg); |
206 | 242 | ||
243 | ts->irq_disabled = 1; | ||
207 | disable_irq(spi->irq); | 244 | disable_irq(spi->irq); |
208 | status = spi_sync(spi, &req->msg); | 245 | status = spi_sync(spi, &req->msg); |
246 | ts->irq_disabled = 0; | ||
209 | enable_irq(spi->irq); | 247 | enable_irq(spi->irq); |
210 | 248 | ||
211 | if (req->msg.status) | 249 | if (req->msg.status) |
@@ -233,6 +271,52 @@ SHOW(temp1) | |||
233 | SHOW(vaux) | 271 | SHOW(vaux) |
234 | SHOW(vbatt) | 272 | SHOW(vbatt) |
235 | 273 | ||
274 | static int is_pen_down(struct device *dev) | ||
275 | { | ||
276 | struct ads7846 *ts = dev_get_drvdata(dev); | ||
277 | |||
278 | return ts->pendown; | ||
279 | } | ||
280 | |||
281 | static ssize_t ads7846_pen_down_show(struct device *dev, | ||
282 | struct device_attribute *attr, char *buf) | ||
283 | { | ||
284 | return sprintf(buf, "%u\n", is_pen_down(dev)); | ||
285 | } | ||
286 | |||
287 | static DEVICE_ATTR(pen_down, S_IRUGO, ads7846_pen_down_show, NULL); | ||
288 | |||
289 | static ssize_t ads7846_disable_show(struct device *dev, | ||
290 | struct device_attribute *attr, char *buf) | ||
291 | { | ||
292 | struct ads7846 *ts = dev_get_drvdata(dev); | ||
293 | |||
294 | return sprintf(buf, "%u\n", ts->disabled); | ||
295 | } | ||
296 | |||
297 | static ssize_t ads7846_disable_store(struct device *dev, | ||
298 | struct device_attribute *attr, | ||
299 | const char *buf, size_t count) | ||
300 | { | ||
301 | struct ads7846 *ts = dev_get_drvdata(dev); | ||
302 | char *endp; | ||
303 | int i; | ||
304 | |||
305 | i = simple_strtoul(buf, &endp, 10); | ||
306 | spin_lock_irq(&ts->lock); | ||
307 | |||
308 | if (i) | ||
309 | ads7846_disable(ts); | ||
310 | else | ||
311 | ads7846_enable(ts); | ||
312 | |||
313 | spin_unlock_irq(&ts->lock); | ||
314 | |||
315 | return count; | ||
316 | } | ||
317 | |||
318 | static DEVICE_ATTR(disable, 0664, ads7846_disable_show, ads7846_disable_store); | ||
319 | |||
236 | /*--------------------------------------------------------------------------*/ | 320 | /*--------------------------------------------------------------------------*/ |
237 | 321 | ||
238 | /* | 322 | /* |
@@ -264,7 +348,7 @@ static void ads7846_rx(void *ads) | |||
264 | if (x == MAX_12BIT) | 348 | if (x == MAX_12BIT) |
265 | x = 0; | 349 | x = 0; |
266 | 350 | ||
267 | if (x && z1 && ts->spi->dev.power.power_state.event == PM_EVENT_ON) { | 351 | if (likely(x && z1 && !device_suspended(&ts->spi->dev))) { |
268 | /* compute touch pressure resistance using equation #2 */ | 352 | /* compute touch pressure resistance using equation #2 */ |
269 | Rt = z2; | 353 | Rt = z2; |
270 | Rt -= z1; | 354 | Rt -= z1; |
@@ -275,6 +359,14 @@ static void ads7846_rx(void *ads) | |||
275 | } else | 359 | } else |
276 | Rt = 0; | 360 | Rt = 0; |
277 | 361 | ||
362 | /* Sample found inconsistent by debouncing or pressure is beyond | ||
363 | * the maximum. Don't report it to user space, repeat at least | ||
364 | * once more the measurement */ | ||
365 | if (ts->tc.ignore || Rt > ts->pressure_max) { | ||
366 | mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD); | ||
367 | return; | ||
368 | } | ||
369 | |||
278 | /* NOTE: "pendown" is inferred from pressure; we don't rely on | 370 | /* NOTE: "pendown" is inferred from pressure; we don't rely on |
279 | * being able to check nPENIRQ status, or "friendly" trigger modes | 371 | * being able to check nPENIRQ status, or "friendly" trigger modes |
280 | * (both-edges is much better than just-falling or low-level). | 372 | * (both-edges is much better than just-falling or low-level). |
@@ -296,11 +388,13 @@ static void ads7846_rx(void *ads) | |||
296 | if (Rt) { | 388 | if (Rt) { |
297 | input_report_abs(input_dev, ABS_X, x); | 389 | input_report_abs(input_dev, ABS_X, x); |
298 | input_report_abs(input_dev, ABS_Y, y); | 390 | input_report_abs(input_dev, ABS_Y, y); |
299 | input_report_abs(input_dev, ABS_PRESSURE, Rt); | ||
300 | sync = 1; | 391 | sync = 1; |
301 | } | 392 | } |
302 | if (sync) | 393 | |
394 | if (sync) { | ||
395 | input_report_abs(input_dev, ABS_PRESSURE, Rt); | ||
303 | input_sync(input_dev); | 396 | input_sync(input_dev); |
397 | } | ||
304 | 398 | ||
305 | #ifdef VERBOSE | 399 | #ifdef VERBOSE |
306 | if (Rt || ts->pendown) | 400 | if (Rt || ts->pendown) |
@@ -308,80 +402,138 @@ static void ads7846_rx(void *ads) | |||
308 | x, y, Rt, Rt ? "" : " UP"); | 402 | x, y, Rt, Rt ? "" : " UP"); |
309 | #endif | 403 | #endif |
310 | 404 | ||
311 | /* don't retrigger while we're suspended */ | ||
312 | spin_lock_irqsave(&ts->lock, flags); | 405 | spin_lock_irqsave(&ts->lock, flags); |
313 | 406 | ||
314 | ts->pendown = (Rt != 0); | 407 | ts->pendown = (Rt != 0); |
315 | ts->pending = 0; | 408 | mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD); |
316 | 409 | ||
317 | if (ts->spi->dev.power.power_state.event == PM_EVENT_ON) { | 410 | spin_unlock_irqrestore(&ts->lock, flags); |
318 | if (ts->pendown) | 411 | } |
319 | mod_timer(&ts->timer, jiffies + TS_POLL_PERIOD); | 412 | |
320 | else if (ts->irq_disabled) { | 413 | static void ads7846_debounce(void *ads) |
321 | ts->irq_disabled = 0; | 414 | { |
322 | enable_irq(ts->spi->irq); | 415 | struct ads7846 *ts = ads; |
416 | struct spi_message *m; | ||
417 | struct spi_transfer *t; | ||
418 | int val; | ||
419 | int status; | ||
420 | |||
421 | m = &ts->msg[ts->msg_idx]; | ||
422 | t = list_entry(m->transfers.prev, struct spi_transfer, transfer_list); | ||
423 | val = (*(u16 *)t->rx_buf) >> 3; | ||
424 | if (!ts->read_cnt || (abs(ts->last_read - val) > ts->debounce_tol)) { | ||
425 | /* Repeat it, if this was the first read or the read | ||
426 | * wasn't consistent enough. */ | ||
427 | if (ts->read_cnt < ts->debounce_max) { | ||
428 | ts->last_read = val; | ||
429 | ts->read_cnt++; | ||
430 | } else { | ||
431 | /* Maximum number of debouncing reached and still | ||
432 | * not enough number of consistent readings. Abort | ||
433 | * the whole sample, repeat it in the next sampling | ||
434 | * period. | ||
435 | */ | ||
436 | ts->tc.ignore = 1; | ||
437 | ts->read_cnt = 0; | ||
438 | /* Last message will contain ads7846_rx() as the | ||
439 | * completion function. | ||
440 | */ | ||
441 | m = ts->last_msg; | ||
323 | } | 442 | } |
443 | /* Start over collecting consistent readings. */ | ||
444 | ts->read_rep = 0; | ||
445 | } else { | ||
446 | if (++ts->read_rep > ts->debounce_rep) { | ||
447 | /* Got a good reading for this coordinate, | ||
448 | * go for the next one. */ | ||
449 | ts->tc.ignore = 0; | ||
450 | ts->msg_idx++; | ||
451 | ts->read_cnt = 0; | ||
452 | ts->read_rep = 0; | ||
453 | m++; | ||
454 | } else | ||
455 | /* Read more values that are consistent. */ | ||
456 | ts->read_cnt++; | ||
324 | } | 457 | } |
325 | 458 | status = spi_async(ts->spi, m); | |
326 | spin_unlock_irqrestore(&ts->lock, flags); | 459 | if (status) |
460 | dev_err(&ts->spi->dev, "spi_async --> %d\n", | ||
461 | status); | ||
327 | } | 462 | } |
328 | 463 | ||
329 | static void ads7846_timer(unsigned long handle) | 464 | static void ads7846_timer(unsigned long handle) |
330 | { | 465 | { |
331 | struct ads7846 *ts = (void *)handle; | 466 | struct ads7846 *ts = (void *)handle; |
332 | int status = 0; | 467 | int status = 0; |
333 | unsigned long flags; | 468 | |
469 | spin_lock_irq(&ts->lock); | ||
470 | |||
471 | if (unlikely(ts->msg_idx && !ts->pendown)) { | ||
472 | /* measurment cycle ended */ | ||
473 | if (!device_suspended(&ts->spi->dev)) { | ||
474 | ts->irq_disabled = 0; | ||
475 | enable_irq(ts->spi->irq); | ||
476 | } | ||
477 | ts->pending = 0; | ||
478 | ts->msg_idx = 0; | ||
479 | } else { | ||
480 | /* pen is still down, continue with the measurement */ | ||
481 | ts->msg_idx = 0; | ||
482 | status = spi_async(ts->spi, &ts->msg[0]); | ||
483 | if (status) | ||
484 | dev_err(&ts->spi->dev, "spi_async --> %d\n", status); | ||
485 | } | ||
486 | |||
487 | spin_unlock_irq(&ts->lock); | ||
488 | } | ||
489 | |||
490 | static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs) | ||
491 | { | ||
492 | struct ads7846 *ts = handle; | ||
493 | unsigned long flags; | ||
334 | 494 | ||
335 | spin_lock_irqsave(&ts->lock, flags); | 495 | spin_lock_irqsave(&ts->lock, flags); |
336 | if (!ts->pending) { | 496 | if (likely(ts->get_pendown_state())) { |
337 | ts->pending = 1; | ||
338 | if (!ts->irq_disabled) { | 497 | if (!ts->irq_disabled) { |
498 | /* REVISIT irq logic for many ARM chips has cloned a | ||
499 | * bug wherein disabling an irq in its handler won't | ||
500 | * work;(it's disabled lazily, and too late to work. | ||
501 | * until all their irq logic is fixed, we must shadow | ||
502 | * that state here. | ||
503 | */ | ||
339 | ts->irq_disabled = 1; | 504 | ts->irq_disabled = 1; |
340 | disable_irq(ts->spi->irq); | 505 | disable_irq(ts->spi->irq); |
506 | ts->pending = 1; | ||
507 | mod_timer(&ts->timer, jiffies); | ||
341 | } | 508 | } |
342 | status = spi_async(ts->spi, &ts->msg); | ||
343 | if (status) | ||
344 | dev_err(&ts->spi->dev, "spi_async --> %d\n", | ||
345 | status); | ||
346 | } | 509 | } |
347 | spin_unlock_irqrestore(&ts->lock, flags); | 510 | spin_unlock_irqrestore(&ts->lock, flags); |
348 | } | ||
349 | 511 | ||
350 | static irqreturn_t ads7846_irq(int irq, void *handle, struct pt_regs *regs) | ||
351 | { | ||
352 | ads7846_timer((unsigned long) handle); | ||
353 | return IRQ_HANDLED; | 512 | return IRQ_HANDLED; |
354 | } | 513 | } |
355 | 514 | ||
356 | /*--------------------------------------------------------------------------*/ | 515 | /*--------------------------------------------------------------------------*/ |
357 | 516 | ||
358 | static int | 517 | /* Must be called with ts->lock held */ |
359 | ads7846_suspend(struct spi_device *spi, pm_message_t message) | 518 | static void ads7846_disable(struct ads7846 *ts) |
360 | { | 519 | { |
361 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 520 | if (ts->disabled) |
362 | unsigned long flags; | 521 | return; |
363 | 522 | ||
364 | spin_lock_irqsave(&ts->lock, flags); | 523 | ts->disabled = 1; |
365 | |||
366 | spi->dev.power.power_state = message; | ||
367 | 524 | ||
368 | /* are we waiting for IRQ, or polling? */ | 525 | /* are we waiting for IRQ, or polling? */ |
369 | if (!ts->pendown) { | 526 | if (!ts->pending) { |
370 | if (!ts->irq_disabled) { | 527 | ts->irq_disabled = 1; |
371 | ts->irq_disabled = 1; | 528 | disable_irq(ts->spi->irq); |
372 | disable_irq(ts->spi->irq); | ||
373 | } | ||
374 | } else { | 529 | } else { |
375 | /* polling; force a final SPI completion; | 530 | /* the timer will run at least once more, and |
376 | * that will clean things up neatly | 531 | * leave everything in a clean state, IRQ disabled |
377 | */ | 532 | */ |
378 | if (!ts->pending) | 533 | while (ts->pending) { |
379 | mod_timer(&ts->timer, jiffies); | 534 | spin_unlock_irq(&ts->lock); |
380 | 535 | msleep(1); | |
381 | while (ts->pendown || ts->pending) { | 536 | spin_lock_irq(&ts->lock); |
382 | spin_unlock_irqrestore(&ts->lock, flags); | ||
383 | udelay(10); | ||
384 | spin_lock_irqsave(&ts->lock, flags); | ||
385 | } | 537 | } |
386 | } | 538 | } |
387 | 539 | ||
@@ -389,17 +541,45 @@ ads7846_suspend(struct spi_device *spi, pm_message_t message) | |||
389 | * leave it that way after every request | 541 | * leave it that way after every request |
390 | */ | 542 | */ |
391 | 543 | ||
392 | spin_unlock_irqrestore(&ts->lock, flags); | 544 | } |
545 | |||
546 | /* Must be called with ts->lock held */ | ||
547 | static void ads7846_enable(struct ads7846 *ts) | ||
548 | { | ||
549 | if (!ts->disabled) | ||
550 | return; | ||
551 | |||
552 | ts->disabled = 0; | ||
553 | ts->irq_disabled = 0; | ||
554 | enable_irq(ts->spi->irq); | ||
555 | } | ||
556 | |||
557 | static int ads7846_suspend(struct spi_device *spi, pm_message_t message) | ||
558 | { | ||
559 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | ||
560 | |||
561 | spin_lock_irq(&ts->lock); | ||
562 | |||
563 | spi->dev.power.power_state = message; | ||
564 | ads7846_disable(ts); | ||
565 | |||
566 | spin_unlock_irq(&ts->lock); | ||
567 | |||
393 | return 0; | 568 | return 0; |
569 | |||
394 | } | 570 | } |
395 | 571 | ||
396 | static int ads7846_resume(struct spi_device *spi) | 572 | static int ads7846_resume(struct spi_device *spi) |
397 | { | 573 | { |
398 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 574 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); |
399 | 575 | ||
400 | ts->irq_disabled = 0; | 576 | spin_lock_irq(&ts->lock); |
401 | enable_irq(ts->spi->irq); | 577 | |
402 | spi->dev.power.power_state = PMSG_ON; | 578 | spi->dev.power.power_state = PMSG_ON; |
579 | ads7846_enable(ts); | ||
580 | |||
581 | spin_unlock_irq(&ts->lock); | ||
582 | |||
403 | return 0; | 583 | return 0; |
404 | } | 584 | } |
405 | 585 | ||
@@ -408,6 +588,7 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
408 | struct ads7846 *ts; | 588 | struct ads7846 *ts; |
409 | struct input_dev *input_dev; | 589 | struct input_dev *input_dev; |
410 | struct ads7846_platform_data *pdata = spi->dev.platform_data; | 590 | struct ads7846_platform_data *pdata = spi->dev.platform_data; |
591 | struct spi_message *m; | ||
411 | struct spi_transfer *x; | 592 | struct spi_transfer *x; |
412 | int err; | 593 | int err; |
413 | 594 | ||
@@ -428,6 +609,11 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
428 | return -EINVAL; | 609 | return -EINVAL; |
429 | } | 610 | } |
430 | 611 | ||
612 | if (pdata->get_pendown_state == NULL) { | ||
613 | dev_dbg(&spi->dev, "no get_pendown_state function?\n"); | ||
614 | return -EINVAL; | ||
615 | } | ||
616 | |||
431 | /* We'd set the wordsize to 12 bits ... except that some controllers | 617 | /* We'd set the wordsize to 12 bits ... except that some controllers |
432 | * will then treat the 8 bit command words as 12 bits (and drop the | 618 | * will then treat the 8 bit command words as 12 bits (and drop the |
433 | * four MSBs of the 12 bit result). Result: inputs must be shifted | 619 | * four MSBs of the 12 bit result). Result: inputs must be shifted |
@@ -451,9 +637,21 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
451 | ts->timer.data = (unsigned long) ts; | 637 | ts->timer.data = (unsigned long) ts; |
452 | ts->timer.function = ads7846_timer; | 638 | ts->timer.function = ads7846_timer; |
453 | 639 | ||
640 | spin_lock_init(&ts->lock); | ||
641 | |||
454 | ts->model = pdata->model ? : 7846; | 642 | ts->model = pdata->model ? : 7846; |
455 | ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; | 643 | ts->vref_delay_usecs = pdata->vref_delay_usecs ? : 100; |
456 | ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; | 644 | ts->x_plate_ohms = pdata->x_plate_ohms ? : 400; |
645 | ts->pressure_max = pdata->pressure_max ? : ~0; | ||
646 | if (pdata->debounce_max) { | ||
647 | ts->debounce_max = pdata->debounce_max; | ||
648 | ts->debounce_tol = pdata->debounce_tol; | ||
649 | ts->debounce_rep = pdata->debounce_rep; | ||
650 | if (ts->debounce_rep > ts->debounce_max + 1) | ||
651 | ts->debounce_rep = ts->debounce_max - 1; | ||
652 | } else | ||
653 | ts->debounce_tol = ~0; | ||
654 | ts->get_pendown_state = pdata->get_pendown_state; | ||
457 | 655 | ||
458 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id); | 656 | snprintf(ts->phys, sizeof(ts->phys), "%s/input0", spi->dev.bus_id); |
459 | 657 | ||
@@ -477,60 +675,100 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
477 | /* set up the transfers to read touchscreen state; this assumes we | 675 | /* set up the transfers to read touchscreen state; this assumes we |
478 | * use formula #2 for pressure, not #3. | 676 | * use formula #2 for pressure, not #3. |
479 | */ | 677 | */ |
480 | INIT_LIST_HEAD(&ts->msg.transfers); | 678 | m = &ts->msg[0]; |
481 | x = ts->xfer; | 679 | x = ts->xfer; |
482 | 680 | ||
681 | spi_message_init(m); | ||
682 | |||
483 | /* y- still on; turn on only y+ (and ADC) */ | 683 | /* y- still on; turn on only y+ (and ADC) */ |
484 | ts->read_y = READ_Y; | 684 | ts->read_y = READ_Y; |
485 | x->tx_buf = &ts->read_y; | 685 | x->tx_buf = &ts->read_y; |
486 | x->len = 1; | 686 | x->len = 1; |
487 | spi_message_add_tail(x, &ts->msg); | 687 | spi_message_add_tail(x, m); |
488 | 688 | ||
489 | x++; | 689 | x++; |
490 | x->rx_buf = &ts->tc.y; | 690 | x->rx_buf = &ts->tc.y; |
491 | x->len = 2; | 691 | x->len = 2; |
492 | spi_message_add_tail(x, &ts->msg); | 692 | spi_message_add_tail(x, m); |
693 | |||
694 | m->complete = ads7846_debounce; | ||
695 | m->context = ts; | ||
696 | |||
697 | m++; | ||
698 | spi_message_init(m); | ||
699 | |||
700 | /* turn y- off, x+ on, then leave in lowpower */ | ||
701 | x++; | ||
702 | ts->read_x = READ_X; | ||
703 | x->tx_buf = &ts->read_x; | ||
704 | x->len = 1; | ||
705 | spi_message_add_tail(x, m); | ||
706 | |||
707 | x++; | ||
708 | x->rx_buf = &ts->tc.x; | ||
709 | x->len = 2; | ||
710 | spi_message_add_tail(x, m); | ||
711 | |||
712 | m->complete = ads7846_debounce; | ||
713 | m->context = ts; | ||
493 | 714 | ||
494 | /* turn y+ off, x- on; we'll use formula #2 */ | 715 | /* turn y+ off, x- on; we'll use formula #2 */ |
495 | if (ts->model == 7846) { | 716 | if (ts->model == 7846) { |
717 | m++; | ||
718 | spi_message_init(m); | ||
719 | |||
496 | x++; | 720 | x++; |
497 | ts->read_z1 = READ_Z1; | 721 | ts->read_z1 = READ_Z1; |
498 | x->tx_buf = &ts->read_z1; | 722 | x->tx_buf = &ts->read_z1; |
499 | x->len = 1; | 723 | x->len = 1; |
500 | spi_message_add_tail(x, &ts->msg); | 724 | spi_message_add_tail(x, m); |
501 | 725 | ||
502 | x++; | 726 | x++; |
503 | x->rx_buf = &ts->tc.z1; | 727 | x->rx_buf = &ts->tc.z1; |
504 | x->len = 2; | 728 | x->len = 2; |
505 | spi_message_add_tail(x, &ts->msg); | 729 | spi_message_add_tail(x, m); |
730 | |||
731 | m->complete = ads7846_debounce; | ||
732 | m->context = ts; | ||
733 | |||
734 | m++; | ||
735 | spi_message_init(m); | ||
506 | 736 | ||
507 | x++; | 737 | x++; |
508 | ts->read_z2 = READ_Z2; | 738 | ts->read_z2 = READ_Z2; |
509 | x->tx_buf = &ts->read_z2; | 739 | x->tx_buf = &ts->read_z2; |
510 | x->len = 1; | 740 | x->len = 1; |
511 | spi_message_add_tail(x, &ts->msg); | 741 | spi_message_add_tail(x, m); |
512 | 742 | ||
513 | x++; | 743 | x++; |
514 | x->rx_buf = &ts->tc.z2; | 744 | x->rx_buf = &ts->tc.z2; |
515 | x->len = 2; | 745 | x->len = 2; |
516 | spi_message_add_tail(x, &ts->msg); | 746 | spi_message_add_tail(x, m); |
747 | |||
748 | m->complete = ads7846_debounce; | ||
749 | m->context = ts; | ||
517 | } | 750 | } |
518 | 751 | ||
519 | /* turn y- off, x+ on, then leave in lowpower */ | 752 | /* power down */ |
753 | m++; | ||
754 | spi_message_init(m); | ||
755 | |||
520 | x++; | 756 | x++; |
521 | ts->read_x = READ_X; | 757 | ts->pwrdown = PWRDOWN; |
522 | x->tx_buf = &ts->read_x; | 758 | x->tx_buf = &ts->pwrdown; |
523 | x->len = 1; | 759 | x->len = 1; |
524 | spi_message_add_tail(x, &ts->msg); | 760 | spi_message_add_tail(x, m); |
525 | 761 | ||
526 | x++; | 762 | x++; |
527 | x->rx_buf = &ts->tc.x; | 763 | x->rx_buf = &ts->dummy; |
528 | x->len = 2; | 764 | x->len = 2; |
529 | CS_CHANGE(*x); | 765 | CS_CHANGE(*x); |
530 | spi_message_add_tail(x, &ts->msg); | 766 | spi_message_add_tail(x, m); |
531 | 767 | ||
532 | ts->msg.complete = ads7846_rx; | 768 | m->complete = ads7846_rx; |
533 | ts->msg.context = ts; | 769 | m->context = ts; |
770 | |||
771 | ts->last_msg = m; | ||
534 | 772 | ||
535 | if (request_irq(spi->irq, ads7846_irq, | 773 | if (request_irq(spi->irq, ads7846_irq, |
536 | SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, | 774 | SA_SAMPLE_RANDOM | SA_TRIGGER_FALLING, |
@@ -559,13 +797,27 @@ static int __devinit ads7846_probe(struct spi_device *spi) | |||
559 | device_create_file(&spi->dev, &dev_attr_vbatt); | 797 | device_create_file(&spi->dev, &dev_attr_vbatt); |
560 | device_create_file(&spi->dev, &dev_attr_vaux); | 798 | device_create_file(&spi->dev, &dev_attr_vaux); |
561 | 799 | ||
800 | device_create_file(&spi->dev, &dev_attr_pen_down); | ||
801 | |||
802 | device_create_file(&spi->dev, &dev_attr_disable); | ||
803 | |||
562 | err = input_register_device(input_dev); | 804 | err = input_register_device(input_dev); |
563 | if (err) | 805 | if (err) |
564 | goto err_free_irq; | 806 | goto err_remove_attr; |
565 | 807 | ||
566 | return 0; | 808 | return 0; |
567 | 809 | ||
568 | err_free_irq: | 810 | err_remove_attr: |
811 | device_remove_file(&spi->dev, &dev_attr_disable); | ||
812 | device_remove_file(&spi->dev, &dev_attr_pen_down); | ||
813 | if (ts->model == 7846) { | ||
814 | device_remove_file(&spi->dev, &dev_attr_temp1); | ||
815 | device_remove_file(&spi->dev, &dev_attr_temp0); | ||
816 | } | ||
817 | if (ts->model != 7845) | ||
818 | device_remove_file(&spi->dev, &dev_attr_vbatt); | ||
819 | device_remove_file(&spi->dev, &dev_attr_vaux); | ||
820 | |||
569 | free_irq(spi->irq, ts); | 821 | free_irq(spi->irq, ts); |
570 | err_free_mem: | 822 | err_free_mem: |
571 | input_free_device(input_dev); | 823 | input_free_device(input_dev); |
@@ -577,20 +829,24 @@ static int __devexit ads7846_remove(struct spi_device *spi) | |||
577 | { | 829 | { |
578 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); | 830 | struct ads7846 *ts = dev_get_drvdata(&spi->dev); |
579 | 831 | ||
832 | input_unregister_device(ts->input); | ||
833 | |||
580 | ads7846_suspend(spi, PMSG_SUSPEND); | 834 | ads7846_suspend(spi, PMSG_SUSPEND); |
581 | free_irq(ts->spi->irq, ts); | ||
582 | if (ts->irq_disabled) | ||
583 | enable_irq(ts->spi->irq); | ||
584 | 835 | ||
836 | device_remove_file(&spi->dev, &dev_attr_disable); | ||
837 | device_remove_file(&spi->dev, &dev_attr_pen_down); | ||
585 | if (ts->model == 7846) { | 838 | if (ts->model == 7846) { |
586 | device_remove_file(&spi->dev, &dev_attr_temp0); | ||
587 | device_remove_file(&spi->dev, &dev_attr_temp1); | 839 | device_remove_file(&spi->dev, &dev_attr_temp1); |
840 | device_remove_file(&spi->dev, &dev_attr_temp0); | ||
588 | } | 841 | } |
589 | if (ts->model != 7845) | 842 | if (ts->model != 7845) |
590 | device_remove_file(&spi->dev, &dev_attr_vbatt); | 843 | device_remove_file(&spi->dev, &dev_attr_vbatt); |
591 | device_remove_file(&spi->dev, &dev_attr_vaux); | 844 | device_remove_file(&spi->dev, &dev_attr_vaux); |
592 | 845 | ||
593 | input_unregister_device(ts->input); | 846 | free_irq(ts->spi->irq, ts); |
847 | /* suspend left the IRQ disabled */ | ||
848 | enable_irq(ts->spi->irq); | ||
849 | |||
594 | kfree(ts); | 850 | kfree(ts); |
595 | 851 | ||
596 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); | 852 | dev_dbg(&spi->dev, "unregistered touchscreen\n"); |
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index f86ed6af3aa2..eb41aba3ddef 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Tilman Schmidt <tilman@imap.cc>, | 5 | * Tilman Schmidt <tilman@imap.cc>, |
6 | * Stefan Eilers. | 6 | * Stefan Eilers. |
7 | * | 7 | * |
8 | * Based on usb-gigaset.c. | ||
9 | * | ||
10 | * ===================================================================== | 8 | * ===================================================================== |
11 | * This program is free software; you can redistribute it and/or | 9 | * This program is free software; you can redistribute it and/or |
12 | * modify it under the terms of the GNU General Public License as | 10 | * modify it under the terms of the GNU General Public License as |
@@ -46,19 +44,20 @@ MODULE_PARM_DESC(cidmode, "Call-ID mode"); | |||
46 | #define GIGASET_DEVFSNAME "gig/bas/" | 44 | #define GIGASET_DEVFSNAME "gig/bas/" |
47 | #define GIGASET_DEVNAME "ttyGB" | 45 | #define GIGASET_DEVNAME "ttyGB" |
48 | 46 | ||
49 | #define IF_WRITEBUF 256 //FIXME | 47 | /* length limit according to Siemens 3070usb-protokoll.doc ch. 2.1 */ |
48 | #define IF_WRITEBUF 264 | ||
50 | 49 | ||
51 | /* Values for the Gigaset 307x */ | 50 | /* Values for the Gigaset 307x */ |
52 | #define USB_GIGA_VENDOR_ID 0x0681 | 51 | #define USB_GIGA_VENDOR_ID 0x0681 |
53 | #define USB_GIGA_PRODUCT_ID 0x0001 | 52 | #define USB_3070_PRODUCT_ID 0x0001 |
54 | #define USB_4175_PRODUCT_ID 0x0002 | 53 | #define USB_3075_PRODUCT_ID 0x0002 |
55 | #define USB_SX303_PRODUCT_ID 0x0021 | 54 | #define USB_SX303_PRODUCT_ID 0x0021 |
56 | #define USB_SX353_PRODUCT_ID 0x0022 | 55 | #define USB_SX353_PRODUCT_ID 0x0022 |
57 | 56 | ||
58 | /* table of devices that work with this driver */ | 57 | /* table of devices that work with this driver */ |
59 | static struct usb_device_id gigaset_table [] = { | 58 | static struct usb_device_id gigaset_table [] = { |
60 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_GIGA_PRODUCT_ID) }, | 59 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3070_PRODUCT_ID) }, |
61 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_4175_PRODUCT_ID) }, | 60 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_3075_PRODUCT_ID) }, |
62 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, | 61 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX303_PRODUCT_ID) }, |
63 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX353_PRODUCT_ID) }, | 62 | { USB_DEVICE(USB_GIGA_VENDOR_ID, USB_SX353_PRODUCT_ID) }, |
64 | { } /* Terminating entry */ | 63 | { } /* Terminating entry */ |
@@ -77,6 +76,10 @@ static int gigaset_probe(struct usb_interface *interface, | |||
77 | /* Function will be called if the device is unplugged */ | 76 | /* Function will be called if the device is unplugged */ |
78 | static void gigaset_disconnect(struct usb_interface *interface); | 77 | static void gigaset_disconnect(struct usb_interface *interface); |
79 | 78 | ||
79 | static void read_ctrl_callback(struct urb *, struct pt_regs *); | ||
80 | static void stopurbs(struct bas_bc_state *); | ||
81 | static int atwrite_submit(struct cardstate *, unsigned char *, int); | ||
82 | static int start_cbsend(struct cardstate *); | ||
80 | 83 | ||
81 | /*==============================================================================*/ | 84 | /*==============================================================================*/ |
82 | 85 | ||
@@ -111,12 +114,14 @@ struct bas_cardstate { | |||
111 | }; | 114 | }; |
112 | 115 | ||
113 | /* status of direct USB connection to 307x base (bits in basstate) */ | 116 | /* status of direct USB connection to 307x base (bits in basstate) */ |
114 | #define BS_ATOPEN 0x001 | 117 | #define BS_ATOPEN 0x001 /* AT channel open */ |
115 | #define BS_B1OPEN 0x002 | 118 | #define BS_B1OPEN 0x002 /* B channel 1 open */ |
116 | #define BS_B2OPEN 0x004 | 119 | #define BS_B2OPEN 0x004 /* B channel 2 open */ |
117 | #define BS_ATREADY 0x008 | 120 | #define BS_ATREADY 0x008 /* base ready for AT command */ |
118 | #define BS_INIT 0x010 | 121 | #define BS_INIT 0x010 /* base has signalled INIT_OK */ |
119 | #define BS_ATTIMER 0x020 | 122 | #define BS_ATTIMER 0x020 /* waiting for HD_READY_SEND_ATDATA */ |
123 | #define BS_ATRDPEND 0x040 /* urb_cmd_in in use */ | ||
124 | #define BS_ATWRPEND 0x080 /* urb_cmd_out in use */ | ||
120 | 125 | ||
121 | 126 | ||
122 | static struct gigaset_driver *driver = NULL; | 127 | static struct gigaset_driver *driver = NULL; |
@@ -130,6 +135,47 @@ static struct usb_driver gigaset_usb_driver = { | |||
130 | .id_table = gigaset_table, | 135 | .id_table = gigaset_table, |
131 | }; | 136 | }; |
132 | 137 | ||
138 | /* get message text for usb_submit_urb return code | ||
139 | */ | ||
140 | static char *get_usb_rcmsg(int rc) | ||
141 | { | ||
142 | static char unkmsg[28]; | ||
143 | |||
144 | switch (rc) { | ||
145 | case 0: | ||
146 | return "success"; | ||
147 | case -ENOMEM: | ||
148 | return "out of memory"; | ||
149 | case -ENODEV: | ||
150 | return "device not present"; | ||
151 | case -ENOENT: | ||
152 | return "endpoint not present"; | ||
153 | case -ENXIO: | ||
154 | return "URB type not supported"; | ||
155 | case -EINVAL: | ||
156 | return "invalid argument"; | ||
157 | case -EAGAIN: | ||
158 | return "start frame too early or too much scheduled"; | ||
159 | case -EFBIG: | ||
160 | return "too many isochronous frames requested"; | ||
161 | case -EPIPE: | ||
162 | return "endpoint stalled"; | ||
163 | case -EMSGSIZE: | ||
164 | return "invalid packet size"; | ||
165 | case -ENOSPC: | ||
166 | return "would overcommit USB bandwidth"; | ||
167 | case -ESHUTDOWN: | ||
168 | return "device shut down"; | ||
169 | case -EPERM: | ||
170 | return "reject flag set"; | ||
171 | case -EHOSTUNREACH: | ||
172 | return "device suspended"; | ||
173 | default: | ||
174 | snprintf(unkmsg, sizeof(unkmsg), "unknown error %d", rc); | ||
175 | return unkmsg; | ||
176 | } | ||
177 | } | ||
178 | |||
133 | /* get message text for USB status code | 179 | /* get message text for USB status code |
134 | */ | 180 | */ |
135 | static char *get_usb_statmsg(int status) | 181 | static char *get_usb_statmsg(int status) |
@@ -140,43 +186,37 @@ static char *get_usb_statmsg(int status) | |||
140 | case 0: | 186 | case 0: |
141 | return "success"; | 187 | return "success"; |
142 | case -ENOENT: | 188 | case -ENOENT: |
143 | return "canceled"; | 189 | return "unlinked (sync)"; |
144 | case -ECONNRESET: | ||
145 | return "canceled (async)"; | ||
146 | case -EINPROGRESS: | 190 | case -EINPROGRESS: |
147 | return "pending"; | 191 | return "pending"; |
148 | case -EPROTO: | 192 | case -EPROTO: |
149 | return "bit stuffing or unknown USB error"; | 193 | return "bit stuffing error, timeout, or unknown USB error"; |
150 | case -EILSEQ: | 194 | case -EILSEQ: |
151 | return "Illegal byte sequence (CRC mismatch)"; | 195 | return "CRC mismatch, timeout, or unknown USB error"; |
152 | case -EPIPE: | ||
153 | return "babble detect or endpoint stalled"; | ||
154 | case -ENOSR: | ||
155 | return "buffer error"; | ||
156 | case -ETIMEDOUT: | 196 | case -ETIMEDOUT: |
157 | return "timed out"; | 197 | return "timed out"; |
158 | case -ENODEV: | 198 | case -EPIPE: |
159 | return "device not present"; | 199 | return "endpoint stalled"; |
200 | case -ECOMM: | ||
201 | return "IN buffer overrun"; | ||
202 | case -ENOSR: | ||
203 | return "OUT buffer underrun"; | ||
204 | case -EOVERFLOW: | ||
205 | return "too much data"; | ||
160 | case -EREMOTEIO: | 206 | case -EREMOTEIO: |
161 | return "short packet detected"; | 207 | return "short packet detected"; |
208 | case -ENODEV: | ||
209 | return "device removed"; | ||
162 | case -EXDEV: | 210 | case -EXDEV: |
163 | return "partial isochronous transfer"; | 211 | return "partial isochronous transfer"; |
164 | case -EINVAL: | 212 | case -EINVAL: |
165 | return "invalid argument"; | 213 | return "invalid argument"; |
166 | case -ENXIO: | 214 | case -ECONNRESET: |
167 | return "URB already queued"; | 215 | return "unlinked (async)"; |
168 | case -EAGAIN: | ||
169 | return "isochronous start frame too early or too much scheduled"; | ||
170 | case -EFBIG: | ||
171 | return "too many isochronous frames requested"; | ||
172 | case -EMSGSIZE: | ||
173 | return "endpoint message size zero"; | ||
174 | case -ESHUTDOWN: | 216 | case -ESHUTDOWN: |
175 | return "endpoint shutdown"; | 217 | return "device shut down"; |
176 | case -EBUSY: | ||
177 | return "another request pending"; | ||
178 | default: | 218 | default: |
179 | snprintf(unkmsg, sizeof(unkmsg), "unknown error %d", status); | 219 | snprintf(unkmsg, sizeof(unkmsg), "unknown status %d", status); |
180 | return unkmsg; | 220 | return unkmsg; |
181 | } | 221 | } |
182 | } | 222 | } |
@@ -277,18 +317,17 @@ static inline void error_hangup(struct bc_state *bcs) | |||
277 | gig_dbg(DEBUG_ANY, "%s: scheduling HUP for channel %d", | 317 | gig_dbg(DEBUG_ANY, "%s: scheduling HUP for channel %d", |
278 | __func__, bcs->channel); | 318 | __func__, bcs->channel); |
279 | 319 | ||
280 | if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) { | 320 | if (!gigaset_add_event(cs, &bcs->at_state, EV_HUP, NULL, 0, NULL)) |
281 | //FIXME what should we do? | 321 | dev_err(cs->dev, "event queue full\n"); |
282 | return; | ||
283 | } | ||
284 | 322 | ||
285 | gigaset_schedule_event(cs); | 323 | gigaset_schedule_event(cs); |
286 | } | 324 | } |
287 | 325 | ||
288 | /* error_reset | 326 | /* error_reset |
289 | * reset Gigaset device because of an unrecoverable error | 327 | * reset Gigaset device because of an unrecoverable error |
290 | * This function may be called from any context and takes care of scheduling | 328 | * This function may be called from any context, and should take care of |
291 | * the necessary actions for execution outside of interrupt context. | 329 | * scheduling the necessary actions for execution outside of interrupt context. |
330 | * Right now, it just generates a kernel message calling for help. | ||
292 | * argument: | 331 | * argument: |
293 | * controller state structure | 332 | * controller state structure |
294 | */ | 333 | */ |
@@ -364,36 +403,38 @@ static void cmd_in_timeout(unsigned long data) | |||
364 | { | 403 | { |
365 | struct cardstate *cs = (struct cardstate *) data; | 404 | struct cardstate *cs = (struct cardstate *) data; |
366 | struct bas_cardstate *ucs = cs->hw.bas; | 405 | struct bas_cardstate *ucs = cs->hw.bas; |
367 | unsigned long flags; | ||
368 | 406 | ||
369 | spin_lock_irqsave(&cs->lock, flags); | ||
370 | if (unlikely(!cs->connected)) { | ||
371 | gig_dbg(DEBUG_USBREQ, "%s: disconnected", __func__); | ||
372 | spin_unlock_irqrestore(&cs->lock, flags); | ||
373 | return; | ||
374 | } | ||
375 | if (!ucs->rcvbuf_size) { | 407 | if (!ucs->rcvbuf_size) { |
376 | gig_dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__); | 408 | gig_dbg(DEBUG_USBREQ, "%s: no receive in progress", __func__); |
377 | spin_unlock_irqrestore(&cs->lock, flags); | ||
378 | return; | 409 | return; |
379 | } | 410 | } |
380 | spin_unlock_irqrestore(&cs->lock, flags); | ||
381 | 411 | ||
382 | dev_err(cs->dev, "timeout reading AT response\n"); | 412 | dev_err(cs->dev, "timeout reading AT response\n"); |
383 | error_reset(cs); //FIXME retry? | 413 | error_reset(cs); //FIXME retry? |
384 | } | 414 | } |
385 | 415 | ||
416 | /* set/clear bits in base connection state, return previous state | ||
417 | */ | ||
418 | inline static int update_basstate(struct bas_cardstate *ucs, | ||
419 | int set, int clear) | ||
420 | { | ||
421 | unsigned long flags; | ||
422 | int state; | ||
386 | 423 | ||
387 | static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs); | 424 | spin_lock_irqsave(&ucs->lock, flags); |
425 | state = atomic_read(&ucs->basstate); | ||
426 | atomic_set(&ucs->basstate, (state & ~clear) | set); | ||
427 | spin_unlock_irqrestore(&ucs->lock, flags); | ||
428 | return state; | ||
429 | } | ||
388 | 430 | ||
389 | /* atread_submit | 431 | /* atread_submit |
390 | * submit an HD_READ_ATMESSAGE command URB | 432 | * submit an HD_READ_ATMESSAGE command URB and optionally start a timeout |
391 | * parameters: | 433 | * parameters: |
392 | * cs controller state structure | 434 | * cs controller state structure |
393 | * timeout timeout in 1/10 sec., 0: none | 435 | * timeout timeout in 1/10 sec., 0: none |
394 | * return value: | 436 | * return value: |
395 | * 0 on success | 437 | * 0 on success |
396 | * -EINVAL if a NULL pointer is encountered somewhere | ||
397 | * -EBUSY if another request is pending | 438 | * -EBUSY if another request is pending |
398 | * any URB submission error code | 439 | * any URB submission error code |
399 | */ | 440 | */ |
@@ -405,7 +446,7 @@ static int atread_submit(struct cardstate *cs, int timeout) | |||
405 | gig_dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)", | 446 | gig_dbg(DEBUG_USBREQ, "-------> HD_READ_ATMESSAGE (%d)", |
406 | ucs->rcvbuf_size); | 447 | ucs->rcvbuf_size); |
407 | 448 | ||
408 | if (ucs->urb_cmd_in->status == -EINPROGRESS) { | 449 | if (update_basstate(ucs, BS_ATRDPEND, 0) & BS_ATRDPEND) { |
409 | dev_err(cs->dev, | 450 | dev_err(cs->dev, |
410 | "could not submit HD_READ_ATMESSAGE: URB busy\n"); | 451 | "could not submit HD_READ_ATMESSAGE: URB busy\n"); |
411 | return -EBUSY; | 452 | return -EBUSY; |
@@ -423,6 +464,7 @@ static int atread_submit(struct cardstate *cs, int timeout) | |||
423 | read_ctrl_callback, cs->inbuf); | 464 | read_ctrl_callback, cs->inbuf); |
424 | 465 | ||
425 | if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { | 466 | if ((ret = usb_submit_urb(ucs->urb_cmd_in, SLAB_ATOMIC)) != 0) { |
467 | update_basstate(ucs, 0, BS_ATRDPEND); | ||
426 | dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", | 468 | dev_err(cs->dev, "could not submit HD_READ_ATMESSAGE: %s\n", |
427 | get_usb_statmsg(ret)); | 469 | get_usb_statmsg(ret)); |
428 | return ret; | 470 | return ret; |
@@ -438,26 +480,6 @@ static int atread_submit(struct cardstate *cs, int timeout) | |||
438 | return 0; | 480 | return 0; |
439 | } | 481 | } |
440 | 482 | ||
441 | static void stopurbs(struct bas_bc_state *); | ||
442 | static int start_cbsend(struct cardstate *); | ||
443 | |||
444 | /* set/clear bits in base connection state | ||
445 | */ | ||
446 | inline static void update_basstate(struct bas_cardstate *ucs, | ||
447 | int set, int clear) | ||
448 | { | ||
449 | unsigned long flags; | ||
450 | int state; | ||
451 | |||
452 | spin_lock_irqsave(&ucs->lock, flags); | ||
453 | state = atomic_read(&ucs->basstate); | ||
454 | state &= ~clear; | ||
455 | state |= set; | ||
456 | atomic_set(&ucs->basstate, state); | ||
457 | spin_unlock_irqrestore(&ucs->lock, flags); | ||
458 | } | ||
459 | |||
460 | |||
461 | /* read_int_callback | 483 | /* read_int_callback |
462 | * USB completion handler for interrupt pipe input | 484 | * USB completion handler for interrupt pipe input |
463 | * called by the USB subsystem in interrupt context | 485 | * called by the USB subsystem in interrupt context |
@@ -471,20 +493,25 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) | |||
471 | struct bas_cardstate *ucs = cs->hw.bas; | 493 | struct bas_cardstate *ucs = cs->hw.bas; |
472 | struct bc_state *bcs; | 494 | struct bc_state *bcs; |
473 | unsigned long flags; | 495 | unsigned long flags; |
474 | int status; | 496 | int rc; |
475 | unsigned l; | 497 | unsigned l; |
476 | int channel; | 498 | int channel; |
477 | 499 | ||
478 | switch (urb->status) { | 500 | switch (urb->status) { |
479 | case 0: /* success */ | 501 | case 0: /* success */ |
480 | break; | 502 | break; |
481 | case -ENOENT: /* canceled */ | 503 | case -ENOENT: /* cancelled */ |
482 | case -ECONNRESET: /* canceled (async) */ | 504 | case -ECONNRESET: /* cancelled (async) */ |
483 | case -EINPROGRESS: /* pending */ | 505 | case -EINPROGRESS: /* pending */ |
484 | /* ignore silently */ | 506 | /* ignore silently */ |
485 | gig_dbg(DEBUG_USBREQ, "%s: %s", | 507 | gig_dbg(DEBUG_USBREQ, "%s: %s", |
486 | __func__, get_usb_statmsg(urb->status)); | 508 | __func__, get_usb_statmsg(urb->status)); |
487 | return; | 509 | return; |
510 | case -ENODEV: /* device removed */ | ||
511 | case -ESHUTDOWN: /* device shut down */ | ||
512 | //FIXME use this as disconnect indicator? | ||
513 | gig_dbg(DEBUG_USBREQ, "%s: device disconnected", __func__); | ||
514 | return; | ||
488 | default: /* severe trouble */ | 515 | default: /* severe trouble */ |
489 | dev_warn(cs->dev, "interrupt read: %s\n", | 516 | dev_warn(cs->dev, "interrupt read: %s\n", |
490 | get_usb_statmsg(urb->status)); | 517 | get_usb_statmsg(urb->status)); |
@@ -492,6 +519,13 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) | |||
492 | goto resubmit; | 519 | goto resubmit; |
493 | } | 520 | } |
494 | 521 | ||
522 | /* drop incomplete packets even if the missing bytes wouldn't matter */ | ||
523 | if (unlikely(urb->actual_length < 3)) { | ||
524 | dev_warn(cs->dev, "incomplete interrupt packet (%d bytes)\n", | ||
525 | urb->actual_length); | ||
526 | goto resubmit; | ||
527 | } | ||
528 | |||
495 | l = (unsigned) ucs->int_in_buf[1] + | 529 | l = (unsigned) ucs->int_in_buf[1] + |
496 | (((unsigned) ucs->int_in_buf[2]) << 8); | 530 | (((unsigned) ucs->int_in_buf[2]) << 8); |
497 | 531 | ||
@@ -558,25 +592,28 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) | |||
558 | } | 592 | } |
559 | spin_lock_irqsave(&cs->lock, flags); | 593 | spin_lock_irqsave(&cs->lock, flags); |
560 | if (ucs->rcvbuf_size) { | 594 | if (ucs->rcvbuf_size) { |
561 | spin_unlock_irqrestore(&cs->lock, flags); | 595 | /* throw away previous buffer - we have no queue */ |
562 | dev_err(cs->dev, | 596 | dev_err(cs->dev, |
563 | "receive AT data overrun, %d bytes lost\n", l); | 597 | "receive AT data overrun, %d bytes lost\n", |
564 | error_reset(cs); //FIXME reschedule | 598 | ucs->rcvbuf_size); |
565 | break; | 599 | kfree(ucs->rcvbuf); |
600 | ucs->rcvbuf_size = 0; | ||
566 | } | 601 | } |
567 | if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { | 602 | if ((ucs->rcvbuf = kmalloc(l, GFP_ATOMIC)) == NULL) { |
568 | spin_unlock_irqrestore(&cs->lock, flags); | 603 | spin_unlock_irqrestore(&cs->lock, flags); |
569 | dev_err(cs->dev, "out of memory, %d bytes lost\n", l); | 604 | dev_err(cs->dev, "out of memory receiving AT data\n"); |
570 | error_reset(cs); //FIXME reschedule | 605 | error_reset(cs); |
571 | break; | 606 | break; |
572 | } | 607 | } |
573 | ucs->rcvbuf_size = l; | 608 | ucs->rcvbuf_size = l; |
574 | ucs->retry_cmd_in = 0; | 609 | ucs->retry_cmd_in = 0; |
575 | if ((status = atread_submit(cs, BAS_TIMEOUT)) < 0) { | 610 | if ((rc = atread_submit(cs, BAS_TIMEOUT)) < 0) { |
576 | kfree(ucs->rcvbuf); | 611 | kfree(ucs->rcvbuf); |
577 | ucs->rcvbuf = NULL; | 612 | ucs->rcvbuf = NULL; |
578 | ucs->rcvbuf_size = 0; | 613 | ucs->rcvbuf_size = 0; |
579 | error_reset(cs); //FIXME reschedule | 614 | if (rc != -ENODEV) |
615 | //FIXME corrective action? | ||
616 | error_reset(cs); | ||
580 | } | 617 | } |
581 | spin_unlock_irqrestore(&cs->lock, flags); | 618 | spin_unlock_irqrestore(&cs->lock, flags); |
582 | break; | 619 | break; |
@@ -598,12 +635,10 @@ static void read_int_callback(struct urb *urb, struct pt_regs *regs) | |||
598 | check_pending(ucs); | 635 | check_pending(ucs); |
599 | 636 | ||
600 | resubmit: | 637 | resubmit: |
601 | spin_lock_irqsave(&cs->lock, flags); | 638 | rc = usb_submit_urb(urb, SLAB_ATOMIC); |
602 | status = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; | 639 | if (unlikely(rc != 0 && rc != -ENODEV)) { |
603 | spin_unlock_irqrestore(&cs->lock, flags); | ||
604 | if (unlikely(status)) { | ||
605 | dev_err(cs->dev, "could not resubmit interrupt URB: %s\n", | 640 | dev_err(cs->dev, "could not resubmit interrupt URB: %s\n", |
606 | get_usb_statmsg(status)); | 641 | get_usb_rcmsg(rc)); |
607 | error_reset(cs); | 642 | error_reset(cs); |
608 | } | 643 | } |
609 | } | 644 | } |
@@ -622,18 +657,12 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) | |||
622 | struct bas_cardstate *ucs = cs->hw.bas; | 657 | struct bas_cardstate *ucs = cs->hw.bas; |
623 | int have_data = 0; | 658 | int have_data = 0; |
624 | unsigned numbytes; | 659 | unsigned numbytes; |
625 | unsigned long flags; | 660 | int rc; |
626 | 661 | ||
627 | spin_lock_irqsave(&cs->lock, flags); | 662 | update_basstate(ucs, 0, BS_ATRDPEND); |
628 | if (unlikely(!cs->connected)) { | ||
629 | warn("%s: disconnected", __func__); | ||
630 | spin_unlock_irqrestore(&cs->lock, flags); | ||
631 | return; | ||
632 | } | ||
633 | 663 | ||
634 | if (!ucs->rcvbuf_size) { | 664 | if (!ucs->rcvbuf_size) { |
635 | dev_warn(cs->dev, "%s: no receive in progress\n", __func__); | 665 | dev_warn(cs->dev, "%s: no receive in progress\n", __func__); |
636 | spin_unlock_irqrestore(&cs->lock, flags); | ||
637 | return; | 666 | return; |
638 | } | 667 | } |
639 | 668 | ||
@@ -666,9 +695,11 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) | |||
666 | } | 695 | } |
667 | break; | 696 | break; |
668 | 697 | ||
669 | case -ENOENT: /* canceled */ | 698 | case -ENOENT: /* cancelled */ |
670 | case -ECONNRESET: /* canceled (async) */ | 699 | case -ECONNRESET: /* cancelled (async) */ |
671 | case -EINPROGRESS: /* pending */ | 700 | case -EINPROGRESS: /* pending */ |
701 | case -ENODEV: /* device removed */ | ||
702 | case -ESHUTDOWN: /* device shut down */ | ||
672 | /* no action necessary */ | 703 | /* no action necessary */ |
673 | gig_dbg(DEBUG_USBREQ, "%s: %s", | 704 | gig_dbg(DEBUG_USBREQ, "%s: %s", |
674 | __func__, get_usb_statmsg(urb->status)); | 705 | __func__, get_usb_statmsg(urb->status)); |
@@ -681,11 +712,11 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) | |||
681 | if (ucs->retry_cmd_in++ < BAS_RETRY) { | 712 | if (ucs->retry_cmd_in++ < BAS_RETRY) { |
682 | dev_notice(cs->dev, "control read: retry %d\n", | 713 | dev_notice(cs->dev, "control read: retry %d\n", |
683 | ucs->retry_cmd_in); | 714 | ucs->retry_cmd_in); |
684 | if (atread_submit(cs, BAS_TIMEOUT) >= 0) { | 715 | rc = atread_submit(cs, BAS_TIMEOUT); |
685 | /* resubmitted - bypass regular exit block */ | 716 | if (rc >= 0 || rc == -ENODEV) |
686 | spin_unlock_irqrestore(&cs->lock, flags); | 717 | /* resubmitted or disconnected */ |
718 | /* - bypass regular exit block */ | ||
687 | return; | 719 | return; |
688 | } | ||
689 | } else { | 720 | } else { |
690 | dev_err(cs->dev, | 721 | dev_err(cs->dev, |
691 | "control read: giving up after %d tries\n", | 722 | "control read: giving up after %d tries\n", |
@@ -697,7 +728,6 @@ static void read_ctrl_callback(struct urb *urb, struct pt_regs *regs) | |||
697 | kfree(ucs->rcvbuf); | 728 | kfree(ucs->rcvbuf); |
698 | ucs->rcvbuf = NULL; | 729 | ucs->rcvbuf = NULL; |
699 | ucs->rcvbuf_size = 0; | 730 | ucs->rcvbuf_size = 0; |
700 | spin_unlock_irqrestore(&cs->lock, flags); | ||
701 | if (have_data) { | 731 | if (have_data) { |
702 | gig_dbg(DEBUG_INTR, "%s-->BH", __func__); | 732 | gig_dbg(DEBUG_INTR, "%s-->BH", __func__); |
703 | gigaset_schedule_event(cs); | 733 | gigaset_schedule_event(cs); |
@@ -719,8 +749,11 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs) | |||
719 | int i, rc; | 749 | int i, rc; |
720 | 750 | ||
721 | /* status codes not worth bothering the tasklet with */ | 751 | /* status codes not worth bothering the tasklet with */ |
722 | if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || | 752 | if (unlikely(urb->status == -ENOENT || |
723 | urb->status == -EINPROGRESS)) { | 753 | urb->status == -ECONNRESET || |
754 | urb->status == -EINPROGRESS || | ||
755 | urb->status == -ENODEV || | ||
756 | urb->status == -ESHUTDOWN)) { | ||
724 | gig_dbg(DEBUG_ISO, "%s: %s", | 757 | gig_dbg(DEBUG_ISO, "%s: %s", |
725 | __func__, get_usb_statmsg(urb->status)); | 758 | __func__, get_usb_statmsg(urb->status)); |
726 | return; | 759 | return; |
@@ -740,9 +773,9 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs) | |||
740 | for (i = 0; i < BAS_NUMFRAMES; i++) { | 773 | for (i = 0; i < BAS_NUMFRAMES; i++) { |
741 | ubc->isoinlost += urb->iso_frame_desc[i].actual_length; | 774 | ubc->isoinlost += urb->iso_frame_desc[i].actual_length; |
742 | if (unlikely(urb->iso_frame_desc[i].status != 0 && | 775 | if (unlikely(urb->iso_frame_desc[i].status != 0 && |
743 | urb->iso_frame_desc[i].status != -EINPROGRESS)) { | 776 | urb->iso_frame_desc[i].status != |
777 | -EINPROGRESS)) | ||
744 | ubc->loststatus = urb->iso_frame_desc[i].status; | 778 | ubc->loststatus = urb->iso_frame_desc[i].status; |
745 | } | ||
746 | urb->iso_frame_desc[i].status = 0; | 779 | urb->iso_frame_desc[i].status = 0; |
747 | urb->iso_frame_desc[i].actual_length = 0; | 780 | urb->iso_frame_desc[i].actual_length = 0; |
748 | } | 781 | } |
@@ -754,10 +787,10 @@ static void read_iso_callback(struct urb *urb, struct pt_regs *regs) | |||
754 | gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", | 787 | gig_dbg(DEBUG_ISO, "%s: isoc read overrun/resubmit", |
755 | __func__); | 788 | __func__); |
756 | rc = usb_submit_urb(urb, SLAB_ATOMIC); | 789 | rc = usb_submit_urb(urb, SLAB_ATOMIC); |
757 | if (unlikely(rc != 0)) { | 790 | if (unlikely(rc != 0 && rc != -ENODEV)) { |
758 | dev_err(bcs->cs->dev, | 791 | dev_err(bcs->cs->dev, |
759 | "could not resubmit isochronous read " | 792 | "could not resubmit isochronous read " |
760 | "URB: %s\n", get_usb_statmsg(rc)); | 793 | "URB: %s\n", get_usb_rcmsg(rc)); |
761 | dump_urb(DEBUG_ISO, "isoc read", urb); | 794 | dump_urb(DEBUG_ISO, "isoc read", urb); |
762 | error_hangup(bcs); | 795 | error_hangup(bcs); |
763 | } | 796 | } |
@@ -780,8 +813,11 @@ static void write_iso_callback(struct urb *urb, struct pt_regs *regs) | |||
780 | unsigned long flags; | 813 | unsigned long flags; |
781 | 814 | ||
782 | /* status codes not worth bothering the tasklet with */ | 815 | /* status codes not worth bothering the tasklet with */ |
783 | if (unlikely(urb->status == -ENOENT || urb->status == -ECONNRESET || | 816 | if (unlikely(urb->status == -ENOENT || |
784 | urb->status == -EINPROGRESS)) { | 817 | urb->status == -ECONNRESET || |
818 | urb->status == -EINPROGRESS || | ||
819 | urb->status == -ENODEV || | ||
820 | urb->status == -ESHUTDOWN)) { | ||
785 | gig_dbg(DEBUG_ISO, "%s: %s", | 821 | gig_dbg(DEBUG_ISO, "%s: %s", |
786 | __func__, get_usb_statmsg(urb->status)); | 822 | __func__, get_usb_statmsg(urb->status)); |
787 | return; | 823 | return; |
@@ -822,7 +858,6 @@ static int starturbs(struct bc_state *bcs) | |||
822 | for (k = 0; k < BAS_INURBS; k++) { | 858 | for (k = 0; k < BAS_INURBS; k++) { |
823 | urb = ubc->isoinurbs[k]; | 859 | urb = ubc->isoinurbs[k]; |
824 | if (!urb) { | 860 | if (!urb) { |
825 | dev_err(bcs->cs->dev, "isoinurbs[%d]==NULL\n", k); | ||
826 | rc = -EFAULT; | 861 | rc = -EFAULT; |
827 | goto error; | 862 | goto error; |
828 | } | 863 | } |
@@ -844,12 +879,8 @@ static int starturbs(struct bc_state *bcs) | |||
844 | } | 879 | } |
845 | 880 | ||
846 | dump_urb(DEBUG_ISO, "Initial isoc read", urb); | 881 | dump_urb(DEBUG_ISO, "Initial isoc read", urb); |
847 | if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) { | 882 | if ((rc = usb_submit_urb(urb, SLAB_ATOMIC)) != 0) |
848 | dev_err(bcs->cs->dev, | ||
849 | "could not submit isochronous read URB %d: %s\n", | ||
850 | k, get_usb_statmsg(rc)); | ||
851 | goto error; | 883 | goto error; |
852 | } | ||
853 | } | 884 | } |
854 | 885 | ||
855 | /* initialize L2 transmission */ | 886 | /* initialize L2 transmission */ |
@@ -859,7 +890,6 @@ static int starturbs(struct bc_state *bcs) | |||
859 | for (k = 0; k < BAS_OUTURBS; ++k) { | 890 | for (k = 0; k < BAS_OUTURBS; ++k) { |
860 | urb = ubc->isoouturbs[k].urb; | 891 | urb = ubc->isoouturbs[k].urb; |
861 | if (!urb) { | 892 | if (!urb) { |
862 | dev_err(bcs->cs->dev, "isoouturbs[%d].urb==NULL\n", k); | ||
863 | rc = -EFAULT; | 893 | rc = -EFAULT; |
864 | goto error; | 894 | goto error; |
865 | } | 895 | } |
@@ -885,12 +915,8 @@ static int starturbs(struct bc_state *bcs) | |||
885 | for (k = 0; k < 2; ++k) { | 915 | for (k = 0; k < 2; ++k) { |
886 | dump_urb(DEBUG_ISO, "Initial isoc write", urb); | 916 | dump_urb(DEBUG_ISO, "Initial isoc write", urb); |
887 | rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); | 917 | rc = usb_submit_urb(ubc->isoouturbs[k].urb, SLAB_ATOMIC); |
888 | if (rc != 0) { | 918 | if (rc != 0) |
889 | dev_err(bcs->cs->dev, | ||
890 | "could not submit isochronous write URB %d: %s\n", | ||
891 | k, get_usb_statmsg(rc)); | ||
892 | goto error; | 919 | goto error; |
893 | } | ||
894 | } | 920 | } |
895 | dump_urb(DEBUG_ISO, "Initial isoc write (free)", urb); | 921 | dump_urb(DEBUG_ISO, "Initial isoc write (free)", urb); |
896 | ubc->isooutfree = &ubc->isoouturbs[2]; | 922 | ubc->isooutfree = &ubc->isoouturbs[2]; |
@@ -916,15 +942,15 @@ static void stopurbs(struct bas_bc_state *ubc) | |||
916 | for (k = 0; k < BAS_INURBS; ++k) { | 942 | for (k = 0; k < BAS_INURBS; ++k) { |
917 | rc = usb_unlink_urb(ubc->isoinurbs[k]); | 943 | rc = usb_unlink_urb(ubc->isoinurbs[k]); |
918 | gig_dbg(DEBUG_ISO, | 944 | gig_dbg(DEBUG_ISO, |
919 | "%s: isoc input URB %d unlinked, result = %d", | 945 | "%s: isoc input URB %d unlinked, result = %s", |
920 | __func__, k, rc); | 946 | __func__, k, get_usb_rcmsg(rc)); |
921 | } | 947 | } |
922 | 948 | ||
923 | for (k = 0; k < BAS_OUTURBS; ++k) { | 949 | for (k = 0; k < BAS_OUTURBS; ++k) { |
924 | rc = usb_unlink_urb(ubc->isoouturbs[k].urb); | 950 | rc = usb_unlink_urb(ubc->isoouturbs[k].urb); |
925 | gig_dbg(DEBUG_ISO, | 951 | gig_dbg(DEBUG_ISO, |
926 | "%s: isoc output URB %d unlinked, result = %d", | 952 | "%s: isoc output URB %d unlinked, result = %s", |
927 | __func__, k, rc); | 953 | __func__, k, get_usb_rcmsg(rc)); |
928 | } | 954 | } |
929 | } | 955 | } |
930 | 956 | ||
@@ -934,7 +960,7 @@ static void stopurbs(struct bas_bc_state *ubc) | |||
934 | /* submit_iso_write_urb | 960 | /* submit_iso_write_urb |
935 | * fill and submit the next isochronous write URB | 961 | * fill and submit the next isochronous write URB |
936 | * parameters: | 962 | * parameters: |
937 | * bcs B channel state structure | 963 | * ucx context structure containing URB |
938 | * return value: | 964 | * return value: |
939 | * number of frames submitted in URB | 965 | * number of frames submitted in URB |
940 | * 0 if URB not submitted because no data available (isooutbuf busy) | 966 | * 0 if URB not submitted because no data available (isooutbuf busy) |
@@ -946,7 +972,6 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) | |||
946 | struct bas_bc_state *ubc = ucx->bcs->hw.bas; | 972 | struct bas_bc_state *ubc = ucx->bcs->hw.bas; |
947 | struct usb_iso_packet_descriptor *ifd; | 973 | struct usb_iso_packet_descriptor *ifd; |
948 | int corrbytes, nframe, rc; | 974 | int corrbytes, nframe, rc; |
949 | unsigned long flags; | ||
950 | 975 | ||
951 | /* urb->dev is clobbered by USB subsystem */ | 976 | /* urb->dev is clobbered by USB subsystem */ |
952 | urb->dev = ucx->bcs->cs->hw.bas->udev; | 977 | urb->dev = ucx->bcs->cs->hw.bas->udev; |
@@ -992,20 +1017,22 @@ static int submit_iso_write_urb(struct isow_urbctx_t *ucx) | |||
992 | ifd->status = 0; | 1017 | ifd->status = 0; |
993 | ifd->actual_length = 0; | 1018 | ifd->actual_length = 0; |
994 | } | 1019 | } |
995 | if ((urb->number_of_packets = nframe) > 0) { | 1020 | if (unlikely(nframe == 0)) |
996 | spin_lock_irqsave(&ucx->bcs->cs->lock, flags); | 1021 | return 0; /* no data to send */ |
997 | rc = ucx->bcs->cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; | 1022 | urb->number_of_packets = nframe; |
998 | spin_unlock_irqrestore(&ucx->bcs->cs->lock, flags); | ||
999 | 1023 | ||
1000 | if (rc) { | 1024 | rc = usb_submit_urb(urb, SLAB_ATOMIC); |
1025 | if (unlikely(rc)) { | ||
1026 | if (rc == -ENODEV) | ||
1027 | /* device removed - give up silently */ | ||
1028 | gig_dbg(DEBUG_ISO, "%s: disconnected", __func__); | ||
1029 | else | ||
1001 | dev_err(ucx->bcs->cs->dev, | 1030 | dev_err(ucx->bcs->cs->dev, |
1002 | "could not submit isochronous write URB: %s\n", | 1031 | "could not submit isochronous write URB: %s\n", |
1003 | get_usb_statmsg(rc)); | 1032 | get_usb_rcmsg(rc)); |
1004 | dump_urb(DEBUG_ISO, "isoc write", urb); | 1033 | return rc; |
1005 | return rc; | ||
1006 | } | ||
1007 | ++ubc->numsub; | ||
1008 | } | 1034 | } |
1035 | ++ubc->numsub; | ||
1009 | return nframe; | 1036 | return nframe; |
1010 | } | 1037 | } |
1011 | 1038 | ||
@@ -1028,6 +1055,7 @@ static void write_iso_tasklet(unsigned long data) | |||
1028 | int i; | 1055 | int i; |
1029 | struct sk_buff *skb; | 1056 | struct sk_buff *skb; |
1030 | int len; | 1057 | int len; |
1058 | int rc; | ||
1031 | 1059 | ||
1032 | /* loop while completed URBs arrive in time */ | 1060 | /* loop while completed URBs arrive in time */ |
1033 | for (;;) { | 1061 | for (;;) { |
@@ -1057,7 +1085,8 @@ static void write_iso_tasklet(unsigned long data) | |||
1057 | ubc->isooutfree = NULL; | 1085 | ubc->isooutfree = NULL; |
1058 | spin_unlock_irqrestore(&ubc->isooutlock, flags); | 1086 | spin_unlock_irqrestore(&ubc->isooutlock, flags); |
1059 | if (next) { | 1087 | if (next) { |
1060 | if (submit_iso_write_urb(next) <= 0) { | 1088 | rc = submit_iso_write_urb(next); |
1089 | if (unlikely(rc <= 0 && rc != -ENODEV)) { | ||
1061 | /* could not submit URB, put it back */ | 1090 | /* could not submit URB, put it back */ |
1062 | spin_lock_irqsave(&ubc->isooutlock, flags); | 1091 | spin_lock_irqsave(&ubc->isooutlock, flags); |
1063 | if (ubc->isooutfree == NULL) { | 1092 | if (ubc->isooutfree == NULL) { |
@@ -1077,17 +1106,18 @@ static void write_iso_tasklet(unsigned long data) | |||
1077 | /* process completed URB */ | 1106 | /* process completed URB */ |
1078 | urb = done->urb; | 1107 | urb = done->urb; |
1079 | switch (urb->status) { | 1108 | switch (urb->status) { |
1109 | case -EXDEV: /* partial completion */ | ||
1110 | gig_dbg(DEBUG_ISO, "%s: URB partially completed", | ||
1111 | __func__); | ||
1112 | /* fall through - what's the difference anyway? */ | ||
1080 | case 0: /* normal completion */ | 1113 | case 0: /* normal completion */ |
1081 | break; | 1114 | /* inspect individual frames |
1082 | case -EXDEV: /* inspect individual frames */ | 1115 | * assumptions (for lack of documentation): |
1083 | /* assumptions (for lack of documentation): | 1116 | * - actual_length bytes of first frame in error are |
1084 | * - actual_length bytes of the frame in error are | ||
1085 | * successfully sent | 1117 | * successfully sent |
1086 | * - all following frames are not sent at all | 1118 | * - all following frames are not sent at all |
1087 | */ | 1119 | */ |
1088 | gig_dbg(DEBUG_ISO, "%s: URB partially completed", | 1120 | offset = done->limit; /* default (no error) */ |
1089 | __func__); | ||
1090 | offset = done->limit; /* just in case */ | ||
1091 | for (i = 0; i < BAS_NUMFRAMES; i++) { | 1121 | for (i = 0; i < BAS_NUMFRAMES; i++) { |
1092 | ifd = &urb->iso_frame_desc[i]; | 1122 | ifd = &urb->iso_frame_desc[i]; |
1093 | if (ifd->status || | 1123 | if (ifd->status || |
@@ -1122,7 +1152,7 @@ static void write_iso_tasklet(unsigned long data) | |||
1122 | } | 1152 | } |
1123 | #endif | 1153 | #endif |
1124 | break; | 1154 | break; |
1125 | case -EPIPE: //FIXME is this the code for "underrun"? | 1155 | case -EPIPE: /* stall - probably underrun */ |
1126 | dev_err(cs->dev, "isochronous write stalled\n"); | 1156 | dev_err(cs->dev, "isochronous write stalled\n"); |
1127 | error_hangup(bcs); | 1157 | error_hangup(bcs); |
1128 | break; | 1158 | break; |
@@ -1142,7 +1172,8 @@ static void write_iso_tasklet(unsigned long data) | |||
1142 | spin_unlock_irqrestore(&ubc->isooutlock, flags); | 1172 | spin_unlock_irqrestore(&ubc->isooutlock, flags); |
1143 | if (next) { | 1173 | if (next) { |
1144 | /* only one URB still active - resubmit one */ | 1174 | /* only one URB still active - resubmit one */ |
1145 | if (submit_iso_write_urb(next) <= 0) { | 1175 | rc = submit_iso_write_urb(next); |
1176 | if (unlikely(rc <= 0 && rc != -ENODEV)) { | ||
1146 | /* couldn't submit */ | 1177 | /* couldn't submit */ |
1147 | error_hangup(bcs); | 1178 | error_hangup(bcs); |
1148 | } | 1179 | } |
@@ -1222,10 +1253,9 @@ static void read_iso_tasklet(unsigned long data) | |||
1222 | break; | 1253 | break; |
1223 | case -ENOENT: | 1254 | case -ENOENT: |
1224 | case -ECONNRESET: | 1255 | case -ECONNRESET: |
1225 | gig_dbg(DEBUG_ISO, "%s: URB canceled", __func__); | 1256 | case -EINPROGRESS: |
1226 | continue; /* -> skip */ | 1257 | gig_dbg(DEBUG_ISO, "%s: %s", |
1227 | case -EINPROGRESS: /* huh? */ | 1258 | __func__, get_usb_statmsg(urb->status)); |
1228 | gig_dbg(DEBUG_ISO, "%s: URB still pending", __func__); | ||
1229 | continue; /* -> skip */ | 1259 | continue; /* -> skip */ |
1230 | case -EPIPE: | 1260 | case -EPIPE: |
1231 | dev_err(cs->dev, "isochronous read stalled\n"); | 1261 | dev_err(cs->dev, "isochronous read stalled\n"); |
@@ -1290,13 +1320,11 @@ static void read_iso_tasklet(unsigned long data) | |||
1290 | urb->dev = bcs->cs->hw.bas->udev; | 1320 | urb->dev = bcs->cs->hw.bas->udev; |
1291 | urb->transfer_flags = URB_ISO_ASAP; | 1321 | urb->transfer_flags = URB_ISO_ASAP; |
1292 | urb->number_of_packets = BAS_NUMFRAMES; | 1322 | urb->number_of_packets = BAS_NUMFRAMES; |
1293 | spin_lock_irqsave(&cs->lock, flags); | 1323 | rc = usb_submit_urb(urb, SLAB_ATOMIC); |
1294 | rc = cs->connected ? usb_submit_urb(urb, SLAB_ATOMIC) : -ENODEV; | 1324 | if (unlikely(rc != 0 && rc != -ENODEV)) { |
1295 | spin_unlock_irqrestore(&cs->lock, flags); | ||
1296 | if (rc) { | ||
1297 | dev_err(cs->dev, | 1325 | dev_err(cs->dev, |
1298 | "could not resubmit isochronous read URB: %s\n", | 1326 | "could not resubmit isochronous read URB: %s\n", |
1299 | get_usb_statmsg(rc)); | 1327 | get_usb_rcmsg(rc)); |
1300 | dump_urb(DEBUG_ISO, "resubmit iso read", urb); | 1328 | dump_urb(DEBUG_ISO, "resubmit iso read", urb); |
1301 | error_hangup(bcs); | 1329 | error_hangup(bcs); |
1302 | } | 1330 | } |
@@ -1397,7 +1425,6 @@ static void write_ctrl_callback(struct urb *urb, struct pt_regs *regs) | |||
1397 | * timeout timeout in seconds (0: no timeout) | 1425 | * timeout timeout in seconds (0: no timeout) |
1398 | * return value: | 1426 | * return value: |
1399 | * 0 on success | 1427 | * 0 on success |
1400 | * -EINVAL if a NULL pointer is encountered somewhere | ||
1401 | * -EBUSY if another request is pending | 1428 | * -EBUSY if another request is pending |
1402 | * any URB submission error code | 1429 | * any URB submission error code |
1403 | */ | 1430 | */ |
@@ -1418,12 +1445,6 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) | |||
1418 | req, ucs->pending); | 1445 | req, ucs->pending); |
1419 | return -EBUSY; | 1446 | return -EBUSY; |
1420 | } | 1447 | } |
1421 | if (ucs->urb_ctrl->status == -EINPROGRESS) { | ||
1422 | spin_unlock_irqrestore(&ucs->lock, flags); | ||
1423 | dev_err(bcs->cs->dev, | ||
1424 | "could not submit request 0x%02x: URB busy\n", req); | ||
1425 | return -EBUSY; | ||
1426 | } | ||
1427 | 1448 | ||
1428 | ucs->dr_ctrl.bRequestType = OUT_VENDOR_REQ; | 1449 | ucs->dr_ctrl.bRequestType = OUT_VENDOR_REQ; |
1429 | ucs->dr_ctrl.bRequest = req; | 1450 | ucs->dr_ctrl.bRequest = req; |
@@ -1465,22 +1486,36 @@ static int req_submit(struct bc_state *bcs, int req, int val, int timeout) | |||
1465 | static int gigaset_init_bchannel(struct bc_state *bcs) | 1486 | static int gigaset_init_bchannel(struct bc_state *bcs) |
1466 | { | 1487 | { |
1467 | int req, ret; | 1488 | int req, ret; |
1489 | unsigned long flags; | ||
1490 | |||
1491 | spin_lock_irqsave(&bcs->cs->lock, flags); | ||
1492 | if (unlikely(!bcs->cs->connected)) { | ||
1493 | gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); | ||
1494 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1495 | return -ENODEV; | ||
1496 | } | ||
1468 | 1497 | ||
1469 | if ((ret = starturbs(bcs)) < 0) { | 1498 | if ((ret = starturbs(bcs)) < 0) { |
1470 | dev_err(bcs->cs->dev, | 1499 | dev_err(bcs->cs->dev, |
1471 | "could not start isochronous I/O for channel %d\n", | 1500 | "could not start isochronous I/O for channel B%d: %s\n", |
1472 | bcs->channel + 1); | 1501 | bcs->channel + 1, |
1473 | error_hangup(bcs); | 1502 | ret == -EFAULT ? "null URB" : get_usb_rcmsg(ret)); |
1503 | if (ret != -ENODEV) | ||
1504 | error_hangup(bcs); | ||
1505 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1474 | return ret; | 1506 | return ret; |
1475 | } | 1507 | } |
1476 | 1508 | ||
1477 | req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; | 1509 | req = bcs->channel ? HD_OPEN_B2CHANNEL : HD_OPEN_B1CHANNEL; |
1478 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { | 1510 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) { |
1479 | dev_err(bcs->cs->dev, "could not open channel %d: %s\n", | 1511 | dev_err(bcs->cs->dev, "could not open channel B%d\n", |
1480 | bcs->channel + 1, get_usb_statmsg(ret)); | 1512 | bcs->channel + 1); |
1481 | stopurbs(bcs->hw.bas); | 1513 | stopurbs(bcs->hw.bas); |
1482 | error_hangup(bcs); | 1514 | if (ret != -ENODEV) |
1515 | error_hangup(bcs); | ||
1483 | } | 1516 | } |
1517 | |||
1518 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1484 | return ret; | 1519 | return ret; |
1485 | } | 1520 | } |
1486 | 1521 | ||
@@ -1497,19 +1532,30 @@ static int gigaset_init_bchannel(struct bc_state *bcs) | |||
1497 | static int gigaset_close_bchannel(struct bc_state *bcs) | 1532 | static int gigaset_close_bchannel(struct bc_state *bcs) |
1498 | { | 1533 | { |
1499 | int req, ret; | 1534 | int req, ret; |
1535 | unsigned long flags; | ||
1536 | |||
1537 | spin_lock_irqsave(&bcs->cs->lock, flags); | ||
1538 | if (unlikely(!bcs->cs->connected)) { | ||
1539 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1540 | gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); | ||
1541 | return -ENODEV; | ||
1542 | } | ||
1500 | 1543 | ||
1501 | if (!(atomic_read(&bcs->cs->hw.bas->basstate) & | 1544 | if (!(atomic_read(&bcs->cs->hw.bas->basstate) & |
1502 | (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) { | 1545 | (bcs->channel ? BS_B2OPEN : BS_B1OPEN))) { |
1503 | /* channel not running: just signal common.c */ | 1546 | /* channel not running: just signal common.c */ |
1547 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1504 | gigaset_bchannel_down(bcs); | 1548 | gigaset_bchannel_down(bcs); |
1505 | return 0; | 1549 | return 0; |
1506 | } | 1550 | } |
1507 | 1551 | ||
1552 | /* channel running: tell device to close it */ | ||
1508 | req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; | 1553 | req = bcs->channel ? HD_CLOSE_B2CHANNEL : HD_CLOSE_B1CHANNEL; |
1509 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) | 1554 | if ((ret = req_submit(bcs, req, 0, BAS_TIMEOUT)) < 0) |
1510 | dev_err(bcs->cs->dev, | 1555 | dev_err(bcs->cs->dev, "closing channel B%d failed\n", |
1511 | "could not submit HD_CLOSE_BxCHANNEL request: %s\n", | 1556 | bcs->channel + 1); |
1512 | get_usb_statmsg(ret)); | 1557 | |
1558 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
1513 | return ret; | 1559 | return ret; |
1514 | } | 1560 | } |
1515 | 1561 | ||
@@ -1545,8 +1591,6 @@ static void complete_cb(struct cardstate *cs) | |||
1545 | kfree(cb); | 1591 | kfree(cb); |
1546 | } | 1592 | } |
1547 | 1593 | ||
1548 | static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len); | ||
1549 | |||
1550 | /* write_command_callback | 1594 | /* write_command_callback |
1551 | * USB completion handler for AT command transmission | 1595 | * USB completion handler for AT command transmission |
1552 | * called by the USB subsystem in interrupt context | 1596 | * called by the USB subsystem in interrupt context |
@@ -1560,13 +1604,17 @@ static void write_command_callback(struct urb *urb, struct pt_regs *regs) | |||
1560 | struct bas_cardstate *ucs = cs->hw.bas; | 1604 | struct bas_cardstate *ucs = cs->hw.bas; |
1561 | unsigned long flags; | 1605 | unsigned long flags; |
1562 | 1606 | ||
1607 | update_basstate(ucs, 0, BS_ATWRPEND); | ||
1608 | |||
1563 | /* check status */ | 1609 | /* check status */ |
1564 | switch (urb->status) { | 1610 | switch (urb->status) { |
1565 | case 0: /* normal completion */ | 1611 | case 0: /* normal completion */ |
1566 | break; | 1612 | break; |
1567 | case -ENOENT: /* canceled */ | 1613 | case -ENOENT: /* cancelled */ |
1568 | case -ECONNRESET: /* canceled (async) */ | 1614 | case -ECONNRESET: /* cancelled (async) */ |
1569 | case -EINPROGRESS: /* pending */ | 1615 | case -EINPROGRESS: /* pending */ |
1616 | case -ENODEV: /* device removed */ | ||
1617 | case -ESHUTDOWN: /* device shut down */ | ||
1570 | /* ignore silently */ | 1618 | /* ignore silently */ |
1571 | gig_dbg(DEBUG_USBREQ, "%s: %s", | 1619 | gig_dbg(DEBUG_USBREQ, "%s: %s", |
1572 | __func__, get_usb_statmsg(urb->status)); | 1620 | __func__, get_usb_statmsg(urb->status)); |
@@ -1627,19 +1675,17 @@ static void atrdy_timeout(unsigned long data) | |||
1627 | * len length of command to send | 1675 | * len length of command to send |
1628 | * return value: | 1676 | * return value: |
1629 | * 0 on success | 1677 | * 0 on success |
1630 | * -EFAULT if a NULL pointer is encountered somewhere | ||
1631 | * -EBUSY if another request is pending | 1678 | * -EBUSY if another request is pending |
1632 | * any URB submission error code | 1679 | * any URB submission error code |
1633 | */ | 1680 | */ |
1634 | static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) | 1681 | static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) |
1635 | { | 1682 | { |
1636 | struct bas_cardstate *ucs = cs->hw.bas; | 1683 | struct bas_cardstate *ucs = cs->hw.bas; |
1637 | unsigned long flags; | 1684 | int rc; |
1638 | int ret; | ||
1639 | 1685 | ||
1640 | gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len); | 1686 | gig_dbg(DEBUG_USBREQ, "-------> HD_WRITE_ATMESSAGE (%d)", len); |
1641 | 1687 | ||
1642 | if (ucs->urb_cmd_out->status == -EINPROGRESS) { | 1688 | if (update_basstate(ucs, BS_ATWRPEND, 0) & BS_ATWRPEND) { |
1643 | dev_err(cs->dev, | 1689 | dev_err(cs->dev, |
1644 | "could not submit HD_WRITE_ATMESSAGE: URB busy\n"); | 1690 | "could not submit HD_WRITE_ATMESSAGE: URB busy\n"); |
1645 | return -EBUSY; | 1691 | return -EBUSY; |
@@ -1654,29 +1700,22 @@ static int atwrite_submit(struct cardstate *cs, unsigned char *buf, int len) | |||
1654 | usb_sndctrlpipe(ucs->udev, 0), | 1700 | usb_sndctrlpipe(ucs->udev, 0), |
1655 | (unsigned char*) &ucs->dr_cmd_out, buf, len, | 1701 | (unsigned char*) &ucs->dr_cmd_out, buf, len, |
1656 | write_command_callback, cs); | 1702 | write_command_callback, cs); |
1657 | 1703 | rc = usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC); | |
1658 | spin_lock_irqsave(&cs->lock, flags); | 1704 | if (unlikely(rc)) { |
1659 | ret = cs->connected ? usb_submit_urb(ucs->urb_cmd_out, SLAB_ATOMIC) : -ENODEV; | 1705 | update_basstate(ucs, 0, BS_ATWRPEND); |
1660 | spin_unlock_irqrestore(&cs->lock, flags); | ||
1661 | |||
1662 | if (ret) { | ||
1663 | dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n", | 1706 | dev_err(cs->dev, "could not submit HD_WRITE_ATMESSAGE: %s\n", |
1664 | get_usb_statmsg(ret)); | 1707 | get_usb_rcmsg(rc)); |
1665 | return ret; | 1708 | return rc; |
1666 | } | 1709 | } |
1667 | 1710 | ||
1668 | /* submitted successfully */ | 1711 | /* submitted successfully, start timeout if necessary */ |
1669 | update_basstate(ucs, 0, BS_ATREADY); | 1712 | if (!(update_basstate(ucs, BS_ATTIMER, BS_ATREADY) & BS_ATTIMER)) { |
1670 | |||
1671 | /* start timeout if necessary */ | ||
1672 | if (!(atomic_read(&ucs->basstate) & BS_ATTIMER)) { | ||
1673 | gig_dbg(DEBUG_OUTPUT, "setting ATREADY timeout of %d/10 secs", | 1713 | gig_dbg(DEBUG_OUTPUT, "setting ATREADY timeout of %d/10 secs", |
1674 | ATRDY_TIMEOUT); | 1714 | ATRDY_TIMEOUT); |
1675 | ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10; | 1715 | ucs->timer_atrdy.expires = jiffies + ATRDY_TIMEOUT * HZ / 10; |
1676 | ucs->timer_atrdy.data = (unsigned long) cs; | 1716 | ucs->timer_atrdy.data = (unsigned long) cs; |
1677 | ucs->timer_atrdy.function = atrdy_timeout; | 1717 | ucs->timer_atrdy.function = atrdy_timeout; |
1678 | add_timer(&ucs->timer_atrdy); | 1718 | add_timer(&ucs->timer_atrdy); |
1679 | update_basstate(ucs, BS_ATTIMER, 0); | ||
1680 | } | 1719 | } |
1681 | return 0; | 1720 | return 0; |
1682 | } | 1721 | } |
@@ -1702,7 +1741,6 @@ static int start_cbsend(struct cardstate *cs) | |||
1702 | gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open"); | 1741 | gig_dbg(DEBUG_TRANSCMD|DEBUG_LOCKCMD, "AT channel not open"); |
1703 | rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT); | 1742 | rc = req_submit(cs->bcs, HD_OPEN_ATCHANNEL, 0, BAS_TIMEOUT); |
1704 | if (rc < 0) { | 1743 | if (rc < 0) { |
1705 | dev_err(cs->dev, "could not open AT channel\n"); | ||
1706 | /* flush command queue */ | 1744 | /* flush command queue */ |
1707 | spin_lock_irqsave(&cs->cmdlock, flags); | 1745 | spin_lock_irqsave(&cs->cmdlock, flags); |
1708 | while (cs->cmdbuf != NULL) | 1746 | while (cs->cmdbuf != NULL) |
@@ -1786,8 +1824,14 @@ static int gigaset_write_cmd(struct cardstate *cs, | |||
1786 | cs->lastcmdbuf = cb; | 1824 | cs->lastcmdbuf = cb; |
1787 | spin_unlock_irqrestore(&cs->cmdlock, flags); | 1825 | spin_unlock_irqrestore(&cs->cmdlock, flags); |
1788 | 1826 | ||
1827 | spin_lock_irqsave(&cs->lock, flags); | ||
1828 | if (unlikely(!cs->connected)) { | ||
1829 | spin_unlock_irqrestore(&cs->lock, flags); | ||
1830 | gig_dbg(DEBUG_USBREQ, "%s: not connected", __func__); | ||
1831 | return -ENODEV; | ||
1832 | } | ||
1789 | status = start_cbsend(cs); | 1833 | status = start_cbsend(cs); |
1790 | 1834 | spin_unlock_irqrestore(&cs->lock, flags); | |
1791 | return status < 0 ? status : len; | 1835 | return status < 0 ? status : len; |
1792 | } | 1836 | } |
1793 | 1837 | ||
@@ -1849,12 +1893,32 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6]) | |||
1849 | */ | 1893 | */ |
1850 | static int gigaset_freebcshw(struct bc_state *bcs) | 1894 | static int gigaset_freebcshw(struct bc_state *bcs) |
1851 | { | 1895 | { |
1852 | if (!bcs->hw.bas) | 1896 | struct bas_bc_state *ubc = bcs->hw.bas; |
1897 | int i; | ||
1898 | |||
1899 | if (!ubc) | ||
1853 | return 0; | 1900 | return 0; |
1854 | 1901 | ||
1855 | if (bcs->hw.bas->isooutbuf) | 1902 | /* kill URBs and tasklets before freeing - better safe than sorry */ |
1856 | kfree(bcs->hw.bas->isooutbuf); | 1903 | atomic_set(&ubc->running, 0); |
1857 | kfree(bcs->hw.bas); | 1904 | for (i = 0; i < BAS_OUTURBS; ++i) |
1905 | if (ubc->isoouturbs[i].urb) { | ||
1906 | gig_dbg(DEBUG_INIT, "%s: killing iso out URB %d", | ||
1907 | __func__, i); | ||
1908 | usb_kill_urb(ubc->isoouturbs[i].urb); | ||
1909 | usb_free_urb(ubc->isoouturbs[i].urb); | ||
1910 | } | ||
1911 | for (i = 0; i < BAS_INURBS; ++i) | ||
1912 | if (ubc->isoinurbs[i]) { | ||
1913 | gig_dbg(DEBUG_INIT, "%s: killing iso in URB %d", | ||
1914 | __func__, i); | ||
1915 | usb_kill_urb(ubc->isoinurbs[i]); | ||
1916 | usb_free_urb(ubc->isoinurbs[i]); | ||
1917 | } | ||
1918 | tasklet_kill(&ubc->sent_tasklet); | ||
1919 | tasklet_kill(&ubc->rcvd_tasklet); | ||
1920 | kfree(ubc->isooutbuf); | ||
1921 | kfree(ubc); | ||
1858 | bcs->hw.bas = NULL; | 1922 | bcs->hw.bas = NULL; |
1859 | return 1; | 1923 | return 1; |
1860 | } | 1924 | } |
@@ -1931,13 +1995,9 @@ static void gigaset_reinitbcshw(struct bc_state *bcs) | |||
1931 | 1995 | ||
1932 | static void gigaset_freecshw(struct cardstate *cs) | 1996 | static void gigaset_freecshw(struct cardstate *cs) |
1933 | { | 1997 | { |
1934 | struct bas_cardstate *ucs = cs->hw.bas; | 1998 | /* timers, URBs and rcvbuf are disposed of in disconnect */ |
1935 | |||
1936 | del_timer(&ucs->timer_ctrl); | ||
1937 | del_timer(&ucs->timer_atrdy); | ||
1938 | del_timer(&ucs->timer_cmd_in); | ||
1939 | |||
1940 | kfree(cs->hw.bas); | 1999 | kfree(cs->hw.bas); |
2000 | cs->hw.bas = NULL; | ||
1941 | } | 2001 | } |
1942 | 2002 | ||
1943 | static int gigaset_initcshw(struct cardstate *cs) | 2003 | static int gigaset_initcshw(struct cardstate *cs) |
@@ -2041,23 +2101,13 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2041 | struct bas_bc_state *ubc; | 2101 | struct bas_bc_state *ubc; |
2042 | struct usb_endpoint_descriptor *endpoint; | 2102 | struct usb_endpoint_descriptor *endpoint; |
2043 | int i, j; | 2103 | int i, j; |
2044 | int ret; | 2104 | int rc; |
2045 | 2105 | ||
2046 | gig_dbg(DEBUG_ANY, | 2106 | gig_dbg(DEBUG_ANY, |
2047 | "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", | 2107 | "%s: Check if device matches .. (Vendor: 0x%x, Product: 0x%x)", |
2048 | __func__, le16_to_cpu(udev->descriptor.idVendor), | 2108 | __func__, le16_to_cpu(udev->descriptor.idVendor), |
2049 | le16_to_cpu(udev->descriptor.idProduct)); | 2109 | le16_to_cpu(udev->descriptor.idProduct)); |
2050 | 2110 | ||
2051 | /* See if the device offered us matches what we can accept */ | ||
2052 | if ((le16_to_cpu(udev->descriptor.idVendor) != USB_GIGA_VENDOR_ID) || | ||
2053 | (le16_to_cpu(udev->descriptor.idProduct) != USB_GIGA_PRODUCT_ID && | ||
2054 | le16_to_cpu(udev->descriptor.idProduct) != USB_4175_PRODUCT_ID && | ||
2055 | le16_to_cpu(udev->descriptor.idProduct) != USB_SX303_PRODUCT_ID && | ||
2056 | le16_to_cpu(udev->descriptor.idProduct) != USB_SX353_PRODUCT_ID)) { | ||
2057 | gig_dbg(DEBUG_ANY, "%s: unmatched ID - exiting", __func__); | ||
2058 | return -ENODEV; | ||
2059 | } | ||
2060 | |||
2061 | /* set required alternate setting */ | 2111 | /* set required alternate setting */ |
2062 | hostif = interface->cur_altsetting; | 2112 | hostif = interface->cur_altsetting; |
2063 | if (hostif->desc.bAlternateSetting != 3) { | 2113 | if (hostif->desc.bAlternateSetting != 3) { |
@@ -2105,45 +2155,22 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2105 | * - three for the different uses of the default control pipe | 2155 | * - three for the different uses of the default control pipe |
2106 | * - three for each isochronous pipe | 2156 | * - three for each isochronous pipe |
2107 | */ | 2157 | */ |
2108 | ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL); | 2158 | if (!(ucs->urb_int_in = usb_alloc_urb(0, SLAB_KERNEL)) || |
2109 | if (!ucs->urb_int_in) { | 2159 | !(ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL)) || |
2110 | dev_err(cs->dev, "no free urbs available\n"); | 2160 | !(ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL)) || |
2111 | goto error; | 2161 | !(ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL))) |
2112 | } | 2162 | goto allocerr; |
2113 | ucs->urb_cmd_in = usb_alloc_urb(0, SLAB_KERNEL); | ||
2114 | if (!ucs->urb_cmd_in) { | ||
2115 | dev_err(cs->dev, "no free urbs available\n"); | ||
2116 | goto error; | ||
2117 | } | ||
2118 | ucs->urb_cmd_out = usb_alloc_urb(0, SLAB_KERNEL); | ||
2119 | if (!ucs->urb_cmd_out) { | ||
2120 | dev_err(cs->dev, "no free urbs available\n"); | ||
2121 | goto error; | ||
2122 | } | ||
2123 | ucs->urb_ctrl = usb_alloc_urb(0, SLAB_KERNEL); | ||
2124 | if (!ucs->urb_ctrl) { | ||
2125 | dev_err(cs->dev, "no free urbs available\n"); | ||
2126 | goto error; | ||
2127 | } | ||
2128 | 2163 | ||
2129 | for (j = 0; j < 2; ++j) { | 2164 | for (j = 0; j < 2; ++j) { |
2130 | ubc = cs->bcs[j].hw.bas; | 2165 | ubc = cs->bcs[j].hw.bas; |
2131 | for (i = 0; i < BAS_OUTURBS; ++i) { | 2166 | for (i = 0; i < BAS_OUTURBS; ++i) |
2132 | ubc->isoouturbs[i].urb = | 2167 | if (!(ubc->isoouturbs[i].urb = |
2133 | usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); | 2168 | usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) |
2134 | if (!ubc->isoouturbs[i].urb) { | 2169 | goto allocerr; |
2135 | dev_err(cs->dev, "no free urbs available\n"); | 2170 | for (i = 0; i < BAS_INURBS; ++i) |
2136 | goto error; | 2171 | if (!(ubc->isoinurbs[i] = |
2137 | } | 2172 | usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL))) |
2138 | } | 2173 | goto allocerr; |
2139 | for (i = 0; i < BAS_INURBS; ++i) { | ||
2140 | ubc->isoinurbs[i] = | ||
2141 | usb_alloc_urb(BAS_NUMFRAMES, SLAB_KERNEL); | ||
2142 | if (!ubc->isoinurbs[i]) { | ||
2143 | dev_err(cs->dev, "no free urbs available\n"); | ||
2144 | goto error; | ||
2145 | } | ||
2146 | } | ||
2147 | } | 2174 | } |
2148 | 2175 | ||
2149 | ucs->rcvbuf = NULL; | 2176 | ucs->rcvbuf = NULL; |
@@ -2156,15 +2183,14 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2156 | (endpoint->bEndpointAddress) & 0x0f), | 2183 | (endpoint->bEndpointAddress) & 0x0f), |
2157 | ucs->int_in_buf, 3, read_int_callback, cs, | 2184 | ucs->int_in_buf, 3, read_int_callback, cs, |
2158 | endpoint->bInterval); | 2185 | endpoint->bInterval); |
2159 | ret = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL); | 2186 | if ((rc = usb_submit_urb(ucs->urb_int_in, SLAB_KERNEL)) != 0) { |
2160 | if (ret) { | ||
2161 | dev_err(cs->dev, "could not submit interrupt URB: %s\n", | 2187 | dev_err(cs->dev, "could not submit interrupt URB: %s\n", |
2162 | get_usb_statmsg(ret)); | 2188 | get_usb_rcmsg(rc)); |
2163 | goto error; | 2189 | goto error; |
2164 | } | 2190 | } |
2165 | 2191 | ||
2166 | /* tell the device that the driver is ready */ | 2192 | /* tell the device that the driver is ready */ |
2167 | if ((ret = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0)) != 0) | 2193 | if ((rc = req_submit(cs->bcs, HD_DEVICE_INIT_ACK, 0, 0)) != 0) |
2168 | goto error; | 2194 | goto error; |
2169 | 2195 | ||
2170 | /* tell common part that the device is ready */ | 2196 | /* tell common part that the device is ready */ |
@@ -2179,6 +2205,8 @@ static int gigaset_probe(struct usb_interface *interface, | |||
2179 | 2205 | ||
2180 | return 0; | 2206 | return 0; |
2181 | 2207 | ||
2208 | allocerr: | ||
2209 | dev_err(cs->dev, "could not allocate URBs\n"); | ||
2182 | error: | 2210 | error: |
2183 | freeurbs(cs); | 2211 | freeurbs(cs); |
2184 | usb_set_intfdata(interface, NULL); | 2212 | usb_set_intfdata(interface, NULL); |
@@ -2193,19 +2221,34 @@ static void gigaset_disconnect(struct usb_interface *interface) | |||
2193 | { | 2221 | { |
2194 | struct cardstate *cs; | 2222 | struct cardstate *cs; |
2195 | struct bas_cardstate *ucs; | 2223 | struct bas_cardstate *ucs; |
2224 | int j; | ||
2196 | 2225 | ||
2197 | cs = usb_get_intfdata(interface); | 2226 | cs = usb_get_intfdata(interface); |
2198 | 2227 | ||
2199 | ucs = cs->hw.bas; | 2228 | ucs = cs->hw.bas; |
2200 | 2229 | ||
2201 | dev_info(cs->dev, "disconnecting Gigaset base\n"); | 2230 | dev_info(cs->dev, "disconnecting Gigaset base\n"); |
2231 | |||
2232 | /* mark base as not ready, all channels disconnected */ | ||
2233 | atomic_set(&ucs->basstate, 0); | ||
2234 | |||
2235 | /* tell LL all channels are down */ | ||
2236 | //FIXME shouldn't gigaset_stop() do this? | ||
2237 | for (j = 0; j < 2; ++j) | ||
2238 | gigaset_bchannel_down(cs->bcs + j); | ||
2239 | |||
2240 | /* stop driver (common part) */ | ||
2202 | gigaset_stop(cs); | 2241 | gigaset_stop(cs); |
2242 | |||
2243 | /* stop timers and URBs, free ressources */ | ||
2244 | del_timer_sync(&ucs->timer_ctrl); | ||
2245 | del_timer_sync(&ucs->timer_atrdy); | ||
2246 | del_timer_sync(&ucs->timer_cmd_in); | ||
2203 | freeurbs(cs); | 2247 | freeurbs(cs); |
2204 | usb_set_intfdata(interface, NULL); | 2248 | usb_set_intfdata(interface, NULL); |
2205 | kfree(ucs->rcvbuf); | 2249 | kfree(ucs->rcvbuf); |
2206 | ucs->rcvbuf = NULL; | 2250 | ucs->rcvbuf = NULL; |
2207 | ucs->rcvbuf_size = 0; | 2251 | ucs->rcvbuf_size = 0; |
2208 | atomic_set(&ucs->basstate, 0); | ||
2209 | usb_put_dev(ucs->udev); | 2252 | usb_put_dev(ucs->udev); |
2210 | ucs->interface = NULL; | 2253 | ucs->interface = NULL; |
2211 | ucs->udev = NULL; | 2254 | ucs->udev = NULL; |
@@ -2277,6 +2320,8 @@ error: if (cardstate) | |||
2277 | */ | 2320 | */ |
2278 | static void __exit bas_gigaset_exit(void) | 2321 | static void __exit bas_gigaset_exit(void) |
2279 | { | 2322 | { |
2323 | struct bas_cardstate *ucs = cardstate->hw.bas; | ||
2324 | |||
2280 | gigaset_blockdriver(driver); /* => probe will fail | 2325 | gigaset_blockdriver(driver); /* => probe will fail |
2281 | * => no gigaset_start any more | 2326 | * => no gigaset_start any more |
2282 | */ | 2327 | */ |
@@ -2284,14 +2329,26 @@ static void __exit bas_gigaset_exit(void) | |||
2284 | gigaset_shutdown(cardstate); | 2329 | gigaset_shutdown(cardstate); |
2285 | /* from now on, no isdn callback should be possible */ | 2330 | /* from now on, no isdn callback should be possible */ |
2286 | 2331 | ||
2287 | if (atomic_read(&cardstate->hw.bas->basstate) & BS_ATOPEN) { | 2332 | /* close all still open channels */ |
2288 | gig_dbg(DEBUG_ANY, "closing AT channel"); | 2333 | if (atomic_read(&ucs->basstate) & BS_B1OPEN) { |
2289 | if (req_submit(cardstate->bcs, | 2334 | gig_dbg(DEBUG_INIT, "closing B1 channel"); |
2290 | HD_CLOSE_ATCHANNEL, 0, BAS_TIMEOUT) >= 0) { | 2335 | usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), |
2291 | /* successfully submitted */ | 2336 | HD_CLOSE_B1CHANNEL, OUT_VENDOR_REQ, 0, 0, |
2292 | //FIXME wait for completion? | 2337 | NULL, 0, BAS_TIMEOUT); |
2293 | } | 2338 | } |
2339 | if (atomic_read(&ucs->basstate) & BS_B2OPEN) { | ||
2340 | gig_dbg(DEBUG_INIT, "closing B2 channel"); | ||
2341 | usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), | ||
2342 | HD_CLOSE_B2CHANNEL, OUT_VENDOR_REQ, 0, 0, | ||
2343 | NULL, 0, BAS_TIMEOUT); | ||
2344 | } | ||
2345 | if (atomic_read(&ucs->basstate) & BS_ATOPEN) { | ||
2346 | gig_dbg(DEBUG_INIT, "closing AT channel"); | ||
2347 | usb_control_msg(ucs->udev, usb_sndctrlpipe(ucs->udev, 0), | ||
2348 | HD_CLOSE_ATCHANNEL, OUT_VENDOR_REQ, 0, 0, | ||
2349 | NULL, 0, BAS_TIMEOUT); | ||
2294 | } | 2350 | } |
2351 | atomic_set(&ucs->basstate, 0); | ||
2295 | 2352 | ||
2296 | /* deregister this driver with the USB subsystem */ | 2353 | /* deregister this driver with the USB subsystem */ |
2297 | usb_deregister(&gigaset_usb_driver); | 2354 | usb_deregister(&gigaset_usb_driver); |
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 749b3da1236e..e55767b2ccd3 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
@@ -781,8 +781,7 @@ error: if (cs) | |||
781 | } | 781 | } |
782 | EXPORT_SYMBOL_GPL(gigaset_initcs); | 782 | EXPORT_SYMBOL_GPL(gigaset_initcs); |
783 | 783 | ||
784 | /* ReInitialize the b-channel structure */ | 784 | /* ReInitialize the b-channel structure on hangup */ |
785 | /* e.g. called on hangup, disconnect */ | ||
786 | void gigaset_bcs_reinit(struct bc_state *bcs) | 785 | void gigaset_bcs_reinit(struct bc_state *bcs) |
787 | { | 786 | { |
788 | struct sk_buff *skb; | 787 | struct sk_buff *skb; |
diff --git a/drivers/isdn/gigaset/ev-layer.c b/drivers/isdn/gigaset/ev-layer.c index 1ba3424a286b..18e05c09b71c 100644 --- a/drivers/isdn/gigaset/ev-layer.c +++ b/drivers/isdn/gigaset/ev-layer.c | |||
@@ -373,6 +373,9 @@ struct reply_t gigaset_tab_cid_m10x[] = /* for M10x */ | |||
373 | 373 | ||
374 | {EV_TIMEOUT, 750,750, -1, 0, 0, {ACT_CONNTIMEOUT}}, | 374 | {EV_TIMEOUT, 750,750, -1, 0, 0, {ACT_CONNTIMEOUT}}, |
375 | 375 | ||
376 | /* B channel closed (general case) */ | ||
377 | {EV_BC_CLOSED, -1, -1, -1, -1,-1, {ACT_NOTIFY_BC_DOWN}}, //FIXME | ||
378 | |||
376 | /* misc. */ | 379 | /* misc. */ |
377 | {EV_PROTO_L2, -1, -1, -1, -1,-1, {ACT_PROTO_L2}}, //FIXME | 380 | {EV_PROTO_L2, -1, -1, -1, -1,-1, {ACT_PROTO_L2}}, //FIXME |
378 | 381 | ||
diff --git a/drivers/isdn/gigaset/gigaset.h b/drivers/isdn/gigaset/gigaset.h index 9d21ba8757b0..22b9693f7c0a 100644 --- a/drivers/isdn/gigaset/gigaset.h +++ b/drivers/isdn/gigaset/gigaset.h | |||
@@ -75,7 +75,7 @@ extern int gigaset_debuglevel; /* "needs" cast to (enum debuglevel) */ | |||
75 | * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and | 75 | * e.g. 'insmod usb_gigaset.o debug=0x2c' will set DEBUG_OPEN, DEBUG_CMD and |
76 | * DEBUG_INTR. | 76 | * DEBUG_INTR. |
77 | */ | 77 | */ |
78 | enum debuglevel { /* up to 24 bits (atomic_t) */ | 78 | enum debuglevel { |
79 | DEBUG_REG = 0x0002, /* serial port I/O register operations */ | 79 | DEBUG_REG = 0x0002, /* serial port I/O register operations */ |
80 | DEBUG_OPEN = 0x0004, /* open/close serial port */ | 80 | DEBUG_OPEN = 0x0004, /* open/close serial port */ |
81 | DEBUG_INTR = 0x0008, /* interrupt processing */ | 81 | DEBUG_INTR = 0x0008, /* interrupt processing */ |
@@ -141,7 +141,7 @@ enum debuglevel { /* up to 24 bits (atomic_t) */ | |||
141 | printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \ | 141 | printk(KERN_DEBUG KBUILD_MODNAME ": " format "\n", \ |
142 | ## arg); \ | 142 | ## arg); \ |
143 | } while (0) | 143 | } while (0) |
144 | #define DEBUG_DEFAULT (DEBUG_INIT | DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) | 144 | #define DEBUG_DEFAULT (DEBUG_TRANSCMD | DEBUG_CMD | DEBUG_USBREQ) |
145 | 145 | ||
146 | #else | 146 | #else |
147 | 147 | ||
@@ -627,8 +627,7 @@ struct gigaset_ops { | |||
627 | /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ | 627 | /* Called by gigaset_freecs() for freeing bcs->hw.xxx */ |
628 | int (*freebcshw)(struct bc_state *bcs); | 628 | int (*freebcshw)(struct bc_state *bcs); |
629 | 629 | ||
630 | /* Called by gigaset_stop() or gigaset_bchannel_down() for resetting | 630 | /* Called by gigaset_bchannel_down() for resetting bcs->hw.xxx */ |
631 | bcs->hw.xxx */ | ||
632 | void (*reinitbcshw)(struct bc_state *bcs); | 631 | void (*reinitbcshw)(struct bc_state *bcs); |
633 | 632 | ||
634 | /* Called by gigaset_initcs() for setting up cs->hw.xxx */ | 633 | /* Called by gigaset_initcs() for setting up cs->hw.xxx */ |
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c index 0815dbfb8291..1654fa413575 100644 --- a/drivers/isdn/gigaset/i4l.c +++ b/drivers/isdn/gigaset/i4l.c | |||
@@ -73,7 +73,7 @@ static int writebuf_from_LL(int driverID, int channel, int ack, | |||
73 | len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]); | 73 | len, skblen, (unsigned) skb->head[0], (unsigned) skb->head[1]); |
74 | 74 | ||
75 | /* pass to device-specific module */ | 75 | /* pass to device-specific module */ |
76 | return cs->ops->send_skb(bcs, skb); //FIXME cs->ops->send_skb() must handle !cs->connected correctly | 76 | return cs->ops->send_skb(bcs, skb); |
77 | } | 77 | } |
78 | 78 | ||
79 | void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb) | 79 | void gigaset_skb_sent(struct bc_state *bcs, struct sk_buff *skb) |
diff --git a/drivers/isdn/gigaset/isocdata.c b/drivers/isdn/gigaset/isocdata.c index 45f017ed6e8c..8667daaa1a82 100644 --- a/drivers/isdn/gigaset/isocdata.c +++ b/drivers/isdn/gigaset/isocdata.c | |||
@@ -992,14 +992,18 @@ int gigaset_isoc_send_skb(struct bc_state *bcs, struct sk_buff *skb) | |||
992 | int len = skb->len; | 992 | int len = skb->len; |
993 | unsigned long flags; | 993 | unsigned long flags; |
994 | 994 | ||
995 | spin_lock_irqsave(&bcs->cs->lock, flags); | ||
996 | if (!bcs->cs->connected) { | ||
997 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | ||
998 | return -ENODEV; | ||
999 | } | ||
1000 | |||
995 | skb_queue_tail(&bcs->squeue, skb); | 1001 | skb_queue_tail(&bcs->squeue, skb); |
996 | gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d", | 1002 | gig_dbg(DEBUG_ISO, "%s: skb queued, qlen=%d", |
997 | __func__, skb_queue_len(&bcs->squeue)); | 1003 | __func__, skb_queue_len(&bcs->squeue)); |
998 | 1004 | ||
999 | /* tasklet submits URB if necessary */ | 1005 | /* tasklet submits URB if necessary */ |
1000 | spin_lock_irqsave(&bcs->cs->lock, flags); | 1006 | tasklet_schedule(&bcs->hw.bas->sent_tasklet); |
1001 | if (bcs->cs->connected) | ||
1002 | tasklet_schedule(&bcs->hw.bas->sent_tasklet); | ||
1003 | spin_unlock_irqrestore(&bcs->cs->lock, flags); | 1007 | spin_unlock_irqrestore(&bcs->cs->lock, flags); |
1004 | 1008 | ||
1005 | return len; /* ok so far */ | 1009 | return len; /* ok so far */ |
diff --git a/drivers/macintosh/therm_adt746x.c b/drivers/macintosh/therm_adt746x.c index 5ebfd1d138da..5282fec17075 100644 --- a/drivers/macintosh/therm_adt746x.c +++ b/drivers/macintosh/therm_adt746x.c | |||
@@ -627,8 +627,8 @@ thermostat_init(void) | |||
627 | if(therm_type == ADT7460) | 627 | if(therm_type == ADT7460) |
628 | device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed); | 628 | device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed); |
629 | 629 | ||
630 | #ifndef CONFIG_I2C_KEYWEST | 630 | #ifndef CONFIG_I2C_POWERMAC |
631 | request_module("i2c-keywest"); | 631 | request_module("i2c-powermac"); |
632 | #endif | 632 | #endif |
633 | 633 | ||
634 | return i2c_add_driver(&thermostat_driver); | 634 | return i2c_add_driver(&thermostat_driver); |
diff --git a/drivers/md/md.c b/drivers/md/md.c index 434ca39d19c1..d7316b829a62 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c | |||
@@ -279,11 +279,6 @@ static inline int mddev_lock(mddev_t * mddev) | |||
279 | return mutex_lock_interruptible(&mddev->reconfig_mutex); | 279 | return mutex_lock_interruptible(&mddev->reconfig_mutex); |
280 | } | 280 | } |
281 | 281 | ||
282 | static inline void mddev_lock_uninterruptible(mddev_t * mddev) | ||
283 | { | ||
284 | mutex_lock(&mddev->reconfig_mutex); | ||
285 | } | ||
286 | |||
287 | static inline int mddev_trylock(mddev_t * mddev) | 282 | static inline int mddev_trylock(mddev_t * mddev) |
288 | { | 283 | { |
289 | return mutex_trylock(&mddev->reconfig_mutex); | 284 | return mutex_trylock(&mddev->reconfig_mutex); |
@@ -2458,9 +2453,11 @@ md_attr_show(struct kobject *kobj, struct attribute *attr, char *page) | |||
2458 | 2453 | ||
2459 | if (!entry->show) | 2454 | if (!entry->show) |
2460 | return -EIO; | 2455 | return -EIO; |
2461 | mddev_lock(mddev); | 2456 | rv = mddev_lock(mddev); |
2462 | rv = entry->show(mddev, page); | 2457 | if (!rv) { |
2463 | mddev_unlock(mddev); | 2458 | rv = entry->show(mddev, page); |
2459 | mddev_unlock(mddev); | ||
2460 | } | ||
2464 | return rv; | 2461 | return rv; |
2465 | } | 2462 | } |
2466 | 2463 | ||
@@ -2474,9 +2471,11 @@ md_attr_store(struct kobject *kobj, struct attribute *attr, | |||
2474 | 2471 | ||
2475 | if (!entry->store) | 2472 | if (!entry->store) |
2476 | return -EIO; | 2473 | return -EIO; |
2477 | mddev_lock(mddev); | 2474 | rv = mddev_lock(mddev); |
2478 | rv = entry->store(mddev, page, length); | 2475 | if (!rv) { |
2479 | mddev_unlock(mddev); | 2476 | rv = entry->store(mddev, page, length); |
2477 | mddev_unlock(mddev); | ||
2478 | } | ||
2480 | return rv; | 2479 | return rv; |
2481 | } | 2480 | } |
2482 | 2481 | ||
@@ -4341,8 +4340,9 @@ static int md_seq_show(struct seq_file *seq, void *v) | |||
4341 | return 0; | 4340 | return 0; |
4342 | } | 4341 | } |
4343 | 4342 | ||
4344 | if (mddev_lock(mddev)!=0) | 4343 | if (mddev_lock(mddev) < 0) |
4345 | return -EINTR; | 4344 | return -EINTR; |
4345 | |||
4346 | if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { | 4346 | if (mddev->pers || mddev->raid_disks || !list_empty(&mddev->disks)) { |
4347 | seq_printf(seq, "%s : %sactive", mdname(mddev), | 4347 | seq_printf(seq, "%s : %sactive", mdname(mddev), |
4348 | mddev->pers ? "" : "in"); | 4348 | mddev->pers ? "" : "in"); |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 6081941de1b3..4070eff6f0f8 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
@@ -315,10 +315,11 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
315 | if (r1_bio->bios[mirror] == bio) | 315 | if (r1_bio->bios[mirror] == bio) |
316 | break; | 316 | break; |
317 | 317 | ||
318 | if (error == -ENOTSUPP && test_bit(R1BIO_Barrier, &r1_bio->state)) { | 318 | if (error == -EOPNOTSUPP && test_bit(R1BIO_Barrier, &r1_bio->state)) { |
319 | set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags); | 319 | set_bit(BarriersNotsupp, &conf->mirrors[mirror].rdev->flags); |
320 | set_bit(R1BIO_BarrierRetry, &r1_bio->state); | 320 | set_bit(R1BIO_BarrierRetry, &r1_bio->state); |
321 | r1_bio->mddev->barriers_work = 0; | 321 | r1_bio->mddev->barriers_work = 0; |
322 | /* Don't rdev_dec_pending in this branch - keep it for the retry */ | ||
322 | } else { | 323 | } else { |
323 | /* | 324 | /* |
324 | * this branch is our 'one mirror IO has finished' event handler: | 325 | * this branch is our 'one mirror IO has finished' event handler: |
@@ -365,6 +366,7 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
365 | } | 366 | } |
366 | } | 367 | } |
367 | } | 368 | } |
369 | rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); | ||
368 | } | 370 | } |
369 | /* | 371 | /* |
370 | * | 372 | * |
@@ -374,11 +376,9 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
374 | if (atomic_dec_and_test(&r1_bio->remaining)) { | 376 | if (atomic_dec_and_test(&r1_bio->remaining)) { |
375 | if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { | 377 | if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { |
376 | reschedule_retry(r1_bio); | 378 | reschedule_retry(r1_bio); |
377 | /* Don't dec_pending yet, we want to hold | ||
378 | * the reference over the retry | ||
379 | */ | ||
380 | goto out; | 379 | goto out; |
381 | } | 380 | } |
381 | /* it really is the end of this request */ | ||
382 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { | 382 | if (test_bit(R1BIO_BehindIO, &r1_bio->state)) { |
383 | /* free extra copy of the data pages */ | 383 | /* free extra copy of the data pages */ |
384 | int i = bio->bi_vcnt; | 384 | int i = bio->bi_vcnt; |
@@ -393,8 +393,6 @@ static int raid1_end_write_request(struct bio *bio, unsigned int bytes_done, int | |||
393 | md_write_end(r1_bio->mddev); | 393 | md_write_end(r1_bio->mddev); |
394 | raid_end_bio_io(r1_bio); | 394 | raid_end_bio_io(r1_bio); |
395 | } | 395 | } |
396 | |||
397 | rdev_dec_pending(conf->mirrors[mirror].rdev, conf->mddev); | ||
398 | out: | 396 | out: |
399 | if (to_put) | 397 | if (to_put) |
400 | bio_put(to_put); | 398 | bio_put(to_put); |
@@ -753,18 +751,24 @@ static int make_request(request_queue_t *q, struct bio * bio) | |||
753 | const int rw = bio_data_dir(bio); | 751 | const int rw = bio_data_dir(bio); |
754 | int do_barriers; | 752 | int do_barriers; |
755 | 753 | ||
756 | if (unlikely(!mddev->barriers_work && bio_barrier(bio))) { | ||
757 | bio_endio(bio, bio->bi_size, -EOPNOTSUPP); | ||
758 | return 0; | ||
759 | } | ||
760 | |||
761 | /* | 754 | /* |
762 | * Register the new request and wait if the reconstruction | 755 | * Register the new request and wait if the reconstruction |
763 | * thread has put up a bar for new requests. | 756 | * thread has put up a bar for new requests. |
764 | * Continue immediately if no resync is active currently. | 757 | * Continue immediately if no resync is active currently. |
758 | * We test barriers_work *after* md_write_start as md_write_start | ||
759 | * may cause the first superblock write, and that will check out | ||
760 | * if barriers work. | ||
765 | */ | 761 | */ |
762 | |||
766 | md_write_start(mddev, bio); /* wait on superblock update early */ | 763 | md_write_start(mddev, bio); /* wait on superblock update early */ |
767 | 764 | ||
765 | if (unlikely(!mddev->barriers_work && bio_barrier(bio))) { | ||
766 | if (rw == WRITE) | ||
767 | md_write_end(mddev); | ||
768 | bio_endio(bio, bio->bi_size, -EOPNOTSUPP); | ||
769 | return 0; | ||
770 | } | ||
771 | |||
768 | wait_barrier(conf); | 772 | wait_barrier(conf); |
769 | 773 | ||
770 | disk_stat_inc(mddev->gendisk, ios[rw]); | 774 | disk_stat_inc(mddev->gendisk, ios[rw]); |
@@ -1404,10 +1408,11 @@ static void raid1d(mddev_t *mddev) | |||
1404 | unplug = 1; | 1408 | unplug = 1; |
1405 | } else if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { | 1409 | } else if (test_bit(R1BIO_BarrierRetry, &r1_bio->state)) { |
1406 | /* some requests in the r1bio were BIO_RW_BARRIER | 1410 | /* some requests in the r1bio were BIO_RW_BARRIER |
1407 | * requests which failed with -ENOTSUPP. Hohumm.. | 1411 | * requests which failed with -EOPNOTSUPP. Hohumm.. |
1408 | * Better resubmit without the barrier. | 1412 | * Better resubmit without the barrier. |
1409 | * We know which devices to resubmit for, because | 1413 | * We know which devices to resubmit for, because |
1410 | * all others have had their bios[] entry cleared. | 1414 | * all others have had their bios[] entry cleared. |
1415 | * We already have a nr_pending reference on these rdevs. | ||
1411 | */ | 1416 | */ |
1412 | int i; | 1417 | int i; |
1413 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); | 1418 | clear_bit(R1BIO_BarrierRetry, &r1_bio->state); |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 617012bc107a..1440935414e6 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
@@ -1407,43 +1407,54 @@ static void raid10d(mddev_t *mddev) | |||
1407 | if (s > (PAGE_SIZE>>9)) | 1407 | if (s > (PAGE_SIZE>>9)) |
1408 | s = PAGE_SIZE >> 9; | 1408 | s = PAGE_SIZE >> 9; |
1409 | 1409 | ||
1410 | rcu_read_lock(); | ||
1410 | do { | 1411 | do { |
1411 | int d = r10_bio->devs[sl].devnum; | 1412 | int d = r10_bio->devs[sl].devnum; |
1412 | rdev = conf->mirrors[d].rdev; | 1413 | rdev = rcu_dereference(conf->mirrors[d].rdev); |
1413 | if (rdev && | 1414 | if (rdev && |
1414 | test_bit(In_sync, &rdev->flags) && | 1415 | test_bit(In_sync, &rdev->flags)) { |
1415 | sync_page_io(rdev->bdev, | 1416 | atomic_inc(&rdev->nr_pending); |
1416 | r10_bio->devs[sl].addr + | 1417 | rcu_read_unlock(); |
1417 | sect + rdev->data_offset, | 1418 | success = sync_page_io(rdev->bdev, |
1418 | s<<9, | 1419 | r10_bio->devs[sl].addr + |
1419 | conf->tmppage, READ)) | 1420 | sect + rdev->data_offset, |
1420 | success = 1; | 1421 | s<<9, |
1421 | else { | 1422 | conf->tmppage, READ); |
1422 | sl++; | 1423 | rdev_dec_pending(rdev, mddev); |
1423 | if (sl == conf->copies) | 1424 | rcu_read_lock(); |
1424 | sl = 0; | 1425 | if (success) |
1426 | break; | ||
1425 | } | 1427 | } |
1428 | sl++; | ||
1429 | if (sl == conf->copies) | ||
1430 | sl = 0; | ||
1426 | } while (!success && sl != r10_bio->read_slot); | 1431 | } while (!success && sl != r10_bio->read_slot); |
1432 | rcu_read_unlock(); | ||
1427 | 1433 | ||
1428 | if (success) { | 1434 | if (success) { |
1429 | int start = sl; | 1435 | int start = sl; |
1430 | /* write it back and re-read */ | 1436 | /* write it back and re-read */ |
1437 | rcu_read_lock(); | ||
1431 | while (sl != r10_bio->read_slot) { | 1438 | while (sl != r10_bio->read_slot) { |
1432 | int d; | 1439 | int d; |
1433 | if (sl==0) | 1440 | if (sl==0) |
1434 | sl = conf->copies; | 1441 | sl = conf->copies; |
1435 | sl--; | 1442 | sl--; |
1436 | d = r10_bio->devs[sl].devnum; | 1443 | d = r10_bio->devs[sl].devnum; |
1437 | rdev = conf->mirrors[d].rdev; | 1444 | rdev = rcu_dereference(conf->mirrors[d].rdev); |
1438 | atomic_add(s, &rdev->corrected_errors); | ||
1439 | if (rdev && | 1445 | if (rdev && |
1440 | test_bit(In_sync, &rdev->flags)) { | 1446 | test_bit(In_sync, &rdev->flags)) { |
1447 | atomic_inc(&rdev->nr_pending); | ||
1448 | rcu_read_unlock(); | ||
1449 | atomic_add(s, &rdev->corrected_errors); | ||
1441 | if (sync_page_io(rdev->bdev, | 1450 | if (sync_page_io(rdev->bdev, |
1442 | r10_bio->devs[sl].addr + | 1451 | r10_bio->devs[sl].addr + |
1443 | sect + rdev->data_offset, | 1452 | sect + rdev->data_offset, |
1444 | s<<9, conf->tmppage, WRITE) == 0) | 1453 | s<<9, conf->tmppage, WRITE) == 0) |
1445 | /* Well, this device is dead */ | 1454 | /* Well, this device is dead */ |
1446 | md_error(mddev, rdev); | 1455 | md_error(mddev, rdev); |
1456 | rdev_dec_pending(rdev, mddev); | ||
1457 | rcu_read_lock(); | ||
1447 | } | 1458 | } |
1448 | } | 1459 | } |
1449 | sl = start; | 1460 | sl = start; |
@@ -1453,17 +1464,22 @@ static void raid10d(mddev_t *mddev) | |||
1453 | sl = conf->copies; | 1464 | sl = conf->copies; |
1454 | sl--; | 1465 | sl--; |
1455 | d = r10_bio->devs[sl].devnum; | 1466 | d = r10_bio->devs[sl].devnum; |
1456 | rdev = conf->mirrors[d].rdev; | 1467 | rdev = rcu_dereference(conf->mirrors[d].rdev); |
1457 | if (rdev && | 1468 | if (rdev && |
1458 | test_bit(In_sync, &rdev->flags)) { | 1469 | test_bit(In_sync, &rdev->flags)) { |
1470 | atomic_inc(&rdev->nr_pending); | ||
1471 | rcu_read_unlock(); | ||
1459 | if (sync_page_io(rdev->bdev, | 1472 | if (sync_page_io(rdev->bdev, |
1460 | r10_bio->devs[sl].addr + | 1473 | r10_bio->devs[sl].addr + |
1461 | sect + rdev->data_offset, | 1474 | sect + rdev->data_offset, |
1462 | s<<9, conf->tmppage, READ) == 0) | 1475 | s<<9, conf->tmppage, READ) == 0) |
1463 | /* Well, this device is dead */ | 1476 | /* Well, this device is dead */ |
1464 | md_error(mddev, rdev); | 1477 | md_error(mddev, rdev); |
1478 | rdev_dec_pending(rdev, mddev); | ||
1479 | rcu_read_lock(); | ||
1465 | } | 1480 | } |
1466 | } | 1481 | } |
1482 | rcu_read_unlock(); | ||
1467 | } else { | 1483 | } else { |
1468 | /* Cannot read from anywhere -- bye bye array */ | 1484 | /* Cannot read from anywhere -- bye bye array */ |
1469 | md_error(mddev, conf->mirrors[r10_bio->devs[r10_bio->read_slot].devnum].rdev); | 1485 | md_error(mddev, conf->mirrors[r10_bio->devs[r10_bio->read_slot].devnum].rdev); |
diff --git a/drivers/media/video/cx88/cx88-alsa.c b/drivers/media/video/cx88/cx88-alsa.c index f9d87b86492c..320b3d9384ba 100644 --- a/drivers/media/video/cx88/cx88-alsa.c +++ b/drivers/media/video/cx88/cx88-alsa.c | |||
@@ -616,7 +616,7 @@ static struct snd_kcontrol_new snd_cx88_capture_volume = { | |||
616 | * Only boards with eeprom and byte 1 at eeprom=1 have it | 616 | * Only boards with eeprom and byte 1 at eeprom=1 have it |
617 | */ | 617 | */ |
618 | 618 | ||
619 | static struct pci_device_id cx88_audio_pci_tbl[] = { | 619 | static struct pci_device_id cx88_audio_pci_tbl[] __devinitdata = { |
620 | {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, | 620 | {0x14f1,0x8801,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, |
621 | {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, | 621 | {0x14f1,0x8811,PCI_ANY_ID,PCI_ANY_ID,0,0,0}, |
622 | {0, } | 622 | {0, } |
diff --git a/drivers/mmc/pxamci.c b/drivers/mmc/pxamci.c index eb9a8826e9b5..eb42cb349420 100644 --- a/drivers/mmc/pxamci.c +++ b/drivers/mmc/pxamci.c | |||
@@ -65,11 +65,6 @@ struct pxamci_host { | |||
65 | unsigned int dma_dir; | 65 | unsigned int dma_dir; |
66 | }; | 66 | }; |
67 | 67 | ||
68 | static inline unsigned int ns_to_clocks(unsigned int ns) | ||
69 | { | ||
70 | return (ns * (CLOCKRATE / 1000000) + 999) / 1000; | ||
71 | } | ||
72 | |||
73 | static void pxamci_stop_clock(struct pxamci_host *host) | 68 | static void pxamci_stop_clock(struct pxamci_host *host) |
74 | { | 69 | { |
75 | if (readl(host->base + MMC_STAT) & STAT_CLK_EN) { | 70 | if (readl(host->base + MMC_STAT) & STAT_CLK_EN) { |
@@ -113,6 +108,7 @@ static void pxamci_disable_irq(struct pxamci_host *host, unsigned int mask) | |||
113 | static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | 108 | static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) |
114 | { | 109 | { |
115 | unsigned int nob = data->blocks; | 110 | unsigned int nob = data->blocks; |
111 | unsigned long long clks; | ||
116 | unsigned int timeout; | 112 | unsigned int timeout; |
117 | u32 dcmd; | 113 | u32 dcmd; |
118 | int i; | 114 | int i; |
@@ -125,7 +121,9 @@ static void pxamci_setup_data(struct pxamci_host *host, struct mmc_data *data) | |||
125 | writel(nob, host->base + MMC_NOB); | 121 | writel(nob, host->base + MMC_NOB); |
126 | writel(1 << data->blksz_bits, host->base + MMC_BLKLEN); | 122 | writel(1 << data->blksz_bits, host->base + MMC_BLKLEN); |
127 | 123 | ||
128 | timeout = ns_to_clocks(data->timeout_ns) + data->timeout_clks; | 124 | clks = (unsigned long long)data->timeout_ns * CLOCKRATE; |
125 | do_div(clks, 1000000000UL); | ||
126 | timeout = (unsigned int)clks + (data->timeout_clks << host->clkrt); | ||
129 | writel((timeout + 255) / 256, host->base + MMC_RDTO); | 127 | writel((timeout + 255) / 256, host->base + MMC_RDTO); |
130 | 128 | ||
131 | if (data->flags & MMC_DATA_READ) { | 129 | if (data->flags & MMC_DATA_READ) { |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index add8dc4aa7b0..c99e87838f92 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -3768,6 +3768,7 @@ e1000_clean_rx_irq_ps(struct e1000_adapter *adapter, | |||
3768 | ps_page->ps_page[j] = NULL; | 3768 | ps_page->ps_page[j] = NULL; |
3769 | skb->len += length; | 3769 | skb->len += length; |
3770 | skb->data_len += length; | 3770 | skb->data_len += length; |
3771 | skb->truesize += length; | ||
3771 | } | 3772 | } |
3772 | 3773 | ||
3773 | copydone: | 3774 | copydone: |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 7627a75f4f7c..f7235c9bc421 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -105,6 +105,8 @@ | |||
105 | * 0.50: 20 Jan 2006: Add 8021pq tagging support. | 105 | * 0.50: 20 Jan 2006: Add 8021pq tagging support. |
106 | * 0.51: 20 Jan 2006: Add 64bit consistent memory allocation for rings. | 106 | * 0.51: 20 Jan 2006: Add 64bit consistent memory allocation for rings. |
107 | * 0.52: 20 Jan 2006: Add MSI/MSIX support. | 107 | * 0.52: 20 Jan 2006: Add MSI/MSIX support. |
108 | * 0.53: 19 Mar 2006: Fix init from low power mode and add hw reset. | ||
109 | * 0.54: 21 Mar 2006: Fix spin locks for multi irqs and cleanup. | ||
108 | * | 110 | * |
109 | * Known bugs: | 111 | * Known bugs: |
110 | * We suspect that on some hardware no TX done interrupts are generated. | 112 | * We suspect that on some hardware no TX done interrupts are generated. |
@@ -116,7 +118,7 @@ | |||
116 | * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few | 118 | * DEV_NEED_TIMERIRQ will not harm you on sane hardware, only generating a few |
117 | * superfluous timer interrupts from the nic. | 119 | * superfluous timer interrupts from the nic. |
118 | */ | 120 | */ |
119 | #define FORCEDETH_VERSION "0.52" | 121 | #define FORCEDETH_VERSION "0.54" |
120 | #define DRV_NAME "forcedeth" | 122 | #define DRV_NAME "forcedeth" |
121 | 123 | ||
122 | #include <linux/module.h> | 124 | #include <linux/module.h> |
@@ -160,6 +162,7 @@ | |||
160 | #define DEV_HAS_VLAN 0x0020 /* device supports vlan tagging and striping */ | 162 | #define DEV_HAS_VLAN 0x0020 /* device supports vlan tagging and striping */ |
161 | #define DEV_HAS_MSI 0x0040 /* device supports MSI */ | 163 | #define DEV_HAS_MSI 0x0040 /* device supports MSI */ |
162 | #define DEV_HAS_MSI_X 0x0080 /* device supports MSI-X */ | 164 | #define DEV_HAS_MSI_X 0x0080 /* device supports MSI-X */ |
165 | #define DEV_HAS_POWER_CNTRL 0x0100 /* device supports power savings */ | ||
163 | 166 | ||
164 | enum { | 167 | enum { |
165 | NvRegIrqStatus = 0x000, | 168 | NvRegIrqStatus = 0x000, |
@@ -203,6 +206,8 @@ enum { | |||
203 | #define NVREG_MISC1_HD 0x02 | 206 | #define NVREG_MISC1_HD 0x02 |
204 | #define NVREG_MISC1_FORCE 0x3b0f3c | 207 | #define NVREG_MISC1_FORCE 0x3b0f3c |
205 | 208 | ||
209 | NvRegMacReset = 0x3c, | ||
210 | #define NVREG_MAC_RESET_ASSERT 0x0F3 | ||
206 | NvRegTransmitterControl = 0x084, | 211 | NvRegTransmitterControl = 0x084, |
207 | #define NVREG_XMITCTL_START 0x01 | 212 | #define NVREG_XMITCTL_START 0x01 |
208 | NvRegTransmitterStatus = 0x088, | 213 | NvRegTransmitterStatus = 0x088, |
@@ -326,6 +331,10 @@ enum { | |||
326 | NvRegMSIXMap0 = 0x3e0, | 331 | NvRegMSIXMap0 = 0x3e0, |
327 | NvRegMSIXMap1 = 0x3e4, | 332 | NvRegMSIXMap1 = 0x3e4, |
328 | NvRegMSIXIrqStatus = 0x3f0, | 333 | NvRegMSIXIrqStatus = 0x3f0, |
334 | |||
335 | NvRegPowerState2 = 0x600, | ||
336 | #define NVREG_POWERSTATE2_POWERUP_MASK 0x0F11 | ||
337 | #define NVREG_POWERSTATE2_POWERUP_REV_A3 0x0001 | ||
329 | }; | 338 | }; |
330 | 339 | ||
331 | /* Big endian: should work, but is untested */ | 340 | /* Big endian: should work, but is untested */ |
@@ -414,7 +423,8 @@ typedef union _ring_type { | |||
414 | #define NV_RX3_VLAN_TAG_MASK (0x0000FFFF) | 423 | #define NV_RX3_VLAN_TAG_MASK (0x0000FFFF) |
415 | 424 | ||
416 | /* Miscelaneous hardware related defines: */ | 425 | /* Miscelaneous hardware related defines: */ |
417 | #define NV_PCI_REGSZ 0x270 | 426 | #define NV_PCI_REGSZ_VER1 0x270 |
427 | #define NV_PCI_REGSZ_VER2 0x604 | ||
418 | 428 | ||
419 | /* various timeout delays: all in usec */ | 429 | /* various timeout delays: all in usec */ |
420 | #define NV_TXRX_RESET_DELAY 4 | 430 | #define NV_TXRX_RESET_DELAY 4 |
@@ -431,6 +441,7 @@ typedef union _ring_type { | |||
431 | #define NV_MIIBUSY_DELAY 50 | 441 | #define NV_MIIBUSY_DELAY 50 |
432 | #define NV_MIIPHY_DELAY 10 | 442 | #define NV_MIIPHY_DELAY 10 |
433 | #define NV_MIIPHY_DELAYMAX 10000 | 443 | #define NV_MIIPHY_DELAYMAX 10000 |
444 | #define NV_MAC_RESET_DELAY 64 | ||
434 | 445 | ||
435 | #define NV_WAKEUPPATTERNS 5 | 446 | #define NV_WAKEUPPATTERNS 5 |
436 | #define NV_WAKEUPMASKENTRIES 4 | 447 | #define NV_WAKEUPMASKENTRIES 4 |
@@ -552,6 +563,8 @@ struct fe_priv { | |||
552 | u32 desc_ver; | 563 | u32 desc_ver; |
553 | u32 txrxctl_bits; | 564 | u32 txrxctl_bits; |
554 | u32 vlanctl_bits; | 565 | u32 vlanctl_bits; |
566 | u32 driver_data; | ||
567 | u32 register_size; | ||
555 | 568 | ||
556 | void __iomem *base; | 569 | void __iomem *base; |
557 | 570 | ||
@@ -698,6 +711,72 @@ static void setup_hw_rings(struct net_device *dev, int rxtx_flags) | |||
698 | } | 711 | } |
699 | } | 712 | } |
700 | 713 | ||
714 | static int using_multi_irqs(struct net_device *dev) | ||
715 | { | ||
716 | struct fe_priv *np = get_nvpriv(dev); | ||
717 | |||
718 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | ||
719 | ((np->msi_flags & NV_MSI_X_ENABLED) && | ||
720 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) | ||
721 | return 0; | ||
722 | else | ||
723 | return 1; | ||
724 | } | ||
725 | |||
726 | static void nv_enable_irq(struct net_device *dev) | ||
727 | { | ||
728 | struct fe_priv *np = get_nvpriv(dev); | ||
729 | |||
730 | if (!using_multi_irqs(dev)) { | ||
731 | if (np->msi_flags & NV_MSI_X_ENABLED) | ||
732 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); | ||
733 | else | ||
734 | enable_irq(dev->irq); | ||
735 | } else { | ||
736 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | ||
737 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); | ||
738 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); | ||
739 | } | ||
740 | } | ||
741 | |||
742 | static void nv_disable_irq(struct net_device *dev) | ||
743 | { | ||
744 | struct fe_priv *np = get_nvpriv(dev); | ||
745 | |||
746 | if (!using_multi_irqs(dev)) { | ||
747 | if (np->msi_flags & NV_MSI_X_ENABLED) | ||
748 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); | ||
749 | else | ||
750 | disable_irq(dev->irq); | ||
751 | } else { | ||
752 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | ||
753 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); | ||
754 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); | ||
755 | } | ||
756 | } | ||
757 | |||
758 | /* In MSIX mode, a write to irqmask behaves as XOR */ | ||
759 | static void nv_enable_hw_interrupts(struct net_device *dev, u32 mask) | ||
760 | { | ||
761 | u8 __iomem *base = get_hwbase(dev); | ||
762 | |||
763 | writel(mask, base + NvRegIrqMask); | ||
764 | } | ||
765 | |||
766 | static void nv_disable_hw_interrupts(struct net_device *dev, u32 mask) | ||
767 | { | ||
768 | struct fe_priv *np = get_nvpriv(dev); | ||
769 | u8 __iomem *base = get_hwbase(dev); | ||
770 | |||
771 | if (np->msi_flags & NV_MSI_X_ENABLED) { | ||
772 | writel(mask, base + NvRegIrqMask); | ||
773 | } else { | ||
774 | if (np->msi_flags & NV_MSI_ENABLED) | ||
775 | writel(0, base + NvRegMSIIrqMask); | ||
776 | writel(0, base + NvRegIrqMask); | ||
777 | } | ||
778 | } | ||
779 | |||
701 | #define MII_READ (-1) | 780 | #define MII_READ (-1) |
702 | /* mii_rw: read/write a register on the PHY. | 781 | /* mii_rw: read/write a register on the PHY. |
703 | * | 782 | * |
@@ -919,6 +998,24 @@ static void nv_txrx_reset(struct net_device *dev) | |||
919 | pci_push(base); | 998 | pci_push(base); |
920 | } | 999 | } |
921 | 1000 | ||
1001 | static void nv_mac_reset(struct net_device *dev) | ||
1002 | { | ||
1003 | struct fe_priv *np = netdev_priv(dev); | ||
1004 | u8 __iomem *base = get_hwbase(dev); | ||
1005 | |||
1006 | dprintk(KERN_DEBUG "%s: nv_mac_reset\n", dev->name); | ||
1007 | writel(NVREG_TXRXCTL_BIT2 | NVREG_TXRXCTL_RESET | np->txrxctl_bits, base + NvRegTxRxControl); | ||
1008 | pci_push(base); | ||
1009 | writel(NVREG_MAC_RESET_ASSERT, base + NvRegMacReset); | ||
1010 | pci_push(base); | ||
1011 | udelay(NV_MAC_RESET_DELAY); | ||
1012 | writel(0, base + NvRegMacReset); | ||
1013 | pci_push(base); | ||
1014 | udelay(NV_MAC_RESET_DELAY); | ||
1015 | writel(NVREG_TXRXCTL_BIT2 | np->txrxctl_bits, base + NvRegTxRxControl); | ||
1016 | pci_push(base); | ||
1017 | } | ||
1018 | |||
922 | /* | 1019 | /* |
923 | * nv_get_stats: dev->get_stats function | 1020 | * nv_get_stats: dev->get_stats function |
924 | * Get latest stats value from the nic. | 1021 | * Get latest stats value from the nic. |
@@ -989,24 +1086,25 @@ static void nv_do_rx_refill(unsigned long data) | |||
989 | struct net_device *dev = (struct net_device *) data; | 1086 | struct net_device *dev = (struct net_device *) data; |
990 | struct fe_priv *np = netdev_priv(dev); | 1087 | struct fe_priv *np = netdev_priv(dev); |
991 | 1088 | ||
992 | 1089 | if (!using_multi_irqs(dev)) { | |
993 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 1090 | if (np->msi_flags & NV_MSI_X_ENABLED) |
994 | ((np->msi_flags & NV_MSI_X_ENABLED) && | 1091 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); |
995 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | 1092 | else |
996 | disable_irq(dev->irq); | 1093 | disable_irq(dev->irq); |
997 | } else { | 1094 | } else { |
998 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | 1095 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); |
999 | } | 1096 | } |
1000 | if (nv_alloc_rx(dev)) { | 1097 | if (nv_alloc_rx(dev)) { |
1001 | spin_lock(&np->lock); | 1098 | spin_lock_irq(&np->lock); |
1002 | if (!np->in_shutdown) | 1099 | if (!np->in_shutdown) |
1003 | mod_timer(&np->oom_kick, jiffies + OOM_REFILL); | 1100 | mod_timer(&np->oom_kick, jiffies + OOM_REFILL); |
1004 | spin_unlock(&np->lock); | 1101 | spin_unlock_irq(&np->lock); |
1005 | } | 1102 | } |
1006 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 1103 | if (!using_multi_irqs(dev)) { |
1007 | ((np->msi_flags & NV_MSI_X_ENABLED) && | 1104 | if (np->msi_flags & NV_MSI_X_ENABLED) |
1008 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | 1105 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); |
1009 | enable_irq(dev->irq); | 1106 | else |
1107 | enable_irq(dev->irq); | ||
1010 | } else { | 1108 | } else { |
1011 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | 1109 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); |
1012 | } | 1110 | } |
@@ -1331,7 +1429,7 @@ static void nv_tx_timeout(struct net_device *dev) | |||
1331 | dev->name, (unsigned long)np->ring_addr, | 1429 | dev->name, (unsigned long)np->ring_addr, |
1332 | np->next_tx, np->nic_tx); | 1430 | np->next_tx, np->nic_tx); |
1333 | printk(KERN_INFO "%s: Dumping tx registers\n", dev->name); | 1431 | printk(KERN_INFO "%s: Dumping tx registers\n", dev->name); |
1334 | for (i=0;i<0x400;i+= 32) { | 1432 | for (i=0;i<=np->register_size;i+= 32) { |
1335 | printk(KERN_INFO "%3x: %08x %08x %08x %08x %08x %08x %08x %08x\n", | 1433 | printk(KERN_INFO "%3x: %08x %08x %08x %08x %08x %08x %08x %08x\n", |
1336 | i, | 1434 | i, |
1337 | readl(base + i + 0), readl(base + i + 4), | 1435 | readl(base + i + 0), readl(base + i + 4), |
@@ -1638,15 +1736,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu) | |||
1638 | * guessed, there is probably a simpler approach. | 1736 | * guessed, there is probably a simpler approach. |
1639 | * Changing the MTU is a rare event, it shouldn't matter. | 1737 | * Changing the MTU is a rare event, it shouldn't matter. |
1640 | */ | 1738 | */ |
1641 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 1739 | nv_disable_irq(dev); |
1642 | ((np->msi_flags & NV_MSI_X_ENABLED) && | ||
1643 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | ||
1644 | disable_irq(dev->irq); | ||
1645 | } else { | ||
1646 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | ||
1647 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); | ||
1648 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); | ||
1649 | } | ||
1650 | spin_lock_bh(&dev->xmit_lock); | 1740 | spin_lock_bh(&dev->xmit_lock); |
1651 | spin_lock(&np->lock); | 1741 | spin_lock(&np->lock); |
1652 | /* stop engines */ | 1742 | /* stop engines */ |
@@ -1679,15 +1769,7 @@ static int nv_change_mtu(struct net_device *dev, int new_mtu) | |||
1679 | nv_start_tx(dev); | 1769 | nv_start_tx(dev); |
1680 | spin_unlock(&np->lock); | 1770 | spin_unlock(&np->lock); |
1681 | spin_unlock_bh(&dev->xmit_lock); | 1771 | spin_unlock_bh(&dev->xmit_lock); |
1682 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 1772 | nv_enable_irq(dev); |
1683 | ((np->msi_flags & NV_MSI_X_ENABLED) && | ||
1684 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | ||
1685 | enable_irq(dev->irq); | ||
1686 | } else { | ||
1687 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector); | ||
1688 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector); | ||
1689 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector); | ||
1690 | } | ||
1691 | } | 1773 | } |
1692 | return 0; | 1774 | return 0; |
1693 | } | 1775 | } |
@@ -2078,16 +2160,16 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data, struct pt_regs *regs) | |||
2078 | if (!(events & np->irqmask)) | 2160 | if (!(events & np->irqmask)) |
2079 | break; | 2161 | break; |
2080 | 2162 | ||
2081 | spin_lock(&np->lock); | 2163 | spin_lock_irq(&np->lock); |
2082 | nv_tx_done(dev); | 2164 | nv_tx_done(dev); |
2083 | spin_unlock(&np->lock); | 2165 | spin_unlock_irq(&np->lock); |
2084 | 2166 | ||
2085 | if (events & (NVREG_IRQ_TX_ERR)) { | 2167 | if (events & (NVREG_IRQ_TX_ERR)) { |
2086 | dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", | 2168 | dprintk(KERN_DEBUG "%s: received irq with events 0x%x. Probably TX fail.\n", |
2087 | dev->name, events); | 2169 | dev->name, events); |
2088 | } | 2170 | } |
2089 | if (i > max_interrupt_work) { | 2171 | if (i > max_interrupt_work) { |
2090 | spin_lock(&np->lock); | 2172 | spin_lock_irq(&np->lock); |
2091 | /* disable interrupts on the nic */ | 2173 | /* disable interrupts on the nic */ |
2092 | writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask); | 2174 | writel(NVREG_IRQ_TX_ALL, base + NvRegIrqMask); |
2093 | pci_push(base); | 2175 | pci_push(base); |
@@ -2097,7 +2179,7 @@ static irqreturn_t nv_nic_irq_tx(int foo, void *data, struct pt_regs *regs) | |||
2097 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); | 2179 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); |
2098 | } | 2180 | } |
2099 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i); | 2181 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_tx.\n", dev->name, i); |
2100 | spin_unlock(&np->lock); | 2182 | spin_unlock_irq(&np->lock); |
2101 | break; | 2183 | break; |
2102 | } | 2184 | } |
2103 | 2185 | ||
@@ -2127,14 +2209,14 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data, struct pt_regs *regs) | |||
2127 | 2209 | ||
2128 | nv_rx_process(dev); | 2210 | nv_rx_process(dev); |
2129 | if (nv_alloc_rx(dev)) { | 2211 | if (nv_alloc_rx(dev)) { |
2130 | spin_lock(&np->lock); | 2212 | spin_lock_irq(&np->lock); |
2131 | if (!np->in_shutdown) | 2213 | if (!np->in_shutdown) |
2132 | mod_timer(&np->oom_kick, jiffies + OOM_REFILL); | 2214 | mod_timer(&np->oom_kick, jiffies + OOM_REFILL); |
2133 | spin_unlock(&np->lock); | 2215 | spin_unlock_irq(&np->lock); |
2134 | } | 2216 | } |
2135 | 2217 | ||
2136 | if (i > max_interrupt_work) { | 2218 | if (i > max_interrupt_work) { |
2137 | spin_lock(&np->lock); | 2219 | spin_lock_irq(&np->lock); |
2138 | /* disable interrupts on the nic */ | 2220 | /* disable interrupts on the nic */ |
2139 | writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask); | 2221 | writel(NVREG_IRQ_RX_ALL, base + NvRegIrqMask); |
2140 | pci_push(base); | 2222 | pci_push(base); |
@@ -2144,7 +2226,7 @@ static irqreturn_t nv_nic_irq_rx(int foo, void *data, struct pt_regs *regs) | |||
2144 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); | 2226 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); |
2145 | } | 2227 | } |
2146 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i); | 2228 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_rx.\n", dev->name, i); |
2147 | spin_unlock(&np->lock); | 2229 | spin_unlock_irq(&np->lock); |
2148 | break; | 2230 | break; |
2149 | } | 2231 | } |
2150 | 2232 | ||
@@ -2173,14 +2255,14 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data, struct pt_regs *regs) | |||
2173 | break; | 2255 | break; |
2174 | 2256 | ||
2175 | if (events & NVREG_IRQ_LINK) { | 2257 | if (events & NVREG_IRQ_LINK) { |
2176 | spin_lock(&np->lock); | 2258 | spin_lock_irq(&np->lock); |
2177 | nv_link_irq(dev); | 2259 | nv_link_irq(dev); |
2178 | spin_unlock(&np->lock); | 2260 | spin_unlock_irq(&np->lock); |
2179 | } | 2261 | } |
2180 | if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { | 2262 | if (np->need_linktimer && time_after(jiffies, np->link_timeout)) { |
2181 | spin_lock(&np->lock); | 2263 | spin_lock_irq(&np->lock); |
2182 | nv_linkchange(dev); | 2264 | nv_linkchange(dev); |
2183 | spin_unlock(&np->lock); | 2265 | spin_unlock_irq(&np->lock); |
2184 | np->link_timeout = jiffies + LINK_TIMEOUT; | 2266 | np->link_timeout = jiffies + LINK_TIMEOUT; |
2185 | } | 2267 | } |
2186 | if (events & (NVREG_IRQ_UNKNOWN)) { | 2268 | if (events & (NVREG_IRQ_UNKNOWN)) { |
@@ -2188,7 +2270,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data, struct pt_regs *regs) | |||
2188 | dev->name, events); | 2270 | dev->name, events); |
2189 | } | 2271 | } |
2190 | if (i > max_interrupt_work) { | 2272 | if (i > max_interrupt_work) { |
2191 | spin_lock(&np->lock); | 2273 | spin_lock_irq(&np->lock); |
2192 | /* disable interrupts on the nic */ | 2274 | /* disable interrupts on the nic */ |
2193 | writel(NVREG_IRQ_OTHER, base + NvRegIrqMask); | 2275 | writel(NVREG_IRQ_OTHER, base + NvRegIrqMask); |
2194 | pci_push(base); | 2276 | pci_push(base); |
@@ -2198,7 +2280,7 @@ static irqreturn_t nv_nic_irq_other(int foo, void *data, struct pt_regs *regs) | |||
2198 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); | 2280 | mod_timer(&np->nic_poll, jiffies + POLL_WAIT); |
2199 | } | 2281 | } |
2200 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i); | 2282 | printk(KERN_DEBUG "%s: too many iterations (%d) in nv_nic_irq_other.\n", dev->name, i); |
2201 | spin_unlock(&np->lock); | 2283 | spin_unlock_irq(&np->lock); |
2202 | break; | 2284 | break; |
2203 | } | 2285 | } |
2204 | 2286 | ||
@@ -2221,10 +2303,11 @@ static void nv_do_nic_poll(unsigned long data) | |||
2221 | * nv_nic_irq because that may decide to do otherwise | 2303 | * nv_nic_irq because that may decide to do otherwise |
2222 | */ | 2304 | */ |
2223 | 2305 | ||
2224 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 2306 | if (!using_multi_irqs(dev)) { |
2225 | ((np->msi_flags & NV_MSI_X_ENABLED) && | 2307 | if (np->msi_flags & NV_MSI_X_ENABLED) |
2226 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | 2308 | disable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); |
2227 | disable_irq(dev->irq); | 2309 | else |
2310 | disable_irq(dev->irq); | ||
2228 | mask = np->irqmask; | 2311 | mask = np->irqmask; |
2229 | } else { | 2312 | } else { |
2230 | if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { | 2313 | if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { |
@@ -2247,11 +2330,12 @@ static void nv_do_nic_poll(unsigned long data) | |||
2247 | writel(mask, base + NvRegIrqMask); | 2330 | writel(mask, base + NvRegIrqMask); |
2248 | pci_push(base); | 2331 | pci_push(base); |
2249 | 2332 | ||
2250 | if (!(np->msi_flags & NV_MSI_X_ENABLED) || | 2333 | if (!using_multi_irqs(dev)) { |
2251 | ((np->msi_flags & NV_MSI_X_ENABLED) && | ||
2252 | ((np->msi_flags & NV_MSI_X_VECTORS_MASK) == 0x1))) { | ||
2253 | nv_nic_irq((int) 0, (void *) data, (struct pt_regs *) NULL); | 2334 | nv_nic_irq((int) 0, (void *) data, (struct pt_regs *) NULL); |
2254 | enable_irq(dev->irq); | 2335 | if (np->msi_flags & NV_MSI_X_ENABLED) |
2336 | enable_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector); | ||
2337 | else | ||
2338 | enable_irq(dev->irq); | ||
2255 | } else { | 2339 | } else { |
2256 | if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { | 2340 | if (np->nic_poll_irq & NVREG_IRQ_RX_ALL) { |
2257 | nv_nic_irq_rx((int) 0, (void *) data, (struct pt_regs *) NULL); | 2341 | nv_nic_irq_rx((int) 0, (void *) data, (struct pt_regs *) NULL); |
@@ -2488,11 +2572,11 @@ static int nv_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
2488 | } | 2572 | } |
2489 | 2573 | ||
2490 | #define FORCEDETH_REGS_VER 1 | 2574 | #define FORCEDETH_REGS_VER 1 |
2491 | #define FORCEDETH_REGS_SIZE 0x400 /* 256 32-bit registers */ | ||
2492 | 2575 | ||
2493 | static int nv_get_regs_len(struct net_device *dev) | 2576 | static int nv_get_regs_len(struct net_device *dev) |
2494 | { | 2577 | { |
2495 | return FORCEDETH_REGS_SIZE; | 2578 | struct fe_priv *np = netdev_priv(dev); |
2579 | return np->register_size; | ||
2496 | } | 2580 | } |
2497 | 2581 | ||
2498 | static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) | 2582 | static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *buf) |
@@ -2504,7 +2588,7 @@ static void nv_get_regs(struct net_device *dev, struct ethtool_regs *regs, void | |||
2504 | 2588 | ||
2505 | regs->version = FORCEDETH_REGS_VER; | 2589 | regs->version = FORCEDETH_REGS_VER; |
2506 | spin_lock_irq(&np->lock); | 2590 | spin_lock_irq(&np->lock); |
2507 | for (i=0;i<FORCEDETH_REGS_SIZE/sizeof(u32);i++) | 2591 | for (i = 0;i <= np->register_size/sizeof(u32); i++) |
2508 | rbuf[i] = readl(base + i*sizeof(u32)); | 2592 | rbuf[i] = readl(base + i*sizeof(u32)); |
2509 | spin_unlock_irq(&np->lock); | 2593 | spin_unlock_irq(&np->lock); |
2510 | } | 2594 | } |
@@ -2598,6 +2682,113 @@ static void set_msix_vector_map(struct net_device *dev, u32 vector, u32 irqmask) | |||
2598 | writel(readl(base + NvRegMSIXMap1) | msixmap, base + NvRegMSIXMap1); | 2682 | writel(readl(base + NvRegMSIXMap1) | msixmap, base + NvRegMSIXMap1); |
2599 | } | 2683 | } |
2600 | 2684 | ||
2685 | static int nv_request_irq(struct net_device *dev) | ||
2686 | { | ||
2687 | struct fe_priv *np = get_nvpriv(dev); | ||
2688 | u8 __iomem *base = get_hwbase(dev); | ||
2689 | int ret = 1; | ||
2690 | int i; | ||
2691 | |||
2692 | if (np->msi_flags & NV_MSI_X_CAPABLE) { | ||
2693 | for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { | ||
2694 | np->msi_x_entry[i].entry = i; | ||
2695 | } | ||
2696 | if ((ret = pci_enable_msix(np->pci_dev, np->msi_x_entry, (np->msi_flags & NV_MSI_X_VECTORS_MASK))) == 0) { | ||
2697 | np->msi_flags |= NV_MSI_X_ENABLED; | ||
2698 | if (optimization_mode == NV_OPTIMIZATION_MODE_THROUGHPUT) { | ||
2699 | /* Request irq for rx handling */ | ||
2700 | if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, &nv_nic_irq_rx, SA_SHIRQ, dev->name, dev) != 0) { | ||
2701 | printk(KERN_INFO "forcedeth: request_irq failed for rx %d\n", ret); | ||
2702 | pci_disable_msix(np->pci_dev); | ||
2703 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2704 | goto out_err; | ||
2705 | } | ||
2706 | /* Request irq for tx handling */ | ||
2707 | if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, &nv_nic_irq_tx, SA_SHIRQ, dev->name, dev) != 0) { | ||
2708 | printk(KERN_INFO "forcedeth: request_irq failed for tx %d\n", ret); | ||
2709 | pci_disable_msix(np->pci_dev); | ||
2710 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2711 | goto out_free_rx; | ||
2712 | } | ||
2713 | /* Request irq for link and timer handling */ | ||
2714 | if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_OTHER].vector, &nv_nic_irq_other, SA_SHIRQ, dev->name, dev) != 0) { | ||
2715 | printk(KERN_INFO "forcedeth: request_irq failed for link %d\n", ret); | ||
2716 | pci_disable_msix(np->pci_dev); | ||
2717 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2718 | goto out_free_tx; | ||
2719 | } | ||
2720 | /* map interrupts to their respective vector */ | ||
2721 | writel(0, base + NvRegMSIXMap0); | ||
2722 | writel(0, base + NvRegMSIXMap1); | ||
2723 | set_msix_vector_map(dev, NV_MSI_X_VECTOR_RX, NVREG_IRQ_RX_ALL); | ||
2724 | set_msix_vector_map(dev, NV_MSI_X_VECTOR_TX, NVREG_IRQ_TX_ALL); | ||
2725 | set_msix_vector_map(dev, NV_MSI_X_VECTOR_OTHER, NVREG_IRQ_OTHER); | ||
2726 | } else { | ||
2727 | /* Request irq for all interrupts */ | ||
2728 | if (request_irq(np->msi_x_entry[NV_MSI_X_VECTOR_ALL].vector, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) { | ||
2729 | printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); | ||
2730 | pci_disable_msix(np->pci_dev); | ||
2731 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2732 | goto out_err; | ||
2733 | } | ||
2734 | |||
2735 | /* map interrupts to vector 0 */ | ||
2736 | writel(0, base + NvRegMSIXMap0); | ||
2737 | writel(0, base + NvRegMSIXMap1); | ||
2738 | } | ||
2739 | } | ||
2740 | } | ||
2741 | if (ret != 0 && np->msi_flags & NV_MSI_CAPABLE) { | ||
2742 | if ((ret = pci_enable_msi(np->pci_dev)) == 0) { | ||
2743 | np->msi_flags |= NV_MSI_ENABLED; | ||
2744 | if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) { | ||
2745 | printk(KERN_INFO "forcedeth: request_irq failed %d\n", ret); | ||
2746 | pci_disable_msi(np->pci_dev); | ||
2747 | np->msi_flags &= ~NV_MSI_ENABLED; | ||
2748 | goto out_err; | ||
2749 | } | ||
2750 | |||
2751 | /* map interrupts to vector 0 */ | ||
2752 | writel(0, base + NvRegMSIMap0); | ||
2753 | writel(0, base + NvRegMSIMap1); | ||
2754 | /* enable msi vector 0 */ | ||
2755 | writel(NVREG_MSI_VECTOR_0_ENABLED, base + NvRegMSIIrqMask); | ||
2756 | } | ||
2757 | } | ||
2758 | if (ret != 0) { | ||
2759 | if (request_irq(np->pci_dev->irq, &nv_nic_irq, SA_SHIRQ, dev->name, dev) != 0) | ||
2760 | goto out_err; | ||
2761 | } | ||
2762 | |||
2763 | return 0; | ||
2764 | out_free_tx: | ||
2765 | free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_TX].vector, dev); | ||
2766 | out_free_rx: | ||
2767 | free_irq(np->msi_x_entry[NV_MSI_X_VECTOR_RX].vector, dev); | ||
2768 | out_err: | ||
2769 | return 1; | ||
2770 | } | ||
2771 | |||
2772 | static void nv_free_irq(struct net_device *dev) | ||
2773 | { | ||
2774 | struct fe_priv *np = get_nvpriv(dev); | ||
2775 | int i; | ||
2776 | |||
2777 | if (np->msi_flags & NV_MSI_X_ENABLED) { | ||
2778 | for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { | ||
2779 | free_irq(np->msi_x_entry[i].vector, dev); | ||
2780 | } | ||
2781 | pci_disable_msix(np->pci_dev); | ||
2782 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2783 | } else { | ||
2784 | free_irq(np->pci_dev->irq, dev); | ||
2785 | if (np->msi_flags & NV_MSI_ENABLED) { | ||
2786 | pci_disable_msi(np->pci_dev); | ||
2787 | np->msi_flags &= ~NV_MSI_ENABLED; | ||
2788 | } | ||
2789 | } | ||
2790 | } | ||
2791 | |||
2601 | static int nv_open(struct net_device *dev) | 2792 | static int nv_open(struct net_device *dev) |
2602 | { | 2793 | { |
2603 | struct fe_priv *np = netdev_priv(dev); | 2794 | struct fe_priv *np = netdev_priv(dev); |
@@ -2608,6 +2799,8 @@ static int nv_open(struct net_device *dev) | |||
2608 | dprintk(KERN_DEBUG "nv_open: begin\n"); | 2799 | dprintk(KERN_DEBUG "nv_open: begin\n"); |
2609 | 2800 | ||
2610 | /* 1) erase previous misconfiguration */ | 2801 | /* 1) erase previous misconfiguration */ |
2802 | if (np->driver_data & DEV_HAS_POWER_CNTRL) | ||
2803 | nv_mac_reset(dev); | ||
2611 | /* 4.1-1: stop adapter: ignored, 4.3 seems to be overkill */ | 2804 | /* 4.1-1: stop adapter: ignored, 4.3 seems to be overkill */ |
2612 | writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); | 2805 | writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); |
2613 | writel(0, base + NvRegMulticastAddrB); | 2806 | writel(0, base + NvRegMulticastAddrB); |
@@ -2688,12 +2881,16 @@ static int nv_open(struct net_device *dev) | |||
2688 | udelay(10); | 2881 | udelay(10); |
2689 | writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState); | 2882 | writel(readl(base + NvRegPowerState) | NVREG_POWERSTATE_VALID, base + NvRegPowerState); |
2690 | 2883 | ||
2691 | writel(0, base + NvRegIrqMask); | 2884 | nv_disable_hw_interrupts(dev, np->irqmask); |
2692 | pci_push(base); | 2885 | pci_push(base); |
2693 | writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); | 2886 | writel(NVREG_MIISTAT_MASK2, base + NvRegMIIStatus); |
2694 | writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); | 2887 | writel(NVREG_IRQSTAT_MASK, base + NvRegIrqStatus); |
2695 | pci_push(base); | 2888 | pci_push(base); |
2696 | 2889 | ||
2890 | if (nv_request_irq(dev)) { | ||
2891 | goto out_drain; | ||
2892 | } | ||
2893 | |||
2697 | if (np->msi_flags & NV_MSI_X_CAPABLE) { | 2894 | if (np->msi_flags & NV_MSI_X_CAPABLE) { |
2698 | for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { | 2895 | for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { |
2699 | np->msi_x_entry[i].entry = i; | 2896 | np->msi_x_entry[i].entry = i; |
@@ -2767,7 +2964,7 @@ static int nv_open(struct net_device *dev) | |||
2767 | } | 2964 | } |
2768 | 2965 | ||
2769 | /* ask for interrupts */ | 2966 | /* ask for interrupts */ |
2770 | writel(np->irqmask, base + NvRegIrqMask); | 2967 | nv_enable_hw_interrupts(dev, np->irqmask); |
2771 | 2968 | ||
2772 | spin_lock_irq(&np->lock); | 2969 | spin_lock_irq(&np->lock); |
2773 | writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); | 2970 | writel(NVREG_MCASTADDRA_FORCE, base + NvRegMulticastAddrA); |
@@ -2811,7 +3008,6 @@ static int nv_close(struct net_device *dev) | |||
2811 | { | 3008 | { |
2812 | struct fe_priv *np = netdev_priv(dev); | 3009 | struct fe_priv *np = netdev_priv(dev); |
2813 | u8 __iomem *base; | 3010 | u8 __iomem *base; |
2814 | int i; | ||
2815 | 3011 | ||
2816 | spin_lock_irq(&np->lock); | 3012 | spin_lock_irq(&np->lock); |
2817 | np->in_shutdown = 1; | 3013 | np->in_shutdown = 1; |
@@ -2829,31 +3025,13 @@ static int nv_close(struct net_device *dev) | |||
2829 | 3025 | ||
2830 | /* disable interrupts on the nic or we will lock up */ | 3026 | /* disable interrupts on the nic or we will lock up */ |
2831 | base = get_hwbase(dev); | 3027 | base = get_hwbase(dev); |
2832 | if (np->msi_flags & NV_MSI_X_ENABLED) { | 3028 | nv_disable_hw_interrupts(dev, np->irqmask); |
2833 | writel(np->irqmask, base + NvRegIrqMask); | ||
2834 | } else { | ||
2835 | if (np->msi_flags & NV_MSI_ENABLED) | ||
2836 | writel(0, base + NvRegMSIIrqMask); | ||
2837 | writel(0, base + NvRegIrqMask); | ||
2838 | } | ||
2839 | pci_push(base); | 3029 | pci_push(base); |
2840 | dprintk(KERN_INFO "%s: Irqmask is zero again\n", dev->name); | 3030 | dprintk(KERN_INFO "%s: Irqmask is zero again\n", dev->name); |
2841 | 3031 | ||
2842 | spin_unlock_irq(&np->lock); | 3032 | spin_unlock_irq(&np->lock); |
2843 | 3033 | ||
2844 | if (np->msi_flags & NV_MSI_X_ENABLED) { | 3034 | nv_free_irq(dev); |
2845 | for (i = 0; i < (np->msi_flags & NV_MSI_X_VECTORS_MASK); i++) { | ||
2846 | free_irq(np->msi_x_entry[i].vector, dev); | ||
2847 | } | ||
2848 | pci_disable_msix(np->pci_dev); | ||
2849 | np->msi_flags &= ~NV_MSI_X_ENABLED; | ||
2850 | } else { | ||
2851 | free_irq(np->pci_dev->irq, dev); | ||
2852 | if (np->msi_flags & NV_MSI_ENABLED) { | ||
2853 | pci_disable_msi(np->pci_dev); | ||
2854 | np->msi_flags &= ~NV_MSI_ENABLED; | ||
2855 | } | ||
2856 | } | ||
2857 | 3035 | ||
2858 | drain_ring(dev); | 3036 | drain_ring(dev); |
2859 | 3037 | ||
@@ -2878,6 +3056,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2878 | unsigned long addr; | 3056 | unsigned long addr; |
2879 | u8 __iomem *base; | 3057 | u8 __iomem *base; |
2880 | int err, i; | 3058 | int err, i; |
3059 | u32 powerstate; | ||
2881 | 3060 | ||
2882 | dev = alloc_etherdev(sizeof(struct fe_priv)); | 3061 | dev = alloc_etherdev(sizeof(struct fe_priv)); |
2883 | err = -ENOMEM; | 3062 | err = -ENOMEM; |
@@ -2910,6 +3089,11 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2910 | if (err < 0) | 3089 | if (err < 0) |
2911 | goto out_disable; | 3090 | goto out_disable; |
2912 | 3091 | ||
3092 | if (id->driver_data & (DEV_HAS_VLAN|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL)) | ||
3093 | np->register_size = NV_PCI_REGSZ_VER2; | ||
3094 | else | ||
3095 | np->register_size = NV_PCI_REGSZ_VER1; | ||
3096 | |||
2913 | err = -EINVAL; | 3097 | err = -EINVAL; |
2914 | addr = 0; | 3098 | addr = 0; |
2915 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 3099 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
@@ -2918,7 +3102,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2918 | pci_resource_len(pci_dev, i), | 3102 | pci_resource_len(pci_dev, i), |
2919 | pci_resource_flags(pci_dev, i)); | 3103 | pci_resource_flags(pci_dev, i)); |
2920 | if (pci_resource_flags(pci_dev, i) & IORESOURCE_MEM && | 3104 | if (pci_resource_flags(pci_dev, i) & IORESOURCE_MEM && |
2921 | pci_resource_len(pci_dev, i) >= NV_PCI_REGSZ) { | 3105 | pci_resource_len(pci_dev, i) >= np->register_size) { |
2922 | addr = pci_resource_start(pci_dev, i); | 3106 | addr = pci_resource_start(pci_dev, i); |
2923 | break; | 3107 | break; |
2924 | } | 3108 | } |
@@ -2929,24 +3113,25 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2929 | goto out_relreg; | 3113 | goto out_relreg; |
2930 | } | 3114 | } |
2931 | 3115 | ||
3116 | /* copy of driver data */ | ||
3117 | np->driver_data = id->driver_data; | ||
3118 | |||
2932 | /* handle different descriptor versions */ | 3119 | /* handle different descriptor versions */ |
2933 | if (id->driver_data & DEV_HAS_HIGH_DMA) { | 3120 | if (id->driver_data & DEV_HAS_HIGH_DMA) { |
2934 | /* packet format 3: supports 40-bit addressing */ | 3121 | /* packet format 3: supports 40-bit addressing */ |
2935 | np->desc_ver = DESC_VER_3; | 3122 | np->desc_ver = DESC_VER_3; |
3123 | np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; | ||
2936 | if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) { | 3124 | if (pci_set_dma_mask(pci_dev, DMA_39BIT_MASK)) { |
2937 | printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", | 3125 | printk(KERN_INFO "forcedeth: 64-bit DMA failed, using 32-bit addressing for device %s.\n", |
2938 | pci_name(pci_dev)); | 3126 | pci_name(pci_dev)); |
2939 | } else { | 3127 | } else { |
2940 | if (pci_set_consistent_dma_mask(pci_dev, 0x0000007fffffffffULL)) { | 3128 | dev->features |= NETIF_F_HIGHDMA; |
2941 | printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed for device %s.\n", | 3129 | printk(KERN_INFO "forcedeth: using HIGHDMA\n"); |
2942 | pci_name(pci_dev)); | 3130 | } |
2943 | goto out_relreg; | 3131 | if (pci_set_consistent_dma_mask(pci_dev, 0x0000007fffffffffULL)) { |
2944 | } else { | 3132 | printk(KERN_INFO "forcedeth: 64-bit DMA (consistent) failed for device %s.\n", |
2945 | dev->features |= NETIF_F_HIGHDMA; | 3133 | pci_name(pci_dev)); |
2946 | printk(KERN_INFO "forcedeth: using HIGHDMA\n"); | ||
2947 | } | ||
2948 | } | 3134 | } |
2949 | np->txrxctl_bits = NVREG_TXRXCTL_DESC_3; | ||
2950 | } else if (id->driver_data & DEV_HAS_LARGEDESC) { | 3135 | } else if (id->driver_data & DEV_HAS_LARGEDESC) { |
2951 | /* packet format 2: supports jumbo frames */ | 3136 | /* packet format 2: supports jumbo frames */ |
2952 | np->desc_ver = DESC_VER_2; | 3137 | np->desc_ver = DESC_VER_2; |
@@ -2986,7 +3171,7 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
2986 | } | 3171 | } |
2987 | 3172 | ||
2988 | err = -ENOMEM; | 3173 | err = -ENOMEM; |
2989 | np->base = ioremap(addr, NV_PCI_REGSZ); | 3174 | np->base = ioremap(addr, np->register_size); |
2990 | if (!np->base) | 3175 | if (!np->base) |
2991 | goto out_relreg; | 3176 | goto out_relreg; |
2992 | dev->base_addr = (unsigned long)np->base; | 3177 | dev->base_addr = (unsigned long)np->base; |
@@ -3062,6 +3247,20 @@ static int __devinit nv_probe(struct pci_dev *pci_dev, const struct pci_device_i | |||
3062 | writel(0, base + NvRegWakeUpFlags); | 3247 | writel(0, base + NvRegWakeUpFlags); |
3063 | np->wolenabled = 0; | 3248 | np->wolenabled = 0; |
3064 | 3249 | ||
3250 | if (id->driver_data & DEV_HAS_POWER_CNTRL) { | ||
3251 | u8 revision_id; | ||
3252 | pci_read_config_byte(pci_dev, PCI_REVISION_ID, &revision_id); | ||
3253 | |||
3254 | /* take phy and nic out of low power mode */ | ||
3255 | powerstate = readl(base + NvRegPowerState2); | ||
3256 | powerstate &= ~NVREG_POWERSTATE2_POWERUP_MASK; | ||
3257 | if ((id->device == PCI_DEVICE_ID_NVIDIA_NVENET_12 || | ||
3258 | id->device == PCI_DEVICE_ID_NVIDIA_NVENET_13) && | ||
3259 | revision_id >= 0xA3) | ||
3260 | powerstate |= NVREG_POWERSTATE2_POWERUP_REV_A3; | ||
3261 | writel(powerstate, base + NvRegPowerState2); | ||
3262 | } | ||
3263 | |||
3065 | if (np->desc_ver == DESC_VER_1) { | 3264 | if (np->desc_ver == DESC_VER_1) { |
3066 | np->tx_flags = NV_TX_VALID; | 3265 | np->tx_flags = NV_TX_VALID; |
3067 | } else { | 3266 | } else { |
@@ -3223,19 +3422,19 @@ static struct pci_device_id pci_tbl[] = { | |||
3223 | }, | 3422 | }, |
3224 | { /* MCP51 Ethernet Controller */ | 3423 | { /* MCP51 Ethernet Controller */ |
3225 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12), | 3424 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_12), |
3226 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA, | 3425 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL, |
3227 | }, | 3426 | }, |
3228 | { /* MCP51 Ethernet Controller */ | 3427 | { /* MCP51 Ethernet Controller */ |
3229 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_13), | 3428 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_13), |
3230 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA, | 3429 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL, |
3231 | }, | 3430 | }, |
3232 | { /* MCP55 Ethernet Controller */ | 3431 | { /* MCP55 Ethernet Controller */ |
3233 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), | 3432 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_14), |
3234 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X, | 3433 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL, |
3235 | }, | 3434 | }, |
3236 | { /* MCP55 Ethernet Controller */ | 3435 | { /* MCP55 Ethernet Controller */ |
3237 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), | 3436 | PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NVENET_15), |
3238 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X, | 3437 | .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL, |
3239 | }, | 3438 | }, |
3240 | {0,}, | 3439 | {0,}, |
3241 | }; | 3440 | }; |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 771e25d8c417..218d31764c52 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -210,7 +210,8 @@ static int gfar_probe(struct platform_device *pdev) | |||
210 | goto regs_fail; | 210 | goto regs_fail; |
211 | } | 211 | } |
212 | 212 | ||
213 | spin_lock_init(&priv->lock); | 213 | spin_lock_init(&priv->txlock); |
214 | spin_lock_init(&priv->rxlock); | ||
214 | 215 | ||
215 | platform_set_drvdata(pdev, dev); | 216 | platform_set_drvdata(pdev, dev); |
216 | 217 | ||
@@ -515,11 +516,13 @@ void stop_gfar(struct net_device *dev) | |||
515 | phy_stop(priv->phydev); | 516 | phy_stop(priv->phydev); |
516 | 517 | ||
517 | /* Lock it down */ | 518 | /* Lock it down */ |
518 | spin_lock_irqsave(&priv->lock, flags); | 519 | spin_lock_irqsave(&priv->txlock, flags); |
520 | spin_lock(&priv->rxlock); | ||
519 | 521 | ||
520 | gfar_halt(dev); | 522 | gfar_halt(dev); |
521 | 523 | ||
522 | spin_unlock_irqrestore(&priv->lock, flags); | 524 | spin_unlock(&priv->rxlock); |
525 | spin_unlock_irqrestore(&priv->txlock, flags); | ||
523 | 526 | ||
524 | /* Free the IRQs */ | 527 | /* Free the IRQs */ |
525 | if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { | 528 | if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_MULTI_INTR) { |
@@ -605,14 +608,15 @@ void gfar_start(struct net_device *dev) | |||
605 | tempval |= DMACTRL_INIT_SETTINGS; | 608 | tempval |= DMACTRL_INIT_SETTINGS; |
606 | gfar_write(&priv->regs->dmactrl, tempval); | 609 | gfar_write(&priv->regs->dmactrl, tempval); |
607 | 610 | ||
608 | /* Clear THLT, so that the DMA starts polling now */ | ||
609 | gfar_write(®s->tstat, TSTAT_CLEAR_THALT); | ||
610 | |||
611 | /* Make sure we aren't stopped */ | 611 | /* Make sure we aren't stopped */ |
612 | tempval = gfar_read(&priv->regs->dmactrl); | 612 | tempval = gfar_read(&priv->regs->dmactrl); |
613 | tempval &= ~(DMACTRL_GRS | DMACTRL_GTS); | 613 | tempval &= ~(DMACTRL_GRS | DMACTRL_GTS); |
614 | gfar_write(&priv->regs->dmactrl, tempval); | 614 | gfar_write(&priv->regs->dmactrl, tempval); |
615 | 615 | ||
616 | /* Clear THLT/RHLT, so that the DMA starts polling now */ | ||
617 | gfar_write(®s->tstat, TSTAT_CLEAR_THALT); | ||
618 | gfar_write(®s->rstat, RSTAT_CLEAR_RHALT); | ||
619 | |||
616 | /* Unmask the interrupts we look for */ | 620 | /* Unmask the interrupts we look for */ |
617 | gfar_write(®s->imask, IMASK_DEFAULT); | 621 | gfar_write(®s->imask, IMASK_DEFAULT); |
618 | } | 622 | } |
@@ -928,12 +932,13 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
928 | struct txfcb *fcb = NULL; | 932 | struct txfcb *fcb = NULL; |
929 | struct txbd8 *txbdp; | 933 | struct txbd8 *txbdp; |
930 | u16 status; | 934 | u16 status; |
935 | unsigned long flags; | ||
931 | 936 | ||
932 | /* Update transmit stats */ | 937 | /* Update transmit stats */ |
933 | priv->stats.tx_bytes += skb->len; | 938 | priv->stats.tx_bytes += skb->len; |
934 | 939 | ||
935 | /* Lock priv now */ | 940 | /* Lock priv now */ |
936 | spin_lock_irq(&priv->lock); | 941 | spin_lock_irqsave(&priv->txlock, flags); |
937 | 942 | ||
938 | /* Point at the first free tx descriptor */ | 943 | /* Point at the first free tx descriptor */ |
939 | txbdp = priv->cur_tx; | 944 | txbdp = priv->cur_tx; |
@@ -1004,7 +1009,7 @@ static int gfar_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1004 | gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT); | 1009 | gfar_write(&priv->regs->tstat, TSTAT_CLEAR_THALT); |
1005 | 1010 | ||
1006 | /* Unlock priv */ | 1011 | /* Unlock priv */ |
1007 | spin_unlock_irq(&priv->lock); | 1012 | spin_unlock_irqrestore(&priv->txlock, flags); |
1008 | 1013 | ||
1009 | return 0; | 1014 | return 0; |
1010 | } | 1015 | } |
@@ -1049,7 +1054,7 @@ static void gfar_vlan_rx_register(struct net_device *dev, | |||
1049 | unsigned long flags; | 1054 | unsigned long flags; |
1050 | u32 tempval; | 1055 | u32 tempval; |
1051 | 1056 | ||
1052 | spin_lock_irqsave(&priv->lock, flags); | 1057 | spin_lock_irqsave(&priv->rxlock, flags); |
1053 | 1058 | ||
1054 | priv->vlgrp = grp; | 1059 | priv->vlgrp = grp; |
1055 | 1060 | ||
@@ -1076,7 +1081,7 @@ static void gfar_vlan_rx_register(struct net_device *dev, | |||
1076 | gfar_write(&priv->regs->rctrl, tempval); | 1081 | gfar_write(&priv->regs->rctrl, tempval); |
1077 | } | 1082 | } |
1078 | 1083 | ||
1079 | spin_unlock_irqrestore(&priv->lock, flags); | 1084 | spin_unlock_irqrestore(&priv->rxlock, flags); |
1080 | } | 1085 | } |
1081 | 1086 | ||
1082 | 1087 | ||
@@ -1085,12 +1090,12 @@ static void gfar_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid) | |||
1085 | struct gfar_private *priv = netdev_priv(dev); | 1090 | struct gfar_private *priv = netdev_priv(dev); |
1086 | unsigned long flags; | 1091 | unsigned long flags; |
1087 | 1092 | ||
1088 | spin_lock_irqsave(&priv->lock, flags); | 1093 | spin_lock_irqsave(&priv->rxlock, flags); |
1089 | 1094 | ||
1090 | if (priv->vlgrp) | 1095 | if (priv->vlgrp) |
1091 | priv->vlgrp->vlan_devices[vid] = NULL; | 1096 | priv->vlgrp->vlan_devices[vid] = NULL; |
1092 | 1097 | ||
1093 | spin_unlock_irqrestore(&priv->lock, flags); | 1098 | spin_unlock_irqrestore(&priv->rxlock, flags); |
1094 | } | 1099 | } |
1095 | 1100 | ||
1096 | 1101 | ||
@@ -1179,7 +1184,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs) | |||
1179 | gfar_write(&priv->regs->ievent, IEVENT_TX_MASK); | 1184 | gfar_write(&priv->regs->ievent, IEVENT_TX_MASK); |
1180 | 1185 | ||
1181 | /* Lock priv */ | 1186 | /* Lock priv */ |
1182 | spin_lock(&priv->lock); | 1187 | spin_lock(&priv->txlock); |
1183 | bdp = priv->dirty_tx; | 1188 | bdp = priv->dirty_tx; |
1184 | while ((bdp->status & TXBD_READY) == 0) { | 1189 | while ((bdp->status & TXBD_READY) == 0) { |
1185 | /* If dirty_tx and cur_tx are the same, then either the */ | 1190 | /* If dirty_tx and cur_tx are the same, then either the */ |
@@ -1224,7 +1229,7 @@ static irqreturn_t gfar_transmit(int irq, void *dev_id, struct pt_regs *regs) | |||
1224 | else | 1229 | else |
1225 | gfar_write(&priv->regs->txic, 0); | 1230 | gfar_write(&priv->regs->txic, 0); |
1226 | 1231 | ||
1227 | spin_unlock(&priv->lock); | 1232 | spin_unlock(&priv->txlock); |
1228 | 1233 | ||
1229 | return IRQ_HANDLED; | 1234 | return IRQ_HANDLED; |
1230 | } | 1235 | } |
@@ -1305,9 +1310,10 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs) | |||
1305 | { | 1310 | { |
1306 | struct net_device *dev = (struct net_device *) dev_id; | 1311 | struct net_device *dev = (struct net_device *) dev_id; |
1307 | struct gfar_private *priv = netdev_priv(dev); | 1312 | struct gfar_private *priv = netdev_priv(dev); |
1308 | |||
1309 | #ifdef CONFIG_GFAR_NAPI | 1313 | #ifdef CONFIG_GFAR_NAPI |
1310 | u32 tempval; | 1314 | u32 tempval; |
1315 | #else | ||
1316 | unsigned long flags; | ||
1311 | #endif | 1317 | #endif |
1312 | 1318 | ||
1313 | /* Clear IEVENT, so rx interrupt isn't called again | 1319 | /* Clear IEVENT, so rx interrupt isn't called again |
@@ -1330,7 +1336,7 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs) | |||
1330 | } | 1336 | } |
1331 | #else | 1337 | #else |
1332 | 1338 | ||
1333 | spin_lock(&priv->lock); | 1339 | spin_lock_irqsave(&priv->rxlock, flags); |
1334 | gfar_clean_rx_ring(dev, priv->rx_ring_size); | 1340 | gfar_clean_rx_ring(dev, priv->rx_ring_size); |
1335 | 1341 | ||
1336 | /* If we are coalescing interrupts, update the timer */ | 1342 | /* If we are coalescing interrupts, update the timer */ |
@@ -1341,7 +1347,7 @@ irqreturn_t gfar_receive(int irq, void *dev_id, struct pt_regs *regs) | |||
1341 | else | 1347 | else |
1342 | gfar_write(&priv->regs->rxic, 0); | 1348 | gfar_write(&priv->regs->rxic, 0); |
1343 | 1349 | ||
1344 | spin_unlock(&priv->lock); | 1350 | spin_unlock_irqrestore(&priv->rxlock, flags); |
1345 | #endif | 1351 | #endif |
1346 | 1352 | ||
1347 | return IRQ_HANDLED; | 1353 | return IRQ_HANDLED; |
@@ -1490,13 +1496,6 @@ int gfar_clean_rx_ring(struct net_device *dev, int rx_work_limit) | |||
1490 | /* Update the current rxbd pointer to be the next one */ | 1496 | /* Update the current rxbd pointer to be the next one */ |
1491 | priv->cur_rx = bdp; | 1497 | priv->cur_rx = bdp; |
1492 | 1498 | ||
1493 | /* If no packets have arrived since the | ||
1494 | * last one we processed, clear the IEVENT RX and | ||
1495 | * BSY bits so that another interrupt won't be | ||
1496 | * generated when we set IMASK */ | ||
1497 | if (bdp->status & RXBD_EMPTY) | ||
1498 | gfar_write(&priv->regs->ievent, IEVENT_RX_MASK); | ||
1499 | |||
1500 | return howmany; | 1499 | return howmany; |
1501 | } | 1500 | } |
1502 | 1501 | ||
@@ -1516,7 +1515,7 @@ static int gfar_poll(struct net_device *dev, int *budget) | |||
1516 | rx_work_limit -= howmany; | 1515 | rx_work_limit -= howmany; |
1517 | *budget -= howmany; | 1516 | *budget -= howmany; |
1518 | 1517 | ||
1519 | if (rx_work_limit >= 0) { | 1518 | if (rx_work_limit > 0) { |
1520 | netif_rx_complete(dev); | 1519 | netif_rx_complete(dev); |
1521 | 1520 | ||
1522 | /* Clear the halt bit in RSTAT */ | 1521 | /* Clear the halt bit in RSTAT */ |
@@ -1533,7 +1532,8 @@ static int gfar_poll(struct net_device *dev, int *budget) | |||
1533 | gfar_write(&priv->regs->rxic, 0); | 1532 | gfar_write(&priv->regs->rxic, 0); |
1534 | } | 1533 | } |
1535 | 1534 | ||
1536 | return (rx_work_limit < 0) ? 1 : 0; | 1535 | /* Return 1 if there's more work to do */ |
1536 | return (rx_work_limit > 0) ? 0 : 1; | ||
1537 | } | 1537 | } |
1538 | #endif | 1538 | #endif |
1539 | 1539 | ||
@@ -1629,7 +1629,7 @@ static void adjust_link(struct net_device *dev) | |||
1629 | struct phy_device *phydev = priv->phydev; | 1629 | struct phy_device *phydev = priv->phydev; |
1630 | int new_state = 0; | 1630 | int new_state = 0; |
1631 | 1631 | ||
1632 | spin_lock_irqsave(&priv->lock, flags); | 1632 | spin_lock_irqsave(&priv->txlock, flags); |
1633 | if (phydev->link) { | 1633 | if (phydev->link) { |
1634 | u32 tempval = gfar_read(®s->maccfg2); | 1634 | u32 tempval = gfar_read(®s->maccfg2); |
1635 | u32 ecntrl = gfar_read(®s->ecntrl); | 1635 | u32 ecntrl = gfar_read(®s->ecntrl); |
@@ -1694,7 +1694,7 @@ static void adjust_link(struct net_device *dev) | |||
1694 | if (new_state && netif_msg_link(priv)) | 1694 | if (new_state && netif_msg_link(priv)) |
1695 | phy_print_status(phydev); | 1695 | phy_print_status(phydev); |
1696 | 1696 | ||
1697 | spin_unlock_irqrestore(&priv->lock, flags); | 1697 | spin_unlock_irqrestore(&priv->txlock, flags); |
1698 | } | 1698 | } |
1699 | 1699 | ||
1700 | /* Update the hash table based on the current list of multicast | 1700 | /* Update the hash table based on the current list of multicast |
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h index d37d5401be6e..127c98cf3336 100644 --- a/drivers/net/gianfar.h +++ b/drivers/net/gianfar.h | |||
@@ -656,43 +656,62 @@ struct gfar { | |||
656 | * the buffer descriptor determines the actual condition. | 656 | * the buffer descriptor determines the actual condition. |
657 | */ | 657 | */ |
658 | struct gfar_private { | 658 | struct gfar_private { |
659 | /* pointers to arrays of skbuffs for tx and rx */ | 659 | /* Fields controlled by TX lock */ |
660 | spinlock_t txlock; | ||
661 | |||
662 | /* Pointer to the array of skbuffs */ | ||
660 | struct sk_buff ** tx_skbuff; | 663 | struct sk_buff ** tx_skbuff; |
661 | struct sk_buff ** rx_skbuff; | ||
662 | 664 | ||
663 | /* indices pointing to the next free sbk in skb arrays */ | 665 | /* next free skb in the array */ |
664 | u16 skb_curtx; | 666 | u16 skb_curtx; |
665 | u16 skb_currx; | ||
666 | 667 | ||
667 | /* index of the first skb which hasn't been transmitted | 668 | /* First skb in line to be transmitted */ |
668 | * yet. */ | ||
669 | u16 skb_dirtytx; | 669 | u16 skb_dirtytx; |
670 | 670 | ||
671 | /* Configuration info for the coalescing features */ | 671 | /* Configuration info for the coalescing features */ |
672 | unsigned char txcoalescing; | 672 | unsigned char txcoalescing; |
673 | unsigned short txcount; | 673 | unsigned short txcount; |
674 | unsigned short txtime; | 674 | unsigned short txtime; |
675 | |||
676 | /* Buffer descriptor pointers */ | ||
677 | struct txbd8 *tx_bd_base; /* First tx buffer descriptor */ | ||
678 | struct txbd8 *cur_tx; /* Next free ring entry */ | ||
679 | struct txbd8 *dirty_tx; /* First buffer in line | ||
680 | to be transmitted */ | ||
681 | unsigned int tx_ring_size; | ||
682 | |||
683 | /* RX Locked fields */ | ||
684 | spinlock_t rxlock; | ||
685 | |||
686 | /* skb array and index */ | ||
687 | struct sk_buff ** rx_skbuff; | ||
688 | u16 skb_currx; | ||
689 | |||
690 | /* RX Coalescing values */ | ||
675 | unsigned char rxcoalescing; | 691 | unsigned char rxcoalescing; |
676 | unsigned short rxcount; | 692 | unsigned short rxcount; |
677 | unsigned short rxtime; | 693 | unsigned short rxtime; |
678 | 694 | ||
679 | /* GFAR addresses */ | 695 | struct rxbd8 *rx_bd_base; /* First Rx buffers */ |
680 | struct rxbd8 *rx_bd_base; /* Base addresses of Rx and Tx Buffers */ | ||
681 | struct txbd8 *tx_bd_base; | ||
682 | struct rxbd8 *cur_rx; /* Next free rx ring entry */ | 696 | struct rxbd8 *cur_rx; /* Next free rx ring entry */ |
683 | struct txbd8 *cur_tx; /* Next free ring entry */ | 697 | |
684 | struct txbd8 *dirty_tx; /* The Ring entry to be freed. */ | 698 | /* RX parameters */ |
685 | struct gfar __iomem *regs; /* Pointer to the GFAR memory mapped Registers */ | 699 | unsigned int rx_ring_size; |
686 | u32 __iomem *hash_regs[16]; | ||
687 | int hash_width; | ||
688 | struct net_device_stats stats; /* linux network statistics */ | ||
689 | struct gfar_extra_stats extra_stats; | ||
690 | spinlock_t lock; | ||
691 | unsigned int rx_buffer_size; | 700 | unsigned int rx_buffer_size; |
692 | unsigned int rx_stash_size; | 701 | unsigned int rx_stash_size; |
693 | unsigned int rx_stash_index; | 702 | unsigned int rx_stash_index; |
694 | unsigned int tx_ring_size; | 703 | |
695 | unsigned int rx_ring_size; | 704 | struct vlan_group *vlgrp; |
705 | |||
706 | /* Unprotected fields */ | ||
707 | /* Pointer to the GFAR memory mapped Registers */ | ||
708 | struct gfar __iomem *regs; | ||
709 | |||
710 | /* Hash registers and their width */ | ||
711 | u32 __iomem *hash_regs[16]; | ||
712 | int hash_width; | ||
713 | |||
714 | /* global parameters */ | ||
696 | unsigned int fifo_threshold; | 715 | unsigned int fifo_threshold; |
697 | unsigned int fifo_starve; | 716 | unsigned int fifo_starve; |
698 | unsigned int fifo_starve_off; | 717 | unsigned int fifo_starve_off; |
@@ -702,13 +721,15 @@ struct gfar_private { | |||
702 | extended_hash:1, | 721 | extended_hash:1, |
703 | bd_stash_en:1; | 722 | bd_stash_en:1; |
704 | unsigned short padding; | 723 | unsigned short padding; |
705 | struct vlan_group *vlgrp; | 724 | |
706 | /* Info structure initialized by board setup code */ | ||
707 | unsigned int interruptTransmit; | 725 | unsigned int interruptTransmit; |
708 | unsigned int interruptReceive; | 726 | unsigned int interruptReceive; |
709 | unsigned int interruptError; | 727 | unsigned int interruptError; |
728 | |||
729 | /* info structure initialized by platform code */ | ||
710 | struct gianfar_platform_data *einfo; | 730 | struct gianfar_platform_data *einfo; |
711 | 731 | ||
732 | /* PHY stuff */ | ||
712 | struct phy_device *phydev; | 733 | struct phy_device *phydev; |
713 | struct mii_bus *mii_bus; | 734 | struct mii_bus *mii_bus; |
714 | int oldspeed; | 735 | int oldspeed; |
@@ -716,6 +737,10 @@ struct gfar_private { | |||
716 | int oldlink; | 737 | int oldlink; |
717 | 738 | ||
718 | uint32_t msg_enable; | 739 | uint32_t msg_enable; |
740 | |||
741 | /* Network Statistics */ | ||
742 | struct net_device_stats stats; | ||
743 | struct gfar_extra_stats extra_stats; | ||
719 | }; | 744 | }; |
720 | 745 | ||
721 | static inline u32 gfar_read(volatile unsigned __iomem *addr) | 746 | static inline u32 gfar_read(volatile unsigned __iomem *addr) |
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c index 5de7b2e259dc..d69698c695ef 100644 --- a/drivers/net/gianfar_ethtool.c +++ b/drivers/net/gianfar_ethtool.c | |||
@@ -455,10 +455,14 @@ static int gfar_sringparam(struct net_device *dev, struct ethtool_ringparam *rva | |||
455 | 455 | ||
456 | /* Halt TX and RX, and process the frames which | 456 | /* Halt TX and RX, and process the frames which |
457 | * have already been received */ | 457 | * have already been received */ |
458 | spin_lock_irqsave(&priv->lock, flags); | 458 | spin_lock_irqsave(&priv->txlock, flags); |
459 | spin_lock(&priv->rxlock); | ||
460 | |||
459 | gfar_halt(dev); | 461 | gfar_halt(dev); |
460 | gfar_clean_rx_ring(dev, priv->rx_ring_size); | 462 | gfar_clean_rx_ring(dev, priv->rx_ring_size); |
461 | spin_unlock_irqrestore(&priv->lock, flags); | 463 | |
464 | spin_unlock(&priv->rxlock); | ||
465 | spin_unlock_irqrestore(&priv->txlock, flags); | ||
462 | 466 | ||
463 | /* Now we take down the rings to rebuild them */ | 467 | /* Now we take down the rings to rebuild them */ |
464 | stop_gfar(dev); | 468 | stop_gfar(dev); |
@@ -488,10 +492,14 @@ static int gfar_set_rx_csum(struct net_device *dev, uint32_t data) | |||
488 | 492 | ||
489 | /* Halt TX and RX, and process the frames which | 493 | /* Halt TX and RX, and process the frames which |
490 | * have already been received */ | 494 | * have already been received */ |
491 | spin_lock_irqsave(&priv->lock, flags); | 495 | spin_lock_irqsave(&priv->txlock, flags); |
496 | spin_lock(&priv->rxlock); | ||
497 | |||
492 | gfar_halt(dev); | 498 | gfar_halt(dev); |
493 | gfar_clean_rx_ring(dev, priv->rx_ring_size); | 499 | gfar_clean_rx_ring(dev, priv->rx_ring_size); |
494 | spin_unlock_irqrestore(&priv->lock, flags); | 500 | |
501 | spin_unlock(&priv->rxlock); | ||
502 | spin_unlock_irqrestore(&priv->txlock, flags); | ||
495 | 503 | ||
496 | /* Now we take down the rings to rebuild them */ | 504 | /* Now we take down the rings to rebuild them */ |
497 | stop_gfar(dev); | 505 | stop_gfar(dev); |
@@ -523,7 +531,7 @@ static int gfar_set_tx_csum(struct net_device *dev, uint32_t data) | |||
523 | if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) | 531 | if (!(priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_CSUM)) |
524 | return -EOPNOTSUPP; | 532 | return -EOPNOTSUPP; |
525 | 533 | ||
526 | spin_lock_irqsave(&priv->lock, flags); | 534 | spin_lock_irqsave(&priv->txlock, flags); |
527 | gfar_halt(dev); | 535 | gfar_halt(dev); |
528 | 536 | ||
529 | if (data) | 537 | if (data) |
@@ -532,7 +540,7 @@ static int gfar_set_tx_csum(struct net_device *dev, uint32_t data) | |||
532 | dev->features &= ~NETIF_F_IP_CSUM; | 540 | dev->features &= ~NETIF_F_IP_CSUM; |
533 | 541 | ||
534 | gfar_start(dev); | 542 | gfar_start(dev); |
535 | spin_unlock_irqrestore(&priv->lock, flags); | 543 | spin_unlock_irqrestore(&priv->txlock, flags); |
536 | 544 | ||
537 | return 0; | 545 | return 0; |
538 | } | 546 | } |
diff --git a/drivers/net/gianfar_sysfs.c b/drivers/net/gianfar_sysfs.c index 51ef181b1368..a6d5c43199cb 100644 --- a/drivers/net/gianfar_sysfs.c +++ b/drivers/net/gianfar_sysfs.c | |||
@@ -82,7 +82,7 @@ static ssize_t gfar_set_bd_stash(struct class_device *cdev, | |||
82 | else | 82 | else |
83 | return count; | 83 | return count; |
84 | 84 | ||
85 | spin_lock_irqsave(&priv->lock, flags); | 85 | spin_lock_irqsave(&priv->rxlock, flags); |
86 | 86 | ||
87 | /* Set the new stashing value */ | 87 | /* Set the new stashing value */ |
88 | priv->bd_stash_en = new_setting; | 88 | priv->bd_stash_en = new_setting; |
@@ -96,7 +96,7 @@ static ssize_t gfar_set_bd_stash(struct class_device *cdev, | |||
96 | 96 | ||
97 | gfar_write(&priv->regs->attr, temp); | 97 | gfar_write(&priv->regs->attr, temp); |
98 | 98 | ||
99 | spin_unlock_irqrestore(&priv->lock, flags); | 99 | spin_unlock_irqrestore(&priv->rxlock, flags); |
100 | 100 | ||
101 | return count; | 101 | return count; |
102 | } | 102 | } |
@@ -118,7 +118,7 @@ static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, | |||
118 | u32 temp; | 118 | u32 temp; |
119 | unsigned long flags; | 119 | unsigned long flags; |
120 | 120 | ||
121 | spin_lock_irqsave(&priv->lock, flags); | 121 | spin_lock_irqsave(&priv->rxlock, flags); |
122 | if (length > priv->rx_buffer_size) | 122 | if (length > priv->rx_buffer_size) |
123 | return count; | 123 | return count; |
124 | 124 | ||
@@ -142,7 +142,7 @@ static ssize_t gfar_set_rx_stash_size(struct class_device *cdev, | |||
142 | 142 | ||
143 | gfar_write(&priv->regs->attr, temp); | 143 | gfar_write(&priv->regs->attr, temp); |
144 | 144 | ||
145 | spin_unlock_irqrestore(&priv->lock, flags); | 145 | spin_unlock_irqrestore(&priv->rxlock, flags); |
146 | 146 | ||
147 | return count; | 147 | return count; |
148 | } | 148 | } |
@@ -166,7 +166,7 @@ static ssize_t gfar_set_rx_stash_index(struct class_device *cdev, | |||
166 | u32 temp; | 166 | u32 temp; |
167 | unsigned long flags; | 167 | unsigned long flags; |
168 | 168 | ||
169 | spin_lock_irqsave(&priv->lock, flags); | 169 | spin_lock_irqsave(&priv->rxlock, flags); |
170 | if (index > priv->rx_stash_size) | 170 | if (index > priv->rx_stash_size) |
171 | return count; | 171 | return count; |
172 | 172 | ||
@@ -180,7 +180,7 @@ static ssize_t gfar_set_rx_stash_index(struct class_device *cdev, | |||
180 | temp |= ATTRELI_EI(index); | 180 | temp |= ATTRELI_EI(index); |
181 | gfar_write(&priv->regs->attreli, flags); | 181 | gfar_write(&priv->regs->attreli, flags); |
182 | 182 | ||
183 | spin_unlock_irqrestore(&priv->lock, flags); | 183 | spin_unlock_irqrestore(&priv->rxlock, flags); |
184 | 184 | ||
185 | return count; | 185 | return count; |
186 | } | 186 | } |
@@ -205,7 +205,7 @@ static ssize_t gfar_set_fifo_threshold(struct class_device *cdev, | |||
205 | if (length > GFAR_MAX_FIFO_THRESHOLD) | 205 | if (length > GFAR_MAX_FIFO_THRESHOLD) |
206 | return count; | 206 | return count; |
207 | 207 | ||
208 | spin_lock_irqsave(&priv->lock, flags); | 208 | spin_lock_irqsave(&priv->txlock, flags); |
209 | 209 | ||
210 | priv->fifo_threshold = length; | 210 | priv->fifo_threshold = length; |
211 | 211 | ||
@@ -214,7 +214,7 @@ static ssize_t gfar_set_fifo_threshold(struct class_device *cdev, | |||
214 | temp |= length; | 214 | temp |= length; |
215 | gfar_write(&priv->regs->fifo_tx_thr, temp); | 215 | gfar_write(&priv->regs->fifo_tx_thr, temp); |
216 | 216 | ||
217 | spin_unlock_irqrestore(&priv->lock, flags); | 217 | spin_unlock_irqrestore(&priv->txlock, flags); |
218 | 218 | ||
219 | return count; | 219 | return count; |
220 | } | 220 | } |
@@ -240,7 +240,7 @@ static ssize_t gfar_set_fifo_starve(struct class_device *cdev, | |||
240 | if (num > GFAR_MAX_FIFO_STARVE) | 240 | if (num > GFAR_MAX_FIFO_STARVE) |
241 | return count; | 241 | return count; |
242 | 242 | ||
243 | spin_lock_irqsave(&priv->lock, flags); | 243 | spin_lock_irqsave(&priv->txlock, flags); |
244 | 244 | ||
245 | priv->fifo_starve = num; | 245 | priv->fifo_starve = num; |
246 | 246 | ||
@@ -249,7 +249,7 @@ static ssize_t gfar_set_fifo_starve(struct class_device *cdev, | |||
249 | temp |= num; | 249 | temp |= num; |
250 | gfar_write(&priv->regs->fifo_tx_starve, temp); | 250 | gfar_write(&priv->regs->fifo_tx_starve, temp); |
251 | 251 | ||
252 | spin_unlock_irqrestore(&priv->lock, flags); | 252 | spin_unlock_irqrestore(&priv->txlock, flags); |
253 | 253 | ||
254 | return count; | 254 | return count; |
255 | } | 255 | } |
@@ -274,7 +274,7 @@ static ssize_t gfar_set_fifo_starve_off(struct class_device *cdev, | |||
274 | if (num > GFAR_MAX_FIFO_STARVE_OFF) | 274 | if (num > GFAR_MAX_FIFO_STARVE_OFF) |
275 | return count; | 275 | return count; |
276 | 276 | ||
277 | spin_lock_irqsave(&priv->lock, flags); | 277 | spin_lock_irqsave(&priv->txlock, flags); |
278 | 278 | ||
279 | priv->fifo_starve_off = num; | 279 | priv->fifo_starve_off = num; |
280 | 280 | ||
@@ -283,7 +283,7 @@ static ssize_t gfar_set_fifo_starve_off(struct class_device *cdev, | |||
283 | temp |= num; | 283 | temp |= num; |
284 | gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); | 284 | gfar_write(&priv->regs->fifo_tx_starve_shutoff, temp); |
285 | 285 | ||
286 | spin_unlock_irqrestore(&priv->lock, flags); | 286 | spin_unlock_irqrestore(&priv->txlock, flags); |
287 | 287 | ||
288 | return count; | 288 | return count; |
289 | } | 289 | } |
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index ea62a3e7d586..411f4d809c47 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -1419,6 +1419,8 @@ static int mv643xx_eth_probe(struct platform_device *pdev) | |||
1419 | mv643xx_eth_update_pscr(dev, &cmd); | 1419 | mv643xx_eth_update_pscr(dev, &cmd); |
1420 | mv643xx_set_settings(dev, &cmd); | 1420 | mv643xx_set_settings(dev, &cmd); |
1421 | 1421 | ||
1422 | SET_MODULE_OWNER(dev); | ||
1423 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
1422 | err = register_netdev(dev); | 1424 | err = register_netdev(dev); |
1423 | if (err) | 1425 | if (err) |
1424 | goto out; | 1426 | goto out; |
diff --git a/drivers/net/ne.c b/drivers/net/ne.c index 08b218c5bfbc..93c494bcd18d 100644 --- a/drivers/net/ne.c +++ b/drivers/net/ne.c | |||
@@ -226,7 +226,7 @@ struct net_device * __init ne_probe(int unit) | |||
226 | netdev_boot_setup_check(dev); | 226 | netdev_boot_setup_check(dev); |
227 | 227 | ||
228 | #ifdef CONFIG_TOSHIBA_RBTX4938 | 228 | #ifdef CONFIG_TOSHIBA_RBTX4938 |
229 | dev->base_addr = 0x07f20280; | 229 | dev->base_addr = RBTX4938_RTL_8019_BASE; |
230 | dev->irq = RBTX4938_RTL_8019_IRQ; | 230 | dev->irq = RBTX4938_RTL_8019_IRQ; |
231 | #endif | 231 | #endif |
232 | err = do_ne_probe(dev); | 232 | err = do_ne_probe(dev); |
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c index 506e777c5f06..d090df413049 100644 --- a/drivers/net/pcmcia/pcnet_cs.c +++ b/drivers/net/pcmcia/pcnet_cs.c | |||
@@ -1639,6 +1639,7 @@ static struct pcmcia_device_id pcnet_ids[] = { | |||
1639 | PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722), | 1639 | PCMCIA_DEVICE_PROD_ID12("CONTEC", "C-NET(PC)C-10L", 0x21cab552, 0xf6f90722), |
1640 | PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2), | 1640 | PCMCIA_DEVICE_PROD_ID12("corega", "FEther PCC-TXF", 0x0a21501a, 0xa51564a2), |
1641 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd), | 1641 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-T", 0x5261440f, 0xfa9d85bd), |
1642 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega EtherII PCC-TD", 0x5261440f, 0xc49bd73d), | ||
1642 | PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), | 1643 | PCMCIA_DEVICE_PROD_ID12("Corega K.K.", "corega EtherII PCC-TD", 0xd4fdcbd8, 0xc49bd73d), |
1643 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa), | 1644 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega Ether PCC-T", 0x5261440f, 0x6705fcaa), |
1644 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9), | 1645 | PCMCIA_DEVICE_PROD_ID12("corega K.K.", "corega FastEther PCC-TX", 0x5261440f, 0x485e85d9), |
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 67b0eab16589..227df9876a2c 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -51,7 +51,7 @@ | |||
51 | #include "sky2.h" | 51 | #include "sky2.h" |
52 | 52 | ||
53 | #define DRV_NAME "sky2" | 53 | #define DRV_NAME "sky2" |
54 | #define DRV_VERSION "1.1" | 54 | #define DRV_VERSION "1.2" |
55 | #define PFX DRV_NAME " " | 55 | #define PFX DRV_NAME " " |
56 | 56 | ||
57 | /* | 57 | /* |
@@ -925,8 +925,7 @@ static inline struct sk_buff *sky2_alloc_skb(unsigned int size, gfp_t gfp_mask) | |||
925 | skb = alloc_skb(size + RX_SKB_ALIGN, gfp_mask); | 925 | skb = alloc_skb(size + RX_SKB_ALIGN, gfp_mask); |
926 | if (likely(skb)) { | 926 | if (likely(skb)) { |
927 | unsigned long p = (unsigned long) skb->data; | 927 | unsigned long p = (unsigned long) skb->data; |
928 | skb_reserve(skb, | 928 | skb_reserve(skb, ALIGN(p, RX_SKB_ALIGN) - p); |
929 | ((p + RX_SKB_ALIGN - 1) & ~(RX_SKB_ALIGN - 1)) - p); | ||
930 | } | 929 | } |
931 | 930 | ||
932 | return skb; | 931 | return skb; |
@@ -1686,13 +1685,12 @@ static void sky2_tx_timeout(struct net_device *dev) | |||
1686 | } | 1685 | } |
1687 | 1686 | ||
1688 | 1687 | ||
1689 | #define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) | ||
1690 | /* Want receive buffer size to be multiple of 64 bits | 1688 | /* Want receive buffer size to be multiple of 64 bits |
1691 | * and incl room for vlan and truncation | 1689 | * and incl room for vlan and truncation |
1692 | */ | 1690 | */ |
1693 | static inline unsigned sky2_buf_size(int mtu) | 1691 | static inline unsigned sky2_buf_size(int mtu) |
1694 | { | 1692 | { |
1695 | return roundup(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8; | 1693 | return ALIGN(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8; |
1696 | } | 1694 | } |
1697 | 1695 | ||
1698 | static int sky2_change_mtu(struct net_device *dev, int new_mtu) | 1696 | static int sky2_change_mtu(struct net_device *dev, int new_mtu) |
@@ -2086,6 +2084,20 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port, | |||
2086 | } | 2084 | } |
2087 | } | 2085 | } |
2088 | 2086 | ||
2087 | /* If idle then force a fake soft NAPI poll once a second | ||
2088 | * to work around cases where sharing an edge triggered interrupt. | ||
2089 | */ | ||
2090 | static void sky2_idle(unsigned long arg) | ||
2091 | { | ||
2092 | struct net_device *dev = (struct net_device *) arg; | ||
2093 | |||
2094 | local_irq_disable(); | ||
2095 | if (__netif_rx_schedule_prep(dev)) | ||
2096 | __netif_rx_schedule(dev); | ||
2097 | local_irq_enable(); | ||
2098 | } | ||
2099 | |||
2100 | |||
2089 | static int sky2_poll(struct net_device *dev0, int *budget) | 2101 | static int sky2_poll(struct net_device *dev0, int *budget) |
2090 | { | 2102 | { |
2091 | struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw; | 2103 | struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw; |
@@ -2093,6 +2105,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
2093 | int work_done = 0; | 2105 | int work_done = 0; |
2094 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); | 2106 | u32 status = sky2_read32(hw, B0_Y2_SP_EISR); |
2095 | 2107 | ||
2108 | restart_poll: | ||
2096 | if (unlikely(status & ~Y2_IS_STAT_BMU)) { | 2109 | if (unlikely(status & ~Y2_IS_STAT_BMU)) { |
2097 | if (status & Y2_IS_HW_ERR) | 2110 | if (status & Y2_IS_HW_ERR) |
2098 | sky2_hw_intr(hw); | 2111 | sky2_hw_intr(hw); |
@@ -2123,7 +2136,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
2123 | } | 2136 | } |
2124 | 2137 | ||
2125 | if (status & Y2_IS_STAT_BMU) { | 2138 | if (status & Y2_IS_STAT_BMU) { |
2126 | work_done = sky2_status_intr(hw, work_limit); | 2139 | work_done += sky2_status_intr(hw, work_limit - work_done); |
2127 | *budget -= work_done; | 2140 | *budget -= work_done; |
2128 | dev0->quota -= work_done; | 2141 | dev0->quota -= work_done; |
2129 | 2142 | ||
@@ -2133,9 +2146,24 @@ static int sky2_poll(struct net_device *dev0, int *budget) | |||
2133 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); | 2146 | sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); |
2134 | } | 2147 | } |
2135 | 2148 | ||
2136 | netif_rx_complete(dev0); | 2149 | mod_timer(&hw->idle_timer, jiffies + HZ); |
2150 | |||
2151 | local_irq_disable(); | ||
2152 | __netif_rx_complete(dev0); | ||
2137 | 2153 | ||
2138 | status = sky2_read32(hw, B0_Y2_SP_LISR); | 2154 | status = sky2_read32(hw, B0_Y2_SP_LISR); |
2155 | |||
2156 | if (unlikely(status)) { | ||
2157 | /* More work pending, try and keep going */ | ||
2158 | if (__netif_rx_schedule_prep(dev0)) { | ||
2159 | __netif_rx_reschedule(dev0, work_done); | ||
2160 | status = sky2_read32(hw, B0_Y2_SP_EISR); | ||
2161 | local_irq_enable(); | ||
2162 | goto restart_poll; | ||
2163 | } | ||
2164 | } | ||
2165 | |||
2166 | local_irq_enable(); | ||
2139 | return 0; | 2167 | return 0; |
2140 | } | 2168 | } |
2141 | 2169 | ||
@@ -2153,8 +2181,6 @@ static irqreturn_t sky2_intr(int irq, void *dev_id, struct pt_regs *regs) | |||
2153 | prefetch(&hw->st_le[hw->st_idx]); | 2181 | prefetch(&hw->st_le[hw->st_idx]); |
2154 | if (likely(__netif_rx_schedule_prep(dev0))) | 2182 | if (likely(__netif_rx_schedule_prep(dev0))) |
2155 | __netif_rx_schedule(dev0); | 2183 | __netif_rx_schedule(dev0); |
2156 | else | ||
2157 | printk(KERN_DEBUG PFX "irq race detected\n"); | ||
2158 | 2184 | ||
2159 | return IRQ_HANDLED; | 2185 | return IRQ_HANDLED; |
2160 | } | 2186 | } |
@@ -2193,7 +2219,7 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk) | |||
2193 | } | 2219 | } |
2194 | 2220 | ||
2195 | 2221 | ||
2196 | static int sky2_reset(struct sky2_hw *hw) | 2222 | static int __devinit sky2_reset(struct sky2_hw *hw) |
2197 | { | 2223 | { |
2198 | u16 status; | 2224 | u16 status; |
2199 | u8 t8, pmd_type; | 2225 | u8 t8, pmd_type; |
@@ -3276,6 +3302,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev, | |||
3276 | 3302 | ||
3277 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); | 3303 | sky2_write32(hw, B0_IMSK, Y2_IS_BASE); |
3278 | 3304 | ||
3305 | setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) dev); | ||
3306 | |||
3279 | pci_set_drvdata(pdev, hw); | 3307 | pci_set_drvdata(pdev, hw); |
3280 | 3308 | ||
3281 | return 0; | 3309 | return 0; |
@@ -3311,13 +3339,15 @@ static void __devexit sky2_remove(struct pci_dev *pdev) | |||
3311 | if (!hw) | 3339 | if (!hw) |
3312 | return; | 3340 | return; |
3313 | 3341 | ||
3342 | del_timer_sync(&hw->idle_timer); | ||
3343 | |||
3344 | sky2_write32(hw, B0_IMSK, 0); | ||
3314 | dev0 = hw->dev[0]; | 3345 | dev0 = hw->dev[0]; |
3315 | dev1 = hw->dev[1]; | 3346 | dev1 = hw->dev[1]; |
3316 | if (dev1) | 3347 | if (dev1) |
3317 | unregister_netdev(dev1); | 3348 | unregister_netdev(dev1); |
3318 | unregister_netdev(dev0); | 3349 | unregister_netdev(dev0); |
3319 | 3350 | ||
3320 | sky2_write32(hw, B0_IMSK, 0); | ||
3321 | sky2_set_power_state(hw, PCI_D3hot); | 3351 | sky2_set_power_state(hw, PCI_D3hot); |
3322 | sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); | 3352 | sky2_write16(hw, B0_Y2LED, LED_STAT_OFF); |
3323 | sky2_write8(hw, B0_CTST, CS_RST_SET); | 3353 | sky2_write8(hw, B0_CTST, CS_RST_SET); |
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 89dd18cd12f0..b026f5653f04 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h | |||
@@ -1880,6 +1880,8 @@ struct sky2_hw { | |||
1880 | struct sky2_status_le *st_le; | 1880 | struct sky2_status_le *st_le; |
1881 | u32 st_idx; | 1881 | u32 st_idx; |
1882 | dma_addr_t st_dma; | 1882 | dma_addr_t st_dma; |
1883 | |||
1884 | struct timer_list idle_timer; | ||
1883 | int msi_detected; | 1885 | int msi_detected; |
1884 | wait_queue_head_t msi_wait; | 1886 | wait_queue_head_t msi_wait; |
1885 | }; | 1887 | }; |
diff --git a/drivers/net/sungem_phy.c b/drivers/net/sungem_phy.c index cb0aba95d4e3..046371ee5bbe 100644 --- a/drivers/net/sungem_phy.c +++ b/drivers/net/sungem_phy.c | |||
@@ -275,7 +275,7 @@ static int bcm5411_init(struct mii_phy* phy) | |||
275 | return 0; | 275 | return 0; |
276 | } | 276 | } |
277 | 277 | ||
278 | static int bcm5411_suspend(struct mii_phy* phy) | 278 | static int generic_suspend(struct mii_phy* phy) |
279 | { | 279 | { |
280 | phy_write(phy, MII_BMCR, BMCR_PDOWN); | 280 | phy_write(phy, MII_BMCR, BMCR_PDOWN); |
281 | 281 | ||
@@ -738,7 +738,7 @@ static struct mii_phy_def bcm5401_phy_def = { | |||
738 | /* Broadcom BCM 5411 */ | 738 | /* Broadcom BCM 5411 */ |
739 | static struct mii_phy_ops bcm5411_phy_ops = { | 739 | static struct mii_phy_ops bcm5411_phy_ops = { |
740 | .init = bcm5411_init, | 740 | .init = bcm5411_init, |
741 | .suspend = bcm5411_suspend, | 741 | .suspend = generic_suspend, |
742 | .setup_aneg = bcm54xx_setup_aneg, | 742 | .setup_aneg = bcm54xx_setup_aneg, |
743 | .setup_forced = bcm54xx_setup_forced, | 743 | .setup_forced = bcm54xx_setup_forced, |
744 | .poll_link = genmii_poll_link, | 744 | .poll_link = genmii_poll_link, |
@@ -757,7 +757,7 @@ static struct mii_phy_def bcm5411_phy_def = { | |||
757 | /* Broadcom BCM 5421 */ | 757 | /* Broadcom BCM 5421 */ |
758 | static struct mii_phy_ops bcm5421_phy_ops = { | 758 | static struct mii_phy_ops bcm5421_phy_ops = { |
759 | .init = bcm5421_init, | 759 | .init = bcm5421_init, |
760 | .suspend = bcm5411_suspend, | 760 | .suspend = generic_suspend, |
761 | .setup_aneg = bcm54xx_setup_aneg, | 761 | .setup_aneg = bcm54xx_setup_aneg, |
762 | .setup_forced = bcm54xx_setup_forced, | 762 | .setup_forced = bcm54xx_setup_forced, |
763 | .poll_link = genmii_poll_link, | 763 | .poll_link = genmii_poll_link, |
@@ -776,7 +776,7 @@ static struct mii_phy_def bcm5421_phy_def = { | |||
776 | /* Broadcom BCM 5421 built-in K2 */ | 776 | /* Broadcom BCM 5421 built-in K2 */ |
777 | static struct mii_phy_ops bcm5421k2_phy_ops = { | 777 | static struct mii_phy_ops bcm5421k2_phy_ops = { |
778 | .init = bcm5421_init, | 778 | .init = bcm5421_init, |
779 | .suspend = bcm5411_suspend, | 779 | .suspend = generic_suspend, |
780 | .setup_aneg = bcm54xx_setup_aneg, | 780 | .setup_aneg = bcm54xx_setup_aneg, |
781 | .setup_forced = bcm54xx_setup_forced, | 781 | .setup_forced = bcm54xx_setup_forced, |
782 | .poll_link = genmii_poll_link, | 782 | .poll_link = genmii_poll_link, |
@@ -795,7 +795,7 @@ static struct mii_phy_def bcm5421k2_phy_def = { | |||
795 | /* Broadcom BCM 5462 built-in Vesta */ | 795 | /* Broadcom BCM 5462 built-in Vesta */ |
796 | static struct mii_phy_ops bcm5462V_phy_ops = { | 796 | static struct mii_phy_ops bcm5462V_phy_ops = { |
797 | .init = bcm5421_init, | 797 | .init = bcm5421_init, |
798 | .suspend = bcm5411_suspend, | 798 | .suspend = generic_suspend, |
799 | .setup_aneg = bcm54xx_setup_aneg, | 799 | .setup_aneg = bcm54xx_setup_aneg, |
800 | .setup_forced = bcm54xx_setup_forced, | 800 | .setup_forced = bcm54xx_setup_forced, |
801 | .poll_link = genmii_poll_link, | 801 | .poll_link = genmii_poll_link, |
@@ -816,6 +816,7 @@ static struct mii_phy_def bcm5462V_phy_def = { | |||
816 | * would be useful here) --BenH. | 816 | * would be useful here) --BenH. |
817 | */ | 817 | */ |
818 | static struct mii_phy_ops marvell_phy_ops = { | 818 | static struct mii_phy_ops marvell_phy_ops = { |
819 | .suspend = generic_suspend, | ||
819 | .setup_aneg = marvell_setup_aneg, | 820 | .setup_aneg = marvell_setup_aneg, |
820 | .setup_forced = marvell_setup_forced, | 821 | .setup_forced = marvell_setup_forced, |
821 | .poll_link = genmii_poll_link, | 822 | .poll_link = genmii_poll_link, |
diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c index 73e271e59c6a..beeb612be98f 100644 --- a/drivers/net/tg3.c +++ b/drivers/net/tg3.c | |||
@@ -69,8 +69,8 @@ | |||
69 | 69 | ||
70 | #define DRV_MODULE_NAME "tg3" | 70 | #define DRV_MODULE_NAME "tg3" |
71 | #define PFX DRV_MODULE_NAME ": " | 71 | #define PFX DRV_MODULE_NAME ": " |
72 | #define DRV_MODULE_VERSION "3.56" | 72 | #define DRV_MODULE_VERSION "3.57" |
73 | #define DRV_MODULE_RELDATE "Apr 1, 2006" | 73 | #define DRV_MODULE_RELDATE "Apr 28, 2006" |
74 | 74 | ||
75 | #define TG3_DEF_MAC_MODE 0 | 75 | #define TG3_DEF_MAC_MODE 0 |
76 | #define TG3_DEF_RX_MODE 0 | 76 | #define TG3_DEF_RX_MODE 0 |
@@ -974,6 +974,8 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp) | |||
974 | return err; | 974 | return err; |
975 | } | 975 | } |
976 | 976 | ||
977 | static void tg3_link_report(struct tg3 *); | ||
978 | |||
977 | /* This will reset the tigon3 PHY if there is no valid | 979 | /* This will reset the tigon3 PHY if there is no valid |
978 | * link unless the FORCE argument is non-zero. | 980 | * link unless the FORCE argument is non-zero. |
979 | */ | 981 | */ |
@@ -987,6 +989,11 @@ static int tg3_phy_reset(struct tg3 *tp) | |||
987 | if (err != 0) | 989 | if (err != 0) |
988 | return -EBUSY; | 990 | return -EBUSY; |
989 | 991 | ||
992 | if (netif_running(tp->dev) && netif_carrier_ok(tp->dev)) { | ||
993 | netif_carrier_off(tp->dev); | ||
994 | tg3_link_report(tp); | ||
995 | } | ||
996 | |||
990 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || | 997 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5703 || |
991 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || | 998 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5704 || |
992 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) { | 999 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5705) { |
@@ -1023,6 +1030,12 @@ out: | |||
1023 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x14e2); | 1030 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x14e2); |
1024 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); | 1031 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); |
1025 | } | 1032 | } |
1033 | else if (tp->tg3_flags2 & TG3_FLG2_PHY_JITTER_BUG) { | ||
1034 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0c00); | ||
1035 | tg3_writephy(tp, MII_TG3_DSP_ADDRESS, 0x000a); | ||
1036 | tg3_writephy(tp, MII_TG3_DSP_RW_PORT, 0x010b); | ||
1037 | tg3_writephy(tp, MII_TG3_AUX_CTRL, 0x0400); | ||
1038 | } | ||
1026 | /* Set Extended packet length bit (bit 14) on all chips that */ | 1039 | /* Set Extended packet length bit (bit 14) on all chips that */ |
1027 | /* support jumbo frames */ | 1040 | /* support jumbo frames */ |
1028 | if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { | 1041 | if ((tp->phy_id & PHY_ID_MASK) == PHY_ID_BCM5401) { |
@@ -3531,7 +3544,7 @@ static irqreturn_t tg3_test_isr(int irq, void *dev_id, | |||
3531 | return IRQ_RETVAL(0); | 3544 | return IRQ_RETVAL(0); |
3532 | } | 3545 | } |
3533 | 3546 | ||
3534 | static int tg3_init_hw(struct tg3 *); | 3547 | static int tg3_init_hw(struct tg3 *, int); |
3535 | static int tg3_halt(struct tg3 *, int, int); | 3548 | static int tg3_halt(struct tg3 *, int, int); |
3536 | 3549 | ||
3537 | #ifdef CONFIG_NET_POLL_CONTROLLER | 3550 | #ifdef CONFIG_NET_POLL_CONTROLLER |
@@ -3567,7 +3580,7 @@ static void tg3_reset_task(void *_data) | |||
3567 | tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; | 3580 | tp->tg3_flags2 &= ~TG3_FLG2_RESTART_TIMER; |
3568 | 3581 | ||
3569 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); | 3582 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 0); |
3570 | tg3_init_hw(tp); | 3583 | tg3_init_hw(tp, 1); |
3571 | 3584 | ||
3572 | tg3_netif_start(tp); | 3585 | tg3_netif_start(tp); |
3573 | 3586 | ||
@@ -4042,7 +4055,7 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu) | |||
4042 | 4055 | ||
4043 | tg3_set_mtu(dev, tp, new_mtu); | 4056 | tg3_set_mtu(dev, tp, new_mtu); |
4044 | 4057 | ||
4045 | tg3_init_hw(tp); | 4058 | tg3_init_hw(tp, 0); |
4046 | 4059 | ||
4047 | tg3_netif_start(tp); | 4060 | tg3_netif_start(tp); |
4048 | 4061 | ||
@@ -5719,9 +5732,23 @@ static int tg3_set_mac_addr(struct net_device *dev, void *p) | |||
5719 | if (!netif_running(dev)) | 5732 | if (!netif_running(dev)) |
5720 | return 0; | 5733 | return 0; |
5721 | 5734 | ||
5722 | spin_lock_bh(&tp->lock); | 5735 | if (tp->tg3_flags & TG3_FLAG_ENABLE_ASF) { |
5723 | __tg3_set_mac_addr(tp); | 5736 | /* Reset chip so that ASF can re-init any MAC addresses it |
5724 | spin_unlock_bh(&tp->lock); | 5737 | * needs. |
5738 | */ | ||
5739 | tg3_netif_stop(tp); | ||
5740 | tg3_full_lock(tp, 1); | ||
5741 | |||
5742 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | ||
5743 | tg3_init_hw(tp, 0); | ||
5744 | |||
5745 | tg3_netif_start(tp); | ||
5746 | tg3_full_unlock(tp); | ||
5747 | } else { | ||
5748 | spin_lock_bh(&tp->lock); | ||
5749 | __tg3_set_mac_addr(tp); | ||
5750 | spin_unlock_bh(&tp->lock); | ||
5751 | } | ||
5725 | 5752 | ||
5726 | return 0; | 5753 | return 0; |
5727 | } | 5754 | } |
@@ -5771,7 +5798,7 @@ static void __tg3_set_coalesce(struct tg3 *tp, struct ethtool_coalesce *ec) | |||
5771 | } | 5798 | } |
5772 | 5799 | ||
5773 | /* tp->lock is held. */ | 5800 | /* tp->lock is held. */ |
5774 | static int tg3_reset_hw(struct tg3 *tp) | 5801 | static int tg3_reset_hw(struct tg3 *tp, int reset_phy) |
5775 | { | 5802 | { |
5776 | u32 val, rdmac_mode; | 5803 | u32 val, rdmac_mode; |
5777 | int i, err, limit; | 5804 | int i, err, limit; |
@@ -5786,7 +5813,7 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
5786 | tg3_abort_hw(tp, 1); | 5813 | tg3_abort_hw(tp, 1); |
5787 | } | 5814 | } |
5788 | 5815 | ||
5789 | if (tp->tg3_flags2 & TG3_FLG2_MII_SERDES) | 5816 | if ((tp->tg3_flags2 & TG3_FLG2_MII_SERDES) && reset_phy) |
5790 | tg3_phy_reset(tp); | 5817 | tg3_phy_reset(tp); |
5791 | 5818 | ||
5792 | err = tg3_chip_reset(tp); | 5819 | err = tg3_chip_reset(tp); |
@@ -6327,7 +6354,7 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6327 | tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); | 6354 | tw32(GRC_LOCAL_CTRL, tp->grc_local_ctrl); |
6328 | } | 6355 | } |
6329 | 6356 | ||
6330 | err = tg3_setup_phy(tp, 1); | 6357 | err = tg3_setup_phy(tp, reset_phy); |
6331 | if (err) | 6358 | if (err) |
6332 | return err; | 6359 | return err; |
6333 | 6360 | ||
@@ -6400,7 +6427,7 @@ static int tg3_reset_hw(struct tg3 *tp) | |||
6400 | /* Called at device open time to get the chip ready for | 6427 | /* Called at device open time to get the chip ready for |
6401 | * packet processing. Invoked with tp->lock held. | 6428 | * packet processing. Invoked with tp->lock held. |
6402 | */ | 6429 | */ |
6403 | static int tg3_init_hw(struct tg3 *tp) | 6430 | static int tg3_init_hw(struct tg3 *tp, int reset_phy) |
6404 | { | 6431 | { |
6405 | int err; | 6432 | int err; |
6406 | 6433 | ||
@@ -6413,7 +6440,7 @@ static int tg3_init_hw(struct tg3 *tp) | |||
6413 | 6440 | ||
6414 | tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); | 6441 | tw32(TG3PCI_MEM_WIN_BASE_ADDR, 0); |
6415 | 6442 | ||
6416 | err = tg3_reset_hw(tp); | 6443 | err = tg3_reset_hw(tp, reset_phy); |
6417 | 6444 | ||
6418 | out: | 6445 | out: |
6419 | return err; | 6446 | return err; |
@@ -6683,7 +6710,7 @@ static int tg3_test_msi(struct tg3 *tp) | |||
6683 | tg3_full_lock(tp, 1); | 6710 | tg3_full_lock(tp, 1); |
6684 | 6711 | ||
6685 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 6712 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
6686 | err = tg3_init_hw(tp); | 6713 | err = tg3_init_hw(tp, 1); |
6687 | 6714 | ||
6688 | tg3_full_unlock(tp); | 6715 | tg3_full_unlock(tp); |
6689 | 6716 | ||
@@ -6748,7 +6775,7 @@ static int tg3_open(struct net_device *dev) | |||
6748 | 6775 | ||
6749 | tg3_full_lock(tp, 0); | 6776 | tg3_full_lock(tp, 0); |
6750 | 6777 | ||
6751 | err = tg3_init_hw(tp); | 6778 | err = tg3_init_hw(tp, 1); |
6752 | if (err) { | 6779 | if (err) { |
6753 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 6780 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
6754 | tg3_free_rings(tp); | 6781 | tg3_free_rings(tp); |
@@ -7839,7 +7866,7 @@ static int tg3_set_ringparam(struct net_device *dev, struct ethtool_ringparam *e | |||
7839 | 7866 | ||
7840 | if (netif_running(dev)) { | 7867 | if (netif_running(dev)) { |
7841 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 7868 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
7842 | tg3_init_hw(tp); | 7869 | tg3_init_hw(tp, 1); |
7843 | tg3_netif_start(tp); | 7870 | tg3_netif_start(tp); |
7844 | } | 7871 | } |
7845 | 7872 | ||
@@ -7884,7 +7911,7 @@ static int tg3_set_pauseparam(struct net_device *dev, struct ethtool_pauseparam | |||
7884 | 7911 | ||
7885 | if (netif_running(dev)) { | 7912 | if (netif_running(dev)) { |
7886 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 7913 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
7887 | tg3_init_hw(tp); | 7914 | tg3_init_hw(tp, 1); |
7888 | tg3_netif_start(tp); | 7915 | tg3_netif_start(tp); |
7889 | } | 7916 | } |
7890 | 7917 | ||
@@ -8522,7 +8549,7 @@ static int tg3_test_loopback(struct tg3 *tp) | |||
8522 | if (!netif_running(tp->dev)) | 8549 | if (!netif_running(tp->dev)) |
8523 | return TG3_LOOPBACK_FAILED; | 8550 | return TG3_LOOPBACK_FAILED; |
8524 | 8551 | ||
8525 | tg3_reset_hw(tp); | 8552 | tg3_reset_hw(tp, 1); |
8526 | 8553 | ||
8527 | if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) | 8554 | if (tg3_run_loopback(tp, TG3_MAC_LOOPBACK)) |
8528 | err |= TG3_MAC_LOOPBACK_FAILED; | 8555 | err |= TG3_MAC_LOOPBACK_FAILED; |
@@ -8596,7 +8623,7 @@ static void tg3_self_test(struct net_device *dev, struct ethtool_test *etest, | |||
8596 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); | 8623 | tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); |
8597 | if (netif_running(dev)) { | 8624 | if (netif_running(dev)) { |
8598 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; | 8625 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; |
8599 | tg3_init_hw(tp); | 8626 | tg3_init_hw(tp, 1); |
8600 | tg3_netif_start(tp); | 8627 | tg3_netif_start(tp); |
8601 | } | 8628 | } |
8602 | 8629 | ||
@@ -9377,7 +9404,7 @@ static int tg3_nvram_write_block_buffered(struct tg3 *tp, u32 offset, u32 len, | |||
9377 | 9404 | ||
9378 | if ((page_off == 0) || (i == 0)) | 9405 | if ((page_off == 0) || (i == 0)) |
9379 | nvram_cmd |= NVRAM_CMD_FIRST; | 9406 | nvram_cmd |= NVRAM_CMD_FIRST; |
9380 | else if (page_off == (tp->nvram_pagesize - 4)) | 9407 | if (page_off == (tp->nvram_pagesize - 4)) |
9381 | nvram_cmd |= NVRAM_CMD_LAST; | 9408 | nvram_cmd |= NVRAM_CMD_LAST; |
9382 | 9409 | ||
9383 | if (i == (len - 4)) | 9410 | if (i == (len - 4)) |
@@ -10353,10 +10380,13 @@ static int __devinit tg3_get_invariants(struct tg3 *tp) | |||
10353 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) | 10380 | if (tp->pci_chip_rev_id == CHIPREV_ID_5704_A0) |
10354 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; | 10381 | tp->tg3_flags2 |= TG3_FLG2_PHY_5704_A0_BUG; |
10355 | 10382 | ||
10356 | if ((tp->tg3_flags2 & TG3_FLG2_5705_PLUS) && | 10383 | if (tp->tg3_flags2 & TG3_FLG2_5705_PLUS) { |
10357 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5755) && | 10384 | if (GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5755 || |
10358 | (GET_ASIC_REV(tp->pci_chip_rev_id) != ASIC_REV_5787)) | 10385 | GET_ASIC_REV(tp->pci_chip_rev_id) == ASIC_REV_5787) |
10359 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | 10386 | tp->tg3_flags2 |= TG3_FLG2_PHY_JITTER_BUG; |
10387 | else | ||
10388 | tp->tg3_flags2 |= TG3_FLG2_PHY_BER_BUG; | ||
10389 | } | ||
10360 | 10390 | ||
10361 | tp->coalesce_mode = 0; | 10391 | tp->coalesce_mode = 0; |
10362 | if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && | 10392 | if (GET_CHIP_REV(tp->pci_chip_rev_id) != CHIPREV_5700_AX && |
@@ -11569,7 +11599,7 @@ static int tg3_suspend(struct pci_dev *pdev, pm_message_t state) | |||
11569 | tg3_full_lock(tp, 0); | 11599 | tg3_full_lock(tp, 0); |
11570 | 11600 | ||
11571 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; | 11601 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; |
11572 | tg3_init_hw(tp); | 11602 | tg3_init_hw(tp, 1); |
11573 | 11603 | ||
11574 | tp->timer.expires = jiffies + tp->timer_offset; | 11604 | tp->timer.expires = jiffies + tp->timer_offset; |
11575 | add_timer(&tp->timer); | 11605 | add_timer(&tp->timer); |
@@ -11603,7 +11633,7 @@ static int tg3_resume(struct pci_dev *pdev) | |||
11603 | tg3_full_lock(tp, 0); | 11633 | tg3_full_lock(tp, 0); |
11604 | 11634 | ||
11605 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; | 11635 | tp->tg3_flags |= TG3_FLAG_INIT_COMPLETE; |
11606 | tg3_init_hw(tp); | 11636 | tg3_init_hw(tp, 1); |
11607 | 11637 | ||
11608 | tp->timer.expires = jiffies + tp->timer_offset; | 11638 | tp->timer.expires = jiffies + tp->timer_offset; |
11609 | add_timer(&tp->timer); | 11639 | add_timer(&tp->timer); |
diff --git a/drivers/net/tg3.h b/drivers/net/tg3.h index 8c8b987d1250..0e29b885d449 100644 --- a/drivers/net/tg3.h +++ b/drivers/net/tg3.h | |||
@@ -2215,6 +2215,7 @@ struct tg3 { | |||
2215 | #define TG3_FLG2_HW_TSO_2 0x08000000 | 2215 | #define TG3_FLG2_HW_TSO_2 0x08000000 |
2216 | #define TG3_FLG2_HW_TSO (TG3_FLG2_HW_TSO_1 | TG3_FLG2_HW_TSO_2) | 2216 | #define TG3_FLG2_HW_TSO (TG3_FLG2_HW_TSO_1 | TG3_FLG2_HW_TSO_2) |
2217 | #define TG3_FLG2_1SHOT_MSI 0x10000000 | 2217 | #define TG3_FLG2_1SHOT_MSI 0x10000000 |
2218 | #define TG3_FLG2_PHY_JITTER_BUG 0x20000000 | ||
2218 | 2219 | ||
2219 | u32 split_mode_max_reqs; | 2220 | u32 split_mode_max_reqs; |
2220 | #define SPLIT_MODE_5704_MAX_REQ 3 | 2221 | #define SPLIT_MODE_5704_MAX_REQ 3 |
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index 6a23964c1317..a6dc53b4250d 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c | |||
@@ -129,6 +129,7 @@ | |||
129 | - Massive clean-up | 129 | - Massive clean-up |
130 | - Rewrite PHY, media handling (remove options, full_duplex, backoff) | 130 | - Rewrite PHY, media handling (remove options, full_duplex, backoff) |
131 | - Fix Tx engine race for good | 131 | - Fix Tx engine race for good |
132 | - Craig Brind: Zero padded aligned buffers for short packets. | ||
132 | 133 | ||
133 | */ | 134 | */ |
134 | 135 | ||
@@ -1326,7 +1327,12 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1326 | rp->stats.tx_dropped++; | 1327 | rp->stats.tx_dropped++; |
1327 | return 0; | 1328 | return 0; |
1328 | } | 1329 | } |
1330 | |||
1331 | /* Padding is not copied and so must be redone. */ | ||
1329 | skb_copy_and_csum_dev(skb, rp->tx_buf[entry]); | 1332 | skb_copy_and_csum_dev(skb, rp->tx_buf[entry]); |
1333 | if (skb->len < ETH_ZLEN) | ||
1334 | memset(rp->tx_buf[entry] + skb->len, 0, | ||
1335 | ETH_ZLEN - skb->len); | ||
1330 | rp->tx_skbuff_dma[entry] = 0; | 1336 | rp->tx_skbuff_dma[entry] = 0; |
1331 | rp->tx_ring[entry].addr = cpu_to_le32(rp->tx_bufs_dma + | 1337 | rp->tx_ring[entry].addr = cpu_to_le32(rp->tx_bufs_dma + |
1332 | (rp->tx_buf[entry] - | 1338 | (rp->tx_buf[entry] - |
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig index bad09ebdb50b..e0874cbfefea 100644 --- a/drivers/net/wireless/Kconfig +++ b/drivers/net/wireless/Kconfig | |||
@@ -6,7 +6,7 @@ menu "Wireless LAN (non-hamradio)" | |||
6 | depends on NETDEVICES | 6 | depends on NETDEVICES |
7 | 7 | ||
8 | config NET_RADIO | 8 | config NET_RADIO |
9 | bool "Wireless LAN drivers (non-hamradio)" | 9 | bool "Wireless LAN drivers (non-hamradio) & Wireless Extensions" |
10 | select WIRELESS_EXT | 10 | select WIRELESS_EXT |
11 | ---help--- | 11 | ---help--- |
12 | Support for wireless LANs and everything having to do with radio, | 12 | Support for wireless LANs and everything having to do with radio, |
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 108d9fed8f07..00764ddd74d8 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -3139,6 +3139,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) | |||
3139 | } | 3139 | } |
3140 | if ( status & EV_LINK ) { | 3140 | if ( status & EV_LINK ) { |
3141 | union iwreq_data wrqu; | 3141 | union iwreq_data wrqu; |
3142 | int scan_forceloss = 0; | ||
3142 | /* The link status has changed, if you want to put a | 3143 | /* The link status has changed, if you want to put a |
3143 | monitor hook in, do it here. (Remember that | 3144 | monitor hook in, do it here. (Remember that |
3144 | interrupts are still disabled!) | 3145 | interrupts are still disabled!) |
@@ -3157,7 +3158,8 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) | |||
3157 | code) */ | 3158 | code) */ |
3158 | #define AUTHFAIL 0x0300 /* Authentication failure (low byte is reason | 3159 | #define AUTHFAIL 0x0300 /* Authentication failure (low byte is reason |
3159 | code) */ | 3160 | code) */ |
3160 | #define ASSOCIATED 0x0400 /* Assocatied */ | 3161 | #define ASSOCIATED 0x0400 /* Associated */ |
3162 | #define REASSOCIATED 0x0600 /* Reassociated? Only on firmware >= 5.30.17 */ | ||
3161 | #define RC_RESERVED 0 /* Reserved return code */ | 3163 | #define RC_RESERVED 0 /* Reserved return code */ |
3162 | #define RC_NOREASON 1 /* Unspecified reason */ | 3164 | #define RC_NOREASON 1 /* Unspecified reason */ |
3163 | #define RC_AUTHINV 2 /* Previous authentication invalid */ | 3165 | #define RC_AUTHINV 2 /* Previous authentication invalid */ |
@@ -3174,44 +3176,30 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) | |||
3174 | leaving BSS */ | 3176 | leaving BSS */ |
3175 | #define RC_NOAUTH 9 /* Station requesting (Re)Association is not | 3177 | #define RC_NOAUTH 9 /* Station requesting (Re)Association is not |
3176 | Authenticated with the responding station */ | 3178 | Authenticated with the responding station */ |
3177 | if (newStatus != ASSOCIATED) { | 3179 | if (newStatus == FORCELOSS && apriv->scan_timeout > 0) |
3178 | if (auto_wep && !apriv->expires) { | 3180 | scan_forceloss = 1; |
3179 | apriv->expires = RUN_AT(3*HZ); | 3181 | if(newStatus == ASSOCIATED || newStatus == REASSOCIATED) { |
3180 | wake_up_interruptible(&apriv->thr_wait); | ||
3181 | } | ||
3182 | } else { | ||
3183 | struct task_struct *task = apriv->task; | ||
3184 | if (auto_wep) | 3182 | if (auto_wep) |
3185 | apriv->expires = 0; | 3183 | apriv->expires = 0; |
3186 | if (task) | 3184 | if (apriv->task) |
3187 | wake_up_process (task); | 3185 | wake_up_process (apriv->task); |
3188 | set_bit(FLAG_UPDATE_UNI, &apriv->flags); | 3186 | set_bit(FLAG_UPDATE_UNI, &apriv->flags); |
3189 | set_bit(FLAG_UPDATE_MULTI, &apriv->flags); | 3187 | set_bit(FLAG_UPDATE_MULTI, &apriv->flags); |
3190 | } | 3188 | |
3191 | /* Question : is ASSOCIATED the only status | ||
3192 | * that is valid ? We want to catch handover | ||
3193 | * and reassociations as valid status | ||
3194 | * Jean II */ | ||
3195 | if(newStatus == ASSOCIATED) { | ||
3196 | #if 0 | ||
3197 | /* FIXME: Grabbing scan results here | ||
3198 | * seems to be too early??? Just wait for | ||
3199 | * timeout instead. */ | ||
3200 | if (apriv->scan_timeout > 0) { | ||
3201 | set_bit(JOB_SCAN_RESULTS, &apriv->flags); | ||
3202 | wake_up_interruptible(&apriv->thr_wait); | ||
3203 | } | ||
3204 | #endif | ||
3205 | if (down_trylock(&apriv->sem) != 0) { | 3189 | if (down_trylock(&apriv->sem) != 0) { |
3206 | set_bit(JOB_EVENT, &apriv->flags); | 3190 | set_bit(JOB_EVENT, &apriv->flags); |
3207 | wake_up_interruptible(&apriv->thr_wait); | 3191 | wake_up_interruptible(&apriv->thr_wait); |
3208 | } else | 3192 | } else |
3209 | airo_send_event(dev); | 3193 | airo_send_event(dev); |
3210 | } else { | 3194 | } else if (!scan_forceloss) { |
3211 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); | 3195 | if (auto_wep && !apriv->expires) { |
3212 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | 3196 | apriv->expires = RUN_AT(3*HZ); |
3197 | wake_up_interruptible(&apriv->thr_wait); | ||
3198 | } | ||
3213 | 3199 | ||
3214 | /* Send event to user space */ | 3200 | /* Send event to user space */ |
3201 | memset(wrqu.ap_addr.sa_data, '\0', ETH_ALEN); | ||
3202 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; | ||
3215 | wireless_send_event(dev, SIOCGIWAP, &wrqu,NULL); | 3203 | wireless_send_event(dev, SIOCGIWAP, &wrqu,NULL); |
3216 | } | 3204 | } |
3217 | } | 3205 | } |
@@ -7136,10 +7124,10 @@ static int airo_set_scan(struct net_device *dev, | |||
7136 | goto out; | 7124 | goto out; |
7137 | 7125 | ||
7138 | /* Initiate a scan command */ | 7126 | /* Initiate a scan command */ |
7127 | ai->scan_timeout = RUN_AT(3*HZ); | ||
7139 | memset(&cmd, 0, sizeof(cmd)); | 7128 | memset(&cmd, 0, sizeof(cmd)); |
7140 | cmd.cmd=CMD_LISTBSS; | 7129 | cmd.cmd=CMD_LISTBSS; |
7141 | issuecommand(ai, &cmd, &rsp); | 7130 | issuecommand(ai, &cmd, &rsp); |
7142 | ai->scan_timeout = RUN_AT(3*HZ); | ||
7143 | wake = 1; | 7131 | wake = 1; |
7144 | 7132 | ||
7145 | out: | 7133 | out: |
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 87afa6878f26..8606c88886fc 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -3463,6 +3463,7 @@ static void atmel_command_irq(struct atmel_private *priv) | |||
3463 | u8 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); | 3463 | u8 status = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_STATUS_OFFSET)); |
3464 | u8 command = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET)); | 3464 | u8 command = atmel_rmem8(priv, atmel_co(priv, CMD_BLOCK_COMMAND_OFFSET)); |
3465 | int fast_scan; | 3465 | int fast_scan; |
3466 | union iwreq_data wrqu; | ||
3466 | 3467 | ||
3467 | if (status == CMD_STATUS_IDLE || | 3468 | if (status == CMD_STATUS_IDLE || |
3468 | status == CMD_STATUS_IN_PROGRESS) | 3469 | status == CMD_STATUS_IN_PROGRESS) |
@@ -3487,6 +3488,7 @@ static void atmel_command_irq(struct atmel_private *priv) | |||
3487 | atmel_scan(priv, 1); | 3488 | atmel_scan(priv, 1); |
3488 | } else { | 3489 | } else { |
3489 | int bss_index = retrieve_bss(priv); | 3490 | int bss_index = retrieve_bss(priv); |
3491 | int notify_scan_complete = 1; | ||
3490 | if (bss_index != -1) { | 3492 | if (bss_index != -1) { |
3491 | atmel_join_bss(priv, bss_index); | 3493 | atmel_join_bss(priv, bss_index); |
3492 | } else if (priv->operating_mode == IW_MODE_ADHOC && | 3494 | } else if (priv->operating_mode == IW_MODE_ADHOC && |
@@ -3495,8 +3497,14 @@ static void atmel_command_irq(struct atmel_private *priv) | |||
3495 | } else { | 3497 | } else { |
3496 | priv->fast_scan = !fast_scan; | 3498 | priv->fast_scan = !fast_scan; |
3497 | atmel_scan(priv, 1); | 3499 | atmel_scan(priv, 1); |
3500 | notify_scan_complete = 0; | ||
3498 | } | 3501 | } |
3499 | priv->site_survey_state = SITE_SURVEY_COMPLETED; | 3502 | priv->site_survey_state = SITE_SURVEY_COMPLETED; |
3503 | if (notify_scan_complete) { | ||
3504 | wrqu.data.length = 0; | ||
3505 | wrqu.data.flags = 0; | ||
3506 | wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); | ||
3507 | } | ||
3500 | } | 3508 | } |
3501 | break; | 3509 | break; |
3502 | 3510 | ||
@@ -3509,6 +3517,9 @@ static void atmel_command_irq(struct atmel_private *priv) | |||
3509 | priv->site_survey_state = SITE_SURVEY_COMPLETED; | 3517 | priv->site_survey_state = SITE_SURVEY_COMPLETED; |
3510 | if (priv->station_is_associated) { | 3518 | if (priv->station_is_associated) { |
3511 | atmel_enter_state(priv, STATION_STATE_READY); | 3519 | atmel_enter_state(priv, STATION_STATE_READY); |
3520 | wrqu.data.length = 0; | ||
3521 | wrqu.data.flags = 0; | ||
3522 | wireless_send_event(priv->dev, SIOCGIWSCAN, &wrqu, NULL); | ||
3512 | } else { | 3523 | } else { |
3513 | atmel_scan(priv, 1); | 3524 | atmel_scan(priv, 1); |
3514 | } | 3525 | } |
diff --git a/drivers/net/wireless/bcm43xx/Kconfig b/drivers/net/wireless/bcm43xx/Kconfig index 418465600a77..25ea4748f0b9 100644 --- a/drivers/net/wireless/bcm43xx/Kconfig +++ b/drivers/net/wireless/bcm43xx/Kconfig | |||
@@ -17,8 +17,11 @@ config BCM43XX_DEBUG | |||
17 | 17 | ||
18 | config BCM43XX_DMA | 18 | config BCM43XX_DMA |
19 | bool | 19 | bool |
20 | depends on BCM43XX | ||
21 | |||
20 | config BCM43XX_PIO | 22 | config BCM43XX_PIO |
21 | bool | 23 | bool |
24 | depends on BCM43XX | ||
22 | 25 | ||
23 | choice | 26 | choice |
24 | prompt "BCM43xx data transfer mode" | 27 | prompt "BCM43xx data transfer mode" |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx.h b/drivers/net/wireless/bcm43xx/bcm43xx.h index dcadd295de4f..2e83083935e1 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx.h | |||
@@ -15,7 +15,6 @@ | |||
15 | 15 | ||
16 | #include "bcm43xx_debugfs.h" | 16 | #include "bcm43xx_debugfs.h" |
17 | #include "bcm43xx_leds.h" | 17 | #include "bcm43xx_leds.h" |
18 | #include "bcm43xx_sysfs.h" | ||
19 | 18 | ||
20 | 19 | ||
21 | #define PFX KBUILD_MODNAME ": " | 20 | #define PFX KBUILD_MODNAME ": " |
@@ -638,8 +637,6 @@ struct bcm43xx_key { | |||
638 | }; | 637 | }; |
639 | 638 | ||
640 | struct bcm43xx_private { | 639 | struct bcm43xx_private { |
641 | struct bcm43xx_sysfs sysfs; | ||
642 | |||
643 | struct ieee80211_device *ieee; | 640 | struct ieee80211_device *ieee; |
644 | struct ieee80211softmac_device *softmac; | 641 | struct ieee80211softmac_device *softmac; |
645 | 642 | ||
@@ -772,6 +769,20 @@ struct bcm43xx_private * bcm43xx_priv(struct net_device *dev) | |||
772 | return ieee80211softmac_priv(dev); | 769 | return ieee80211softmac_priv(dev); |
773 | } | 770 | } |
774 | 771 | ||
772 | struct device; | ||
773 | |||
774 | static inline | ||
775 | struct bcm43xx_private * dev_to_bcm(struct device *dev) | ||
776 | { | ||
777 | struct net_device *net_dev; | ||
778 | struct bcm43xx_private *bcm; | ||
779 | |||
780 | net_dev = dev_get_drvdata(dev); | ||
781 | bcm = bcm43xx_priv(net_dev); | ||
782 | |||
783 | return bcm; | ||
784 | } | ||
785 | |||
775 | 786 | ||
776 | /* Helper function, which returns a boolean. | 787 | /* Helper function, which returns a boolean. |
777 | * TRUE, if PIO is used; FALSE, if DMA is used. | 788 | * TRUE, if PIO is used; FALSE, if DMA is used. |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c index d2c3401e9b70..35a4fcb6d923 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_debugfs.c | |||
@@ -452,12 +452,12 @@ void bcm43xx_printk_dump(const char *data, | |||
452 | size_t i; | 452 | size_t i; |
453 | char c; | 453 | char c; |
454 | 454 | ||
455 | printk(KERN_INFO PFX "Data dump (%s, %u bytes):", | 455 | printk(KERN_INFO PFX "Data dump (%s, %zd bytes):", |
456 | description, size); | 456 | description, size); |
457 | for (i = 0; i < size; i++) { | 457 | for (i = 0; i < size; i++) { |
458 | c = data[i]; | 458 | c = data[i]; |
459 | if (i % 8 == 0) | 459 | if (i % 8 == 0) |
460 | printk("\n" KERN_INFO PFX "0x%08x: 0x%02x, ", i, c & 0xff); | 460 | printk("\n" KERN_INFO PFX "0x%08zx: 0x%02x, ", i, c & 0xff); |
461 | else | 461 | else |
462 | printk("0x%02x, ", c & 0xff); | 462 | printk("0x%02x, ", c & 0xff); |
463 | } | 463 | } |
@@ -472,12 +472,12 @@ void bcm43xx_printk_bitdump(const unsigned char *data, | |||
472 | int j; | 472 | int j; |
473 | const unsigned char *d; | 473 | const unsigned char *d; |
474 | 474 | ||
475 | printk(KERN_INFO PFX "*** Bitdump (%s, %u bytes, %s) ***", | 475 | printk(KERN_INFO PFX "*** Bitdump (%s, %zd bytes, %s) ***", |
476 | description, bytes, msb_to_lsb ? "MSB to LSB" : "LSB to MSB"); | 476 | description, bytes, msb_to_lsb ? "MSB to LSB" : "LSB to MSB"); |
477 | for (i = 0; i < bytes; i++) { | 477 | for (i = 0; i < bytes; i++) { |
478 | d = data + i; | 478 | d = data + i; |
479 | if (i % 8 == 0) | 479 | if (i % 8 == 0) |
480 | printk("\n" KERN_INFO PFX "0x%08x: ", i); | 480 | printk("\n" KERN_INFO PFX "0x%08zx: ", i); |
481 | if (msb_to_lsb) { | 481 | if (msb_to_lsb) { |
482 | for (j = 7; j >= 0; j--) { | 482 | for (j = 7; j >= 0; j--) { |
483 | if (*d & (1 << j)) | 483 | if (*d & (1 << j)) |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c index c3681b8f09b4..bbecba02e697 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.c | |||
@@ -196,8 +196,9 @@ static int alloc_ringmemory(struct bcm43xx_dmaring *ring) | |||
196 | } | 196 | } |
197 | if (ring->dmabase + BCM43xx_DMA_RINGMEMSIZE > BCM43xx_DMA_BUSADDRMAX) { | 197 | if (ring->dmabase + BCM43xx_DMA_RINGMEMSIZE > BCM43xx_DMA_BUSADDRMAX) { |
198 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RINGMEMORY >1G " | 198 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RINGMEMORY >1G " |
199 | "(0x%08x, len: %lu)\n", | 199 | "(0x%llx, len: %lu)\n", |
200 | ring->dmabase, BCM43xx_DMA_RINGMEMSIZE); | 200 | (unsigned long long)ring->dmabase, |
201 | BCM43xx_DMA_RINGMEMSIZE); | ||
201 | dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE, | 202 | dma_free_coherent(dev, BCM43xx_DMA_RINGMEMSIZE, |
202 | ring->vbase, ring->dmabase); | 203 | ring->vbase, ring->dmabase); |
203 | return -ENOMEM; | 204 | return -ENOMEM; |
@@ -307,8 +308,8 @@ static int setup_rx_descbuffer(struct bcm43xx_dmaring *ring, | |||
307 | unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0); | 308 | unmap_descbuffer(ring, dmaaddr, ring->rx_buffersize, 0); |
308 | dev_kfree_skb_any(skb); | 309 | dev_kfree_skb_any(skb); |
309 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RX SKB >1G " | 310 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA RX SKB >1G " |
310 | "(0x%08x, len: %u)\n", | 311 | "(0x%llx, len: %u)\n", |
311 | dmaaddr, ring->rx_buffersize); | 312 | (unsigned long long)dmaaddr, ring->rx_buffersize); |
312 | return -ENOMEM; | 313 | return -ENOMEM; |
313 | } | 314 | } |
314 | meta->skb = skb; | 315 | meta->skb = skb; |
@@ -729,8 +730,8 @@ static int dma_tx_fragment(struct bcm43xx_dmaring *ring, | |||
729 | if (unlikely(meta->dmaaddr + skb->len > BCM43xx_DMA_BUSADDRMAX)) { | 730 | if (unlikely(meta->dmaaddr + skb->len > BCM43xx_DMA_BUSADDRMAX)) { |
730 | return_slot(ring, slot); | 731 | return_slot(ring, slot); |
731 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA TX SKB >1G " | 732 | printk(KERN_ERR PFX ">>>FATAL ERROR<<< DMA TX SKB >1G " |
732 | "(0x%08x, len: %u)\n", | 733 | "(0x%llx, len: %u)\n", |
733 | meta->dmaaddr, skb->len); | 734 | (unsigned long long)meta->dmaaddr, skb->len); |
734 | return -ENOMEM; | 735 | return -ENOMEM; |
735 | } | 736 | } |
736 | 737 | ||
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h index 2d520e4b0276..b7d77638ba8c 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_dma.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_dma.h | |||
@@ -213,6 +213,14 @@ static inline | |||
213 | void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring) | 213 | void bcm43xx_dma_rx(struct bcm43xx_dmaring *ring) |
214 | { | 214 | { |
215 | } | 215 | } |
216 | static inline | ||
217 | void bcm43xx_dma_tx_suspend(struct bcm43xx_dmaring *ring) | ||
218 | { | ||
219 | } | ||
220 | static inline | ||
221 | void bcm43xx_dma_tx_resume(struct bcm43xx_dmaring *ring) | ||
222 | { | ||
223 | } | ||
216 | 224 | ||
217 | #endif /* CONFIG_BCM43XX_DMA */ | 225 | #endif /* CONFIG_BCM43XX_DMA */ |
218 | #endif /* BCM43xx_DMA_H_ */ | 226 | #endif /* BCM43xx_DMA_H_ */ |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_main.c b/drivers/net/wireless/bcm43xx/bcm43xx_main.c index c37371fc9e01..9a06e61df0a2 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_main.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_main.c | |||
@@ -52,6 +52,7 @@ | |||
52 | #include "bcm43xx_wx.h" | 52 | #include "bcm43xx_wx.h" |
53 | #include "bcm43xx_ethtool.h" | 53 | #include "bcm43xx_ethtool.h" |
54 | #include "bcm43xx_xmit.h" | 54 | #include "bcm43xx_xmit.h" |
55 | #include "bcm43xx_sysfs.h" | ||
55 | 56 | ||
56 | 57 | ||
57 | MODULE_DESCRIPTION("Broadcom BCM43xx wireless driver"); | 58 | MODULE_DESCRIPTION("Broadcom BCM43xx wireless driver"); |
@@ -3522,6 +3523,7 @@ static inline int bcm43xx_tx(struct bcm43xx_private *bcm, | |||
3522 | err = bcm43xx_pio_tx(bcm, txb); | 3523 | err = bcm43xx_pio_tx(bcm, txb); |
3523 | else | 3524 | else |
3524 | err = bcm43xx_dma_tx(bcm, txb); | 3525 | err = bcm43xx_dma_tx(bcm, txb); |
3526 | bcm->net_dev->trans_start = jiffies; | ||
3525 | 3527 | ||
3526 | return err; | 3528 | return err; |
3527 | } | 3529 | } |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c index 0a66f43ca0c0..33137165727f 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_phy.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_phy.c | |||
@@ -2151,6 +2151,7 @@ int bcm43xx_phy_init_tssi2dbm_table(struct bcm43xx_private *bcm) | |||
2151 | phy->tssi2dbm = NULL; | 2151 | phy->tssi2dbm = NULL; |
2152 | printk(KERN_ERR PFX "Could not generate " | 2152 | printk(KERN_ERR PFX "Could not generate " |
2153 | "tssi2dBm table\n"); | 2153 | "tssi2dBm table\n"); |
2154 | kfree(dyn_tssi2dbm); | ||
2154 | return -ENODEV; | 2155 | return -ENODEV; |
2155 | } | 2156 | } |
2156 | phy->tssi2dbm = dyn_tssi2dbm; | 2157 | phy->tssi2dbm = dyn_tssi2dbm; |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c index c59ddd40680d..0aa1bd269a25 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_pio.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_pio.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "bcm43xx_pio.h" | 27 | #include "bcm43xx_pio.h" |
28 | #include "bcm43xx_main.h" | 28 | #include "bcm43xx_main.h" |
29 | #include "bcm43xx_xmit.h" | 29 | #include "bcm43xx_xmit.h" |
30 | #include "bcm43xx_power.h" | ||
30 | 31 | ||
31 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
32 | 33 | ||
@@ -44,10 +45,10 @@ static void tx_octet(struct bcm43xx_pioqueue *queue, | |||
44 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, | 45 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
45 | octet); | 46 | octet); |
46 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | 47 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
47 | BCM43xx_PIO_TXCTL_WRITEHI); | 48 | BCM43xx_PIO_TXCTL_WRITELO); |
48 | } else { | 49 | } else { |
49 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | 50 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
50 | BCM43xx_PIO_TXCTL_WRITEHI); | 51 | BCM43xx_PIO_TXCTL_WRITELO); |
51 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, | 52 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
52 | octet); | 53 | octet); |
53 | } | 54 | } |
@@ -103,7 +104,7 @@ static void tx_complete(struct bcm43xx_pioqueue *queue, | |||
103 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, | 104 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXDATA, |
104 | skb->data[skb->len - 1]); | 105 | skb->data[skb->len - 1]); |
105 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | 106 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
106 | BCM43xx_PIO_TXCTL_WRITEHI | | 107 | BCM43xx_PIO_TXCTL_WRITELO | |
107 | BCM43xx_PIO_TXCTL_COMPLETE); | 108 | BCM43xx_PIO_TXCTL_COMPLETE); |
108 | } else { | 109 | } else { |
109 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | 110 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, |
@@ -112,9 +113,10 @@ static void tx_complete(struct bcm43xx_pioqueue *queue, | |||
112 | } | 113 | } |
113 | 114 | ||
114 | static u16 generate_cookie(struct bcm43xx_pioqueue *queue, | 115 | static u16 generate_cookie(struct bcm43xx_pioqueue *queue, |
115 | int packetindex) | 116 | struct bcm43xx_pio_txpacket *packet) |
116 | { | 117 | { |
117 | u16 cookie = 0x0000; | 118 | u16 cookie = 0x0000; |
119 | int packetindex; | ||
118 | 120 | ||
119 | /* We use the upper 4 bits for the PIO | 121 | /* We use the upper 4 bits for the PIO |
120 | * controller ID and the lower 12 bits | 122 | * controller ID and the lower 12 bits |
@@ -135,6 +137,7 @@ static u16 generate_cookie(struct bcm43xx_pioqueue *queue, | |||
135 | default: | 137 | default: |
136 | assert(0); | 138 | assert(0); |
137 | } | 139 | } |
140 | packetindex = pio_txpacket_getindex(packet); | ||
138 | assert(((u16)packetindex & 0xF000) == 0x0000); | 141 | assert(((u16)packetindex & 0xF000) == 0x0000); |
139 | cookie |= (u16)packetindex; | 142 | cookie |= (u16)packetindex; |
140 | 143 | ||
@@ -184,7 +187,7 @@ static void pio_tx_write_fragment(struct bcm43xx_pioqueue *queue, | |||
184 | bcm43xx_generate_txhdr(queue->bcm, | 187 | bcm43xx_generate_txhdr(queue->bcm, |
185 | &txhdr, skb->data, skb->len, | 188 | &txhdr, skb->data, skb->len, |
186 | (packet->xmitted_frags == 0), | 189 | (packet->xmitted_frags == 0), |
187 | generate_cookie(queue, pio_txpacket_getindex(packet))); | 190 | generate_cookie(queue, packet)); |
188 | 191 | ||
189 | tx_start(queue); | 192 | tx_start(queue); |
190 | octets = skb->len + sizeof(txhdr); | 193 | octets = skb->len + sizeof(txhdr); |
@@ -241,7 +244,7 @@ static int pio_tx_packet(struct bcm43xx_pio_txpacket *packet) | |||
241 | queue->tx_devq_packets++; | 244 | queue->tx_devq_packets++; |
242 | queue->tx_devq_used += octets; | 245 | queue->tx_devq_used += octets; |
243 | 246 | ||
244 | assert(packet->xmitted_frags <= packet->txb->nr_frags); | 247 | assert(packet->xmitted_frags < packet->txb->nr_frags); |
245 | packet->xmitted_frags++; | 248 | packet->xmitted_frags++; |
246 | packet->xmitted_octets += octets; | 249 | packet->xmitted_octets += octets; |
247 | } | 250 | } |
@@ -257,8 +260,14 @@ static void tx_tasklet(unsigned long d) | |||
257 | unsigned long flags; | 260 | unsigned long flags; |
258 | struct bcm43xx_pio_txpacket *packet, *tmp_packet; | 261 | struct bcm43xx_pio_txpacket *packet, *tmp_packet; |
259 | int err; | 262 | int err; |
263 | u16 txctl; | ||
260 | 264 | ||
261 | bcm43xx_lock_mmio(bcm, flags); | 265 | bcm43xx_lock_mmio(bcm, flags); |
266 | |||
267 | txctl = bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL); | ||
268 | if (txctl & BCM43xx_PIO_TXCTL_SUSPEND) | ||
269 | goto out_unlock; | ||
270 | |||
262 | list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) { | 271 | list_for_each_entry_safe(packet, tmp_packet, &queue->txqueue, list) { |
263 | assert(packet->xmitted_frags < packet->txb->nr_frags); | 272 | assert(packet->xmitted_frags < packet->txb->nr_frags); |
264 | if (packet->xmitted_frags == 0) { | 273 | if (packet->xmitted_frags == 0) { |
@@ -288,6 +297,7 @@ static void tx_tasklet(unsigned long d) | |||
288 | next_packet: | 297 | next_packet: |
289 | continue; | 298 | continue; |
290 | } | 299 | } |
300 | out_unlock: | ||
291 | bcm43xx_unlock_mmio(bcm, flags); | 301 | bcm43xx_unlock_mmio(bcm, flags); |
292 | } | 302 | } |
293 | 303 | ||
@@ -330,12 +340,19 @@ struct bcm43xx_pioqueue * bcm43xx_setup_pioqueue(struct bcm43xx_private *bcm, | |||
330 | (unsigned long)queue); | 340 | (unsigned long)queue); |
331 | 341 | ||
332 | value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); | 342 | value = bcm43xx_read32(bcm, BCM43xx_MMIO_STATUS_BITFIELD); |
333 | value |= BCM43xx_SBF_XFER_REG_BYTESWAP; | 343 | value &= ~BCM43xx_SBF_XFER_REG_BYTESWAP; |
334 | bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value); | 344 | bcm43xx_write32(bcm, BCM43xx_MMIO_STATUS_BITFIELD, value); |
335 | 345 | ||
336 | qsize = bcm43xx_read16(bcm, queue->mmio_base + BCM43xx_PIO_TXQBUFSIZE); | 346 | qsize = bcm43xx_read16(bcm, queue->mmio_base + BCM43xx_PIO_TXQBUFSIZE); |
347 | if (qsize == 0) { | ||
348 | printk(KERN_ERR PFX "ERROR: This card does not support PIO " | ||
349 | "operation mode. Please use DMA mode " | ||
350 | "(module parameter pio=0).\n"); | ||
351 | goto err_freequeue; | ||
352 | } | ||
337 | if (qsize <= BCM43xx_PIO_TXQADJUST) { | 353 | if (qsize <= BCM43xx_PIO_TXQADJUST) { |
338 | printk(KERN_ERR PFX "PIO tx device-queue too small (%u)\n", qsize); | 354 | printk(KERN_ERR PFX "PIO tx device-queue too small (%u)\n", |
355 | qsize); | ||
339 | goto err_freequeue; | 356 | goto err_freequeue; |
340 | } | 357 | } |
341 | qsize -= BCM43xx_PIO_TXQADJUST; | 358 | qsize -= BCM43xx_PIO_TXQADJUST; |
@@ -444,15 +461,10 @@ int bcm43xx_pio_tx(struct bcm43xx_private *bcm, | |||
444 | { | 461 | { |
445 | struct bcm43xx_pioqueue *queue = bcm43xx_current_pio(bcm)->queue1; | 462 | struct bcm43xx_pioqueue *queue = bcm43xx_current_pio(bcm)->queue1; |
446 | struct bcm43xx_pio_txpacket *packet; | 463 | struct bcm43xx_pio_txpacket *packet; |
447 | u16 tmp; | ||
448 | 464 | ||
449 | assert(!queue->tx_suspended); | 465 | assert(!queue->tx_suspended); |
450 | assert(!list_empty(&queue->txfree)); | 466 | assert(!list_empty(&queue->txfree)); |
451 | 467 | ||
452 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL); | ||
453 | if (tmp & BCM43xx_PIO_TXCTL_SUSPEND) | ||
454 | return -EBUSY; | ||
455 | |||
456 | packet = list_entry(queue->txfree.next, struct bcm43xx_pio_txpacket, list); | 468 | packet = list_entry(queue->txfree.next, struct bcm43xx_pio_txpacket, list); |
457 | packet->txb = txb; | 469 | packet->txb = txb; |
458 | packet->xmitted_frags = 0; | 470 | packet->xmitted_frags = 0; |
@@ -462,7 +474,7 @@ int bcm43xx_pio_tx(struct bcm43xx_private *bcm, | |||
462 | assert(queue->nr_txfree < BCM43xx_PIO_MAXTXPACKETS); | 474 | assert(queue->nr_txfree < BCM43xx_PIO_MAXTXPACKETS); |
463 | 475 | ||
464 | /* Suspend TX, if we are out of packets in the "free" queue. */ | 476 | /* Suspend TX, if we are out of packets in the "free" queue. */ |
465 | if (unlikely(list_empty(&queue->txfree))) { | 477 | if (list_empty(&queue->txfree)) { |
466 | netif_stop_queue(queue->bcm->net_dev); | 478 | netif_stop_queue(queue->bcm->net_dev); |
467 | queue->tx_suspended = 1; | 479 | queue->tx_suspended = 1; |
468 | } | 480 | } |
@@ -480,15 +492,15 @@ void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm, | |||
480 | 492 | ||
481 | queue = parse_cookie(bcm, status->cookie, &packet); | 493 | queue = parse_cookie(bcm, status->cookie, &packet); |
482 | assert(queue); | 494 | assert(queue); |
483 | //TODO | 495 | |
484 | if (!queue) | ||
485 | return; | ||
486 | free_txpacket(packet, 1); | 496 | free_txpacket(packet, 1); |
487 | if (unlikely(queue->tx_suspended)) { | 497 | if (queue->tx_suspended) { |
488 | queue->tx_suspended = 0; | 498 | queue->tx_suspended = 0; |
489 | netif_wake_queue(queue->bcm->net_dev); | 499 | netif_wake_queue(queue->bcm->net_dev); |
490 | } | 500 | } |
491 | /* If there are packets on the txqueue, poke the tasklet. */ | 501 | /* If there are packets on the txqueue, poke the tasklet |
502 | * to transmit them. | ||
503 | */ | ||
492 | if (!list_empty(&queue->txqueue)) | 504 | if (!list_empty(&queue->txqueue)) |
493 | tasklet_schedule(&queue->txtask); | 505 | tasklet_schedule(&queue->txtask); |
494 | } | 506 | } |
@@ -519,12 +531,9 @@ void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue) | |||
519 | int i, preamble_readwords; | 531 | int i, preamble_readwords; |
520 | struct sk_buff *skb; | 532 | struct sk_buff *skb; |
521 | 533 | ||
522 | return; | ||
523 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL); | 534 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXCTL); |
524 | if (!(tmp & BCM43xx_PIO_RXCTL_DATAAVAILABLE)) { | 535 | if (!(tmp & BCM43xx_PIO_RXCTL_DATAAVAILABLE)) |
525 | dprintkl(KERN_ERR PFX "PIO RX: No data available\n");//TODO: remove this printk. | ||
526 | return; | 536 | return; |
527 | } | ||
528 | bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, | 537 | bcm43xx_pio_write(queue, BCM43xx_PIO_RXCTL, |
529 | BCM43xx_PIO_RXCTL_DATAAVAILABLE); | 538 | BCM43xx_PIO_RXCTL_DATAAVAILABLE); |
530 | 539 | ||
@@ -538,8 +547,7 @@ return; | |||
538 | return; | 547 | return; |
539 | data_ready: | 548 | data_ready: |
540 | 549 | ||
541 | //FIXME: endianess in this function. | 550 | len = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
542 | len = le16_to_cpu(bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA)); | ||
543 | if (unlikely(len > 0x700)) { | 551 | if (unlikely(len > 0x700)) { |
544 | pio_rx_error(queue, 0, "len > 0x700"); | 552 | pio_rx_error(queue, 0, "len > 0x700"); |
545 | return; | 553 | return; |
@@ -555,7 +563,7 @@ data_ready: | |||
555 | preamble_readwords = 18 / sizeof(u16); | 563 | preamble_readwords = 18 / sizeof(u16); |
556 | for (i = 0; i < preamble_readwords; i++) { | 564 | for (i = 0; i < preamble_readwords; i++) { |
557 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); | 565 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
558 | preamble[i + 1] = cpu_to_be16(tmp);//FIXME? | 566 | preamble[i + 1] = cpu_to_le16(tmp); |
559 | } | 567 | } |
560 | rxhdr = (struct bcm43xx_rxhdr *)preamble; | 568 | rxhdr = (struct bcm43xx_rxhdr *)preamble; |
561 | rxflags2 = le16_to_cpu(rxhdr->flags2); | 569 | rxflags2 = le16_to_cpu(rxhdr->flags2); |
@@ -591,16 +599,40 @@ data_ready: | |||
591 | } | 599 | } |
592 | skb_put(skb, len); | 600 | skb_put(skb, len); |
593 | for (i = 0; i < len - 1; i += 2) { | 601 | for (i = 0; i < len - 1; i += 2) { |
594 | tmp = cpu_to_be16(bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA)); | 602 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
595 | *((u16 *)(skb->data + i)) = tmp; | 603 | *((u16 *)(skb->data + i)) = cpu_to_le16(tmp); |
596 | } | 604 | } |
597 | if (len % 2) { | 605 | if (len % 2) { |
598 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); | 606 | tmp = bcm43xx_pio_read(queue, BCM43xx_PIO_RXDATA); |
599 | skb->data[len - 1] = (tmp & 0x00FF); | 607 | skb->data[len - 1] = (tmp & 0x00FF); |
608 | /* The specs say the following is required, but | ||
609 | * it is wrong and corrupts the PLCP. If we don't do | ||
610 | * this, the PLCP seems to be correct. So ifdef it out for now. | ||
611 | */ | ||
612 | #if 0 | ||
600 | if (rxflags2 & BCM43xx_RXHDR_FLAGS2_TYPE2FRAME) | 613 | if (rxflags2 & BCM43xx_RXHDR_FLAGS2_TYPE2FRAME) |
601 | skb->data[0x20] = (tmp & 0xFF00) >> 8; | 614 | skb->data[2] = (tmp & 0xFF00) >> 8; |
602 | else | 615 | else |
603 | skb->data[0x1E] = (tmp & 0xFF00) >> 8; | 616 | skb->data[0] = (tmp & 0xFF00) >> 8; |
617 | #endif | ||
604 | } | 618 | } |
619 | skb_trim(skb, len - IEEE80211_FCS_LEN); | ||
605 | bcm43xx_rx(queue->bcm, skb, rxhdr); | 620 | bcm43xx_rx(queue->bcm, skb, rxhdr); |
606 | } | 621 | } |
622 | |||
623 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue) | ||
624 | { | ||
625 | bcm43xx_power_saving_ctl_bits(queue->bcm, -1, 1); | ||
626 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | ||
627 | bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL) | ||
628 | | BCM43xx_PIO_TXCTL_SUSPEND); | ||
629 | } | ||
630 | |||
631 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue) | ||
632 | { | ||
633 | bcm43xx_pio_write(queue, BCM43xx_PIO_TXCTL, | ||
634 | bcm43xx_pio_read(queue, BCM43xx_PIO_TXCTL) | ||
635 | & ~BCM43xx_PIO_TXCTL_SUSPEND); | ||
636 | bcm43xx_power_saving_ctl_bits(queue->bcm, -1, -1); | ||
637 | tasklet_schedule(&queue->txtask); | ||
638 | } | ||
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_pio.h b/drivers/net/wireless/bcm43xx/bcm43xx_pio.h index 970627bc1769..dfc78209e3a3 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_pio.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_pio.h | |||
@@ -14,8 +14,8 @@ | |||
14 | #define BCM43xx_PIO_RXCTL 0x08 | 14 | #define BCM43xx_PIO_RXCTL 0x08 |
15 | #define BCM43xx_PIO_RXDATA 0x0A | 15 | #define BCM43xx_PIO_RXDATA 0x0A |
16 | 16 | ||
17 | #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 0) | 17 | #define BCM43xx_PIO_TXCTL_WRITELO (1 << 0) |
18 | #define BCM43xx_PIO_TXCTL_WRITELO (1 << 1) | 18 | #define BCM43xx_PIO_TXCTL_WRITEHI (1 << 1) |
19 | #define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2) | 19 | #define BCM43xx_PIO_TXCTL_COMPLETE (1 << 2) |
20 | #define BCM43xx_PIO_TXCTL_INIT (1 << 3) | 20 | #define BCM43xx_PIO_TXCTL_INIT (1 << 3) |
21 | #define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7) | 21 | #define BCM43xx_PIO_TXCTL_SUSPEND (1 << 7) |
@@ -95,6 +95,7 @@ void bcm43xx_pio_write(struct bcm43xx_pioqueue *queue, | |||
95 | u16 offset, u16 value) | 95 | u16 offset, u16 value) |
96 | { | 96 | { |
97 | bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value); | 97 | bcm43xx_write16(queue->bcm, queue->mmio_base + offset, value); |
98 | mmiowb(); | ||
98 | } | 99 | } |
99 | 100 | ||
100 | 101 | ||
@@ -107,6 +108,9 @@ void bcm43xx_pio_handle_xmitstatus(struct bcm43xx_private *bcm, | |||
107 | struct bcm43xx_xmitstatus *status); | 108 | struct bcm43xx_xmitstatus *status); |
108 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue); | 109 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue); |
109 | 110 | ||
111 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue); | ||
112 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue); | ||
113 | |||
110 | #else /* CONFIG_BCM43XX_PIO */ | 114 | #else /* CONFIG_BCM43XX_PIO */ |
111 | 115 | ||
112 | static inline | 116 | static inline |
@@ -133,6 +137,14 @@ static inline | |||
133 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue) | 137 | void bcm43xx_pio_rx(struct bcm43xx_pioqueue *queue) |
134 | { | 138 | { |
135 | } | 139 | } |
140 | static inline | ||
141 | void bcm43xx_pio_tx_suspend(struct bcm43xx_pioqueue *queue) | ||
142 | { | ||
143 | } | ||
144 | static inline | ||
145 | void bcm43xx_pio_tx_resume(struct bcm43xx_pioqueue *queue) | ||
146 | { | ||
147 | } | ||
136 | 148 | ||
137 | #endif /* CONFIG_BCM43XX_PIO */ | 149 | #endif /* CONFIG_BCM43XX_PIO */ |
138 | #endif /* BCM43xx_PIO_H_ */ | 150 | #endif /* BCM43xx_PIO_H_ */ |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_power.c b/drivers/net/wireless/bcm43xx/bcm43xx_power.c index 3c92b62807c5..6569da3a7a39 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_power.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_power.c | |||
@@ -35,77 +35,101 @@ | |||
35 | #include "bcm43xx_main.h" | 35 | #include "bcm43xx_main.h" |
36 | 36 | ||
37 | 37 | ||
38 | /* Get the Slow Clock Source */ | ||
39 | static int bcm43xx_pctl_get_slowclksrc(struct bcm43xx_private *bcm) | ||
40 | { | ||
41 | u32 tmp; | ||
42 | int err; | ||
43 | |||
44 | assert(bcm->current_core == &bcm->core_chipcommon); | ||
45 | if (bcm->current_core->rev < 6) { | ||
46 | if (bcm->bustype == BCM43xx_BUSTYPE_PCMCIA || | ||
47 | bcm->bustype == BCM43xx_BUSTYPE_SB) | ||
48 | return BCM43xx_PCTL_CLKSRC_XTALOS; | ||
49 | if (bcm->bustype == BCM43xx_BUSTYPE_PCI) { | ||
50 | err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_OUT, &tmp); | ||
51 | assert(!err); | ||
52 | if (tmp & 0x10) | ||
53 | return BCM43xx_PCTL_CLKSRC_PCI; | ||
54 | return BCM43xx_PCTL_CLKSRC_XTALOS; | ||
55 | } | ||
56 | } | ||
57 | if (bcm->current_core->rev < 10) { | ||
58 | tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL); | ||
59 | tmp &= 0x7; | ||
60 | if (tmp == 0) | ||
61 | return BCM43xx_PCTL_CLKSRC_LOPWROS; | ||
62 | if (tmp == 1) | ||
63 | return BCM43xx_PCTL_CLKSRC_XTALOS; | ||
64 | if (tmp == 2) | ||
65 | return BCM43xx_PCTL_CLKSRC_PCI; | ||
66 | } | ||
67 | |||
68 | return BCM43xx_PCTL_CLKSRC_XTALOS; | ||
69 | } | ||
70 | |||
38 | /* Get max/min slowclock frequency | 71 | /* Get max/min slowclock frequency |
39 | * as described in http://bcm-specs.sipsolutions.net/PowerControl | 72 | * as described in http://bcm-specs.sipsolutions.net/PowerControl |
40 | */ | 73 | */ |
41 | static int bcm43xx_pctl_clockfreqlimit(struct bcm43xx_private *bcm, | 74 | static int bcm43xx_pctl_clockfreqlimit(struct bcm43xx_private *bcm, |
42 | int get_max) | 75 | int get_max) |
43 | { | 76 | { |
44 | int limit = 0; | 77 | int limit; |
78 | int clocksrc; | ||
45 | int divisor; | 79 | int divisor; |
46 | int selection; | ||
47 | int err; | ||
48 | u32 tmp; | 80 | u32 tmp; |
49 | struct bcm43xx_coreinfo *old_core; | ||
50 | 81 | ||
51 | if (!(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL)) | 82 | assert(bcm->chipcommon_capabilities & BCM43xx_CAPABILITIES_PCTL); |
52 | goto out; | 83 | assert(bcm->current_core == &bcm->core_chipcommon); |
53 | old_core = bcm->current_core; | ||
54 | err = bcm43xx_switch_core(bcm, &bcm->core_chipcommon); | ||
55 | if (err) | ||
56 | goto out; | ||
57 | 84 | ||
85 | clocksrc = bcm43xx_pctl_get_slowclksrc(bcm); | ||
58 | if (bcm->current_core->rev < 6) { | 86 | if (bcm->current_core->rev < 6) { |
59 | if ((bcm->bustype == BCM43xx_BUSTYPE_PCMCIA) || | 87 | switch (clocksrc) { |
60 | (bcm->bustype == BCM43xx_BUSTYPE_SB)) { | 88 | case BCM43xx_PCTL_CLKSRC_PCI: |
61 | selection = 1; | 89 | divisor = 64; |
90 | break; | ||
91 | case BCM43xx_PCTL_CLKSRC_XTALOS: | ||
62 | divisor = 32; | 92 | divisor = 32; |
63 | } else { | 93 | break; |
64 | err = bcm43xx_pci_read_config32(bcm, BCM43xx_PCTL_OUT, &tmp); | 94 | default: |
65 | if (err) { | 95 | assert(0); |
66 | printk(KERN_ERR PFX "clockfreqlimit pcicfg read failure\n"); | 96 | divisor = 1; |
67 | goto out_switchback; | ||
68 | } | ||
69 | if (tmp & 0x10) { | ||
70 | /* PCI */ | ||
71 | selection = 2; | ||
72 | divisor = 64; | ||
73 | } else { | ||
74 | /* XTAL */ | ||
75 | selection = 1; | ||
76 | divisor = 32; | ||
77 | } | ||
78 | } | 97 | } |
79 | } else if (bcm->current_core->rev < 10) { | 98 | } else if (bcm->current_core->rev < 10) { |
80 | selection = (tmp & 0x07); | 99 | switch (clocksrc) { |
81 | if (selection) { | 100 | case BCM43xx_PCTL_CLKSRC_LOPWROS: |
101 | divisor = 1; | ||
102 | break; | ||
103 | case BCM43xx_PCTL_CLKSRC_XTALOS: | ||
104 | case BCM43xx_PCTL_CLKSRC_PCI: | ||
82 | tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL); | 105 | tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SLOWCLKCTL); |
83 | divisor = 4 * (1 + ((tmp & 0xFFFF0000) >> 16)); | 106 | divisor = ((tmp & 0xFFFF0000) >> 16) + 1; |
84 | } else | 107 | divisor *= 4; |
108 | break; | ||
109 | default: | ||
110 | assert(0); | ||
85 | divisor = 1; | 111 | divisor = 1; |
112 | } | ||
86 | } else { | 113 | } else { |
87 | tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL); | 114 | tmp = bcm43xx_read32(bcm, BCM43xx_CHIPCOMMON_SYSCLKCTL); |
88 | divisor = 4 * (1 + ((tmp & 0xFFFF0000) >> 16)); | 115 | divisor = ((tmp & 0xFFFF0000) >> 16) + 1; |
89 | selection = 1; | 116 | divisor *= 4; |
90 | } | 117 | } |
91 | 118 | ||
92 | switch (selection) { | 119 | switch (clocksrc) { |
93 | case 0: | 120 | case BCM43xx_PCTL_CLKSRC_LOPWROS: |
94 | /* LPO */ | ||
95 | if (get_max) | 121 | if (get_max) |
96 | limit = 43000; | 122 | limit = 43000; |
97 | else | 123 | else |
98 | limit = 25000; | 124 | limit = 25000; |
99 | break; | 125 | break; |
100 | case 1: | 126 | case BCM43xx_PCTL_CLKSRC_XTALOS: |
101 | /* XTAL */ | ||
102 | if (get_max) | 127 | if (get_max) |
103 | limit = 20200000; | 128 | limit = 20200000; |
104 | else | 129 | else |
105 | limit = 19800000; | 130 | limit = 19800000; |
106 | break; | 131 | break; |
107 | case 2: | 132 | case BCM43xx_PCTL_CLKSRC_PCI: |
108 | /* PCI */ | ||
109 | if (get_max) | 133 | if (get_max) |
110 | limit = 34000000; | 134 | limit = 34000000; |
111 | else | 135 | else |
@@ -113,17 +137,14 @@ static int bcm43xx_pctl_clockfreqlimit(struct bcm43xx_private *bcm, | |||
113 | break; | 137 | break; |
114 | default: | 138 | default: |
115 | assert(0); | 139 | assert(0); |
140 | limit = 0; | ||
116 | } | 141 | } |
117 | limit /= divisor; | 142 | limit /= divisor; |
118 | 143 | ||
119 | out_switchback: | ||
120 | err = bcm43xx_switch_core(bcm, old_core); | ||
121 | assert(err == 0); | ||
122 | |||
123 | out: | ||
124 | return limit; | 144 | return limit; |
125 | } | 145 | } |
126 | 146 | ||
147 | |||
127 | /* init power control | 148 | /* init power control |
128 | * as described in http://bcm-specs.sipsolutions.net/PowerControl | 149 | * as described in http://bcm-specs.sipsolutions.net/PowerControl |
129 | */ | 150 | */ |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_power.h b/drivers/net/wireless/bcm43xx/bcm43xx_power.h index 5f63640810bd..c966ab3a5a8c 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_power.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_power.h | |||
@@ -33,6 +33,15 @@ | |||
33 | 33 | ||
34 | #include <linux/types.h> | 34 | #include <linux/types.h> |
35 | 35 | ||
36 | /* Clock sources */ | ||
37 | enum { | ||
38 | /* PCI clock */ | ||
39 | BCM43xx_PCTL_CLKSRC_PCI, | ||
40 | /* Crystal slow clock oscillator */ | ||
41 | BCM43xx_PCTL_CLKSRC_XTALOS, | ||
42 | /* Low power oscillator */ | ||
43 | BCM43xx_PCTL_CLKSRC_LOPWROS, | ||
44 | }; | ||
36 | 45 | ||
37 | struct bcm43xx_private; | 46 | struct bcm43xx_private; |
38 | 47 | ||
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c index c44d890b949b..b438f48e891d 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.c | |||
@@ -71,14 +71,46 @@ static int get_boolean(const char *buf, size_t count) | |||
71 | return -EINVAL; | 71 | return -EINVAL; |
72 | } | 72 | } |
73 | 73 | ||
74 | static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len) | ||
75 | { | ||
76 | int i, pos = 0; | ||
77 | |||
78 | for (i = 0; i < BCM43xx_SPROM_SIZE; i++) { | ||
79 | pos += snprintf(buf + pos, buf_len - pos - 1, | ||
80 | "%04X", swab16(sprom[i]) & 0xFFFF); | ||
81 | } | ||
82 | pos += snprintf(buf + pos, buf_len - pos - 1, "\n"); | ||
83 | |||
84 | return pos + 1; | ||
85 | } | ||
86 | |||
87 | static int hex2sprom(u16 *sprom, const char *dump, size_t len) | ||
88 | { | ||
89 | char tmp[5] = { 0 }; | ||
90 | int cnt = 0; | ||
91 | unsigned long parsed; | ||
92 | |||
93 | if (len < BCM43xx_SPROM_SIZE * sizeof(u16) * 2) | ||
94 | return -EINVAL; | ||
95 | |||
96 | while (cnt < BCM43xx_SPROM_SIZE) { | ||
97 | memcpy(tmp, dump, 4); | ||
98 | dump += 4; | ||
99 | parsed = simple_strtoul(tmp, NULL, 16); | ||
100 | sprom[cnt++] = swab16((u16)parsed); | ||
101 | } | ||
102 | |||
103 | return 0; | ||
104 | } | ||
105 | |||
74 | static ssize_t bcm43xx_attr_sprom_show(struct device *dev, | 106 | static ssize_t bcm43xx_attr_sprom_show(struct device *dev, |
75 | struct device_attribute *attr, | 107 | struct device_attribute *attr, |
76 | char *buf) | 108 | char *buf) |
77 | { | 109 | { |
78 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_sprom); | 110 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
79 | u16 *sprom; | 111 | u16 *sprom; |
80 | unsigned long flags; | 112 | unsigned long flags; |
81 | int i, err; | 113 | int err; |
82 | 114 | ||
83 | if (!capable(CAP_NET_ADMIN)) | 115 | if (!capable(CAP_NET_ADMIN)) |
84 | return -EPERM; | 116 | return -EPERM; |
@@ -91,55 +123,53 @@ static ssize_t bcm43xx_attr_sprom_show(struct device *dev, | |||
91 | bcm43xx_lock_mmio(bcm, flags); | 123 | bcm43xx_lock_mmio(bcm, flags); |
92 | assert(bcm->initialized); | 124 | assert(bcm->initialized); |
93 | err = bcm43xx_sprom_read(bcm, sprom); | 125 | err = bcm43xx_sprom_read(bcm, sprom); |
94 | if (!err) { | 126 | if (!err) |
95 | for (i = 0; i < BCM43xx_SPROM_SIZE; i++) { | 127 | err = sprom2hex(sprom, buf, PAGE_SIZE); |
96 | buf[i * 2] = sprom[i] & 0x00FF; | ||
97 | buf[i * 2 + 1] = (sprom[i] & 0xFF00) >> 8; | ||
98 | } | ||
99 | } | ||
100 | bcm43xx_unlock_mmio(bcm, flags); | 128 | bcm43xx_unlock_mmio(bcm, flags); |
101 | kfree(sprom); | 129 | kfree(sprom); |
102 | 130 | ||
103 | return err ? err : BCM43xx_SPROM_SIZE * sizeof(u16); | 131 | return err; |
104 | } | 132 | } |
105 | 133 | ||
106 | static ssize_t bcm43xx_attr_sprom_store(struct device *dev, | 134 | static ssize_t bcm43xx_attr_sprom_store(struct device *dev, |
107 | struct device_attribute *attr, | 135 | struct device_attribute *attr, |
108 | const char *buf, size_t count) | 136 | const char *buf, size_t count) |
109 | { | 137 | { |
110 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_sprom); | 138 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
111 | u16 *sprom; | 139 | u16 *sprom; |
112 | unsigned long flags; | 140 | unsigned long flags; |
113 | int i, err; | 141 | int err; |
114 | 142 | ||
115 | if (!capable(CAP_NET_ADMIN)) | 143 | if (!capable(CAP_NET_ADMIN)) |
116 | return -EPERM; | 144 | return -EPERM; |
117 | 145 | ||
118 | if (count != BCM43xx_SPROM_SIZE * sizeof(u16)) | ||
119 | return -EINVAL; | ||
120 | sprom = kmalloc(BCM43xx_SPROM_SIZE * sizeof(*sprom), | 146 | sprom = kmalloc(BCM43xx_SPROM_SIZE * sizeof(*sprom), |
121 | GFP_KERNEL); | 147 | GFP_KERNEL); |
122 | if (!sprom) | 148 | if (!sprom) |
123 | return -ENOMEM; | 149 | return -ENOMEM; |
124 | for (i = 0; i < BCM43xx_SPROM_SIZE; i++) { | 150 | err = hex2sprom(sprom, buf, count); |
125 | sprom[i] = buf[i * 2] & 0xFF; | 151 | if (err) |
126 | sprom[i] |= ((u16)(buf[i * 2 + 1] & 0xFF)) << 8; | 152 | goto out_kfree; |
127 | } | ||
128 | bcm43xx_lock_mmio(bcm, flags); | 153 | bcm43xx_lock_mmio(bcm, flags); |
129 | assert(bcm->initialized); | 154 | assert(bcm->initialized); |
130 | err = bcm43xx_sprom_write(bcm, sprom); | 155 | err = bcm43xx_sprom_write(bcm, sprom); |
131 | bcm43xx_unlock_mmio(bcm, flags); | 156 | bcm43xx_unlock_mmio(bcm, flags); |
157 | out_kfree: | ||
132 | kfree(sprom); | 158 | kfree(sprom); |
133 | 159 | ||
134 | return err ? err : count; | 160 | return err ? err : count; |
135 | 161 | ||
136 | } | 162 | } |
137 | 163 | ||
164 | static DEVICE_ATTR(sprom, 0600, | ||
165 | bcm43xx_attr_sprom_show, | ||
166 | bcm43xx_attr_sprom_store); | ||
167 | |||
138 | static ssize_t bcm43xx_attr_interfmode_show(struct device *dev, | 168 | static ssize_t bcm43xx_attr_interfmode_show(struct device *dev, |
139 | struct device_attribute *attr, | 169 | struct device_attribute *attr, |
140 | char *buf) | 170 | char *buf) |
141 | { | 171 | { |
142 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_interfmode); | 172 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
143 | unsigned long flags; | 173 | unsigned long flags; |
144 | int err; | 174 | int err; |
145 | ssize_t count = 0; | 175 | ssize_t count = 0; |
@@ -175,7 +205,7 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev, | |||
175 | struct device_attribute *attr, | 205 | struct device_attribute *attr, |
176 | const char *buf, size_t count) | 206 | const char *buf, size_t count) |
177 | { | 207 | { |
178 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_interfmode); | 208 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
179 | unsigned long flags; | 209 | unsigned long flags; |
180 | int err; | 210 | int err; |
181 | int mode; | 211 | int mode; |
@@ -215,11 +245,15 @@ static ssize_t bcm43xx_attr_interfmode_store(struct device *dev, | |||
215 | return err ? err : count; | 245 | return err ? err : count; |
216 | } | 246 | } |
217 | 247 | ||
248 | static DEVICE_ATTR(interference, 0644, | ||
249 | bcm43xx_attr_interfmode_show, | ||
250 | bcm43xx_attr_interfmode_store); | ||
251 | |||
218 | static ssize_t bcm43xx_attr_preamble_show(struct device *dev, | 252 | static ssize_t bcm43xx_attr_preamble_show(struct device *dev, |
219 | struct device_attribute *attr, | 253 | struct device_attribute *attr, |
220 | char *buf) | 254 | char *buf) |
221 | { | 255 | { |
222 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_preamble); | 256 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
223 | unsigned long flags; | 257 | unsigned long flags; |
224 | int err; | 258 | int err; |
225 | ssize_t count; | 259 | ssize_t count; |
@@ -245,7 +279,7 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev, | |||
245 | struct device_attribute *attr, | 279 | struct device_attribute *attr, |
246 | const char *buf, size_t count) | 280 | const char *buf, size_t count) |
247 | { | 281 | { |
248 | struct bcm43xx_private *bcm = devattr_to_bcm(attr, attr_preamble); | 282 | struct bcm43xx_private *bcm = dev_to_bcm(dev); |
249 | unsigned long flags; | 283 | unsigned long flags; |
250 | int err; | 284 | int err; |
251 | int value; | 285 | int value; |
@@ -267,56 +301,41 @@ static ssize_t bcm43xx_attr_preamble_store(struct device *dev, | |||
267 | return err ? err : count; | 301 | return err ? err : count; |
268 | } | 302 | } |
269 | 303 | ||
304 | static DEVICE_ATTR(shortpreamble, 0644, | ||
305 | bcm43xx_attr_preamble_show, | ||
306 | bcm43xx_attr_preamble_store); | ||
307 | |||
270 | int bcm43xx_sysfs_register(struct bcm43xx_private *bcm) | 308 | int bcm43xx_sysfs_register(struct bcm43xx_private *bcm) |
271 | { | 309 | { |
272 | struct device *dev = &bcm->pci_dev->dev; | 310 | struct device *dev = &bcm->pci_dev->dev; |
273 | struct bcm43xx_sysfs *sysfs = &bcm->sysfs; | ||
274 | int err; | 311 | int err; |
275 | 312 | ||
276 | assert(bcm->initialized); | 313 | assert(bcm->initialized); |
277 | 314 | ||
278 | sysfs->attr_sprom.attr.name = "sprom"; | 315 | err = device_create_file(dev, &dev_attr_sprom); |
279 | sysfs->attr_sprom.attr.owner = THIS_MODULE; | ||
280 | sysfs->attr_sprom.attr.mode = 0600; | ||
281 | sysfs->attr_sprom.show = bcm43xx_attr_sprom_show; | ||
282 | sysfs->attr_sprom.store = bcm43xx_attr_sprom_store; | ||
283 | err = device_create_file(dev, &sysfs->attr_sprom); | ||
284 | if (err) | 316 | if (err) |
285 | goto out; | 317 | goto out; |
286 | 318 | err = device_create_file(dev, &dev_attr_interference); | |
287 | sysfs->attr_interfmode.attr.name = "interference"; | ||
288 | sysfs->attr_interfmode.attr.owner = THIS_MODULE; | ||
289 | sysfs->attr_interfmode.attr.mode = 0600; | ||
290 | sysfs->attr_interfmode.show = bcm43xx_attr_interfmode_show; | ||
291 | sysfs->attr_interfmode.store = bcm43xx_attr_interfmode_store; | ||
292 | err = device_create_file(dev, &sysfs->attr_interfmode); | ||
293 | if (err) | 319 | if (err) |
294 | goto err_remove_sprom; | 320 | goto err_remove_sprom; |
295 | 321 | err = device_create_file(dev, &dev_attr_shortpreamble); | |
296 | sysfs->attr_preamble.attr.name = "shortpreamble"; | ||
297 | sysfs->attr_preamble.attr.owner = THIS_MODULE; | ||
298 | sysfs->attr_preamble.attr.mode = 0600; | ||
299 | sysfs->attr_preamble.show = bcm43xx_attr_preamble_show; | ||
300 | sysfs->attr_preamble.store = bcm43xx_attr_preamble_store; | ||
301 | err = device_create_file(dev, &sysfs->attr_preamble); | ||
302 | if (err) | 322 | if (err) |
303 | goto err_remove_interfmode; | 323 | goto err_remove_interfmode; |
304 | 324 | ||
305 | out: | 325 | out: |
306 | return err; | 326 | return err; |
307 | err_remove_interfmode: | 327 | err_remove_interfmode: |
308 | device_remove_file(dev, &sysfs->attr_interfmode); | 328 | device_remove_file(dev, &dev_attr_interference); |
309 | err_remove_sprom: | 329 | err_remove_sprom: |
310 | device_remove_file(dev, &sysfs->attr_sprom); | 330 | device_remove_file(dev, &dev_attr_sprom); |
311 | goto out; | 331 | goto out; |
312 | } | 332 | } |
313 | 333 | ||
314 | void bcm43xx_sysfs_unregister(struct bcm43xx_private *bcm) | 334 | void bcm43xx_sysfs_unregister(struct bcm43xx_private *bcm) |
315 | { | 335 | { |
316 | struct device *dev = &bcm->pci_dev->dev; | 336 | struct device *dev = &bcm->pci_dev->dev; |
317 | struct bcm43xx_sysfs *sysfs = &bcm->sysfs; | ||
318 | 337 | ||
319 | device_remove_file(dev, &sysfs->attr_preamble); | 338 | device_remove_file(dev, &dev_attr_shortpreamble); |
320 | device_remove_file(dev, &sysfs->attr_interfmode); | 339 | device_remove_file(dev, &dev_attr_interference); |
321 | device_remove_file(dev, &sysfs->attr_sprom); | 340 | device_remove_file(dev, &dev_attr_sprom); |
322 | } | 341 | } |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.h b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.h index 57f14514e3e0..cc701df71e2a 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.h +++ b/drivers/net/wireless/bcm43xx/bcm43xx_sysfs.h | |||
@@ -1,22 +1,6 @@ | |||
1 | #ifndef BCM43xx_SYSFS_H_ | 1 | #ifndef BCM43xx_SYSFS_H_ |
2 | #define BCM43xx_SYSFS_H_ | 2 | #define BCM43xx_SYSFS_H_ |
3 | 3 | ||
4 | #include <linux/device.h> | ||
5 | |||
6 | |||
7 | struct bcm43xx_sysfs { | ||
8 | struct device_attribute attr_sprom; | ||
9 | struct device_attribute attr_interfmode; | ||
10 | struct device_attribute attr_preamble; | ||
11 | }; | ||
12 | |||
13 | #define devattr_to_bcm(attr, attr_name) ({ \ | ||
14 | struct bcm43xx_sysfs *__s; struct bcm43xx_private *__p; \ | ||
15 | __s = container_of((attr), struct bcm43xx_sysfs, attr_name); \ | ||
16 | __p = container_of(__s, struct bcm43xx_private, sysfs); \ | ||
17 | __p; \ | ||
18 | }) | ||
19 | |||
20 | struct bcm43xx_private; | 4 | struct bcm43xx_private; |
21 | 5 | ||
22 | int bcm43xx_sysfs_register(struct bcm43xx_private *bcm); | 6 | int bcm43xx_sysfs_register(struct bcm43xx_private *bcm); |
diff --git a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c index 3daee828ef4b..3edbb481a0a0 100644 --- a/drivers/net/wireless/bcm43xx/bcm43xx_wx.c +++ b/drivers/net/wireless/bcm43xx/bcm43xx_wx.c | |||
@@ -962,22 +962,22 @@ static const struct iw_priv_args bcm43xx_priv_wx_args[] = { | |||
962 | { | 962 | { |
963 | .cmd = PRIV_WX_SET_SHORTPREAMBLE, | 963 | .cmd = PRIV_WX_SET_SHORTPREAMBLE, |
964 | .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 964 | .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
965 | .name = "set_shortpreambl", | 965 | .name = "set_shortpreamb", |
966 | }, | 966 | }, |
967 | { | 967 | { |
968 | .cmd = PRIV_WX_GET_SHORTPREAMBLE, | 968 | .cmd = PRIV_WX_GET_SHORTPREAMBLE, |
969 | .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, | 969 | .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, |
970 | .name = "get_shortpreambl", | 970 | .name = "get_shortpreamb", |
971 | }, | 971 | }, |
972 | { | 972 | { |
973 | .cmd = PRIV_WX_SET_SWENCRYPTION, | 973 | .cmd = PRIV_WX_SET_SWENCRYPTION, |
974 | .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, | 974 | .set_args = IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, |
975 | .name = "set_swencryption", | 975 | .name = "set_swencrypt", |
976 | }, | 976 | }, |
977 | { | 977 | { |
978 | .cmd = PRIV_WX_GET_SWENCRYPTION, | 978 | .cmd = PRIV_WX_GET_SWENCRYPTION, |
979 | .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, | 979 | .get_args = IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | MAX_WX_STRING, |
980 | .name = "get_swencryption", | 980 | .name = "get_swencrypt", |
981 | }, | 981 | }, |
982 | { | 982 | { |
983 | .cmd = PRIV_WX_SPROM_WRITE, | 983 | .cmd = PRIV_WX_SPROM_WRITE, |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index 8b37e824dfcb..8399de581893 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -1860,7 +1860,7 @@ static char * __prism2_translate_scan(local_info_t *local, | |||
1860 | memset(&iwe, 0, sizeof(iwe)); | 1860 | memset(&iwe, 0, sizeof(iwe)); |
1861 | iwe.cmd = SIOCGIWFREQ; | 1861 | iwe.cmd = SIOCGIWFREQ; |
1862 | if (scan) { | 1862 | if (scan) { |
1863 | chan = scan->chid; | 1863 | chan = le16_to_cpu(scan->chid); |
1864 | } else if (bss) { | 1864 | } else if (bss) { |
1865 | chan = bss->chan; | 1865 | chan = bss->chan; |
1866 | } else { | 1866 | } else { |
@@ -1868,7 +1868,7 @@ static char * __prism2_translate_scan(local_info_t *local, | |||
1868 | } | 1868 | } |
1869 | 1869 | ||
1870 | if (chan > 0) { | 1870 | if (chan > 0) { |
1871 | iwe.u.freq.m = freq_list[le16_to_cpu(chan - 1)] * 100000; | 1871 | iwe.u.freq.m = freq_list[chan - 1] * 100000; |
1872 | iwe.u.freq.e = 1; | 1872 | iwe.u.freq.e = 1; |
1873 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, | 1873 | current_ev = iwe_stream_add_event(current_ev, end_buf, &iwe, |
1874 | IW_EV_FREQ_LEN); | 1874 | IW_EV_FREQ_LEN); |
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c index 8dfdfbd5966c..06523e2a8471 100644 --- a/drivers/net/wireless/orinoco.c +++ b/drivers/net/wireless/orinoco.c | |||
@@ -390,7 +390,7 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) | |||
390 | } | 390 | } |
391 | } else { | 391 | } else { |
392 | struct { | 392 | struct { |
393 | __le16 qual, signal, noise; | 393 | __le16 qual, signal, noise, unused; |
394 | } __attribute__ ((packed)) cq; | 394 | } __attribute__ ((packed)) cq; |
395 | 395 | ||
396 | err = HERMES_READ_RECORD(hw, USER_BAP, | 396 | err = HERMES_READ_RECORD(hw, USER_BAP, |
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index 4e53be9c03ab..bbeabe3fc4c6 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c | |||
@@ -535,7 +535,7 @@ pdcs_auto_read(struct subsystem *entry, char *buf, int knob) | |||
535 | { | 535 | { |
536 | char *out = buf; | 536 | char *out = buf; |
537 | struct pdcspath_entry *pathentry; | 537 | struct pdcspath_entry *pathentry; |
538 | 538 | ||
539 | if (!entry || !buf) | 539 | if (!entry || !buf) |
540 | return -EINVAL; | 540 | return -EINVAL; |
541 | 541 | ||
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c index 42b32ff2fca6..278f325021ee 100644 --- a/drivers/parisc/sba_iommu.c +++ b/drivers/parisc/sba_iommu.c | |||
@@ -178,6 +178,11 @@ extern struct proc_dir_entry * proc_mckinley_root; | |||
178 | #define ROPE6_CTL 0x230 | 178 | #define ROPE6_CTL 0x230 |
179 | #define ROPE7_CTL 0x238 | 179 | #define ROPE7_CTL 0x238 |
180 | 180 | ||
181 | #define IOC_ROPE0_CFG 0x500 /* pluto only */ | ||
182 | #define IOC_ROPE_AO 0x10 /* Allow "Relaxed Ordering" */ | ||
183 | |||
184 | |||
185 | |||
181 | #define HF_ENABLE 0x40 | 186 | #define HF_ENABLE 0x40 |
182 | 187 | ||
183 | 188 | ||
@@ -1759,19 +1764,33 @@ printk("sba_hw_init(): mem_boot 0x%x 0x%x 0x%x 0x%x\n", PAGE0->mem_boot.hpa, | |||
1759 | 1764 | ||
1760 | sba_dev->num_ioc = num_ioc; | 1765 | sba_dev->num_ioc = num_ioc; |
1761 | for (i = 0; i < num_ioc; i++) { | 1766 | for (i = 0; i < num_ioc; i++) { |
1762 | /* | 1767 | unsigned long ioc_hpa = sba_dev->ioc[i].ioc_hpa; |
1763 | ** Make sure the box crashes if we get any errors on a rope. | 1768 | unsigned int j; |
1764 | */ | 1769 | |
1765 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE0_CTL); | 1770 | for (j=0; j < sizeof(u64) * ROPES_PER_IOC; j+=sizeof(u64)) { |
1766 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE1_CTL); | 1771 | |
1767 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE2_CTL); | 1772 | /* |
1768 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE3_CTL); | 1773 | * Clear ROPE(N)_CONFIG AO bit. |
1769 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE4_CTL); | 1774 | * Disables "NT Ordering" (~= !"Relaxed Ordering") |
1770 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE5_CTL); | 1775 | * Overrides bit 1 in DMA Hint Sets. |
1771 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE6_CTL); | 1776 | * Improves netperf UDP_STREAM by ~10% for bcm5701. |
1772 | WRITE_REG(HF_ENABLE, sba_dev->ioc[i].ioc_hpa + ROPE7_CTL); | 1777 | */ |
1773 | 1778 | if (IS_PLUTO(sba_dev->iodc)) { | |
1774 | /* flush out the writes */ | 1779 | unsigned long rope_cfg, cfg_val; |
1780 | |||
1781 | rope_cfg = ioc_hpa + IOC_ROPE0_CFG + j; | ||
1782 | cfg_val = READ_REG(rope_cfg); | ||
1783 | cfg_val &= ~IOC_ROPE_AO; | ||
1784 | WRITE_REG(cfg_val, rope_cfg); | ||
1785 | } | ||
1786 | |||
1787 | /* | ||
1788 | ** Make sure the box crashes on rope errors. | ||
1789 | */ | ||
1790 | WRITE_REG(HF_ENABLE, ioc_hpa + ROPE0_CTL + j); | ||
1791 | } | ||
1792 | |||
1793 | /* flush out the last writes */ | ||
1775 | READ_REG(sba_dev->ioc[i].ioc_hpa + ROPE7_CTL); | 1794 | READ_REG(sba_dev->ioc[i].ioc_hpa + ROPE7_CTL); |
1776 | 1795 | ||
1777 | DBG_INIT(" ioc[%d] ROPE_CFG 0x%Lx ROPE_DBG 0x%Lx\n", | 1796 | DBG_INIT(" ioc[%d] ROPE_CFG 0x%Lx ROPE_DBG 0x%Lx\n", |
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c index 719b863bc20e..828eb45062de 100644 --- a/drivers/parisc/superio.c +++ b/drivers/parisc/superio.c | |||
@@ -155,7 +155,7 @@ superio_init(struct pci_dev *pcidev) | |||
155 | struct pci_dev *pdev = sio->lio_pdev; | 155 | struct pci_dev *pdev = sio->lio_pdev; |
156 | u16 word; | 156 | u16 word; |
157 | 157 | ||
158 | if (sio->suckyio_irq_enabled) | 158 | if (sio->suckyio_irq_enabled) |
159 | return; | 159 | return; |
160 | 160 | ||
161 | BUG_ON(!pdev); | 161 | BUG_ON(!pdev); |
@@ -194,7 +194,7 @@ superio_init(struct pci_dev *pcidev) | |||
194 | request_region (sio->acpi_base, 0x1f, "acpi"); | 194 | request_region (sio->acpi_base, 0x1f, "acpi"); |
195 | 195 | ||
196 | /* Enable the legacy I/O function */ | 196 | /* Enable the legacy I/O function */ |
197 | pci_read_config_word (pdev, PCI_COMMAND, &word); | 197 | pci_read_config_word (pdev, PCI_COMMAND, &word); |
198 | word |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO; | 198 | word |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY | PCI_COMMAND_IO; |
199 | pci_write_config_word (pdev, PCI_COMMAND, word); | 199 | pci_write_config_word (pdev, PCI_COMMAND, word); |
200 | 200 | ||
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index d5890027f8af..48bbf32fd980 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c | |||
@@ -97,7 +97,7 @@ static struct superio_struct { /* For Super-IO chips autodetection */ | |||
97 | int io; | 97 | int io; |
98 | int irq; | 98 | int irq; |
99 | int dma; | 99 | int dma; |
100 | } superios[NR_SUPERIOS] __devinitdata = { {0,},}; | 100 | } superios[NR_SUPERIOS] = { {0,},}; |
101 | 101 | ||
102 | static int user_specified; | 102 | static int user_specified; |
103 | #if defined(CONFIG_PARPORT_PC_SUPERIO) || \ | 103 | #if defined(CONFIG_PARPORT_PC_SUPERIO) || \ |
@@ -1557,7 +1557,7 @@ static int __devinit get_superio_dma (struct parport *p) | |||
1557 | return PARPORT_DMA_NONE; | 1557 | return PARPORT_DMA_NONE; |
1558 | } | 1558 | } |
1559 | 1559 | ||
1560 | static int __devinit get_superio_irq (struct parport *p) | 1560 | static int get_superio_irq (struct parport *p) |
1561 | { | 1561 | { |
1562 | int i=0; | 1562 | int i=0; |
1563 | while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) | 1563 | while( (superios[i].io != p->base) && (i<NR_SUPERIOS)) |
@@ -1579,7 +1579,7 @@ static int __devinit get_superio_irq (struct parport *p) | |||
1579 | * this shall always be the case!) | 1579 | * this shall always be the case!) |
1580 | * | 1580 | * |
1581 | */ | 1581 | */ |
1582 | static int __devinit parport_SPP_supported(struct parport *pb) | 1582 | static int parport_SPP_supported(struct parport *pb) |
1583 | { | 1583 | { |
1584 | unsigned char r, w; | 1584 | unsigned char r, w; |
1585 | 1585 | ||
@@ -1660,7 +1660,7 @@ static int __devinit parport_SPP_supported(struct parport *pb) | |||
1660 | * two bits of ECR aren't writable, so we check by writing ECR and | 1660 | * two bits of ECR aren't writable, so we check by writing ECR and |
1661 | * reading it back to see if it's what we expect. | 1661 | * reading it back to see if it's what we expect. |
1662 | */ | 1662 | */ |
1663 | static int __devinit parport_ECR_present(struct parport *pb) | 1663 | static int parport_ECR_present(struct parport *pb) |
1664 | { | 1664 | { |
1665 | struct parport_pc_private *priv = pb->private_data; | 1665 | struct parport_pc_private *priv = pb->private_data; |
1666 | unsigned char r = 0xc; | 1666 | unsigned char r = 0xc; |
@@ -1712,7 +1712,7 @@ static int __devinit parport_ECR_present(struct parport *pb) | |||
1712 | * be misdetected here is rather academic. | 1712 | * be misdetected here is rather academic. |
1713 | */ | 1713 | */ |
1714 | 1714 | ||
1715 | static int __devinit parport_PS2_supported(struct parport *pb) | 1715 | static int parport_PS2_supported(struct parport *pb) |
1716 | { | 1716 | { |
1717 | int ok = 0; | 1717 | int ok = 0; |
1718 | 1718 | ||
@@ -1868,7 +1868,7 @@ static int __devinit parport_ECP_supported(struct parport *pb) | |||
1868 | } | 1868 | } |
1869 | #endif | 1869 | #endif |
1870 | 1870 | ||
1871 | static int __devinit parport_ECPPS2_supported(struct parport *pb) | 1871 | static int parport_ECPPS2_supported(struct parport *pb) |
1872 | { | 1872 | { |
1873 | const struct parport_pc_private *priv = pb->private_data; | 1873 | const struct parport_pc_private *priv = pb->private_data; |
1874 | int result; | 1874 | int result; |
@@ -1886,7 +1886,7 @@ static int __devinit parport_ECPPS2_supported(struct parport *pb) | |||
1886 | 1886 | ||
1887 | /* EPP mode detection */ | 1887 | /* EPP mode detection */ |
1888 | 1888 | ||
1889 | static int __devinit parport_EPP_supported(struct parport *pb) | 1889 | static int parport_EPP_supported(struct parport *pb) |
1890 | { | 1890 | { |
1891 | const struct parport_pc_private *priv = pb->private_data; | 1891 | const struct parport_pc_private *priv = pb->private_data; |
1892 | 1892 | ||
@@ -1931,7 +1931,7 @@ static int __devinit parport_EPP_supported(struct parport *pb) | |||
1931 | return 1; | 1931 | return 1; |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | static int __devinit parport_ECPEPP_supported(struct parport *pb) | 1934 | static int parport_ECPEPP_supported(struct parport *pb) |
1935 | { | 1935 | { |
1936 | struct parport_pc_private *priv = pb->private_data; | 1936 | struct parport_pc_private *priv = pb->private_data; |
1937 | int result; | 1937 | int result; |
@@ -2073,7 +2073,7 @@ static int __devinit irq_probe_SPP(struct parport *pb) | |||
2073 | * When ECP is available we can autoprobe for IRQs. | 2073 | * When ECP is available we can autoprobe for IRQs. |
2074 | * NOTE: If we can autoprobe it, we can register the IRQ. | 2074 | * NOTE: If we can autoprobe it, we can register the IRQ. |
2075 | */ | 2075 | */ |
2076 | static int __devinit parport_irq_probe(struct parport *pb) | 2076 | static int parport_irq_probe(struct parport *pb) |
2077 | { | 2077 | { |
2078 | struct parport_pc_private *priv = pb->private_data; | 2078 | struct parport_pc_private *priv = pb->private_data; |
2079 | 2079 | ||
@@ -2779,7 +2779,7 @@ static struct parport_pc_pci { | |||
2779 | /* If set, this is called after probing for ports. If 'failed' | 2779 | /* If set, this is called after probing for ports. If 'failed' |
2780 | * is non-zero we couldn't use any of the ports. */ | 2780 | * is non-zero we couldn't use any of the ports. */ |
2781 | void (*postinit_hook) (struct pci_dev *pdev, int failed); | 2781 | void (*postinit_hook) (struct pci_dev *pdev, int failed); |
2782 | } cards[] __devinitdata = { | 2782 | } cards[] = { |
2783 | /* siig_1p_10x */ { 1, { { 2, 3 }, } }, | 2783 | /* siig_1p_10x */ { 1, { { 2, 3 }, } }, |
2784 | /* siig_2p_10x */ { 2, { { 2, 3 }, { 4, 5 }, } }, | 2784 | /* siig_2p_10x */ { 2, { { 2, 3 }, { 4, 5 }, } }, |
2785 | /* siig_1p_20x */ { 1, { { 0, 1 }, } }, | 2785 | /* siig_1p_20x */ { 1, { { 0, 1 }, } }, |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 2087a397ef16..9855c4c920b8 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
@@ -793,8 +793,10 @@ static int msix_capability_init(struct pci_dev *dev, | |||
793 | if (!entry) | 793 | if (!entry) |
794 | break; | 794 | break; |
795 | vector = get_msi_vector(dev); | 795 | vector = get_msi_vector(dev); |
796 | if (vector < 0) | 796 | if (vector < 0) { |
797 | kmem_cache_free(msi_cachep, entry); | ||
797 | break; | 798 | break; |
799 | } | ||
798 | 800 | ||
799 | j = entries[i].entry; | 801 | j = entries[i].entry; |
800 | entries[i].vector = vector; | 802 | entries[i].vector = vector; |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 827550d25c9e..19e2b174d33c 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -642,13 +642,15 @@ static void quirk_via_irq(struct pci_dev *dev) | |||
642 | new_irq = dev->irq & 0xf; | 642 | new_irq = dev->irq & 0xf; |
643 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); | 643 | pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &irq); |
644 | if (new_irq != irq) { | 644 | if (new_irq != irq) { |
645 | printk(KERN_INFO "PCI: Via IRQ fixup for %s, from %d to %d\n", | 645 | printk(KERN_INFO "PCI: VIA IRQ fixup for %s, from %d to %d\n", |
646 | pci_name(dev), irq, new_irq); | 646 | pci_name(dev), irq, new_irq); |
647 | udelay(15); /* unknown if delay really needed */ | 647 | udelay(15); /* unknown if delay really needed */ |
648 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); | 648 | pci_write_config_byte(dev, PCI_INTERRUPT_LINE, new_irq); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_ANY_ID, quirk_via_irq); | 651 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, quirk_via_irq); |
652 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_4, quirk_via_irq); | ||
653 | DECLARE_PCI_FIXUP_ENABLE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686_5, quirk_via_irq); | ||
652 | 654 | ||
653 | /* | 655 | /* |
654 | * VIA VT82C598 has its device ID settable and many BIOSes | 656 | * VIA VT82C598 has its device ID settable and many BIOSes |
@@ -865,6 +867,35 @@ static void __init quirk_eisa_bridge(struct pci_dev *dev) | |||
865 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_eisa_bridge ); | 867 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82375, quirk_eisa_bridge ); |
866 | 868 | ||
867 | /* | 869 | /* |
870 | * On the MSI-K8T-Neo2Fir Board, the internal Soundcard is disabled | ||
871 | * when a PCI-Soundcard is added. The BIOS only gives Options | ||
872 | * "Disabled" and "AUTO". This Quirk Sets the corresponding | ||
873 | * Register-Value to enable the Soundcard. | ||
874 | */ | ||
875 | static void __init k8t_sound_hostbridge(struct pci_dev *dev) | ||
876 | { | ||
877 | unsigned char val; | ||
878 | |||
879 | printk(KERN_INFO "PCI: Quirk-MSI-K8T Soundcard On\n"); | ||
880 | pci_read_config_byte(dev, 0x50, &val); | ||
881 | if (val == 0x88 || val == 0xc8) { | ||
882 | pci_write_config_byte(dev, 0x50, val & (~0x40)); | ||
883 | |||
884 | /* Verify the Change for Status output */ | ||
885 | pci_read_config_byte(dev, 0x50, &val); | ||
886 | if (val & 0x40) | ||
887 | printk(KERN_INFO "PCI: MSI-K8T soundcard still off\n"); | ||
888 | else | ||
889 | printk(KERN_INFO "PCI: MSI-K8T soundcard on\n"); | ||
890 | } else { | ||
891 | printk(KERN_INFO "PCI: Unexpected Value in PCI-Register: " | ||
892 | "no Change!\n"); | ||
893 | } | ||
894 | |||
895 | } | ||
896 | DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237, k8t_sound_hostbridge); | ||
897 | |||
898 | /* | ||
868 | * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge | 899 | * On ASUS P4B boards, the SMBus PCI Device within the ICH2/4 southbridge |
869 | * is not activated. The myth is that Asus said that they do not want the | 900 | * is not activated. The myth is that Asus said that they do not want the |
870 | * users to be irritated by just another PCI Device in the Win98 device | 901 | * users to be irritated by just another PCI Device in the Win98 device |
diff --git a/drivers/pcmcia/Kconfig b/drivers/pcmcia/Kconfig index cba6c9eef28e..61cb4b29f55c 100644 --- a/drivers/pcmcia/Kconfig +++ b/drivers/pcmcia/Kconfig | |||
@@ -250,7 +250,7 @@ config M32R_CFC_NUM | |||
250 | 250 | ||
251 | config PCMCIA_VRC4171 | 251 | config PCMCIA_VRC4171 |
252 | tristate "NEC VRC4171 Card Controllers support" | 252 | tristate "NEC VRC4171 Card Controllers support" |
253 | depends on VRC4171 && PCMCIA | 253 | depends on CPU_VR41XX && ISA && PCMCIA |
254 | 254 | ||
255 | config PCMCIA_VRC4173 | 255 | config PCMCIA_VRC4173 |
256 | tristate "NEC VRC4173 CARDU support" | 256 | tristate "NEC VRC4173 CARDU support" |
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c index ae10d1eed65e..48d3b3d30c21 100644 --- a/drivers/pcmcia/ds.c +++ b/drivers/pcmcia/ds.c | |||
@@ -236,11 +236,11 @@ static void pcmcia_check_driver(struct pcmcia_driver *p_drv) | |||
236 | /** | 236 | /** |
237 | * pcmcia_load_firmware - load CIS from userspace if device-provided is broken | 237 | * pcmcia_load_firmware - load CIS from userspace if device-provided is broken |
238 | * @dev - the pcmcia device which needs a CIS override | 238 | * @dev - the pcmcia device which needs a CIS override |
239 | * @filename - requested filename in /lib/firmware/cis/ | 239 | * @filename - requested filename in /lib/firmware/ |
240 | * | 240 | * |
241 | * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if | 241 | * This uses the in-kernel firmware loading mechanism to use a "fake CIS" if |
242 | * the one provided by the card is broken. The firmware files reside in | 242 | * the one provided by the card is broken. The firmware files reside in |
243 | * /lib/firmware/cis/ in userspace. | 243 | * /lib/firmware/ in userspace. |
244 | */ | 244 | */ |
245 | static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) | 245 | static int pcmcia_load_firmware(struct pcmcia_device *dev, char * filename) |
246 | { | 246 | { |
@@ -298,9 +298,6 @@ static inline int pcmcia_load_firmware(struct pcmcia_device *dev, char * filenam | |||
298 | * | 298 | * |
299 | * Registers a PCMCIA driver with the PCMCIA bus core. | 299 | * Registers a PCMCIA driver with the PCMCIA bus core. |
300 | */ | 300 | */ |
301 | static int pcmcia_device_probe(struct device *dev); | ||
302 | static int pcmcia_device_remove(struct device * dev); | ||
303 | |||
304 | int pcmcia_register_driver(struct pcmcia_driver *driver) | 301 | int pcmcia_register_driver(struct pcmcia_driver *driver) |
305 | { | 302 | { |
306 | if (!driver) | 303 | if (!driver) |
@@ -400,7 +397,7 @@ static int pcmcia_device_probe(struct device * dev) | |||
400 | * call which will then check whether there are two | 397 | * call which will then check whether there are two |
401 | * pseudo devices, and if not, add the second one. | 398 | * pseudo devices, and if not, add the second one. |
402 | */ | 399 | */ |
403 | did = (struct pcmcia_device_id *) p_dev->dev.driver_data; | 400 | did = p_dev->dev.driver_data; |
404 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && | 401 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && |
405 | (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) | 402 | (p_dev->socket->device_count == 1) && (p_dev->device_no == 0)) |
406 | pcmcia_add_pseudo_device(p_dev->socket); | 403 | pcmcia_add_pseudo_device(p_dev->socket); |
@@ -448,7 +445,6 @@ static void pcmcia_card_remove(struct pcmcia_socket *s, struct pcmcia_device *le | |||
448 | return; | 445 | return; |
449 | } | 446 | } |
450 | 447 | ||
451 | |||
452 | static int pcmcia_device_remove(struct device * dev) | 448 | static int pcmcia_device_remove(struct device * dev) |
453 | { | 449 | { |
454 | struct pcmcia_device *p_dev; | 450 | struct pcmcia_device *p_dev; |
@@ -463,7 +459,7 @@ static int pcmcia_device_remove(struct device * dev) | |||
463 | * pseudo multi-function card, we need to unbind | 459 | * pseudo multi-function card, we need to unbind |
464 | * all devices | 460 | * all devices |
465 | */ | 461 | */ |
466 | did = (struct pcmcia_device_id *) p_dev->dev.driver_data; | 462 | did = p_dev->dev.driver_data; |
467 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && | 463 | if (did && (did->match_flags & PCMCIA_DEV_ID_MATCH_DEVICE_NO) && |
468 | (p_dev->socket->device_count != 0) && | 464 | (p_dev->socket->device_count != 0) && |
469 | (p_dev->device_no == 0)) | 465 | (p_dev->device_no == 0)) |
@@ -476,6 +472,8 @@ static int pcmcia_device_remove(struct device * dev) | |||
476 | if (p_drv->remove) | 472 | if (p_drv->remove) |
477 | p_drv->remove(p_dev); | 473 | p_drv->remove(p_dev); |
478 | 474 | ||
475 | p_dev->dev_node = NULL; | ||
476 | |||
479 | /* check for proper unloading */ | 477 | /* check for proper unloading */ |
480 | if (p_dev->_irq || p_dev->_io || p_dev->_locked) | 478 | if (p_dev->_irq || p_dev->_io || p_dev->_locked) |
481 | printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", | 479 | printk(KERN_INFO "pcmcia: driver %s did not release config properly\n", |
@@ -628,7 +626,7 @@ struct pcmcia_device * pcmcia_device_add(struct pcmcia_socket *s, unsigned int f | |||
628 | } | 626 | } |
629 | 627 | ||
630 | /* Add to the list in pcmcia_bus_socket */ | 628 | /* Add to the list in pcmcia_bus_socket */ |
631 | list_add_tail(&p_dev->socket_device_list, &s->devices_list); | 629 | list_add(&p_dev->socket_device_list, &s->devices_list); |
632 | 630 | ||
633 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); | 631 | spin_unlock_irqrestore(&pcmcia_dev_list_lock, flags); |
634 | 632 | ||
diff --git a/drivers/pcmcia/i82365.c b/drivers/pcmcia/i82365.c index bd0308e89815..a2f05f485156 100644 --- a/drivers/pcmcia/i82365.c +++ b/drivers/pcmcia/i82365.c | |||
@@ -509,7 +509,8 @@ static irqreturn_t i365_count_irq(int irq, void *dev, struct pt_regs *regs) | |||
509 | static u_int __init test_irq(u_short sock, int irq) | 509 | static u_int __init test_irq(u_short sock, int irq) |
510 | { | 510 | { |
511 | debug(2, " testing ISA irq %d\n", irq); | 511 | debug(2, " testing ISA irq %d\n", irq); |
512 | if (request_irq(irq, i365_count_irq, 0, "scan", i365_count_irq) != 0) | 512 | if (request_irq(irq, i365_count_irq, SA_PROBEIRQ, "scan", |
513 | i365_count_irq) != 0) | ||
513 | return 1; | 514 | return 1; |
514 | irq_hits = 0; irq_sock = sock; | 515 | irq_hits = 0; irq_sock = sock; |
515 | msleep(10); | 516 | msleep(10); |
@@ -561,7 +562,7 @@ static u_int __init isa_scan(u_short sock, u_int mask0) | |||
561 | } else { | 562 | } else { |
562 | /* Fallback: just find interrupts that aren't in use */ | 563 | /* Fallback: just find interrupts that aren't in use */ |
563 | for (i = 0; i < 16; i++) | 564 | for (i = 0; i < 16; i++) |
564 | if ((mask0 & (1 << i)) && (_check_irq(i, 0) == 0)) | 565 | if ((mask0 & (1 << i)) && (_check_irq(i, SA_PROBEIRQ) == 0)) |
565 | mask1 |= (1 << i); | 566 | mask1 |= (1 << i); |
566 | printk("default"); | 567 | printk("default"); |
567 | /* If scan failed, default to polled status */ | 568 | /* If scan failed, default to polled status */ |
@@ -725,7 +726,7 @@ static void __init add_pcic(int ns, int type) | |||
725 | u_int cs_mask = mask & ((cs_irq) ? (1<<cs_irq) : ~(1<<12)); | 726 | u_int cs_mask = mask & ((cs_irq) ? (1<<cs_irq) : ~(1<<12)); |
726 | for (cs_irq = 15; cs_irq > 0; cs_irq--) | 727 | for (cs_irq = 15; cs_irq > 0; cs_irq--) |
727 | if ((cs_mask & (1 << cs_irq)) && | 728 | if ((cs_mask & (1 << cs_irq)) && |
728 | (_check_irq(cs_irq, 0) == 0)) | 729 | (_check_irq(cs_irq, SA_PROBEIRQ) == 0)) |
729 | break; | 730 | break; |
730 | if (cs_irq) { | 731 | if (cs_irq) { |
731 | grab_irq = 1; | 732 | grab_irq = 1; |
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c index 45063b4e5b78..3131bb0a0095 100644 --- a/drivers/pcmcia/pcmcia_resource.c +++ b/drivers/pcmcia/pcmcia_resource.c | |||
@@ -88,7 +88,6 @@ static int alloc_io_space(struct pcmcia_socket *s, u_int attr, ioaddr_t *base, | |||
88 | } | 88 | } |
89 | if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { | 89 | if ((s->features & SS_CAP_STATIC_MAP) && s->io_offset) { |
90 | *base = s->io_offset | (*base & 0x0fff); | 90 | *base = s->io_offset | (*base & 0x0fff); |
91 | s->io[0].res->flags = (s->io[0].res->flags & ~IORESOURCE_BITS) | (attr & IORESOURCE_BITS); | ||
92 | return 0; | 91 | return 0; |
93 | } | 92 | } |
94 | /* Check for an already-allocated window that must conflict with | 93 | /* Check for an already-allocated window that must conflict with |
@@ -209,7 +208,6 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, | |||
209 | if (!(s->state & SOCKET_PRESENT)) | 208 | if (!(s->state & SOCKET_PRESENT)) |
210 | return CS_NO_CARD; | 209 | return CS_NO_CARD; |
211 | 210 | ||
212 | config->Function = p_dev->func; | ||
213 | 211 | ||
214 | #ifdef CONFIG_CARDBUS | 212 | #ifdef CONFIG_CARDBUS |
215 | if (s->state & SOCKET_CARDBUS) { | 213 | if (s->state & SOCKET_CARDBUS) { |
@@ -223,14 +221,22 @@ int pccard_get_configuration_info(struct pcmcia_socket *s, | |||
223 | config->AssignedIRQ = s->irq.AssignedIRQ; | 221 | config->AssignedIRQ = s->irq.AssignedIRQ; |
224 | if (config->AssignedIRQ) | 222 | if (config->AssignedIRQ) |
225 | config->Attributes |= CONF_ENABLE_IRQ; | 223 | config->Attributes |= CONF_ENABLE_IRQ; |
226 | config->BasePort1 = s->io[0].res->start; | 224 | if (s->io[0].res) { |
227 | config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; | 225 | config->BasePort1 = s->io[0].res->start; |
226 | config->NumPorts1 = s->io[0].res->end - config->BasePort1 + 1; | ||
227 | } | ||
228 | } | 228 | } |
229 | return CS_SUCCESS; | 229 | return CS_SUCCESS; |
230 | } | 230 | } |
231 | #endif | 231 | #endif |
232 | 232 | ||
233 | c = (p_dev) ? p_dev->function_config : NULL; | 233 | if (p_dev) { |
234 | c = p_dev->function_config; | ||
235 | config->Function = p_dev->func; | ||
236 | } else { | ||
237 | c = NULL; | ||
238 | config->Function = 0; | ||
239 | } | ||
234 | 240 | ||
235 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { | 241 | if ((c == NULL) || !(c->state & CONFIG_LOCKED)) { |
236 | config->Attributes = 0; | 242 | config->Attributes = 0; |
@@ -947,7 +953,5 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev) { | |||
947 | pcmcia_release_irq(p_dev, &p_dev->irq); | 953 | pcmcia_release_irq(p_dev, &p_dev->irq); |
948 | if (&p_dev->win) | 954 | if (&p_dev->win) |
949 | pcmcia_release_window(p_dev->win); | 955 | pcmcia_release_window(p_dev->win); |
950 | |||
951 | p_dev->dev_node = NULL; | ||
952 | } | 956 | } |
953 | EXPORT_SYMBOL(pcmcia_disable_device); | 957 | EXPORT_SYMBOL(pcmcia_disable_device); |
diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index fd3647368955..b7b9e149c5b9 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c | |||
@@ -26,14 +26,6 @@ | |||
26 | #include "soc_common.h" | 26 | #include "soc_common.h" |
27 | 27 | ||
28 | #define NO_KEEP_VS 0x0001 | 28 | #define NO_KEEP_VS 0x0001 |
29 | |||
30 | /* PCMCIA to Scoop linkage | ||
31 | |||
32 | There is no easy way to link multiple scoop devices into one | ||
33 | single entity for the pxa2xx_pcmcia device so this structure | ||
34 | is used which is setup by the platform code | ||
35 | */ | ||
36 | struct scoop_pcmcia_config *platform_scoop_config; | ||
37 | #define SCOOP_DEV platform_scoop_config->devs | 29 | #define SCOOP_DEV platform_scoop_config->devs |
38 | 30 | ||
39 | static void sharpsl_pcmcia_init_reset(struct soc_pcmcia_socket *skt) | 31 | static void sharpsl_pcmcia_init_reset(struct soc_pcmcia_socket *skt) |
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c index c4256aa32bcb..6fff109bdab6 100644 --- a/drivers/pnp/manager.c +++ b/drivers/pnp/manager.c | |||
@@ -479,7 +479,7 @@ int pnp_auto_config_dev(struct pnp_dev *dev) | |||
479 | int pnp_start_dev(struct pnp_dev *dev) | 479 | int pnp_start_dev(struct pnp_dev *dev) |
480 | { | 480 | { |
481 | if (!pnp_can_write(dev)) { | 481 | if (!pnp_can_write(dev)) { |
482 | pnp_info("Device %s does not supported activation.", dev->dev.bus_id); | 482 | pnp_info("Device %s does not support activation.", dev->dev.bus_id); |
483 | return -EINVAL; | 483 | return -EINVAL; |
484 | } | 484 | } |
485 | 485 | ||
@@ -503,7 +503,7 @@ int pnp_start_dev(struct pnp_dev *dev) | |||
503 | int pnp_stop_dev(struct pnp_dev *dev) | 503 | int pnp_stop_dev(struct pnp_dev *dev) |
504 | { | 504 | { |
505 | if (!pnp_can_disable(dev)) { | 505 | if (!pnp_can_disable(dev)) { |
506 | pnp_info("Device %s does not supported disabling.", dev->dev.bus_id); | 506 | pnp_info("Device %s does not support disabling.", dev->dev.bus_id); |
507 | return -EINVAL; | 507 | return -EINVAL; |
508 | } | 508 | } |
509 | if (dev->protocol->disable(dev)<0) { | 509 | if (dev->protocol->disable(dev)<0) { |
diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c index b1e3e6179e56..6c9ad92747fd 100644 --- a/drivers/rtc/rtc-dev.c +++ b/drivers/rtc/rtc-dev.c | |||
@@ -58,7 +58,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
58 | unsigned long data; | 58 | unsigned long data; |
59 | ssize_t ret; | 59 | ssize_t ret; |
60 | 60 | ||
61 | if (count < sizeof(unsigned long)) | 61 | if (count != sizeof(unsigned int) && count < sizeof(unsigned long)) |
62 | return -EINVAL; | 62 | return -EINVAL; |
63 | 63 | ||
64 | add_wait_queue(&rtc->irq_queue, &wait); | 64 | add_wait_queue(&rtc->irq_queue, &wait); |
@@ -90,11 +90,16 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
90 | if (ret == 0) { | 90 | if (ret == 0) { |
91 | /* Check for any data updates */ | 91 | /* Check for any data updates */ |
92 | if (rtc->ops->read_callback) | 92 | if (rtc->ops->read_callback) |
93 | data = rtc->ops->read_callback(rtc->class_dev.dev, data); | 93 | data = rtc->ops->read_callback(rtc->class_dev.dev, |
94 | 94 | data); | |
95 | ret = put_user(data, (unsigned long __user *)buf); | 95 | |
96 | if (ret == 0) | 96 | if (sizeof(int) != sizeof(long) && |
97 | ret = sizeof(unsigned long); | 97 | count == sizeof(unsigned int)) |
98 | ret = put_user(data, (unsigned int __user *)buf) ?: | ||
99 | sizeof(unsigned int); | ||
100 | else | ||
101 | ret = put_user(data, (unsigned long __user *)buf) ?: | ||
102 | sizeof(unsigned long); | ||
98 | } | 103 | } |
99 | return ret; | 104 | return ret; |
100 | } | 105 | } |
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index a3bfebcf31ef..cfb1fff3787c 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c | |||
@@ -315,6 +315,11 @@ dasd_increase_state(struct dasd_device *device) | |||
315 | rc = dasd_state_basic_to_ready(device); | 315 | rc = dasd_state_basic_to_ready(device); |
316 | 316 | ||
317 | if (!rc && | 317 | if (!rc && |
318 | device->state == DASD_STATE_UNFMT && | ||
319 | device->target > DASD_STATE_UNFMT) | ||
320 | rc = -EPERM; | ||
321 | |||
322 | if (!rc && | ||
318 | device->state == DASD_STATE_READY && | 323 | device->state == DASD_STATE_READY && |
319 | device->target >= DASD_STATE_ONLINE) | 324 | device->target >= DASD_STATE_ONLINE) |
320 | rc = dasd_state_ready_to_online(device); | 325 | rc = dasd_state_ready_to_online(device); |
diff --git a/drivers/s390/block/dasd_devmap.c b/drivers/s390/block/dasd_devmap.c index c1c6f1381150..216bc4fba199 100644 --- a/drivers/s390/block/dasd_devmap.c +++ b/drivers/s390/block/dasd_devmap.c | |||
@@ -45,6 +45,7 @@ struct dasd_devmap { | |||
45 | unsigned int devindex; | 45 | unsigned int devindex; |
46 | unsigned short features; | 46 | unsigned short features; |
47 | struct dasd_device *device; | 47 | struct dasd_device *device; |
48 | struct dasd_uid uid; | ||
48 | }; | 49 | }; |
49 | 50 | ||
50 | /* | 51 | /* |
@@ -716,6 +717,68 @@ dasd_discipline_show(struct device *dev, struct device_attribute *attr, char *bu | |||
716 | 717 | ||
717 | static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); | 718 | static DEVICE_ATTR(discipline, 0444, dasd_discipline_show, NULL); |
718 | 719 | ||
720 | static ssize_t | ||
721 | dasd_alias_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
722 | { | ||
723 | struct dasd_devmap *devmap; | ||
724 | int alias; | ||
725 | |||
726 | devmap = dasd_find_busid(dev->bus_id); | ||
727 | spin_lock(&dasd_devmap_lock); | ||
728 | if (!IS_ERR(devmap)) | ||
729 | alias = devmap->uid.alias; | ||
730 | else | ||
731 | alias = 0; | ||
732 | spin_unlock(&dasd_devmap_lock); | ||
733 | |||
734 | return sprintf(buf, alias ? "1\n" : "0\n"); | ||
735 | } | ||
736 | |||
737 | static DEVICE_ATTR(alias, 0444, dasd_alias_show, NULL); | ||
738 | |||
739 | static ssize_t | ||
740 | dasd_vendor_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
741 | { | ||
742 | struct dasd_devmap *devmap; | ||
743 | char *vendor; | ||
744 | |||
745 | devmap = dasd_find_busid(dev->bus_id); | ||
746 | spin_lock(&dasd_devmap_lock); | ||
747 | if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0) | ||
748 | vendor = devmap->uid.vendor; | ||
749 | else | ||
750 | vendor = ""; | ||
751 | spin_unlock(&dasd_devmap_lock); | ||
752 | |||
753 | return snprintf(buf, PAGE_SIZE, "%s\n", vendor); | ||
754 | } | ||
755 | |||
756 | static DEVICE_ATTR(vendor, 0444, dasd_vendor_show, NULL); | ||
757 | |||
758 | #define UID_STRLEN ( /* vendor */ 3 + 1 + /* serial */ 14 + 1 +\ | ||
759 | /* SSID */ 4 + 1 + /* unit addr */ 2 + 1) | ||
760 | |||
761 | static ssize_t | ||
762 | dasd_uid_show(struct device *dev, struct device_attribute *attr, char *buf) | ||
763 | { | ||
764 | struct dasd_devmap *devmap; | ||
765 | char uid[UID_STRLEN]; | ||
766 | |||
767 | devmap = dasd_find_busid(dev->bus_id); | ||
768 | spin_lock(&dasd_devmap_lock); | ||
769 | if (!IS_ERR(devmap) && strlen(devmap->uid.vendor) > 0) | ||
770 | snprintf(uid, sizeof(uid), "%s.%s.%04x.%02x", | ||
771 | devmap->uid.vendor, devmap->uid.serial, | ||
772 | devmap->uid.ssid, devmap->uid.unit_addr); | ||
773 | else | ||
774 | uid[0] = 0; | ||
775 | spin_unlock(&dasd_devmap_lock); | ||
776 | |||
777 | return snprintf(buf, PAGE_SIZE, "%s\n", uid); | ||
778 | } | ||
779 | |||
780 | static DEVICE_ATTR(uid, 0444, dasd_uid_show, NULL); | ||
781 | |||
719 | /* | 782 | /* |
720 | * extended error-reporting | 783 | * extended error-reporting |
721 | */ | 784 | */ |
@@ -759,6 +822,9 @@ static DEVICE_ATTR(eer_enabled, 0644, dasd_eer_show, dasd_eer_store); | |||
759 | static struct attribute * dasd_attrs[] = { | 822 | static struct attribute * dasd_attrs[] = { |
760 | &dev_attr_readonly.attr, | 823 | &dev_attr_readonly.attr, |
761 | &dev_attr_discipline.attr, | 824 | &dev_attr_discipline.attr, |
825 | &dev_attr_alias.attr, | ||
826 | &dev_attr_vendor.attr, | ||
827 | &dev_attr_uid.attr, | ||
762 | &dev_attr_use_diag.attr, | 828 | &dev_attr_use_diag.attr, |
763 | &dev_attr_eer_enabled.attr, | 829 | &dev_attr_eer_enabled.attr, |
764 | NULL, | 830 | NULL, |
@@ -768,6 +834,42 @@ static struct attribute_group dasd_attr_group = { | |||
768 | .attrs = dasd_attrs, | 834 | .attrs = dasd_attrs, |
769 | }; | 835 | }; |
770 | 836 | ||
837 | |||
838 | /* | ||
839 | * Return copy of the device unique identifier. | ||
840 | */ | ||
841 | int | ||
842 | dasd_get_uid(struct ccw_device *cdev, struct dasd_uid *uid) | ||
843 | { | ||
844 | struct dasd_devmap *devmap; | ||
845 | |||
846 | devmap = dasd_find_busid(cdev->dev.bus_id); | ||
847 | if (IS_ERR(devmap)) | ||
848 | return PTR_ERR(devmap); | ||
849 | spin_lock(&dasd_devmap_lock); | ||
850 | *uid = devmap->uid; | ||
851 | spin_unlock(&dasd_devmap_lock); | ||
852 | return 0; | ||
853 | } | ||
854 | |||
855 | /* | ||
856 | * Register the given device unique identifier into devmap struct. | ||
857 | */ | ||
858 | int | ||
859 | dasd_set_uid(struct ccw_device *cdev, struct dasd_uid *uid) | ||
860 | { | ||
861 | struct dasd_devmap *devmap; | ||
862 | |||
863 | devmap = dasd_find_busid(cdev->dev.bus_id); | ||
864 | if (IS_ERR(devmap)) | ||
865 | return PTR_ERR(devmap); | ||
866 | spin_lock(&dasd_devmap_lock); | ||
867 | devmap->uid = *uid; | ||
868 | spin_unlock(&dasd_devmap_lock); | ||
869 | return 0; | ||
870 | } | ||
871 | EXPORT_SYMBOL(dasd_set_uid); | ||
872 | |||
771 | /* | 873 | /* |
772 | * Return value of the specified feature. | 874 | * Return value of the specified feature. |
773 | */ | 875 | */ |
diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index ee09ef33d08d..7d5a6cee4bd8 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c | |||
@@ -446,6 +446,39 @@ dasd_eckd_cdl_reclen(int recid) | |||
446 | return LABEL_SIZE; | 446 | return LABEL_SIZE; |
447 | } | 447 | } |
448 | 448 | ||
449 | /* | ||
450 | * Generate device unique id that specifies the physical device. | ||
451 | */ | ||
452 | static int | ||
453 | dasd_eckd_generate_uid(struct dasd_device *device, struct dasd_uid *uid) | ||
454 | { | ||
455 | struct dasd_eckd_private *private; | ||
456 | struct dasd_eckd_confdata *confdata; | ||
457 | |||
458 | private = (struct dasd_eckd_private *) device->private; | ||
459 | if (!private) | ||
460 | return -ENODEV; | ||
461 | confdata = &private->conf_data; | ||
462 | if (!confdata) | ||
463 | return -ENODEV; | ||
464 | |||
465 | memset(uid, 0, sizeof(struct dasd_uid)); | ||
466 | strncpy(uid->vendor, confdata->ned1.HDA_manufacturer, | ||
467 | sizeof(uid->vendor) - 1); | ||
468 | EBCASC(uid->vendor, sizeof(uid->vendor) - 1); | ||
469 | strncpy(uid->serial, confdata->ned1.HDA_location, | ||
470 | sizeof(uid->serial) - 1); | ||
471 | EBCASC(uid->serial, sizeof(uid->serial) - 1); | ||
472 | uid->ssid = confdata->neq.subsystemID; | ||
473 | if (confdata->ned2.sneq.flags == 0x40) { | ||
474 | uid->alias = 1; | ||
475 | uid->unit_addr = confdata->ned2.sneq.base_unit_addr; | ||
476 | } else | ||
477 | uid->unit_addr = confdata->ned1.unit_addr; | ||
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
449 | static int | 482 | static int |
450 | dasd_eckd_read_conf(struct dasd_device *device) | 483 | dasd_eckd_read_conf(struct dasd_device *device) |
451 | { | 484 | { |
@@ -507,11 +540,15 @@ dasd_eckd_read_conf(struct dasd_device *device) | |||
507 | return 0; | 540 | return 0; |
508 | } | 541 | } |
509 | 542 | ||
510 | 543 | /* | |
544 | * Check device characteristics. | ||
545 | * If the device is accessible using ECKD discipline, the device is enabled. | ||
546 | */ | ||
511 | static int | 547 | static int |
512 | dasd_eckd_check_characteristics(struct dasd_device *device) | 548 | dasd_eckd_check_characteristics(struct dasd_device *device) |
513 | { | 549 | { |
514 | struct dasd_eckd_private *private; | 550 | struct dasd_eckd_private *private; |
551 | struct dasd_uid uid; | ||
515 | void *rdc_data; | 552 | void *rdc_data; |
516 | int rc; | 553 | int rc; |
517 | 554 | ||
@@ -536,6 +573,7 @@ dasd_eckd_check_characteristics(struct dasd_device *device) | |||
536 | 573 | ||
537 | /* Read Device Characteristics */ | 574 | /* Read Device Characteristics */ |
538 | rdc_data = (void *) &(private->rdc_data); | 575 | rdc_data = (void *) &(private->rdc_data); |
576 | memset(rdc_data, 0, sizeof(rdc_data)); | ||
539 | rc = read_dev_chars(device->cdev, &rdc_data, 64); | 577 | rc = read_dev_chars(device->cdev, &rdc_data, 64); |
540 | if (rc) { | 578 | if (rc) { |
541 | DEV_MESSAGE(KERN_WARNING, device, | 579 | DEV_MESSAGE(KERN_WARNING, device, |
@@ -556,8 +594,17 @@ dasd_eckd_check_characteristics(struct dasd_device *device) | |||
556 | 594 | ||
557 | /* Read Configuration Data */ | 595 | /* Read Configuration Data */ |
558 | rc = dasd_eckd_read_conf (device); | 596 | rc = dasd_eckd_read_conf (device); |
559 | return rc; | 597 | if (rc) |
598 | return rc; | ||
599 | |||
600 | /* Generate device unique id and register in devmap */ | ||
601 | rc = dasd_eckd_generate_uid(device, &uid); | ||
602 | if (rc) | ||
603 | return rc; | ||
560 | 604 | ||
605 | rc = dasd_set_uid(device->cdev, &uid); | ||
606 | |||
607 | return rc; | ||
561 | } | 608 | } |
562 | 609 | ||
563 | static struct dasd_ccw_req * | 610 | static struct dasd_ccw_req * |
diff --git a/drivers/s390/block/dasd_eckd.h b/drivers/s390/block/dasd_eckd.h index ad8524bb7bb3..d5734e976e1c 100644 --- a/drivers/s390/block/dasd_eckd.h +++ b/drivers/s390/block/dasd_eckd.h | |||
@@ -228,26 +228,36 @@ struct dasd_eckd_confdata { | |||
228 | unsigned char HDA_manufacturer[3]; | 228 | unsigned char HDA_manufacturer[3]; |
229 | unsigned char HDA_location[2]; | 229 | unsigned char HDA_location[2]; |
230 | unsigned char HDA_seqno[12]; | 230 | unsigned char HDA_seqno[12]; |
231 | __u16 ID; | 231 | __u8 ID; |
232 | __u8 unit_addr; | ||
232 | } __attribute__ ((packed)) ned1; | 233 | } __attribute__ ((packed)) ned1; |
233 | struct { | 234 | union { |
234 | struct { | 235 | struct { |
235 | unsigned char identifier:2; | 236 | struct { |
236 | unsigned char token_id:1; | 237 | unsigned char identifier:2; |
237 | unsigned char sno_valid:1; | 238 | unsigned char token_id:1; |
238 | unsigned char subst_sno:1; | 239 | unsigned char sno_valid:1; |
239 | unsigned char recNED:1; | 240 | unsigned char subst_sno:1; |
240 | unsigned char emuNED:1; | 241 | unsigned char recNED:1; |
241 | unsigned char reserved:1; | 242 | unsigned char emuNED:1; |
242 | } __attribute__ ((packed)) flags; | 243 | unsigned char reserved:1; |
243 | __u8 descriptor; | 244 | } __attribute__ ((packed)) flags; |
244 | __u8 reserved[2]; | 245 | __u8 descriptor; |
245 | unsigned char dev_type[6]; | 246 | __u8 reserved[2]; |
246 | unsigned char dev_model[3]; | 247 | unsigned char dev_type[6]; |
247 | unsigned char DASD_manufacturer[3]; | 248 | unsigned char dev_model[3]; |
248 | unsigned char DASD_location[2]; | 249 | unsigned char DASD_manufacturer[3]; |
249 | unsigned char DASD_seqno[12]; | 250 | unsigned char DASD_location[2]; |
250 | __u16 ID; | 251 | unsigned char DASD_seqno[12]; |
252 | __u16 ID; | ||
253 | } __attribute__ ((packed)) ned; | ||
254 | struct { | ||
255 | unsigned char flags; /* byte 0 */ | ||
256 | unsigned char res2[7]; /* byte 1- 7 */ | ||
257 | unsigned char sua_flags; /* byte 8 */ | ||
258 | __u8 base_unit_addr; /* byte 9 */ | ||
259 | unsigned char res3[22]; /* byte 10-31 */ | ||
260 | } __attribute__ ((packed)) sneq; | ||
251 | } __attribute__ ((packed)) ned2; | 261 | } __attribute__ ((packed)) ned2; |
252 | struct { | 262 | struct { |
253 | struct { | 263 | struct { |
diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h index 4293ba827523..d4b13e300a76 100644 --- a/drivers/s390/block/dasd_int.h +++ b/drivers/s390/block/dasd_int.h | |||
@@ -268,6 +268,16 @@ struct dasd_discipline { | |||
268 | 268 | ||
269 | extern struct dasd_discipline *dasd_diag_discipline_pointer; | 269 | extern struct dasd_discipline *dasd_diag_discipline_pointer; |
270 | 270 | ||
271 | /* | ||
272 | * Unique identifier for dasd device. | ||
273 | */ | ||
274 | struct dasd_uid { | ||
275 | __u8 alias; | ||
276 | char vendor[4]; | ||
277 | char serial[15]; | ||
278 | __u16 ssid; | ||
279 | __u8 unit_addr; | ||
280 | }; | ||
271 | 281 | ||
272 | /* | 282 | /* |
273 | * Notification numbers for extended error reporting notifications: | 283 | * Notification numbers for extended error reporting notifications: |
@@ -516,6 +526,8 @@ void dasd_devmap_exit(void); | |||
516 | struct dasd_device *dasd_create_device(struct ccw_device *); | 526 | struct dasd_device *dasd_create_device(struct ccw_device *); |
517 | void dasd_delete_device(struct dasd_device *); | 527 | void dasd_delete_device(struct dasd_device *); |
518 | 528 | ||
529 | int dasd_get_uid(struct ccw_device *, struct dasd_uid *); | ||
530 | int dasd_set_uid(struct ccw_device *, struct dasd_uid *); | ||
519 | int dasd_get_feature(struct ccw_device *, int); | 531 | int dasd_get_feature(struct ccw_device *, int); |
520 | int dasd_set_feature(struct ccw_device *, int, int); | 532 | int dasd_set_feature(struct ccw_device *, int, int); |
521 | 533 | ||
diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c index c3915f60a3aa..d71ef1adea59 100644 --- a/drivers/s390/char/tape_3590.c +++ b/drivers/s390/char/tape_3590.c | |||
@@ -230,14 +230,16 @@ tape_3590_read_attmsg(struct tape_device *device) | |||
230 | * These functions are used to schedule follow-up actions from within an | 230 | * These functions are used to schedule follow-up actions from within an |
231 | * interrupt context (like unsolicited interrupts). | 231 | * interrupt context (like unsolicited interrupts). |
232 | */ | 232 | */ |
233 | struct work_handler_data { | ||
234 | struct tape_device *device; | ||
235 | enum tape_op op; | ||
236 | struct work_struct work; | ||
237 | }; | ||
238 | |||
233 | static void | 239 | static void |
234 | tape_3590_work_handler(void *data) | 240 | tape_3590_work_handler(void *data) |
235 | { | 241 | { |
236 | struct { | 242 | struct work_handler_data *p = data; |
237 | struct tape_device *device; | ||
238 | enum tape_op op; | ||
239 | struct work_struct work; | ||
240 | } *p = data; | ||
241 | 243 | ||
242 | switch (p->op) { | 244 | switch (p->op) { |
243 | case TO_MSEN: | 245 | case TO_MSEN: |
@@ -257,11 +259,7 @@ tape_3590_work_handler(void *data) | |||
257 | static int | 259 | static int |
258 | tape_3590_schedule_work(struct tape_device *device, enum tape_op op) | 260 | tape_3590_schedule_work(struct tape_device *device, enum tape_op op) |
259 | { | 261 | { |
260 | struct { | 262 | struct work_handler_data *p; |
261 | struct tape_device *device; | ||
262 | enum tape_op op; | ||
263 | struct work_struct work; | ||
264 | } *p; | ||
265 | 263 | ||
266 | if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) | 264 | if ((p = kzalloc(sizeof(*p), GFP_ATOMIC)) == NULL) |
267 | return -ENOMEM; | 265 | return -ENOMEM; |
@@ -316,7 +314,7 @@ tape_3590_bread(struct tape_device *device, struct request *req) | |||
316 | 314 | ||
317 | rq_for_each_bio(bio, req) { | 315 | rq_for_each_bio(bio, req) { |
318 | bio_for_each_segment(bv, bio, i) { | 316 | bio_for_each_segment(bv, bio, i) { |
319 | dst = kmap(bv->bv_page) + bv->bv_offset; | 317 | dst = page_address(bv->bv_page) + bv->bv_offset; |
320 | for (off = 0; off < bv->bv_len; | 318 | for (off = 0; off < bv->bv_len; |
321 | off += TAPEBLOCK_HSEC_SIZE) { | 319 | off += TAPEBLOCK_HSEC_SIZE) { |
322 | ccw->flags = CCW_FLAG_CC; | 320 | ccw->flags = CCW_FLAG_CC; |
@@ -1168,6 +1166,7 @@ tape_3590_setup_device(struct tape_device *device) | |||
1168 | static void | 1166 | static void |
1169 | tape_3590_cleanup_device(struct tape_device *device) | 1167 | tape_3590_cleanup_device(struct tape_device *device) |
1170 | { | 1168 | { |
1169 | flush_scheduled_work(); | ||
1171 | tape_std_unassign(device); | 1170 | tape_std_unassign(device); |
1172 | 1171 | ||
1173 | kfree(device->discdata); | 1172 | kfree(device->discdata); |
@@ -1234,6 +1233,7 @@ static struct tape_discipline tape_discipline_3590 = { | |||
1234 | 1233 | ||
1235 | static struct ccw_device_id tape_3590_ids[] = { | 1234 | static struct ccw_device_id tape_3590_ids[] = { |
1236 | {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590}, | 1235 | {CCW_DEVICE_DEVTYPE(0x3590, 0, 0x3590, 0), .driver_info = tape_3590}, |
1236 | {CCW_DEVICE_DEVTYPE(0x3592, 0, 0x3592, 0), .driver_info = tape_3592}, | ||
1237 | { /* end of list */ } | 1237 | { /* end of list */ } |
1238 | }; | 1238 | }; |
1239 | 1239 | ||
diff --git a/drivers/s390/char/tape_std.h b/drivers/s390/char/tape_std.h index 2d311798edf4..1fc952359341 100644 --- a/drivers/s390/char/tape_std.h +++ b/drivers/s390/char/tape_std.h | |||
@@ -153,6 +153,7 @@ enum s390_tape_type { | |||
153 | tape_3480, | 153 | tape_3480, |
154 | tape_3490, | 154 | tape_3490, |
155 | tape_3590, | 155 | tape_3590, |
156 | tape_3592, | ||
156 | }; | 157 | }; |
157 | 158 | ||
158 | #endif // _TAPE_STD_H | 159 | #endif // _TAPE_STD_H |
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c index 6412b2c3edd3..72187e54dcac 100644 --- a/drivers/s390/cio/chsc.c +++ b/drivers/s390/cio/chsc.c | |||
@@ -242,28 +242,10 @@ s390_subchannel_remove_chpid(struct device *dev, void *data) | |||
242 | if (sch->vpm == mask) | 242 | if (sch->vpm == mask) |
243 | goto out_unreg; | 243 | goto out_unreg; |
244 | 244 | ||
245 | if ((sch->schib.scsw.actl & (SCSW_ACTL_CLEAR_PEND | | 245 | if ((sch->schib.scsw.actl & SCSW_ACTL_DEVACT) && |
246 | SCSW_ACTL_HALT_PEND | | 246 | (sch->schib.scsw.actl & SCSW_ACTL_SCHACT) && |
247 | SCSW_ACTL_START_PEND | | 247 | (sch->schib.pmcw.lpum == mask) && |
248 | SCSW_ACTL_RESUME_PEND)) && | 248 | (sch->vpm == 0)) { |
249 | (sch->schib.pmcw.lpum == mask)) { | ||
250 | int cc = cio_cancel(sch); | ||
251 | |||
252 | if (cc == -ENODEV) | ||
253 | goto out_unreg; | ||
254 | |||
255 | if (cc == -EINVAL) { | ||
256 | cc = cio_clear(sch); | ||
257 | if (cc == -ENODEV) | ||
258 | goto out_unreg; | ||
259 | /* Call handler. */ | ||
260 | if (sch->driver && sch->driver->termination) | ||
261 | sch->driver->termination(&sch->dev); | ||
262 | goto out_unlock; | ||
263 | } | ||
264 | } else if ((sch->schib.scsw.actl & SCSW_ACTL_DEVACT) && | ||
265 | (sch->schib.scsw.actl & SCSW_ACTL_SCHACT) && | ||
266 | (sch->schib.pmcw.lpum == mask)) { | ||
267 | int cc; | 249 | int cc; |
268 | 250 | ||
269 | cc = cio_clear(sch); | 251 | cc = cio_clear(sch); |
@@ -653,13 +635,13 @@ __chp_add(struct subchannel_id schid, void *data) | |||
653 | if (sch->schib.pmcw.chpid[i] == chp->id) { | 635 | if (sch->schib.pmcw.chpid[i] == chp->id) { |
654 | if (stsch(sch->schid, &sch->schib) != 0) { | 636 | if (stsch(sch->schid, &sch->schib) != 0) { |
655 | /* Endgame. */ | 637 | /* Endgame. */ |
656 | spin_unlock(&sch->lock); | 638 | spin_unlock_irq(&sch->lock); |
657 | return -ENXIO; | 639 | return -ENXIO; |
658 | } | 640 | } |
659 | break; | 641 | break; |
660 | } | 642 | } |
661 | if (i==8) { | 643 | if (i==8) { |
662 | spin_unlock(&sch->lock); | 644 | spin_unlock_irq(&sch->lock); |
663 | return 0; | 645 | return 0; |
664 | } | 646 | } |
665 | sch->lpm = ((sch->schib.pmcw.pim & | 647 | sch->lpm = ((sch->schib.pmcw.pim & |
diff --git a/drivers/s390/cio/qdio.c b/drivers/s390/cio/qdio.c index 814f9258ce00..96f519281d92 100644 --- a/drivers/s390/cio/qdio.c +++ b/drivers/s390/cio/qdio.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/kernel.h> | 38 | #include <linux/kernel.h> |
39 | #include <linux/proc_fs.h> | 39 | #include <linux/proc_fs.h> |
40 | #include <linux/timer.h> | 40 | #include <linux/timer.h> |
41 | #include <linux/mempool.h> | ||
41 | 42 | ||
42 | #include <asm/ccwdev.h> | 43 | #include <asm/ccwdev.h> |
43 | #include <asm/io.h> | 44 | #include <asm/io.h> |
@@ -80,6 +81,8 @@ static int indicator_used[INDICATORS_PER_CACHELINE]; | |||
80 | static __u32 * volatile indicators; | 81 | static __u32 * volatile indicators; |
81 | static __u32 volatile spare_indicator; | 82 | static __u32 volatile spare_indicator; |
82 | static atomic_t spare_indicator_usecount; | 83 | static atomic_t spare_indicator_usecount; |
84 | #define QDIO_MEMPOOL_SCSSC_ELEMENTS 2 | ||
85 | static mempool_t *qdio_mempool_scssc; | ||
83 | 86 | ||
84 | static debug_info_t *qdio_dbf_setup; | 87 | static debug_info_t *qdio_dbf_setup; |
85 | static debug_info_t *qdio_dbf_sbal; | 88 | static debug_info_t *qdio_dbf_sbal; |
@@ -1637,7 +1640,7 @@ next: | |||
1637 | 1640 | ||
1638 | } | 1641 | } |
1639 | kfree(irq_ptr->qdr); | 1642 | kfree(irq_ptr->qdr); |
1640 | kfree(irq_ptr); | 1643 | free_page((unsigned long) irq_ptr); |
1641 | } | 1644 | } |
1642 | 1645 | ||
1643 | static void | 1646 | static void |
@@ -2304,7 +2307,7 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) | |||
2304 | 2307 | ||
2305 | QDIO_DBF_TEXT0(0,setup,"getssqd"); | 2308 | QDIO_DBF_TEXT0(0,setup,"getssqd"); |
2306 | qdioac = 0; | 2309 | qdioac = 0; |
2307 | ssqd_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); | 2310 | ssqd_area = mempool_alloc(qdio_mempool_scssc, GFP_ATOMIC); |
2308 | if (!ssqd_area) { | 2311 | if (!ssqd_area) { |
2309 | QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \ | 2312 | QDIO_PRINT_WARN("Could not get memory for chsc. Using all " \ |
2310 | "SIGAs for sch x%x.\n", irq_ptr->schid.sch_no); | 2313 | "SIGAs for sch x%x.\n", irq_ptr->schid.sch_no); |
@@ -2364,7 +2367,7 @@ qdio_get_ssqd_information(struct qdio_irq *irq_ptr) | |||
2364 | out: | 2367 | out: |
2365 | qdio_check_subchannel_qebsm(irq_ptr, qdioac, | 2368 | qdio_check_subchannel_qebsm(irq_ptr, qdioac, |
2366 | ssqd_area->sch_token); | 2369 | ssqd_area->sch_token); |
2367 | free_page ((unsigned long) ssqd_area); | 2370 | mempool_free(ssqd_area, qdio_mempool_scssc); |
2368 | irq_ptr->qdioac = qdioac; | 2371 | irq_ptr->qdioac = qdioac; |
2369 | } | 2372 | } |
2370 | 2373 | ||
@@ -2458,7 +2461,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) | |||
2458 | virt_to_phys((volatile void *)irq_ptr->dev_st_chg_ind); | 2461 | virt_to_phys((volatile void *)irq_ptr->dev_st_chg_ind); |
2459 | } | 2462 | } |
2460 | 2463 | ||
2461 | scssc_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); | 2464 | scssc_area = mempool_alloc(qdio_mempool_scssc, GFP_ATOMIC); |
2462 | if (!scssc_area) { | 2465 | if (!scssc_area) { |
2463 | QDIO_PRINT_WARN("No memory for setting indicators on " \ | 2466 | QDIO_PRINT_WARN("No memory for setting indicators on " \ |
2464 | "subchannel 0.%x.%x.\n", | 2467 | "subchannel 0.%x.%x.\n", |
@@ -2514,7 +2517,7 @@ tiqdio_set_subchannel_ind(struct qdio_irq *irq_ptr, int reset_to_zero) | |||
2514 | QDIO_DBF_HEX2(0,setup,&real_addr_dev_st_chg_ind,sizeof(unsigned long)); | 2517 | QDIO_DBF_HEX2(0,setup,&real_addr_dev_st_chg_ind,sizeof(unsigned long)); |
2515 | result = 0; | 2518 | result = 0; |
2516 | out: | 2519 | out: |
2517 | free_page ((unsigned long) scssc_area); | 2520 | mempool_free(scssc_area, qdio_mempool_scssc); |
2518 | return result; | 2521 | return result; |
2519 | 2522 | ||
2520 | } | 2523 | } |
@@ -2543,7 +2546,7 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) | |||
2543 | if (!irq_ptr->is_thinint_irq) | 2546 | if (!irq_ptr->is_thinint_irq) |
2544 | return -ENODEV; | 2547 | return -ENODEV; |
2545 | 2548 | ||
2546 | scsscf_area = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA); | 2549 | scsscf_area = mempool_alloc(qdio_mempool_scssc, GFP_ATOMIC); |
2547 | if (!scsscf_area) { | 2550 | if (!scsscf_area) { |
2548 | QDIO_PRINT_WARN("No memory for setting delay target on " \ | 2551 | QDIO_PRINT_WARN("No memory for setting delay target on " \ |
2549 | "subchannel 0.%x.%x.\n", | 2552 | "subchannel 0.%x.%x.\n", |
@@ -2581,7 +2584,7 @@ tiqdio_set_delay_target(struct qdio_irq *irq_ptr, unsigned long delay_target) | |||
2581 | QDIO_DBF_HEX2(0,trace,&delay_target,sizeof(unsigned long)); | 2584 | QDIO_DBF_HEX2(0,trace,&delay_target,sizeof(unsigned long)); |
2582 | result = 0; /* not critical */ | 2585 | result = 0; /* not critical */ |
2583 | out: | 2586 | out: |
2584 | free_page ((unsigned long) scsscf_area); | 2587 | mempool_free(scsscf_area, qdio_mempool_scssc); |
2585 | return result; | 2588 | return result; |
2586 | } | 2589 | } |
2587 | 2590 | ||
@@ -2980,7 +2983,7 @@ qdio_allocate(struct qdio_initialize *init_data) | |||
2980 | qdio_allocate_do_dbf(init_data); | 2983 | qdio_allocate_do_dbf(init_data); |
2981 | 2984 | ||
2982 | /* create irq */ | 2985 | /* create irq */ |
2983 | irq_ptr = kzalloc(sizeof(struct qdio_irq), GFP_KERNEL | GFP_DMA); | 2986 | irq_ptr = (void *) get_zeroed_page(GFP_KERNEL | GFP_DMA); |
2984 | 2987 | ||
2985 | QDIO_DBF_TEXT0(0,setup,"irq_ptr:"); | 2988 | QDIO_DBF_TEXT0(0,setup,"irq_ptr:"); |
2986 | QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*)); | 2989 | QDIO_DBF_HEX0(0,setup,&irq_ptr,sizeof(void*)); |
@@ -2995,7 +2998,7 @@ qdio_allocate(struct qdio_initialize *init_data) | |||
2995 | /* QDR must be in DMA area since CCW data address is only 32 bit */ | 2998 | /* QDR must be in DMA area since CCW data address is only 32 bit */ |
2996 | irq_ptr->qdr=kmalloc(sizeof(struct qdr), GFP_KERNEL | GFP_DMA); | 2999 | irq_ptr->qdr=kmalloc(sizeof(struct qdr), GFP_KERNEL | GFP_DMA); |
2997 | if (!(irq_ptr->qdr)) { | 3000 | if (!(irq_ptr->qdr)) { |
2998 | kfree(irq_ptr); | 3001 | free_page((unsigned long) irq_ptr); |
2999 | QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n"); | 3002 | QDIO_PRINT_ERR("kmalloc of irq_ptr->qdr failed!\n"); |
3000 | return -ENOMEM; | 3003 | return -ENOMEM; |
3001 | } | 3004 | } |
@@ -3780,6 +3783,16 @@ oom: | |||
3780 | return -ENOMEM; | 3783 | return -ENOMEM; |
3781 | } | 3784 | } |
3782 | 3785 | ||
3786 | static void *qdio_mempool_alloc(gfp_t gfp_mask, void *size) | ||
3787 | { | ||
3788 | return (void *) get_zeroed_page(gfp_mask|GFP_DMA); | ||
3789 | } | ||
3790 | |||
3791 | static void qdio_mempool_free(void *element, void *size) | ||
3792 | { | ||
3793 | free_page((unsigned long) element); | ||
3794 | } | ||
3795 | |||
3783 | static int __init | 3796 | static int __init |
3784 | init_QDIO(void) | 3797 | init_QDIO(void) |
3785 | { | 3798 | { |
@@ -3809,6 +3822,10 @@ init_QDIO(void) | |||
3809 | 3822 | ||
3810 | qdio_add_procfs_entry(); | 3823 | qdio_add_procfs_entry(); |
3811 | 3824 | ||
3825 | qdio_mempool_scssc = mempool_create(QDIO_MEMPOOL_SCSSC_ELEMENTS, | ||
3826 | qdio_mempool_alloc, | ||
3827 | qdio_mempool_free, NULL); | ||
3828 | |||
3812 | if (tiqdio_check_chsc_availability()) | 3829 | if (tiqdio_check_chsc_availability()) |
3813 | QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n"); | 3830 | QDIO_PRINT_ERR("Not all CHSCs supported. Continuing.\n"); |
3814 | 3831 | ||
@@ -3824,6 +3841,7 @@ cleanup_QDIO(void) | |||
3824 | qdio_remove_procfs_entry(); | 3841 | qdio_remove_procfs_entry(); |
3825 | qdio_release_qdio_memory(); | 3842 | qdio_release_qdio_memory(); |
3826 | qdio_unregister_dbf_views(); | 3843 | qdio_unregister_dbf_views(); |
3844 | mempool_destroy(qdio_mempool_scssc); | ||
3827 | 3845 | ||
3828 | printk("qdio: %s: module removed\n",version); | 3846 | printk("qdio: %s: module removed\n",version); |
3829 | } | 3847 | } |
diff --git a/drivers/s390/net/qeth_main.c b/drivers/s390/net/qeth_main.c index b3c6e7907790..cb14642d97aa 100644 --- a/drivers/s390/net/qeth_main.c +++ b/drivers/s390/net/qeth_main.c | |||
@@ -8014,7 +8014,6 @@ static int (*qeth_old_arp_constructor) (struct neighbour *); | |||
8014 | 8014 | ||
8015 | static struct neigh_ops arp_direct_ops_template = { | 8015 | static struct neigh_ops arp_direct_ops_template = { |
8016 | .family = AF_INET, | 8016 | .family = AF_INET, |
8017 | .destructor = NULL, | ||
8018 | .solicit = NULL, | 8017 | .solicit = NULL, |
8019 | .error_report = NULL, | 8018 | .error_report = NULL, |
8020 | .output = dev_queue_xmit, | 8019 | .output = dev_queue_xmit, |
diff --git a/drivers/s390/s390mach.c b/drivers/s390/s390mach.c index 3bf466603512..f99e55308b32 100644 --- a/drivers/s390/s390mach.c +++ b/drivers/s390/s390mach.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <linux/sched.h> | 13 | #include <linux/sched.h> |
14 | #include <linux/errno.h> | 14 | #include <linux/errno.h> |
15 | #include <linux/workqueue.h> | 15 | #include <linux/workqueue.h> |
16 | #include <linux/time.h> | ||
16 | 17 | ||
17 | #include <asm/lowcore.h> | 18 | #include <asm/lowcore.h> |
18 | 19 | ||
@@ -362,12 +363,19 @@ s390_revalidate_registers(struct mci *mci) | |||
362 | return kill_task; | 363 | return kill_task; |
363 | } | 364 | } |
364 | 365 | ||
366 | #define MAX_IPD_COUNT 29 | ||
367 | #define MAX_IPD_TIME (5 * 60 * USEC_PER_SEC) /* 5 minutes */ | ||
368 | |||
365 | /* | 369 | /* |
366 | * machine check handler. | 370 | * machine check handler. |
367 | */ | 371 | */ |
368 | void | 372 | void |
369 | s390_do_machine_check(struct pt_regs *regs) | 373 | s390_do_machine_check(struct pt_regs *regs) |
370 | { | 374 | { |
375 | static DEFINE_SPINLOCK(ipd_lock); | ||
376 | static unsigned long long last_ipd; | ||
377 | static int ipd_count; | ||
378 | unsigned long long tmp; | ||
371 | struct mci *mci; | 379 | struct mci *mci; |
372 | struct mcck_struct *mcck; | 380 | struct mcck_struct *mcck; |
373 | int umode; | 381 | int umode; |
@@ -404,11 +412,27 @@ s390_do_machine_check(struct pt_regs *regs) | |||
404 | s390_handle_damage("processing backup machine " | 412 | s390_handle_damage("processing backup machine " |
405 | "check with damage."); | 413 | "check with damage."); |
406 | } | 414 | } |
407 | if (!umode) | 415 | |
408 | s390_handle_damage("processing backup machine " | 416 | /* |
409 | "check in kernel mode."); | 417 | * Nullifying exigent condition, therefore we might |
410 | mcck->kill_task = 1; | 418 | * retry this instruction. |
411 | mcck->mcck_code = *(unsigned long long *) mci; | 419 | */ |
420 | |||
421 | spin_lock(&ipd_lock); | ||
422 | |||
423 | tmp = get_clock(); | ||
424 | |||
425 | if (((tmp - last_ipd) >> 12) < MAX_IPD_TIME) | ||
426 | ipd_count++; | ||
427 | else | ||
428 | ipd_count = 1; | ||
429 | |||
430 | last_ipd = tmp; | ||
431 | |||
432 | if (ipd_count == MAX_IPD_COUNT) | ||
433 | s390_handle_damage("too many ipd retries."); | ||
434 | |||
435 | spin_unlock(&ipd_lock); | ||
412 | } | 436 | } |
413 | else { | 437 | else { |
414 | /* Processing damage -> stopping machine */ | 438 | /* Processing damage -> stopping machine */ |
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 3e7302692dbe..a480a3742d47 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig | |||
@@ -446,7 +446,9 @@ config SCSI_DPT_I2O | |||
446 | 446 | ||
447 | config SCSI_ADVANSYS | 447 | config SCSI_ADVANSYS |
448 | tristate "AdvanSys SCSI support" | 448 | tristate "AdvanSys SCSI support" |
449 | depends on (ISA || EISA || PCI) && SCSI && BROKEN | 449 | depends on SCSI |
450 | depends on ISA || EISA || PCI | ||
451 | depends on BROKEN || X86_32 | ||
450 | help | 452 | help |
451 | This is a driver for all SCSI host adapters manufactured by | 453 | This is a driver for all SCSI host adapters manufactured by |
452 | AdvanSys. It is documented in the kernel source in | 454 | AdvanSys. It is documented in the kernel source in |
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c index 28b93057b607..2a419634b256 100644 --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c | |||
@@ -2051,7 +2051,7 @@ STATIC ASC_DCNT AscGetMaxDmaCount(ushort); | |||
2051 | #define ADV_VADDR_TO_U32 virt_to_bus | 2051 | #define ADV_VADDR_TO_U32 virt_to_bus |
2052 | #define ADV_U32_TO_VADDR bus_to_virt | 2052 | #define ADV_U32_TO_VADDR bus_to_virt |
2053 | 2053 | ||
2054 | #define AdvPortAddr ulong /* Virtual memory address size */ | 2054 | #define AdvPortAddr void __iomem * /* Virtual memory address size */ |
2055 | 2055 | ||
2056 | /* | 2056 | /* |
2057 | * Define Adv Library required memory access macros. | 2057 | * Define Adv Library required memory access macros. |
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index 73c8a088c160..aa5eb7ddeda9 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -10,6 +10,8 @@ | |||
10 | #define CPM_UART_H | 10 | #define CPM_UART_H |
11 | 11 | ||
12 | #include <linux/config.h> | 12 | #include <linux/config.h> |
13 | #include <linux/platform_device.h> | ||
14 | #include <linux/fs_uart_pd.h> | ||
13 | 15 | ||
14 | #if defined(CONFIG_CPM2) | 16 | #if defined(CONFIG_CPM2) |
15 | #include "cpm_uart_cpm2.h" | 17 | #include "cpm_uart_cpm2.h" |
@@ -26,14 +28,14 @@ | |||
26 | #define FLAG_SMC 0x00000002 | 28 | #define FLAG_SMC 0x00000002 |
27 | #define FLAG_CONSOLE 0x00000001 | 29 | #define FLAG_CONSOLE 0x00000001 |
28 | 30 | ||
29 | #define UART_SMC1 0 | 31 | #define UART_SMC1 fsid_smc1_uart |
30 | #define UART_SMC2 1 | 32 | #define UART_SMC2 fsid_smc2_uart |
31 | #define UART_SCC1 2 | 33 | #define UART_SCC1 fsid_scc1_uart |
32 | #define UART_SCC2 3 | 34 | #define UART_SCC2 fsid_scc2_uart |
33 | #define UART_SCC3 4 | 35 | #define UART_SCC3 fsid_scc3_uart |
34 | #define UART_SCC4 5 | 36 | #define UART_SCC4 fsid_scc4_uart |
35 | 37 | ||
36 | #define UART_NR 6 | 38 | #define UART_NR fs_uart_nr |
37 | 39 | ||
38 | #define RX_NUM_FIFO 4 | 40 | #define RX_NUM_FIFO 4 |
39 | #define RX_BUF_SIZE 32 | 41 | #define RX_BUF_SIZE 32 |
@@ -64,6 +66,7 @@ struct uart_cpm_port { | |||
64 | uint dp_addr; | 66 | uint dp_addr; |
65 | void *mem_addr; | 67 | void *mem_addr; |
66 | dma_addr_t dma_addr; | 68 | dma_addr_t dma_addr; |
69 | u32 mem_size; | ||
67 | /* helpers */ | 70 | /* helpers */ |
68 | int baud; | 71 | int baud; |
69 | int bits; | 72 | int bits; |
@@ -90,4 +93,36 @@ void scc2_lineif(struct uart_cpm_port *pinfo); | |||
90 | void scc3_lineif(struct uart_cpm_port *pinfo); | 93 | void scc3_lineif(struct uart_cpm_port *pinfo); |
91 | void scc4_lineif(struct uart_cpm_port *pinfo); | 94 | void scc4_lineif(struct uart_cpm_port *pinfo); |
92 | 95 | ||
96 | /* | ||
97 | virtual to phys transtalion | ||
98 | */ | ||
99 | static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo) | ||
100 | { | ||
101 | int offset; | ||
102 | u32 val = (u32)addr; | ||
103 | /* sane check */ | ||
104 | if ((val >= (u32)pinfo->mem_addr) && | ||
105 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { | ||
106 | offset = val - (u32)pinfo->mem_addr; | ||
107 | return pinfo->dma_addr+offset; | ||
108 | } | ||
109 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | ||
110 | return 0; | ||
111 | } | ||
112 | |||
113 | static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo) | ||
114 | { | ||
115 | int offset; | ||
116 | u32 val = addr; | ||
117 | /* sane check */ | ||
118 | if ((val >= pinfo->dma_addr) && | ||
119 | (val<(pinfo->dma_addr + pinfo->mem_size))) { | ||
120 | offset = val - (u32)pinfo->dma_addr; | ||
121 | return (void*)(pinfo->mem_addr+offset); | ||
122 | } | ||
123 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | ||
124 | return 0; | ||
125 | } | ||
126 | |||
127 | |||
93 | #endif /* CPM_UART_H */ | 128 | #endif /* CPM_UART_H */ |
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index b7bf4c698a47..ced193bf9e1e 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <linux/device.h> | 41 | #include <linux/device.h> |
42 | #include <linux/bootmem.h> | 42 | #include <linux/bootmem.h> |
43 | #include <linux/dma-mapping.h> | 43 | #include <linux/dma-mapping.h> |
44 | #include <linux/fs_uart_pd.h> | ||
44 | 45 | ||
45 | #include <asm/io.h> | 46 | #include <asm/io.h> |
46 | #include <asm/irq.h> | 47 | #include <asm/irq.h> |
@@ -60,7 +61,7 @@ | |||
60 | /* Track which ports are configured as uarts */ | 61 | /* Track which ports are configured as uarts */ |
61 | int cpm_uart_port_map[UART_NR]; | 62 | int cpm_uart_port_map[UART_NR]; |
62 | /* How many ports did we config as uarts */ | 63 | /* How many ports did we config as uarts */ |
63 | int cpm_uart_nr; | 64 | int cpm_uart_nr = 0; |
64 | 65 | ||
65 | /**************************************************************/ | 66 | /**************************************************************/ |
66 | 67 | ||
@@ -71,18 +72,36 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo); | |||
71 | 72 | ||
72 | /**************************************************************/ | 73 | /**************************************************************/ |
73 | 74 | ||
74 | static inline unsigned long cpu2cpm_addr(void *addr) | 75 | |
76 | /* Place-holder for board-specific stuff */ | ||
77 | struct platform_device* __attribute__ ((weak)) __init | ||
78 | early_uart_get_pdev(int index) | ||
75 | { | 79 | { |
76 | if ((unsigned long)addr >= CPM_ADDR) | 80 | return NULL; |
77 | return (unsigned long)addr; | ||
78 | return virt_to_bus(addr); | ||
79 | } | 81 | } |
80 | 82 | ||
81 | static inline void *cpm2cpu_addr(unsigned long addr) | 83 | |
84 | void cpm_uart_count(void) | ||
82 | { | 85 | { |
83 | if (addr >= CPM_ADDR) | 86 | cpm_uart_nr = 0; |
84 | return (void *)addr; | 87 | #ifdef CONFIG_SERIAL_CPM_SMC1 |
85 | return bus_to_virt(addr); | 88 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC1; |
89 | #endif | ||
90 | #ifdef CONFIG_SERIAL_CPM_SMC2 | ||
91 | cpm_uart_port_map[cpm_uart_nr++] = UART_SMC2; | ||
92 | #endif | ||
93 | #ifdef CONFIG_SERIAL_CPM_SCC1 | ||
94 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC1; | ||
95 | #endif | ||
96 | #ifdef CONFIG_SERIAL_CPM_SCC2 | ||
97 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC2; | ||
98 | #endif | ||
99 | #ifdef CONFIG_SERIAL_CPM_SCC3 | ||
100 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC3; | ||
101 | #endif | ||
102 | #ifdef CONFIG_SERIAL_CPM_SCC4 | ||
103 | cpm_uart_port_map[cpm_uart_nr++] = UART_SCC4; | ||
104 | #endif | ||
86 | } | 105 | } |
87 | 106 | ||
88 | /* | 107 | /* |
@@ -258,7 +277,7 @@ static void cpm_uart_int_rx(struct uart_port *port, struct pt_regs *regs) | |||
258 | } | 277 | } |
259 | 278 | ||
260 | /* get pointer */ | 279 | /* get pointer */ |
261 | cp = cpm2cpu_addr(bdp->cbd_bufaddr); | 280 | cp = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo); |
262 | 281 | ||
263 | /* loop through the buffer */ | 282 | /* loop through the buffer */ |
264 | while (i-- > 0) { | 283 | while (i-- > 0) { |
@@ -601,7 +620,7 @@ static int cpm_uart_tx_pump(struct uart_port *port) | |||
601 | /* Pick next descriptor and fill from buffer */ | 620 | /* Pick next descriptor and fill from buffer */ |
602 | bdp = pinfo->tx_cur; | 621 | bdp = pinfo->tx_cur; |
603 | 622 | ||
604 | p = cpm2cpu_addr(bdp->cbd_bufaddr); | 623 | p = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo); |
605 | 624 | ||
606 | *p++ = port->x_char; | 625 | *p++ = port->x_char; |
607 | bdp->cbd_datlen = 1; | 626 | bdp->cbd_datlen = 1; |
@@ -628,7 +647,7 @@ static int cpm_uart_tx_pump(struct uart_port *port) | |||
628 | 647 | ||
629 | while (!(bdp->cbd_sc & BD_SC_READY) && (xmit->tail != xmit->head)) { | 648 | while (!(bdp->cbd_sc & BD_SC_READY) && (xmit->tail != xmit->head)) { |
630 | count = 0; | 649 | count = 0; |
631 | p = cpm2cpu_addr(bdp->cbd_bufaddr); | 650 | p = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo); |
632 | while (count < pinfo->tx_fifosize) { | 651 | while (count < pinfo->tx_fifosize) { |
633 | *p++ = xmit->buf[xmit->tail]; | 652 | *p++ = xmit->buf[xmit->tail]; |
634 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 653 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
@@ -677,12 +696,12 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo) | |||
677 | mem_addr = pinfo->mem_addr; | 696 | mem_addr = pinfo->mem_addr; |
678 | bdp = pinfo->rx_cur = pinfo->rx_bd_base; | 697 | bdp = pinfo->rx_cur = pinfo->rx_bd_base; |
679 | for (i = 0; i < (pinfo->rx_nrfifos - 1); i++, bdp++) { | 698 | for (i = 0; i < (pinfo->rx_nrfifos - 1); i++, bdp++) { |
680 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr); | 699 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr, pinfo); |
681 | bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT; | 700 | bdp->cbd_sc = BD_SC_EMPTY | BD_SC_INTRPT; |
682 | mem_addr += pinfo->rx_fifosize; | 701 | mem_addr += pinfo->rx_fifosize; |
683 | } | 702 | } |
684 | 703 | ||
685 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr); | 704 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr, pinfo); |
686 | bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT; | 705 | bdp->cbd_sc = BD_SC_WRAP | BD_SC_EMPTY | BD_SC_INTRPT; |
687 | 706 | ||
688 | /* Set the physical address of the host memory | 707 | /* Set the physical address of the host memory |
@@ -692,12 +711,12 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo) | |||
692 | mem_addr = pinfo->mem_addr + L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize); | 711 | mem_addr = pinfo->mem_addr + L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize); |
693 | bdp = pinfo->tx_cur = pinfo->tx_bd_base; | 712 | bdp = pinfo->tx_cur = pinfo->tx_bd_base; |
694 | for (i = 0; i < (pinfo->tx_nrfifos - 1); i++, bdp++) { | 713 | for (i = 0; i < (pinfo->tx_nrfifos - 1); i++, bdp++) { |
695 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr); | 714 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr, pinfo); |
696 | bdp->cbd_sc = BD_SC_INTRPT; | 715 | bdp->cbd_sc = BD_SC_INTRPT; |
697 | mem_addr += pinfo->tx_fifosize; | 716 | mem_addr += pinfo->tx_fifosize; |
698 | } | 717 | } |
699 | 718 | ||
700 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr); | 719 | bdp->cbd_bufaddr = cpu2cpm_addr(mem_addr, pinfo); |
701 | bdp->cbd_sc = BD_SC_WRAP | BD_SC_INTRPT; | 720 | bdp->cbd_sc = BD_SC_WRAP | BD_SC_INTRPT; |
702 | } | 721 | } |
703 | 722 | ||
@@ -829,14 +848,6 @@ static int cpm_uart_request_port(struct uart_port *port) | |||
829 | if (pinfo->flags & FLAG_CONSOLE) | 848 | if (pinfo->flags & FLAG_CONSOLE) |
830 | return 0; | 849 | return 0; |
831 | 850 | ||
832 | /* | ||
833 | * Setup any port IO, connect any baud rate generators, | ||
834 | * etc. This is expected to be handled by board | ||
835 | * dependant code | ||
836 | */ | ||
837 | if (pinfo->set_lineif) | ||
838 | pinfo->set_lineif(pinfo); | ||
839 | |||
840 | if (IS_SMC(pinfo)) { | 851 | if (IS_SMC(pinfo)) { |
841 | pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX); | 852 | pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX); |
842 | pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | 853 | pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); |
@@ -988,6 +999,54 @@ struct uart_cpm_port cpm_uart_ports[UART_NR] = { | |||
988 | }, | 999 | }, |
989 | }; | 1000 | }; |
990 | 1001 | ||
1002 | int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con) | ||
1003 | { | ||
1004 | struct resource *r; | ||
1005 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; | ||
1006 | int idx = pdata->fs_no; /* It is UART_SMCx or UART_SCCx index */ | ||
1007 | struct uart_cpm_port *pinfo; | ||
1008 | int line; | ||
1009 | u32 mem, pram; | ||
1010 | |||
1011 | for (line=0; line<UART_NR && cpm_uart_port_map[line]!=pdata->fs_no; line++); | ||
1012 | |||
1013 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; | ||
1014 | |||
1015 | pinfo->brg = pdata->brg; | ||
1016 | |||
1017 | if (!is_con) { | ||
1018 | pinfo->port.line = line; | ||
1019 | pinfo->port.flags = UPF_BOOT_AUTOCONF; | ||
1020 | } | ||
1021 | |||
1022 | if (!(r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"))) | ||
1023 | return -EINVAL; | ||
1024 | mem = r->start; | ||
1025 | |||
1026 | if (!(r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "pram"))) | ||
1027 | return -EINVAL; | ||
1028 | pram = r->start; | ||
1029 | |||
1030 | if(idx > fsid_smc2_uart) { | ||
1031 | pinfo->sccp = (scc_t *)mem; | ||
1032 | pinfo->sccup = (scc_uart_t *)pram; | ||
1033 | } else { | ||
1034 | pinfo->smcp = (smc_t *)mem; | ||
1035 | pinfo->smcup = (smc_uart_t *)pram; | ||
1036 | } | ||
1037 | pinfo->tx_nrfifos = pdata->tx_num_fifo; | ||
1038 | pinfo->tx_fifosize = pdata->tx_buf_size; | ||
1039 | |||
1040 | pinfo->rx_nrfifos = pdata->rx_num_fifo; | ||
1041 | pinfo->rx_fifosize = pdata->rx_buf_size; | ||
1042 | |||
1043 | pinfo->port.uartclk = pdata->uart_clk; | ||
1044 | pinfo->port.mapbase = (unsigned long)mem; | ||
1045 | pinfo->port.irq = platform_get_irq(pdev, 0); | ||
1046 | |||
1047 | return 0; | ||
1048 | } | ||
1049 | |||
991 | #ifdef CONFIG_SERIAL_CPM_CONSOLE | 1050 | #ifdef CONFIG_SERIAL_CPM_CONSOLE |
992 | /* | 1051 | /* |
993 | * Print a string to the serial port trying not to disturb | 1052 | * Print a string to the serial port trying not to disturb |
@@ -1027,7 +1086,7 @@ static void cpm_uart_console_write(struct console *co, const char *s, | |||
1027 | * If the buffer address is in the CPM DPRAM, don't | 1086 | * If the buffer address is in the CPM DPRAM, don't |
1028 | * convert it. | 1087 | * convert it. |
1029 | */ | 1088 | */ |
1030 | cp = cpm2cpu_addr(bdp->cbd_bufaddr); | 1089 | cp = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo); |
1031 | 1090 | ||
1032 | *cp = *s; | 1091 | *cp = *s; |
1033 | 1092 | ||
@@ -1044,7 +1103,7 @@ static void cpm_uart_console_write(struct console *co, const char *s, | |||
1044 | while ((bdp->cbd_sc & BD_SC_READY) != 0) | 1103 | while ((bdp->cbd_sc & BD_SC_READY) != 0) |
1045 | ; | 1104 | ; |
1046 | 1105 | ||
1047 | cp = cpm2cpu_addr(bdp->cbd_bufaddr); | 1106 | cp = cpm2cpu_addr(bdp->cbd_bufaddr, pinfo); |
1048 | 1107 | ||
1049 | *cp = 13; | 1108 | *cp = 13; |
1050 | bdp->cbd_datlen = 1; | 1109 | bdp->cbd_datlen = 1; |
@@ -1067,9 +1126,7 @@ static void cpm_uart_console_write(struct console *co, const char *s, | |||
1067 | pinfo->tx_cur = (volatile cbd_t *) bdp; | 1126 | pinfo->tx_cur = (volatile cbd_t *) bdp; |
1068 | } | 1127 | } |
1069 | 1128 | ||
1070 | /* | 1129 | |
1071 | * Setup console. Be careful is called early ! | ||
1072 | */ | ||
1073 | static int __init cpm_uart_console_setup(struct console *co, char *options) | 1130 | static int __init cpm_uart_console_setup(struct console *co, char *options) |
1074 | { | 1131 | { |
1075 | struct uart_port *port; | 1132 | struct uart_port *port; |
@@ -1080,9 +1137,27 @@ static int __init cpm_uart_console_setup(struct console *co, char *options) | |||
1080 | int flow = 'n'; | 1137 | int flow = 'n'; |
1081 | int ret; | 1138 | int ret; |
1082 | 1139 | ||
1140 | struct fs_uart_platform_info *pdata; | ||
1141 | struct platform_device* pdev = early_uart_get_pdev(co->index); | ||
1142 | |||
1083 | port = | 1143 | port = |
1084 | (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]]; | 1144 | (struct uart_port *)&cpm_uart_ports[cpm_uart_port_map[co->index]]; |
1085 | pinfo = (struct uart_cpm_port *)port; | 1145 | pinfo = (struct uart_cpm_port *)port; |
1146 | if (!pdev) { | ||
1147 | pr_info("cpm_uart: console: compat mode\n"); | ||
1148 | /* compatibility - will be cleaned up */ | ||
1149 | cpm_uart_init_portdesc(); | ||
1150 | |||
1151 | if (pinfo->set_lineif) | ||
1152 | pinfo->set_lineif(pinfo); | ||
1153 | } else { | ||
1154 | pdata = pdev->dev.platform_data; | ||
1155 | if (pdata) | ||
1156 | if (pdata->init_ioports) | ||
1157 | pdata->init_ioports(); | ||
1158 | |||
1159 | cpm_uart_drv_get_platform_data(pdev, 1); | ||
1160 | } | ||
1086 | 1161 | ||
1087 | pinfo->flags |= FLAG_CONSOLE; | 1162 | pinfo->flags |= FLAG_CONSOLE; |
1088 | 1163 | ||
@@ -1097,14 +1172,6 @@ static int __init cpm_uart_console_setup(struct console *co, char *options) | |||
1097 | baud = 9600; | 1172 | baud = 9600; |
1098 | } | 1173 | } |
1099 | 1174 | ||
1100 | /* | ||
1101 | * Setup any port IO, connect any baud rate generators, | ||
1102 | * etc. This is expected to be handled by board | ||
1103 | * dependant code | ||
1104 | */ | ||
1105 | if (pinfo->set_lineif) | ||
1106 | pinfo->set_lineif(pinfo); | ||
1107 | |||
1108 | if (IS_SMC(pinfo)) { | 1175 | if (IS_SMC(pinfo)) { |
1109 | pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX); | 1176 | pinfo->smcp->smc_smcm &= ~(SMCM_RX | SMCM_TX); |
1110 | pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); | 1177 | pinfo->smcp->smc_smcmr &= ~(SMCMR_REN | SMCMR_TEN); |
@@ -1143,11 +1210,8 @@ static struct console cpm_scc_uart_console = { | |||
1143 | 1210 | ||
1144 | int __init cpm_uart_console_init(void) | 1211 | int __init cpm_uart_console_init(void) |
1145 | { | 1212 | { |
1146 | int ret = cpm_uart_init_portdesc(); | 1213 | register_console(&cpm_scc_uart_console); |
1147 | 1214 | return 0; | |
1148 | if (!ret) | ||
1149 | register_console(&cpm_scc_uart_console); | ||
1150 | return ret; | ||
1151 | } | 1215 | } |
1152 | 1216 | ||
1153 | console_initcall(cpm_uart_console_init); | 1217 | console_initcall(cpm_uart_console_init); |
@@ -1165,44 +1229,130 @@ static struct uart_driver cpm_reg = { | |||
1165 | .minor = SERIAL_CPM_MINOR, | 1229 | .minor = SERIAL_CPM_MINOR, |
1166 | .cons = CPM_UART_CONSOLE, | 1230 | .cons = CPM_UART_CONSOLE, |
1167 | }; | 1231 | }; |
1168 | 1232 | static int cpm_uart_drv_probe(struct device *dev) | |
1169 | static int __init cpm_uart_init(void) | ||
1170 | { | 1233 | { |
1171 | int ret, i; | 1234 | struct platform_device *pdev = to_platform_device(dev); |
1172 | 1235 | struct fs_uart_platform_info *pdata; | |
1173 | printk(KERN_INFO "Serial: CPM driver $Revision: 0.01 $\n"); | 1236 | int ret = -ENODEV; |
1174 | 1237 | ||
1175 | #ifndef CONFIG_SERIAL_CPM_CONSOLE | 1238 | if(!pdev) { |
1176 | ret = cpm_uart_init_portdesc(); | 1239 | printk(KERN_ERR"CPM UART: platform data missing!\n"); |
1177 | if (ret) | ||
1178 | return ret; | 1240 | return ret; |
1179 | #endif | 1241 | } |
1180 | 1242 | ||
1181 | cpm_reg.nr = cpm_uart_nr; | 1243 | pdata = pdev->dev.platform_data; |
1182 | ret = uart_register_driver(&cpm_reg); | 1244 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", |
1245 | cpm_uart_port_map[pdata->fs_no]); | ||
1183 | 1246 | ||
1184 | if (ret) | 1247 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) |
1185 | return ret; | 1248 | return ret; |
1186 | 1249 | ||
1187 | for (i = 0; i < cpm_uart_nr; i++) { | 1250 | if (pdata->init_ioports) |
1188 | int con = cpm_uart_port_map[i]; | 1251 | pdata->init_ioports(); |
1189 | cpm_uart_ports[con].port.line = i; | ||
1190 | cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF; | ||
1191 | uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port); | ||
1192 | } | ||
1193 | 1252 | ||
1194 | return ret; | 1253 | ret = uart_add_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); |
1254 | |||
1255 | return ret; | ||
1195 | } | 1256 | } |
1196 | 1257 | ||
1197 | static void __exit cpm_uart_exit(void) | 1258 | static int cpm_uart_drv_remove(struct device *dev) |
1259 | { | ||
1260 | struct platform_device *pdev = to_platform_device(dev); | ||
1261 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; | ||
1262 | |||
1263 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", | ||
1264 | cpm_uart_port_map[pdata->fs_no]); | ||
1265 | |||
1266 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); | ||
1267 | return 0; | ||
1268 | } | ||
1269 | |||
1270 | static struct device_driver cpm_smc_uart_driver = { | ||
1271 | .name = "fsl-cpm-smc:uart", | ||
1272 | .bus = &platform_bus_type, | ||
1273 | .probe = cpm_uart_drv_probe, | ||
1274 | .remove = cpm_uart_drv_remove, | ||
1275 | }; | ||
1276 | |||
1277 | static struct device_driver cpm_scc_uart_driver = { | ||
1278 | .name = "fsl-cpm-scc:uart", | ||
1279 | .bus = &platform_bus_type, | ||
1280 | .probe = cpm_uart_drv_probe, | ||
1281 | .remove = cpm_uart_drv_remove, | ||
1282 | }; | ||
1283 | |||
1284 | /* | ||
1285 | This is supposed to match uart devices on platform bus, | ||
1286 | */ | ||
1287 | static int match_is_uart (struct device* dev, void* data) | ||
1198 | { | 1288 | { |
1289 | struct platform_device* pdev = container_of(dev, struct platform_device, dev); | ||
1290 | int ret = 0; | ||
1291 | /* this was setfunc as uart */ | ||
1292 | if(strstr(pdev->name,":uart")) { | ||
1293 | ret = 1; | ||
1294 | } | ||
1295 | return ret; | ||
1296 | } | ||
1297 | |||
1298 | |||
1299 | static int cpm_uart_init(void) { | ||
1300 | |||
1301 | int ret; | ||
1199 | int i; | 1302 | int i; |
1303 | struct device *dev; | ||
1304 | printk(KERN_INFO "Serial: CPM driver $Revision: 0.02 $\n"); | ||
1305 | |||
1306 | /* lookup the bus for uart devices */ | ||
1307 | dev = bus_find_device(&platform_bus_type, NULL, 0, match_is_uart); | ||
1308 | |||
1309 | /* There are devices on the bus - all should be OK */ | ||
1310 | if (dev) { | ||
1311 | cpm_uart_count(); | ||
1312 | cpm_reg.nr = cpm_uart_nr; | ||
1313 | |||
1314 | if (!(ret = uart_register_driver(&cpm_reg))) { | ||
1315 | if ((ret = driver_register(&cpm_smc_uart_driver))) { | ||
1316 | uart_unregister_driver(&cpm_reg); | ||
1317 | return ret; | ||
1318 | } | ||
1319 | if ((ret = driver_register(&cpm_scc_uart_driver))) { | ||
1320 | driver_unregister(&cpm_scc_uart_driver); | ||
1321 | uart_unregister_driver(&cpm_reg); | ||
1322 | } | ||
1323 | } | ||
1324 | } else { | ||
1325 | /* No capable platform devices found - falling back to legacy mode */ | ||
1326 | pr_info("cpm_uart: WARNING: no UART devices found on platform bus!\n"); | ||
1327 | pr_info( | ||
1328 | "cpm_uart: the driver will guess configuration, but this mode is no longer supported.\n"); | ||
1329 | #ifndef CONFIG_SERIAL_CPM_CONSOLE | ||
1330 | ret = cpm_uart_init_portdesc(); | ||
1331 | if (ret) | ||
1332 | return ret; | ||
1333 | #endif | ||
1334 | |||
1335 | cpm_reg.nr = cpm_uart_nr; | ||
1336 | ret = uart_register_driver(&cpm_reg); | ||
1337 | |||
1338 | if (ret) | ||
1339 | return ret; | ||
1340 | |||
1341 | for (i = 0; i < cpm_uart_nr; i++) { | ||
1342 | int con = cpm_uart_port_map[i]; | ||
1343 | cpm_uart_ports[con].port.line = i; | ||
1344 | cpm_uart_ports[con].port.flags = UPF_BOOT_AUTOCONF; | ||
1345 | uart_add_one_port(&cpm_reg, &cpm_uart_ports[con].port); | ||
1346 | } | ||
1200 | 1347 | ||
1201 | for (i = 0; i < cpm_uart_nr; i++) { | ||
1202 | int con = cpm_uart_port_map[i]; | ||
1203 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[con].port); | ||
1204 | } | 1348 | } |
1349 | return ret; | ||
1350 | } | ||
1205 | 1351 | ||
1352 | static void __exit cpm_uart_exit(void) | ||
1353 | { | ||
1354 | driver_unregister(&cpm_scc_uart_driver); | ||
1355 | driver_unregister(&cpm_smc_uart_driver); | ||
1206 | uart_unregister_driver(&cpm_reg); | 1356 | uart_unregister_driver(&cpm_reg); |
1207 | } | 1357 | } |
1208 | 1358 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index d789ee55cbb7..a5a30622637a 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -81,58 +81,11 @@ void cpm_line_cr_cmd(int line, int cmd) | |||
81 | 81 | ||
82 | void smc1_lineif(struct uart_cpm_port *pinfo) | 82 | void smc1_lineif(struct uart_cpm_port *pinfo) |
83 | { | 83 | { |
84 | volatile cpm8xx_t *cp = cpmp; | ||
85 | |||
86 | (void)cp; /* fix warning */ | ||
87 | #if defined (CONFIG_MPC885ADS) | ||
88 | /* Enable SMC1 transceivers */ | ||
89 | { | ||
90 | cp->cp_pepar |= 0x000000c0; | ||
91 | cp->cp_pedir &= ~0x000000c0; | ||
92 | cp->cp_peso &= ~0x00000040; | ||
93 | cp->cp_peso |= 0x00000080; | ||
94 | } | ||
95 | #elif defined (CONFIG_MPC86XADS) | ||
96 | unsigned int iobits = 0x000000c0; | ||
97 | |||
98 | if (!pinfo->is_portb) { | ||
99 | cp->cp_pbpar |= iobits; | ||
100 | cp->cp_pbdir &= ~iobits; | ||
101 | cp->cp_pbodr &= ~iobits; | ||
102 | } else { | ||
103 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_papar |= iobits; | ||
104 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_padir &= ~iobits; | ||
105 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_paodr &= ~iobits; | ||
106 | } | ||
107 | #endif | ||
108 | pinfo->brg = 1; | 84 | pinfo->brg = 1; |
109 | } | 85 | } |
110 | 86 | ||
111 | void smc2_lineif(struct uart_cpm_port *pinfo) | 87 | void smc2_lineif(struct uart_cpm_port *pinfo) |
112 | { | 88 | { |
113 | volatile cpm8xx_t *cp = cpmp; | ||
114 | |||
115 | (void)cp; /* fix warning */ | ||
116 | #if defined (CONFIG_MPC885ADS) | ||
117 | cp->cp_pepar |= 0x00000c00; | ||
118 | cp->cp_pedir &= ~0x00000c00; | ||
119 | cp->cp_peso &= ~0x00000400; | ||
120 | cp->cp_peso |= 0x00000800; | ||
121 | #elif defined (CONFIG_MPC86XADS) | ||
122 | unsigned int iobits = 0x00000c00; | ||
123 | |||
124 | if (!pinfo->is_portb) { | ||
125 | cp->cp_pbpar |= iobits; | ||
126 | cp->cp_pbdir &= ~iobits; | ||
127 | cp->cp_pbodr &= ~iobits; | ||
128 | } else { | ||
129 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_papar |= iobits; | ||
130 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_padir &= ~iobits; | ||
131 | ((immap_t *)IMAP_ADDR)->im_ioport.iop_paodr &= ~iobits; | ||
132 | } | ||
133 | |||
134 | #endif | ||
135 | |||
136 | pinfo->brg = 2; | 89 | pinfo->brg = 2; |
137 | } | 90 | } |
138 | 91 | ||
@@ -191,7 +144,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
191 | /* was hostalloc but changed cause it blows away the */ | 144 | /* was hostalloc but changed cause it blows away the */ |
192 | /* large tlb mapping when pinning the kernel area */ | 145 | /* large tlb mapping when pinning the kernel area */ |
193 | mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); | 146 | mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); |
194 | dma_addr = 0; | 147 | dma_addr = (u32)mem_addr; |
195 | } else | 148 | } else |
196 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, | 149 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, |
197 | GFP_KERNEL); | 150 | GFP_KERNEL); |
@@ -204,8 +157,9 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
204 | } | 157 | } |
205 | 158 | ||
206 | pinfo->dp_addr = dp_offset; | 159 | pinfo->dp_addr = dp_offset; |
207 | pinfo->mem_addr = mem_addr; | 160 | pinfo->mem_addr = mem_addr; /* virtual address*/ |
208 | pinfo->dma_addr = dma_addr; | 161 | pinfo->dma_addr = dma_addr; /* physical address*/ |
162 | pinfo->mem_size = memsz; | ||
209 | 163 | ||
210 | pinfo->rx_buf = mem_addr; | 164 | pinfo->rx_buf = mem_addr; |
211 | pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos | 165 | pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index fd9e53ed3feb..7c6b07aeea92 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -142,14 +142,6 @@ void scc2_lineif(struct uart_cpm_port *pinfo) | |||
142 | * be supported in a sane fashion. | 142 | * be supported in a sane fashion. |
143 | */ | 143 | */ |
144 | #ifndef CONFIG_STX_GP3 | 144 | #ifndef CONFIG_STX_GP3 |
145 | #ifdef CONFIG_MPC8560_ADS | ||
146 | volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; | ||
147 | io->iop_ppard |= 0x00000018; | ||
148 | io->iop_psord &= ~0x00000008; /* Rx */ | ||
149 | io->iop_psord &= ~0x00000010; /* Tx */ | ||
150 | io->iop_pdird &= ~0x00000008; /* Rx */ | ||
151 | io->iop_pdird |= 0x00000010; /* Tx */ | ||
152 | #else | ||
153 | volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; | 145 | volatile iop_cpm2_t *io = &cpm2_immr->im_ioport; |
154 | io->iop_pparb |= 0x008b0000; | 146 | io->iop_pparb |= 0x008b0000; |
155 | io->iop_pdirb |= 0x00880000; | 147 | io->iop_pdirb |= 0x00880000; |
@@ -157,7 +149,6 @@ void scc2_lineif(struct uart_cpm_port *pinfo) | |||
157 | io->iop_pdirb &= ~0x00030000; | 149 | io->iop_pdirb &= ~0x00030000; |
158 | io->iop_psorb &= ~0x00030000; | 150 | io->iop_psorb &= ~0x00030000; |
159 | #endif | 151 | #endif |
160 | #endif | ||
161 | cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff; | 152 | cpm2_immr->im_cpmux.cmx_scr &= 0xff00ffff; |
162 | cpm2_immr->im_cpmux.cmx_scr |= 0x00090000; | 153 | cpm2_immr->im_cpmux.cmx_scr |= 0x00090000; |
163 | pinfo->brg = 2; | 154 | pinfo->brg = 2; |
@@ -218,8 +209,10 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
218 | 209 | ||
219 | memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) + | 210 | memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) + |
220 | L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); | 211 | L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); |
221 | if (is_con) | 212 | if (is_con) { |
222 | mem_addr = alloc_bootmem(memsz); | 213 | mem_addr = alloc_bootmem(memsz); |
214 | dma_addr = mem_addr; | ||
215 | } | ||
223 | else | 216 | else |
224 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, | 217 | mem_addr = dma_alloc_coherent(NULL, memsz, &dma_addr, |
225 | GFP_KERNEL); | 218 | GFP_KERNEL); |
@@ -234,6 +227,7 @@ int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) | |||
234 | pinfo->dp_addr = dp_offset; | 227 | pinfo->dp_addr = dp_offset; |
235 | pinfo->mem_addr = mem_addr; | 228 | pinfo->mem_addr = mem_addr; |
236 | pinfo->dma_addr = dma_addr; | 229 | pinfo->dma_addr = dma_addr; |
230 | pinfo->mem_size = memsz; | ||
237 | 231 | ||
238 | pinfo->rx_buf = mem_addr; | 232 | pinfo->rx_buf = mem_addr; |
239 | pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos | 233 | pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos |
diff --git a/drivers/serial/m32r_sio.c b/drivers/serial/m32r_sio.c index e9c10c0a30fc..321a40f33b50 100644 --- a/drivers/serial/m32r_sio.c +++ b/drivers/serial/m32r_sio.c | |||
@@ -1057,7 +1057,6 @@ static void m32r_sio_console_write(struct console *co, const char *s, | |||
1057 | { | 1057 | { |
1058 | struct uart_sio_port *up = &m32r_sio_ports[co->index]; | 1058 | struct uart_sio_port *up = &m32r_sio_ports[co->index]; |
1059 | unsigned int ier; | 1059 | unsigned int ier; |
1060 | int i; | ||
1061 | 1060 | ||
1062 | /* | 1061 | /* |
1063 | * First save the UER then disable the interrupts | 1062 | * First save the UER then disable the interrupts |
diff --git a/drivers/sn/ioc3.c b/drivers/sn/ioc3.c index 0b49ff78efc1..501316b198e5 100644 --- a/drivers/sn/ioc3.c +++ b/drivers/sn/ioc3.c | |||
@@ -678,7 +678,7 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *pci_id) | |||
678 | /* Track PCI-device specific data */ | 678 | /* Track PCI-device specific data */ |
679 | pci_set_drvdata(pdev, idd); | 679 | pci_set_drvdata(pdev, idd); |
680 | down_write(&ioc3_devices_rwsem); | 680 | down_write(&ioc3_devices_rwsem); |
681 | list_add(&idd->list, &ioc3_devices); | 681 | list_add_tail(&idd->list, &ioc3_devices); |
682 | idd->id = ioc3_counter++; | 682 | idd->id = ioc3_counter++; |
683 | up_write(&ioc3_devices_rwsem); | 683 | up_write(&ioc3_devices_rwsem); |
684 | 684 | ||
diff --git a/drivers/usb/gadget/inode.c b/drivers/usb/gadget/inode.c index 42b457030b03..0eb010a3f5bc 100644 --- a/drivers/usb/gadget/inode.c +++ b/drivers/usb/gadget/inode.c | |||
@@ -1614,6 +1614,7 @@ static int activate_ep_files (struct dev_data *dev) | |||
1614 | data, &ep_config_operations, | 1614 | data, &ep_config_operations, |
1615 | &data->dentry); | 1615 | &data->dentry); |
1616 | if (!data->inode) { | 1616 | if (!data->inode) { |
1617 | usb_ep_free_request(ep, data->req); | ||
1617 | kfree (data); | 1618 | kfree (data); |
1618 | goto enomem; | 1619 | goto enomem; |
1619 | } | 1620 | } |
diff --git a/drivers/usb/gadget/net2280.c b/drivers/usb/gadget/net2280.c index 6a4b93ad1082..0b9293493957 100644 --- a/drivers/usb/gadget/net2280.c +++ b/drivers/usb/gadget/net2280.c | |||
@@ -2166,7 +2166,7 @@ static void handle_ep_small (struct net2280_ep *ep) | |||
2166 | ep->stopped = 1; | 2166 | ep->stopped = 1; |
2167 | set_halt (ep); | 2167 | set_halt (ep); |
2168 | mode = 2; | 2168 | mode = 2; |
2169 | } else if (!req && ep->stopped) | 2169 | } else if (!req && !ep->stopped) |
2170 | write_fifo (ep, NULL); | 2170 | write_fifo (ep, NULL); |
2171 | } | 2171 | } |
2172 | } else { | 2172 | } else { |
@@ -2280,9 +2280,7 @@ static void handle_ep_small (struct net2280_ep *ep) | |||
2280 | /* if we wrote it all, we're usually done */ | 2280 | /* if we wrote it all, we're usually done */ |
2281 | if (req->req.actual == req->req.length) { | 2281 | if (req->req.actual == req->req.length) { |
2282 | if (ep->num == 0) { | 2282 | if (ep->num == 0) { |
2283 | /* wait for control status */ | 2283 | /* send zlps until the status stage */ |
2284 | if (mode != 2) | ||
2285 | req = NULL; | ||
2286 | } else if (!req->req.zero || len != ep->ep.maxpacket) | 2284 | } else if (!req->req.zero || len != ep->ep.maxpacket) |
2287 | mode = 2; | 2285 | mode = 2; |
2288 | } | 2286 | } |
@@ -2744,6 +2742,10 @@ static irqreturn_t net2280_irq (int irq, void *_dev, struct pt_regs * r) | |||
2744 | { | 2742 | { |
2745 | struct net2280 *dev = _dev; | 2743 | struct net2280 *dev = _dev; |
2746 | 2744 | ||
2745 | /* shared interrupt, not ours */ | ||
2746 | if (!(readl(&dev->regs->irqstat0) & (1 << INTA_ASSERTED))) | ||
2747 | return IRQ_NONE; | ||
2748 | |||
2747 | spin_lock (&dev->lock); | 2749 | spin_lock (&dev->lock); |
2748 | 2750 | ||
2749 | /* handle disconnect, dma, and more */ | 2751 | /* handle disconnect, dma, and more */ |
@@ -2831,13 +2833,13 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) | |||
2831 | } | 2833 | } |
2832 | 2834 | ||
2833 | /* alloc, and start init */ | 2835 | /* alloc, and start init */ |
2834 | dev = kmalloc (sizeof *dev, SLAB_KERNEL); | 2836 | dev = kzalloc (sizeof *dev, SLAB_KERNEL); |
2835 | if (dev == NULL){ | 2837 | if (dev == NULL){ |
2836 | retval = -ENOMEM; | 2838 | retval = -ENOMEM; |
2837 | goto done; | 2839 | goto done; |
2838 | } | 2840 | } |
2839 | 2841 | ||
2840 | memset (dev, 0, sizeof *dev); | 2842 | pci_set_drvdata (pdev, dev); |
2841 | spin_lock_init (&dev->lock); | 2843 | spin_lock_init (&dev->lock); |
2842 | dev->pdev = pdev; | 2844 | dev->pdev = pdev; |
2843 | dev->gadget.ops = &net2280_ops; | 2845 | dev->gadget.ops = &net2280_ops; |
@@ -2950,7 +2952,6 @@ static int net2280_probe (struct pci_dev *pdev, const struct pci_device_id *id) | |||
2950 | dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff; | 2952 | dev->chiprev = get_idx_reg (dev->regs, REG_CHIPREV) & 0xffff; |
2951 | 2953 | ||
2952 | /* done */ | 2954 | /* done */ |
2953 | pci_set_drvdata (pdev, dev); | ||
2954 | INFO (dev, "%s\n", driver_desc); | 2955 | INFO (dev, "%s\n", driver_desc); |
2955 | INFO (dev, "irq %s, pci mem %p, chip rev %04x\n", | 2956 | INFO (dev, "irq %s, pci mem %p, chip rev %04x\n", |
2956 | bufp, base, dev->chiprev); | 2957 | bufp, base, dev->chiprev); |
diff --git a/drivers/usb/host/ehci-pci.c b/drivers/usb/host/ehci-pci.c index 1e03f1a5a5fd..a1bd2bea6deb 100644 --- a/drivers/usb/host/ehci-pci.c +++ b/drivers/usb/host/ehci-pci.c | |||
@@ -350,7 +350,7 @@ static const struct hc_driver ehci_pci_hc_driver = { | |||
350 | /* PCI driver selection metadata; PCI hotplugging uses this */ | 350 | /* PCI driver selection metadata; PCI hotplugging uses this */ |
351 | static const struct pci_device_id pci_ids [] = { { | 351 | static const struct pci_device_id pci_ids [] = { { |
352 | /* handle any USB 2.0 EHCI controller */ | 352 | /* handle any USB 2.0 EHCI controller */ |
353 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x20), ~0), | 353 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_EHCI, ~0), |
354 | .driver_data = (unsigned long) &ehci_pci_hc_driver, | 354 | .driver_data = (unsigned long) &ehci_pci_hc_driver, |
355 | }, | 355 | }, |
356 | { /* end: all zeroes */ } | 356 | { /* end: all zeroes */ } |
diff --git a/drivers/usb/host/ohci-pci.c b/drivers/usb/host/ohci-pci.c index 1bfe96f4d045..b268537e389e 100644 --- a/drivers/usb/host/ohci-pci.c +++ b/drivers/usb/host/ohci-pci.c | |||
@@ -206,7 +206,7 @@ static const struct hc_driver ohci_pci_hc_driver = { | |||
206 | 206 | ||
207 | static const struct pci_device_id pci_ids [] = { { | 207 | static const struct pci_device_id pci_ids [] = { { |
208 | /* handle any USB OHCI controller */ | 208 | /* handle any USB OHCI controller */ |
209 | PCI_DEVICE_CLASS((PCI_CLASS_SERIAL_USB << 8) | 0x10, ~0), | 209 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_OHCI, ~0), |
210 | .driver_data = (unsigned long) &ohci_pci_hc_driver, | 210 | .driver_data = (unsigned long) &ohci_pci_hc_driver, |
211 | }, { /* end: all zeroes */ } | 211 | }, { /* end: all zeroes */ } |
212 | }; | 212 | }; |
diff --git a/drivers/usb/host/uhci-hcd.c b/drivers/usb/host/uhci-hcd.c index c0c4db78b590..d225e11f4055 100644 --- a/drivers/usb/host/uhci-hcd.c +++ b/drivers/usb/host/uhci-hcd.c | |||
@@ -858,7 +858,7 @@ static const struct hc_driver uhci_driver = { | |||
858 | 858 | ||
859 | static const struct pci_device_id uhci_pci_ids[] = { { | 859 | static const struct pci_device_id uhci_pci_ids[] = { { |
860 | /* handle any USB UHCI controller */ | 860 | /* handle any USB UHCI controller */ |
861 | PCI_DEVICE_CLASS(((PCI_CLASS_SERIAL_USB << 8) | 0x00), ~0), | 861 | PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_UHCI, ~0), |
862 | .driver_data = (unsigned long) &uhci_driver, | 862 | .driver_data = (unsigned long) &uhci_driver, |
863 | }, { /* end: all zeroes */ } | 863 | }, { /* end: all zeroes */ } |
864 | }; | 864 | }; |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index f5851db67f5b..82151207d814 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
@@ -308,6 +308,7 @@ static struct ftdi_sio_quirk ftdi_HE_TIRA1_quirk = { | |||
308 | 308 | ||
309 | static struct usb_device_id id_table_combined [] = { | 309 | static struct usb_device_id id_table_combined [] = { |
310 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, | 310 | { USB_DEVICE(FTDI_VID, FTDI_IRTRANS_PID) }, |
311 | { USB_DEVICE(FTDI_VID, FTDI_IPLUS_PID) }, | ||
311 | { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, | 312 | { USB_DEVICE(FTDI_VID, FTDI_SIO_PID) }, |
312 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, | 313 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_PID) }, |
313 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, | 314 | { USB_DEVICE(FTDI_VID, FTDI_8U232AM_ALT_PID) }, |
@@ -493,6 +494,8 @@ static struct usb_device_id id_table_combined [] = { | |||
493 | { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) }, | 494 | { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_777_PID) }, |
494 | { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) }, | 495 | { USB_DEVICE(FTDI_VID, FTDI_WESTREX_MODEL_8900F_PID) }, |
495 | { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) }, | 496 | { USB_DEVICE(FTDI_VID, FTDI_PCDJ_DAC2_PID) }, |
497 | { USB_DEVICE(FTDI_VID, FTDI_RRCIRKITS_LOCOBUFFER_PID) }, | ||
498 | { USB_DEVICE(FTDI_VID, FTDI_ASK_RDR400_PID) }, | ||
496 | { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, | 499 | { USB_DEVICE(ICOM_ID1_VID, ICOM_ID1_PID) }, |
497 | { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, | 500 | { USB_DEVICE(PAPOUCH_VID, PAPOUCH_TMU_PID) }, |
498 | { }, /* Optional parameter entry */ | 501 | { }, /* Optional parameter entry */ |
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h index 2155f0e4a378..2c55a5ea9c99 100644 --- a/drivers/usb/serial/ftdi_sio.h +++ b/drivers/usb/serial/ftdi_sio.h | |||
@@ -39,6 +39,9 @@ | |||
39 | /* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */ | 39 | /* www.thoughttechnology.com/ TT-USB provide with procomp use ftdi_sio */ |
40 | #define FTDI_TTUSB_PID 0xFF20 /* Product Id */ | 40 | #define FTDI_TTUSB_PID 0xFF20 /* Product Id */ |
41 | 41 | ||
42 | /* iPlus device */ | ||
43 | #define FTDI_IPLUS_PID 0xD070 /* Product Id */ | ||
44 | |||
42 | /* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ | 45 | /* www.crystalfontz.com devices - thanx for providing free devices for evaluation ! */ |
43 | /* they use the ftdi chipset for the USB interface and the vendor id is the same */ | 46 | /* they use the ftdi chipset for the USB interface and the vendor id is the same */ |
44 | #define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ | 47 | #define FTDI_XF_632_PID 0xFC08 /* 632: 16x2 Character Display */ |
@@ -153,6 +156,11 @@ | |||
153 | #define ICOM_ID1_PID 0x0004 | 156 | #define ICOM_ID1_PID 0x0004 |
154 | 157 | ||
155 | /* | 158 | /* |
159 | * ASK.fr devices | ||
160 | */ | ||
161 | #define FTDI_ASK_RDR400_PID 0xC991 /* ASK RDR 400 series card reader */ | ||
162 | |||
163 | /* | ||
156 | * DSS-20 Sync Station for Sony Ericsson P800 | 164 | * DSS-20 Sync Station for Sony Ericsson P800 |
157 | */ | 165 | */ |
158 | 166 | ||
@@ -400,6 +408,11 @@ | |||
400 | #define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */ | 408 | #define FTDI_WESTREX_MODEL_8900F_PID 0xDC01 /* Model 8900F */ |
401 | 409 | ||
402 | /* | 410 | /* |
411 | * RR-CirKits LocoBuffer USB (http://www.rr-cirkits.com) | ||
412 | */ | ||
413 | #define FTDI_RRCIRKITS_LOCOBUFFER_PID 0xc7d0 /* LocoBuffer USB */ | ||
414 | |||
415 | /* | ||
403 | * Eclo (http://www.eclo.pt/) product IDs. | 416 | * Eclo (http://www.eclo.pt/) product IDs. |
404 | * PID 0xEA90 submitted by Martin Grill. | 417 | * PID 0xEA90 submitted by Martin Grill. |
405 | */ | 418 | */ |
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c index ccf746b27d4e..c96714bb1cb8 100644 --- a/drivers/usb/serial/pl2303.c +++ b/drivers/usb/serial/pl2303.c | |||
@@ -61,6 +61,7 @@ static struct usb_device_id id_table [] = { | |||
61 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, | 61 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID) }, |
62 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) }, | 62 | { USB_DEVICE(ELCOM_VENDOR_ID, ELCOM_PRODUCT_ID_UCSGT) }, |
63 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) }, | 63 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID) }, |
64 | { USB_DEVICE(ITEGNO_VENDOR_ID, ITEGNO_PRODUCT_ID_2080) }, | ||
64 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, | 65 | { USB_DEVICE(MA620_VENDOR_ID, MA620_PRODUCT_ID) }, |
65 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, | 66 | { USB_DEVICE(RATOC_VENDOR_ID, RATOC_PRODUCT_ID) }, |
66 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, | 67 | { USB_DEVICE(TRIPP_VENDOR_ID, TRIPP_PRODUCT_ID) }, |
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h index 09f379b19e98..7f29e81d3e35 100644 --- a/drivers/usb/serial/pl2303.h +++ b/drivers/usb/serial/pl2303.h | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #define ITEGNO_VENDOR_ID 0x0eba | 27 | #define ITEGNO_VENDOR_ID 0x0eba |
28 | #define ITEGNO_PRODUCT_ID 0x1080 | 28 | #define ITEGNO_PRODUCT_ID 0x1080 |
29 | #define ITEGNO_PRODUCT_ID_2080 0x2080 | ||
29 | 30 | ||
30 | #define MA620_VENDOR_ID 0x0df7 | 31 | #define MA620_VENDOR_ID 0x0df7 |
31 | #define MA620_PRODUCT_ID 0x0620 | 32 | #define MA620_PRODUCT_ID 0x0620 |
diff --git a/drivers/usb/serial/whiteheat.c b/drivers/usb/serial/whiteheat.c index 557411c6e7c7..f806553cd9a4 100644 --- a/drivers/usb/serial/whiteheat.c +++ b/drivers/usb/serial/whiteheat.c | |||
@@ -508,6 +508,7 @@ no_firmware: | |||
508 | err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description); | 508 | err("%s: Unable to retrieve firmware version, try replugging\n", serial->type->description); |
509 | err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description); | 509 | err("%s: If the firmware is not running (status led not blinking)\n", serial->type->description); |
510 | err("%s: please contact support@connecttech.com\n", serial->type->description); | 510 | err("%s: please contact support@connecttech.com\n", serial->type->description); |
511 | kfree(result); | ||
511 | return -ENODEV; | 512 | return -ENODEV; |
512 | 513 | ||
513 | no_command_private: | 514 | no_command_private: |
diff --git a/drivers/usb/storage/Kconfig b/drivers/usb/storage/Kconfig index 92be101feba7..be9eec225743 100644 --- a/drivers/usb/storage/Kconfig +++ b/drivers/usb/storage/Kconfig | |||
@@ -48,7 +48,8 @@ config USB_STORAGE_FREECOM | |||
48 | 48 | ||
49 | config USB_STORAGE_ISD200 | 49 | config USB_STORAGE_ISD200 |
50 | bool "ISD-200 USB/ATA Bridge support" | 50 | bool "ISD-200 USB/ATA Bridge support" |
51 | depends on USB_STORAGE && BLK_DEV_IDE | 51 | depends on USB_STORAGE |
52 | depends on BLK_DEV_IDE=y || BLK_DEV_IDE=USB_STORAGE | ||
52 | ---help--- | 53 | ---help--- |
53 | Say Y here if you want to use USB Mass Store devices based | 54 | Say Y here if you want to use USB Mass Store devices based |
54 | on the In-Systems Design ISD-200 USB/ATA bridge. | 55 | on the In-Systems Design ISD-200 USB/ATA bridge. |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index c4a9dcff5f2b..aec5ea8682d5 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
@@ -411,7 +411,7 @@ UNUSUAL_DEV( 0x050d, 0x0115, 0x0133, 0x0133, | |||
411 | UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100, | 411 | UNUSUAL_DEV( 0x0525, 0xa140, 0x0100, 0x0100, |
412 | "Iomega", | 412 | "Iomega", |
413 | "USB Clik! 40", | 413 | "USB Clik! 40", |
414 | US_SC_8070, US_PR_BULK, NULL, | 414 | US_SC_8070, US_PR_DEVICE, NULL, |
415 | US_FL_FIX_INQUIRY ), | 415 | US_FL_FIX_INQUIRY ), |
416 | 416 | ||
417 | /* Yakumo Mega Image 37 | 417 | /* Yakumo Mega Image 37 |
@@ -773,6 +773,13 @@ UNUSUAL_DEV( 0x069b, 0x3004, 0x0001, 0x0001, | |||
773 | US_SC_DEVICE, US_PR_DEVICE, NULL, | 773 | US_SC_DEVICE, US_PR_DEVICE, NULL, |
774 | US_FL_FIX_CAPACITY ), | 774 | US_FL_FIX_CAPACITY ), |
775 | 775 | ||
776 | /* Reported by Olivier Blondeau <zeitoun@gmail.com> */ | ||
777 | UNUSUAL_DEV( 0x0727, 0x0306, 0x0100, 0x0100, | ||
778 | "ATMEL", | ||
779 | "SND1 Storage", | ||
780 | US_SC_DEVICE, US_PR_DEVICE, NULL, | ||
781 | US_FL_IGNORE_RESIDUE), | ||
782 | |||
776 | /* Submitted by Roman Hodek <roman@hodek.net> */ | 783 | /* Submitted by Roman Hodek <roman@hodek.net> */ |
777 | UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, | 784 | UNUSUAL_DEV( 0x0781, 0x0001, 0x0200, 0x0200, |
778 | "Sandisk", | 785 | "Sandisk", |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 9060e7137441..4587087d777a 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -400,6 +400,8 @@ config FB_ASILIANT | |||
400 | select FB_CFB_FILLRECT | 400 | select FB_CFB_FILLRECT |
401 | select FB_CFB_COPYAREA | 401 | select FB_CFB_COPYAREA |
402 | select FB_CFB_IMAGEBLIT | 402 | select FB_CFB_IMAGEBLIT |
403 | help | ||
404 | This is the frame buffer device driver for the Asiliant 69030 chipset | ||
403 | 405 | ||
404 | config FB_IMSTT | 406 | config FB_IMSTT |
405 | bool "IMS Twin Turbo display support" | 407 | bool "IMS Twin Turbo display support" |
diff --git a/drivers/video/aty/radeon_base.c b/drivers/video/aty/radeon_base.c index 9a6b5b39b88e..387a18a47ac2 100644 --- a/drivers/video/aty/radeon_base.c +++ b/drivers/video/aty/radeon_base.c | |||
@@ -2265,7 +2265,7 @@ static struct bin_attribute edid2_attr = { | |||
2265 | }; | 2265 | }; |
2266 | 2266 | ||
2267 | 2267 | ||
2268 | static int radeonfb_pci_register (struct pci_dev *pdev, | 2268 | static int __devinit radeonfb_pci_register (struct pci_dev *pdev, |
2269 | const struct pci_device_id *ent) | 2269 | const struct pci_device_id *ent) |
2270 | { | 2270 | { |
2271 | struct fb_info *info; | 2271 | struct fb_info *info; |
diff --git a/drivers/video/au1200fb.c b/drivers/video/au1200fb.c index b367de30b98c..600d3e0e08b7 100644 --- a/drivers/video/au1200fb.c +++ b/drivers/video/au1200fb.c | |||
@@ -1920,1925 +1920,3 @@ module_exit(au1200fb_cleanup); | |||
1920 | 1920 | ||
1921 | MODULE_DESCRIPTION(DRIVER_DESC); | 1921 | MODULE_DESCRIPTION(DRIVER_DESC); |
1922 | MODULE_LICENSE("GPL"); | 1922 | MODULE_LICENSE("GPL"); |
1923 | /* | ||
1924 | * BRIEF MODULE DESCRIPTION | ||
1925 | * Au1200 LCD Driver. | ||
1926 | * | ||
1927 | * Copyright 2004-2005 AMD | ||
1928 | * Author: AMD | ||
1929 | * | ||
1930 | * Based on: | ||
1931 | * linux/drivers/video/skeletonfb.c -- Skeleton for a frame buffer device | ||
1932 | * Created 28 Dec 1997 by Geert Uytterhoeven | ||
1933 | * | ||
1934 | * This program is free software; you can redistribute it and/or modify it | ||
1935 | * under the terms of the GNU General Public License as published by the | ||
1936 | * Free Software Foundation; either version 2 of the License, or (at your | ||
1937 | * option) any later version. | ||
1938 | * | ||
1939 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
1940 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
1941 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
1942 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
1943 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
1944 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
1945 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
1946 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
1947 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
1948 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
1949 | * | ||
1950 | * You should have received a copy of the GNU General Public License along | ||
1951 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
1952 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
1953 | */ | ||
1954 | |||
1955 | #include <linux/module.h> | ||
1956 | #include <linux/platform_device.h> | ||
1957 | #include <linux/kernel.h> | ||
1958 | #include <linux/errno.h> | ||
1959 | #include <linux/string.h> | ||
1960 | #include <linux/mm.h> | ||
1961 | #include <linux/fb.h> | ||
1962 | #include <linux/init.h> | ||
1963 | #include <linux/interrupt.h> | ||
1964 | #include <linux/ctype.h> | ||
1965 | #include <linux/dma-mapping.h> | ||
1966 | |||
1967 | #include <asm/mach-au1x00/au1000.h> | ||
1968 | #include "au1200fb.h" | ||
1969 | |||
1970 | #ifdef CONFIG_PM | ||
1971 | #include <asm/mach-au1x00/au1xxx_pm.h> | ||
1972 | #endif | ||
1973 | |||
1974 | #ifndef CONFIG_FB_AU1200_DEVS | ||
1975 | #define CONFIG_FB_AU1200_DEVS 4 | ||
1976 | #endif | ||
1977 | |||
1978 | #define DRIVER_NAME "au1200fb" | ||
1979 | #define DRIVER_DESC "LCD controller driver for AU1200 processors" | ||
1980 | |||
1981 | #define DEBUG 1 | ||
1982 | |||
1983 | #define print_err(f, arg...) printk(KERN_ERR DRIVER_NAME ": " f "\n", ## arg) | ||
1984 | #define print_warn(f, arg...) printk(KERN_WARNING DRIVER_NAME ": " f "\n", ## arg) | ||
1985 | #define print_info(f, arg...) printk(KERN_INFO DRIVER_NAME ": " f "\n", ## arg) | ||
1986 | |||
1987 | #if DEBUG | ||
1988 | #define print_dbg(f, arg...) printk(KERN_DEBUG __FILE__ ": " f "\n", ## arg) | ||
1989 | #else | ||
1990 | #define print_dbg(f, arg...) do {} while (0) | ||
1991 | #endif | ||
1992 | |||
1993 | |||
1994 | #define AU1200_LCD_FB_IOCTL 0x46FF | ||
1995 | |||
1996 | #define AU1200_LCD_SET_SCREEN 1 | ||
1997 | #define AU1200_LCD_GET_SCREEN 2 | ||
1998 | #define AU1200_LCD_SET_WINDOW 3 | ||
1999 | #define AU1200_LCD_GET_WINDOW 4 | ||
2000 | #define AU1200_LCD_SET_PANEL 5 | ||
2001 | #define AU1200_LCD_GET_PANEL 6 | ||
2002 | |||
2003 | #define SCREEN_SIZE (1<< 1) | ||
2004 | #define SCREEN_BACKCOLOR (1<< 2) | ||
2005 | #define SCREEN_BRIGHTNESS (1<< 3) | ||
2006 | #define SCREEN_COLORKEY (1<< 4) | ||
2007 | #define SCREEN_MASK (1<< 5) | ||
2008 | |||
2009 | struct au1200_lcd_global_regs_t { | ||
2010 | unsigned int flags; | ||
2011 | unsigned int xsize; | ||
2012 | unsigned int ysize; | ||
2013 | unsigned int backcolor; | ||
2014 | unsigned int brightness; | ||
2015 | unsigned int colorkey; | ||
2016 | unsigned int mask; | ||
2017 | unsigned int panel_choice; | ||
2018 | char panel_desc[80]; | ||
2019 | |||
2020 | }; | ||
2021 | |||
2022 | #define WIN_POSITION (1<< 0) | ||
2023 | #define WIN_ALPHA_COLOR (1<< 1) | ||
2024 | #define WIN_ALPHA_MODE (1<< 2) | ||
2025 | #define WIN_PRIORITY (1<< 3) | ||
2026 | #define WIN_CHANNEL (1<< 4) | ||
2027 | #define WIN_BUFFER_FORMAT (1<< 5) | ||
2028 | #define WIN_COLOR_ORDER (1<< 6) | ||
2029 | #define WIN_PIXEL_ORDER (1<< 7) | ||
2030 | #define WIN_SIZE (1<< 8) | ||
2031 | #define WIN_COLORKEY_MODE (1<< 9) | ||
2032 | #define WIN_DOUBLE_BUFFER_MODE (1<< 10) | ||
2033 | #define WIN_RAM_ARRAY_MODE (1<< 11) | ||
2034 | #define WIN_BUFFER_SCALE (1<< 12) | ||
2035 | #define WIN_ENABLE (1<< 13) | ||
2036 | |||
2037 | struct au1200_lcd_window_regs_t { | ||
2038 | unsigned int flags; | ||
2039 | unsigned int xpos; | ||
2040 | unsigned int ypos; | ||
2041 | unsigned int alpha_color; | ||
2042 | unsigned int alpha_mode; | ||
2043 | unsigned int priority; | ||
2044 | unsigned int channel; | ||
2045 | unsigned int buffer_format; | ||
2046 | unsigned int color_order; | ||
2047 | unsigned int pixel_order; | ||
2048 | unsigned int xsize; | ||
2049 | unsigned int ysize; | ||
2050 | unsigned int colorkey_mode; | ||
2051 | unsigned int double_buffer_mode; | ||
2052 | unsigned int ram_array_mode; | ||
2053 | unsigned int xscale; | ||
2054 | unsigned int yscale; | ||
2055 | unsigned int enable; | ||
2056 | }; | ||
2057 | |||
2058 | |||
2059 | struct au1200_lcd_iodata_t { | ||
2060 | unsigned int subcmd; | ||
2061 | struct au1200_lcd_global_regs_t global; | ||
2062 | struct au1200_lcd_window_regs_t window; | ||
2063 | }; | ||
2064 | |||
2065 | #if defined(__BIG_ENDIAN) | ||
2066 | #define LCD_CONTROL_DEFAULT_PO LCD_CONTROL_PO_11 | ||
2067 | #else | ||
2068 | #define LCD_CONTROL_DEFAULT_PO LCD_CONTROL_PO_00 | ||
2069 | #endif | ||
2070 | #define LCD_CONTROL_DEFAULT_SBPPF LCD_CONTROL_SBPPF_565 | ||
2071 | |||
2072 | /* Private, per-framebuffer management information (independent of the panel itself) */ | ||
2073 | struct au1200fb_device { | ||
2074 | struct fb_info fb_info; /* FB driver info record */ | ||
2075 | |||
2076 | int plane; | ||
2077 | unsigned char* fb_mem; /* FrameBuffer memory map */ | ||
2078 | unsigned int fb_len; | ||
2079 | dma_addr_t fb_phys; | ||
2080 | }; | ||
2081 | |||
2082 | static struct au1200fb_device _au1200fb_devices[CONFIG_FB_AU1200_DEVS]; | ||
2083 | /********************************************************************/ | ||
2084 | |||
2085 | /* LCD controller restrictions */ | ||
2086 | #define AU1200_LCD_MAX_XRES 1280 | ||
2087 | #define AU1200_LCD_MAX_YRES 1024 | ||
2088 | #define AU1200_LCD_MAX_BPP 32 | ||
2089 | #define AU1200_LCD_MAX_CLK 96000000 /* fixme: this needs to go away ? */ | ||
2090 | #define AU1200_LCD_NBR_PALETTE_ENTRIES 256 | ||
2091 | |||
2092 | /* Default number of visible screen buffer to allocate */ | ||
2093 | #define AU1200FB_NBR_VIDEO_BUFFERS 1 | ||
2094 | |||
2095 | /********************************************************************/ | ||
2096 | |||
2097 | static struct au1200_lcd *lcd = (struct au1200_lcd *) AU1200_LCD_ADDR; | ||
2098 | static int window_index = 2; /* default is zero */ | ||
2099 | static int panel_index = 2; /* default is zero */ | ||
2100 | static struct window_settings *win; | ||
2101 | static struct panel_settings *panel; | ||
2102 | static int noblanking = 1; | ||
2103 | static int nohwcursor = 0; | ||
2104 | |||
2105 | struct window_settings { | ||
2106 | unsigned char name[64]; | ||
2107 | uint32 mode_backcolor; | ||
2108 | uint32 mode_colorkey; | ||
2109 | uint32 mode_colorkeymsk; | ||
2110 | struct { | ||
2111 | int xres; | ||
2112 | int yres; | ||
2113 | int xpos; | ||
2114 | int ypos; | ||
2115 | uint32 mode_winctrl1; /* winctrl1[FRM,CCO,PO,PIPE] */ | ||
2116 | uint32 mode_winenable; | ||
2117 | } w[4]; | ||
2118 | }; | ||
2119 | |||
2120 | #if defined(__BIG_ENDIAN) | ||
2121 | #define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_00 | ||
2122 | #else | ||
2123 | #define LCD_WINCTRL1_PO_16BPP LCD_WINCTRL1_PO_01 | ||
2124 | #endif | ||
2125 | |||
2126 | extern int board_au1200fb_panel_init (void); | ||
2127 | extern int board_au1200fb_panel_shutdown (void); | ||
2128 | |||
2129 | #ifdef CONFIG_PM | ||
2130 | int au1200fb_pm_callback(au1xxx_power_dev_t *dev, | ||
2131 | au1xxx_request_t request, void *data); | ||
2132 | au1xxx_power_dev_t *LCD_pm_dev; | ||
2133 | #endif | ||
2134 | |||
2135 | /* | ||
2136 | * Default window configurations | ||
2137 | */ | ||
2138 | static struct window_settings windows[] = { | ||
2139 | { /* Index 0 */ | ||
2140 | "0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx", | ||
2141 | /* mode_backcolor */ 0x006600ff, | ||
2142 | /* mode_colorkey,msk*/ 0, 0, | ||
2143 | { | ||
2144 | { | ||
2145 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2146 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2147 | LCD_WINCTRL1_PO_16BPP, | ||
2148 | /* mode_winenable*/ LCD_WINENABLE_WEN0, | ||
2149 | }, | ||
2150 | { | ||
2151 | /* xres, yres, xpos, ypos */ 100, 100, 100, 100, | ||
2152 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2153 | LCD_WINCTRL1_PO_16BPP | | ||
2154 | LCD_WINCTRL1_PIPE, | ||
2155 | /* mode_winenable*/ LCD_WINENABLE_WEN1, | ||
2156 | }, | ||
2157 | { | ||
2158 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2159 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2160 | LCD_WINCTRL1_PO_16BPP, | ||
2161 | /* mode_winenable*/ 0, | ||
2162 | }, | ||
2163 | { | ||
2164 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2165 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2166 | LCD_WINCTRL1_PO_16BPP | | ||
2167 | LCD_WINCTRL1_PIPE, | ||
2168 | /* mode_winenable*/ 0, | ||
2169 | }, | ||
2170 | }, | ||
2171 | }, | ||
2172 | |||
2173 | { /* Index 1 */ | ||
2174 | "0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx", | ||
2175 | /* mode_backcolor */ 0x006600ff, | ||
2176 | /* mode_colorkey,msk*/ 0, 0, | ||
2177 | { | ||
2178 | { | ||
2179 | /* xres, yres, xpos, ypos */ 320, 240, 5, 5, | ||
2180 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_24BPP | | ||
2181 | LCD_WINCTRL1_PO_00, | ||
2182 | /* mode_winenable*/ LCD_WINENABLE_WEN0, | ||
2183 | }, | ||
2184 | { | ||
2185 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2186 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | ||
2187 | | LCD_WINCTRL1_PO_16BPP, | ||
2188 | /* mode_winenable*/ 0, | ||
2189 | }, | ||
2190 | { | ||
2191 | /* xres, yres, xpos, ypos */ 100, 100, 0, 0, | ||
2192 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2193 | LCD_WINCTRL1_PO_16BPP | | ||
2194 | LCD_WINCTRL1_PIPE, | ||
2195 | /* mode_winenable*/ 0/*LCD_WINENABLE_WEN2*/, | ||
2196 | }, | ||
2197 | { | ||
2198 | /* xres, yres, xpos, ypos */ 200, 25, 0, 0, | ||
2199 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2200 | LCD_WINCTRL1_PO_16BPP | | ||
2201 | LCD_WINCTRL1_PIPE, | ||
2202 | /* mode_winenable*/ 0, | ||
2203 | }, | ||
2204 | }, | ||
2205 | }, | ||
2206 | { /* Index 2 */ | ||
2207 | "0-FS gfx, 1-video, 2-ovly gfx, 3-ovly gfx", | ||
2208 | /* mode_backcolor */ 0x006600ff, | ||
2209 | /* mode_colorkey,msk*/ 0, 0, | ||
2210 | { | ||
2211 | { | ||
2212 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2213 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2214 | LCD_WINCTRL1_PO_16BPP, | ||
2215 | /* mode_winenable*/ LCD_WINENABLE_WEN0, | ||
2216 | }, | ||
2217 | { | ||
2218 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2219 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2220 | LCD_WINCTRL1_PO_16BPP, | ||
2221 | /* mode_winenable*/ 0, | ||
2222 | }, | ||
2223 | { | ||
2224 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2225 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_32BPP | | ||
2226 | LCD_WINCTRL1_PO_00|LCD_WINCTRL1_PIPE, | ||
2227 | /* mode_winenable*/ 0/*LCD_WINENABLE_WEN2*/, | ||
2228 | }, | ||
2229 | { | ||
2230 | /* xres, yres, xpos, ypos */ 0, 0, 0, 0, | ||
2231 | /* mode_winctrl1 */ LCD_WINCTRL1_FRM_16BPP565 | | ||
2232 | LCD_WINCTRL1_PO_16BPP | | ||
2233 | LCD_WINCTRL1_PIPE, | ||
2234 | /* mode_winenable*/ 0, | ||
2235 | }, | ||
2236 | }, | ||
2237 | }, | ||
2238 | /* Need VGA 640 @ 24bpp, @ 32bpp */ | ||
2239 | /* Need VGA 800 @ 24bpp, @ 32bpp */ | ||
2240 | /* Need VGA 1024 @ 24bpp, @ 32bpp */ | ||
2241 | }; | ||
2242 | |||
2243 | /* | ||
2244 | * Controller configurations for various panels. | ||
2245 | */ | ||
2246 | |||
2247 | struct panel_settings | ||
2248 | { | ||
2249 | const char name[25]; /* Full name <vendor>_<model> */ | ||
2250 | |||
2251 | struct fb_monspecs monspecs; /* FB monitor specs */ | ||
2252 | |||
2253 | /* panel timings */ | ||
2254 | uint32 mode_screen; | ||
2255 | uint32 mode_horztiming; | ||
2256 | uint32 mode_verttiming; | ||
2257 | uint32 mode_clkcontrol; | ||
2258 | uint32 mode_pwmdiv; | ||
2259 | uint32 mode_pwmhi; | ||
2260 | uint32 mode_outmask; | ||
2261 | uint32 mode_fifoctrl; | ||
2262 | uint32 mode_toyclksrc; | ||
2263 | uint32 mode_backlight; | ||
2264 | uint32 mode_auxpll; | ||
2265 | int (*device_init)(void); | ||
2266 | int (*device_shutdown)(void); | ||
2267 | #define Xres min_xres | ||
2268 | #define Yres min_yres | ||
2269 | u32 min_xres; /* Minimum horizontal resolution */ | ||
2270 | u32 max_xres; /* Maximum horizontal resolution */ | ||
2271 | u32 min_yres; /* Minimum vertical resolution */ | ||
2272 | u32 max_yres; /* Maximum vertical resolution */ | ||
2273 | }; | ||
2274 | |||
2275 | /********************************************************************/ | ||
2276 | /* fixme: Maybe a modedb for the CRT ? otherwise panels should be as-is */ | ||
2277 | |||
2278 | /* List of panels known to work with the AU1200 LCD controller. | ||
2279 | * To add a new panel, enter the same specifications as the | ||
2280 | * Generic_TFT one, and MAKE SURE that it doesn't conflicts | ||
2281 | * with the controller restrictions. Restrictions are: | ||
2282 | * | ||
2283 | * STN color panels: max_bpp <= 12 | ||
2284 | * STN mono panels: max_bpp <= 4 | ||
2285 | * TFT panels: max_bpp <= 16 | ||
2286 | * max_xres <= 800 | ||
2287 | * max_yres <= 600 | ||
2288 | */ | ||
2289 | static struct panel_settings known_lcd_panels[] = | ||
2290 | { | ||
2291 | [0] = { /* QVGA 320x240 H:33.3kHz V:110Hz */ | ||
2292 | .name = "QVGA_320x240", | ||
2293 | .monspecs = { | ||
2294 | .modedb = NULL, | ||
2295 | .modedb_len = 0, | ||
2296 | .hfmin = 30000, | ||
2297 | .hfmax = 70000, | ||
2298 | .vfmin = 60, | ||
2299 | .vfmax = 60, | ||
2300 | .dclkmin = 6000000, | ||
2301 | .dclkmax = 28000000, | ||
2302 | .input = FB_DISP_RGB, | ||
2303 | }, | ||
2304 | .mode_screen = LCD_SCREEN_SX_N(320) | | ||
2305 | LCD_SCREEN_SY_N(240), | ||
2306 | .mode_horztiming = 0x00c4623b, | ||
2307 | .mode_verttiming = 0x00502814, | ||
2308 | .mode_clkcontrol = 0x00020002, /* /4=24Mhz */ | ||
2309 | .mode_pwmdiv = 0x00000000, | ||
2310 | .mode_pwmhi = 0x00000000, | ||
2311 | .mode_outmask = 0x00FFFFFF, | ||
2312 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2313 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2314 | .mode_backlight = 0x00000000, | ||
2315 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2316 | .device_init = NULL, | ||
2317 | .device_shutdown = NULL, | ||
2318 | 320, 320, | ||
2319 | 240, 240, | ||
2320 | }, | ||
2321 | |||
2322 | [1] = { /* VGA 640x480 H:30.3kHz V:58Hz */ | ||
2323 | .name = "VGA_640x480", | ||
2324 | .monspecs = { | ||
2325 | .modedb = NULL, | ||
2326 | .modedb_len = 0, | ||
2327 | .hfmin = 30000, | ||
2328 | .hfmax = 70000, | ||
2329 | .vfmin = 60, | ||
2330 | .vfmax = 60, | ||
2331 | .dclkmin = 6000000, | ||
2332 | .dclkmax = 28000000, | ||
2333 | .input = FB_DISP_RGB, | ||
2334 | }, | ||
2335 | .mode_screen = 0x13f9df80, | ||
2336 | .mode_horztiming = 0x003c5859, | ||
2337 | .mode_verttiming = 0x00741201, | ||
2338 | .mode_clkcontrol = 0x00020001, /* /4=24Mhz */ | ||
2339 | .mode_pwmdiv = 0x00000000, | ||
2340 | .mode_pwmhi = 0x00000000, | ||
2341 | .mode_outmask = 0x00FFFFFF, | ||
2342 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2343 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2344 | .mode_backlight = 0x00000000, | ||
2345 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2346 | .device_init = NULL, | ||
2347 | .device_shutdown = NULL, | ||
2348 | 640, 480, | ||
2349 | 640, 480, | ||
2350 | }, | ||
2351 | |||
2352 | [2] = { /* SVGA 800x600 H:46.1kHz V:69Hz */ | ||
2353 | .name = "SVGA_800x600", | ||
2354 | .monspecs = { | ||
2355 | .modedb = NULL, | ||
2356 | .modedb_len = 0, | ||
2357 | .hfmin = 30000, | ||
2358 | .hfmax = 70000, | ||
2359 | .vfmin = 60, | ||
2360 | .vfmax = 60, | ||
2361 | .dclkmin = 6000000, | ||
2362 | .dclkmax = 28000000, | ||
2363 | .input = FB_DISP_RGB, | ||
2364 | }, | ||
2365 | .mode_screen = 0x18fa5780, | ||
2366 | .mode_horztiming = 0x00dc7e77, | ||
2367 | .mode_verttiming = 0x00584805, | ||
2368 | .mode_clkcontrol = 0x00020000, /* /2=48Mhz */ | ||
2369 | .mode_pwmdiv = 0x00000000, | ||
2370 | .mode_pwmhi = 0x00000000, | ||
2371 | .mode_outmask = 0x00FFFFFF, | ||
2372 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2373 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2374 | .mode_backlight = 0x00000000, | ||
2375 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2376 | .device_init = NULL, | ||
2377 | .device_shutdown = NULL, | ||
2378 | 800, 800, | ||
2379 | 600, 600, | ||
2380 | }, | ||
2381 | |||
2382 | [3] = { /* XVGA 1024x768 H:56.2kHz V:70Hz */ | ||
2383 | .name = "XVGA_1024x768", | ||
2384 | .monspecs = { | ||
2385 | .modedb = NULL, | ||
2386 | .modedb_len = 0, | ||
2387 | .hfmin = 30000, | ||
2388 | .hfmax = 70000, | ||
2389 | .vfmin = 60, | ||
2390 | .vfmax = 60, | ||
2391 | .dclkmin = 6000000, | ||
2392 | .dclkmax = 28000000, | ||
2393 | .input = FB_DISP_RGB, | ||
2394 | }, | ||
2395 | .mode_screen = 0x1ffaff80, | ||
2396 | .mode_horztiming = 0x007d0e57, | ||
2397 | .mode_verttiming = 0x00740a01, | ||
2398 | .mode_clkcontrol = 0x000A0000, /* /1 */ | ||
2399 | .mode_pwmdiv = 0x00000000, | ||
2400 | .mode_pwmhi = 0x00000000, | ||
2401 | .mode_outmask = 0x00FFFFFF, | ||
2402 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2403 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2404 | .mode_backlight = 0x00000000, | ||
2405 | .mode_auxpll = 6, /* 72MHz AUXPLL */ | ||
2406 | .device_init = NULL, | ||
2407 | .device_shutdown = NULL, | ||
2408 | 1024, 1024, | ||
2409 | 768, 768, | ||
2410 | }, | ||
2411 | |||
2412 | [4] = { /* XVGA XVGA 1280x1024 H:68.5kHz V:65Hz */ | ||
2413 | .name = "XVGA_1280x1024", | ||
2414 | .monspecs = { | ||
2415 | .modedb = NULL, | ||
2416 | .modedb_len = 0, | ||
2417 | .hfmin = 30000, | ||
2418 | .hfmax = 70000, | ||
2419 | .vfmin = 60, | ||
2420 | .vfmax = 60, | ||
2421 | .dclkmin = 6000000, | ||
2422 | .dclkmax = 28000000, | ||
2423 | .input = FB_DISP_RGB, | ||
2424 | }, | ||
2425 | .mode_screen = 0x27fbff80, | ||
2426 | .mode_horztiming = 0x00cdb2c7, | ||
2427 | .mode_verttiming = 0x00600002, | ||
2428 | .mode_clkcontrol = 0x000A0000, /* /1 */ | ||
2429 | .mode_pwmdiv = 0x00000000, | ||
2430 | .mode_pwmhi = 0x00000000, | ||
2431 | .mode_outmask = 0x00FFFFFF, | ||
2432 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2433 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2434 | .mode_backlight = 0x00000000, | ||
2435 | .mode_auxpll = 10, /* 120MHz AUXPLL */ | ||
2436 | .device_init = NULL, | ||
2437 | .device_shutdown = NULL, | ||
2438 | 1280, 1280, | ||
2439 | 1024, 1024, | ||
2440 | }, | ||
2441 | |||
2442 | [5] = { /* Samsung 1024x768 TFT */ | ||
2443 | .name = "Samsung_1024x768_TFT", | ||
2444 | .monspecs = { | ||
2445 | .modedb = NULL, | ||
2446 | .modedb_len = 0, | ||
2447 | .hfmin = 30000, | ||
2448 | .hfmax = 70000, | ||
2449 | .vfmin = 60, | ||
2450 | .vfmax = 60, | ||
2451 | .dclkmin = 6000000, | ||
2452 | .dclkmax = 28000000, | ||
2453 | .input = FB_DISP_RGB, | ||
2454 | }, | ||
2455 | .mode_screen = 0x1ffaff80, | ||
2456 | .mode_horztiming = 0x018cc677, | ||
2457 | .mode_verttiming = 0x00241217, | ||
2458 | .mode_clkcontrol = 0x00000000, /* SCB 0x1 /4=24Mhz */ | ||
2459 | .mode_pwmdiv = 0x8000063f, /* SCB 0x0 */ | ||
2460 | .mode_pwmhi = 0x03400000, /* SCB 0x0 */ | ||
2461 | .mode_outmask = 0x00FFFFFF, | ||
2462 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2463 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2464 | .mode_backlight = 0x00000000, | ||
2465 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2466 | .device_init = board_au1200fb_panel_init, | ||
2467 | .device_shutdown = board_au1200fb_panel_shutdown, | ||
2468 | 1024, 1024, | ||
2469 | 768, 768, | ||
2470 | }, | ||
2471 | |||
2472 | [6] = { /* Toshiba 640x480 TFT */ | ||
2473 | .name = "Toshiba_640x480_TFT", | ||
2474 | .monspecs = { | ||
2475 | .modedb = NULL, | ||
2476 | .modedb_len = 0, | ||
2477 | .hfmin = 30000, | ||
2478 | .hfmax = 70000, | ||
2479 | .vfmin = 60, | ||
2480 | .vfmax = 60, | ||
2481 | .dclkmin = 6000000, | ||
2482 | .dclkmax = 28000000, | ||
2483 | .input = FB_DISP_RGB, | ||
2484 | }, | ||
2485 | .mode_screen = LCD_SCREEN_SX_N(640) | | ||
2486 | LCD_SCREEN_SY_N(480), | ||
2487 | .mode_horztiming = LCD_HORZTIMING_HPW_N(96) | | ||
2488 | LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(51), | ||
2489 | .mode_verttiming = LCD_VERTTIMING_VPW_N(2) | | ||
2490 | LCD_VERTTIMING_VND1_N(11) | LCD_VERTTIMING_VND2_N(32), | ||
2491 | .mode_clkcontrol = 0x00000000, /* /4=24Mhz */ | ||
2492 | .mode_pwmdiv = 0x8000063f, | ||
2493 | .mode_pwmhi = 0x03400000, | ||
2494 | .mode_outmask = 0x00fcfcfc, | ||
2495 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2496 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2497 | .mode_backlight = 0x00000000, | ||
2498 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2499 | .device_init = board_au1200fb_panel_init, | ||
2500 | .device_shutdown = board_au1200fb_panel_shutdown, | ||
2501 | 640, 480, | ||
2502 | 640, 480, | ||
2503 | }, | ||
2504 | |||
2505 | [7] = { /* Sharp 320x240 TFT */ | ||
2506 | .name = "Sharp_320x240_TFT", | ||
2507 | .monspecs = { | ||
2508 | .modedb = NULL, | ||
2509 | .modedb_len = 0, | ||
2510 | .hfmin = 12500, | ||
2511 | .hfmax = 20000, | ||
2512 | .vfmin = 38, | ||
2513 | .vfmax = 81, | ||
2514 | .dclkmin = 4500000, | ||
2515 | .dclkmax = 6800000, | ||
2516 | .input = FB_DISP_RGB, | ||
2517 | }, | ||
2518 | .mode_screen = LCD_SCREEN_SX_N(320) | | ||
2519 | LCD_SCREEN_SY_N(240), | ||
2520 | .mode_horztiming = LCD_HORZTIMING_HPW_N(60) | | ||
2521 | LCD_HORZTIMING_HND1_N(13) | LCD_HORZTIMING_HND2_N(2), | ||
2522 | .mode_verttiming = LCD_VERTTIMING_VPW_N(2) | | ||
2523 | LCD_VERTTIMING_VND1_N(2) | LCD_VERTTIMING_VND2_N(5), | ||
2524 | .mode_clkcontrol = LCD_CLKCONTROL_PCD_N(7), /*16=6Mhz*/ | ||
2525 | .mode_pwmdiv = 0x8000063f, | ||
2526 | .mode_pwmhi = 0x03400000, | ||
2527 | .mode_outmask = 0x00fcfcfc, | ||
2528 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2529 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2530 | .mode_backlight = 0x00000000, | ||
2531 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2532 | .device_init = board_au1200fb_panel_init, | ||
2533 | .device_shutdown = board_au1200fb_panel_shutdown, | ||
2534 | 320, 320, | ||
2535 | 240, 240, | ||
2536 | }, | ||
2537 | |||
2538 | [8] = { /* Toppoly TD070WGCB2 7" 856x480 TFT */ | ||
2539 | .name = "Toppoly_TD070WGCB2", | ||
2540 | .monspecs = { | ||
2541 | .modedb = NULL, | ||
2542 | .modedb_len = 0, | ||
2543 | .hfmin = 30000, | ||
2544 | .hfmax = 70000, | ||
2545 | .vfmin = 60, | ||
2546 | .vfmax = 60, | ||
2547 | .dclkmin = 6000000, | ||
2548 | .dclkmax = 28000000, | ||
2549 | .input = FB_DISP_RGB, | ||
2550 | }, | ||
2551 | .mode_screen = LCD_SCREEN_SX_N(856) | | ||
2552 | LCD_SCREEN_SY_N(480), | ||
2553 | .mode_horztiming = LCD_HORZTIMING_HND2_N(43) | | ||
2554 | LCD_HORZTIMING_HND1_N(43) | LCD_HORZTIMING_HPW_N(114), | ||
2555 | .mode_verttiming = LCD_VERTTIMING_VND2_N(20) | | ||
2556 | LCD_VERTTIMING_VND1_N(21) | LCD_VERTTIMING_VPW_N(4), | ||
2557 | .mode_clkcontrol = 0x00020001, /* /4=24Mhz */ | ||
2558 | .mode_pwmdiv = 0x8000063f, | ||
2559 | .mode_pwmhi = 0x03400000, | ||
2560 | .mode_outmask = 0x00fcfcfc, | ||
2561 | .mode_fifoctrl = 0x2f2f2f2f, | ||
2562 | .mode_toyclksrc = 0x00000004, /* AUXPLL directly */ | ||
2563 | .mode_backlight = 0x00000000, | ||
2564 | .mode_auxpll = 8, /* 96MHz AUXPLL */ | ||
2565 | .device_init = board_au1200fb_panel_init, | ||
2566 | .device_shutdown = board_au1200fb_panel_shutdown, | ||
2567 | 856, 856, | ||
2568 | 480, 480, | ||
2569 | }, | ||
2570 | }; | ||
2571 | |||
2572 | #define NUM_PANELS (ARRAY_SIZE(known_lcd_panels)) | ||
2573 | |||
2574 | /********************************************************************/ | ||
2575 | |||
2576 | #ifdef CONFIG_PM | ||
2577 | static int set_brightness(unsigned int brightness) | ||
2578 | { | ||
2579 | unsigned int hi1, divider; | ||
2580 | |||
2581 | /* limit brightness pwm duty to >= 30/1600 */ | ||
2582 | if (brightness < 30) { | ||
2583 | brightness = 30; | ||
2584 | } | ||
2585 | divider = (lcd->pwmdiv & 0x3FFFF) + 1; | ||
2586 | hi1 = (lcd->pwmhi >> 16) + 1; | ||
2587 | hi1 = (((brightness & 0xFF) + 1) * divider >> 8); | ||
2588 | lcd->pwmhi &= 0xFFFF; | ||
2589 | lcd->pwmhi |= (hi1 << 16); | ||
2590 | |||
2591 | return brightness; | ||
2592 | } | ||
2593 | #endif /* CONFIG_PM */ | ||
2594 | |||
2595 | static int winbpp (unsigned int winctrl1) | ||
2596 | { | ||
2597 | int bits = 0; | ||
2598 | |||
2599 | /* how many bits are needed for each pixel format */ | ||
2600 | switch (winctrl1 & LCD_WINCTRL1_FRM) { | ||
2601 | case LCD_WINCTRL1_FRM_1BPP: | ||
2602 | bits = 1; | ||
2603 | break; | ||
2604 | case LCD_WINCTRL1_FRM_2BPP: | ||
2605 | bits = 2; | ||
2606 | break; | ||
2607 | case LCD_WINCTRL1_FRM_4BPP: | ||
2608 | bits = 4; | ||
2609 | break; | ||
2610 | case LCD_WINCTRL1_FRM_8BPP: | ||
2611 | bits = 8; | ||
2612 | break; | ||
2613 | case LCD_WINCTRL1_FRM_12BPP: | ||
2614 | case LCD_WINCTRL1_FRM_16BPP655: | ||
2615 | case LCD_WINCTRL1_FRM_16BPP565: | ||
2616 | case LCD_WINCTRL1_FRM_16BPP556: | ||
2617 | case LCD_WINCTRL1_FRM_16BPPI1555: | ||
2618 | case LCD_WINCTRL1_FRM_16BPPI5551: | ||
2619 | case LCD_WINCTRL1_FRM_16BPPA1555: | ||
2620 | case LCD_WINCTRL1_FRM_16BPPA5551: | ||
2621 | bits = 16; | ||
2622 | break; | ||
2623 | case LCD_WINCTRL1_FRM_24BPP: | ||
2624 | case LCD_WINCTRL1_FRM_32BPP: | ||
2625 | bits = 32; | ||
2626 | break; | ||
2627 | } | ||
2628 | |||
2629 | return bits; | ||
2630 | } | ||
2631 | |||
2632 | static int fbinfo2index (struct fb_info *fb_info) | ||
2633 | { | ||
2634 | int i; | ||
2635 | |||
2636 | for (i = 0; i < CONFIG_FB_AU1200_DEVS; ++i) { | ||
2637 | if (fb_info == (struct fb_info *)(&_au1200fb_devices[i].fb_info)) | ||
2638 | return i; | ||
2639 | } | ||
2640 | printk("au1200fb: ERROR: fbinfo2index failed!\n"); | ||
2641 | return -1; | ||
2642 | } | ||
2643 | |||
2644 | static int au1200_setlocation (struct au1200fb_device *fbdev, int plane, | ||
2645 | int xpos, int ypos) | ||
2646 | { | ||
2647 | uint32 winctrl0, winctrl1, winenable, fb_offset = 0; | ||
2648 | int xsz, ysz; | ||
2649 | |||
2650 | /* FIX!!! NOT CHECKING FOR COMPLETE OFFSCREEN YET */ | ||
2651 | |||
2652 | winctrl0 = lcd->window[plane].winctrl0; | ||
2653 | winctrl1 = lcd->window[plane].winctrl1; | ||
2654 | winctrl0 &= (LCD_WINCTRL0_A | LCD_WINCTRL0_AEN); | ||
2655 | winctrl1 &= ~(LCD_WINCTRL1_SZX | LCD_WINCTRL1_SZY); | ||
2656 | |||
2657 | /* Check for off-screen adjustments */ | ||
2658 | xsz = win->w[plane].xres; | ||
2659 | ysz = win->w[plane].yres; | ||
2660 | if ((xpos + win->w[plane].xres) > panel->Xres) { | ||
2661 | /* Off-screen to the right */ | ||
2662 | xsz = panel->Xres - xpos; /* off by 1 ??? */ | ||
2663 | /*printk("off screen right\n");*/ | ||
2664 | } | ||
2665 | |||
2666 | if ((ypos + win->w[plane].yres) > panel->Yres) { | ||
2667 | /* Off-screen to the bottom */ | ||
2668 | ysz = panel->Yres - ypos; /* off by 1 ??? */ | ||
2669 | /*printk("off screen bottom\n");*/ | ||
2670 | } | ||
2671 | |||
2672 | if (xpos < 0) { | ||
2673 | /* Off-screen to the left */ | ||
2674 | xsz = win->w[plane].xres + xpos; | ||
2675 | fb_offset += (((0 - xpos) * winbpp(lcd->window[plane].winctrl1))/8); | ||
2676 | xpos = 0; | ||
2677 | /*printk("off screen left\n");*/ | ||
2678 | } | ||
2679 | |||
2680 | if (ypos < 0) { | ||
2681 | /* Off-screen to the top */ | ||
2682 | ysz = win->w[plane].yres + ypos; | ||
2683 | /* fixme: fb_offset += ((0-ypos)*fb_pars[plane].line_length); */ | ||
2684 | ypos = 0; | ||
2685 | /*printk("off screen top\n");*/ | ||
2686 | } | ||
2687 | |||
2688 | /* record settings */ | ||
2689 | win->w[plane].xpos = xpos; | ||
2690 | win->w[plane].ypos = ypos; | ||
2691 | |||
2692 | xsz -= 1; | ||
2693 | ysz -= 1; | ||
2694 | winctrl0 |= (xpos << 21); | ||
2695 | winctrl0 |= (ypos << 10); | ||
2696 | winctrl1 |= (xsz << 11); | ||
2697 | winctrl1 |= (ysz << 0); | ||
2698 | |||
2699 | /* Disable the window while making changes, then restore WINEN */ | ||
2700 | winenable = lcd->winenable & (1 << plane); | ||
2701 | au_sync(); | ||
2702 | lcd->winenable &= ~(1 << plane); | ||
2703 | lcd->window[plane].winctrl0 = winctrl0; | ||
2704 | lcd->window[plane].winctrl1 = winctrl1; | ||
2705 | lcd->window[plane].winbuf0 = | ||
2706 | lcd->window[plane].winbuf1 = fbdev->fb_phys; | ||
2707 | lcd->window[plane].winbufctrl = 0; /* select winbuf0 */ | ||
2708 | lcd->winenable |= winenable; | ||
2709 | au_sync(); | ||
2710 | |||
2711 | return 0; | ||
2712 | } | ||
2713 | |||
2714 | static void au1200_setpanel (struct panel_settings *newpanel) | ||
2715 | { | ||
2716 | /* | ||
2717 | * Perform global setup/init of LCD controller | ||
2718 | */ | ||
2719 | uint32 winenable; | ||
2720 | |||
2721 | /* Make sure all windows disabled */ | ||
2722 | winenable = lcd->winenable; | ||
2723 | lcd->winenable = 0; | ||
2724 | au_sync(); | ||
2725 | /* | ||
2726 | * Ensure everything is disabled before reconfiguring | ||
2727 | */ | ||
2728 | if (lcd->screen & LCD_SCREEN_SEN) { | ||
2729 | /* Wait for vertical sync period */ | ||
2730 | lcd->intstatus = LCD_INT_SS; | ||
2731 | while ((lcd->intstatus & LCD_INT_SS) == 0) { | ||
2732 | au_sync(); | ||
2733 | } | ||
2734 | |||
2735 | lcd->screen &= ~LCD_SCREEN_SEN; /*disable the controller*/ | ||
2736 | |||
2737 | do { | ||
2738 | lcd->intstatus = lcd->intstatus; /*clear interrupts*/ | ||
2739 | au_sync(); | ||
2740 | /*wait for controller to shut down*/ | ||
2741 | } while ((lcd->intstatus & LCD_INT_SD) == 0); | ||
2742 | |||
2743 | /* Call shutdown of current panel (if up) */ | ||
2744 | /* this must occur last, because if an external clock is driving | ||
2745 | the controller, the clock cannot be turned off before first | ||
2746 | shutting down the controller. | ||
2747 | */ | ||
2748 | if (panel->device_shutdown != NULL) | ||
2749 | panel->device_shutdown(); | ||
2750 | } | ||
2751 | |||
2752 | /* Newpanel == NULL indicates a shutdown operation only */ | ||
2753 | if (newpanel == NULL) | ||
2754 | return; | ||
2755 | |||
2756 | panel = newpanel; | ||
2757 | |||
2758 | printk("Panel(%s), %dx%d\n", panel->name, panel->Xres, panel->Yres); | ||
2759 | |||
2760 | /* | ||
2761 | * Setup clocking if internal LCD clock source (assumes sys_auxpll valid) | ||
2762 | */ | ||
2763 | if (!(panel->mode_clkcontrol & LCD_CLKCONTROL_EXT)) | ||
2764 | { | ||
2765 | uint32 sys_clksrc; | ||
2766 | au_writel(panel->mode_auxpll, SYS_AUXPLL); | ||
2767 | sys_clksrc = au_readl(SYS_CLKSRC) & ~0x0000001f; | ||
2768 | sys_clksrc |= panel->mode_toyclksrc; | ||
2769 | au_writel(sys_clksrc, SYS_CLKSRC); | ||
2770 | } | ||
2771 | |||
2772 | /* | ||
2773 | * Configure panel timings | ||
2774 | */ | ||
2775 | lcd->screen = panel->mode_screen; | ||
2776 | lcd->horztiming = panel->mode_horztiming; | ||
2777 | lcd->verttiming = panel->mode_verttiming; | ||
2778 | lcd->clkcontrol = panel->mode_clkcontrol; | ||
2779 | lcd->pwmdiv = panel->mode_pwmdiv; | ||
2780 | lcd->pwmhi = panel->mode_pwmhi; | ||
2781 | lcd->outmask = panel->mode_outmask; | ||
2782 | lcd->fifoctrl = panel->mode_fifoctrl; | ||
2783 | au_sync(); | ||
2784 | |||
2785 | /* fixme: Check window settings to make sure still valid | ||
2786 | * for new geometry */ | ||
2787 | #if 0 | ||
2788 | au1200_setlocation(fbdev, 0, win->w[0].xpos, win->w[0].ypos); | ||
2789 | au1200_setlocation(fbdev, 1, win->w[1].xpos, win->w[1].ypos); | ||
2790 | au1200_setlocation(fbdev, 2, win->w[2].xpos, win->w[2].ypos); | ||
2791 | au1200_setlocation(fbdev, 3, win->w[3].xpos, win->w[3].ypos); | ||
2792 | #endif | ||
2793 | lcd->winenable = winenable; | ||
2794 | |||
2795 | /* | ||
2796 | * Re-enable screen now that it is configured | ||
2797 | */ | ||
2798 | lcd->screen |= LCD_SCREEN_SEN; | ||
2799 | au_sync(); | ||
2800 | |||
2801 | /* Call init of panel */ | ||
2802 | if (panel->device_init != NULL) panel->device_init(); | ||
2803 | |||
2804 | /* FIX!!!! not appropriate on panel change!!! Global setup/init */ | ||
2805 | lcd->intenable = 0; | ||
2806 | lcd->intstatus = ~0; | ||
2807 | lcd->backcolor = win->mode_backcolor; | ||
2808 | |||
2809 | /* Setup Color Key - FIX!!! */ | ||
2810 | lcd->colorkey = win->mode_colorkey; | ||
2811 | lcd->colorkeymsk = win->mode_colorkeymsk; | ||
2812 | |||
2813 | /* Setup HWCursor - FIX!!! Need to support this eventually */ | ||
2814 | lcd->hwc.cursorctrl = 0; | ||
2815 | lcd->hwc.cursorpos = 0; | ||
2816 | lcd->hwc.cursorcolor0 = 0; | ||
2817 | lcd->hwc.cursorcolor1 = 0; | ||
2818 | lcd->hwc.cursorcolor2 = 0; | ||
2819 | lcd->hwc.cursorcolor3 = 0; | ||
2820 | |||
2821 | |||
2822 | #if 0 | ||
2823 | #define D(X) printk("%25s: %08X\n", #X, X) | ||
2824 | D(lcd->screen); | ||
2825 | D(lcd->horztiming); | ||
2826 | D(lcd->verttiming); | ||
2827 | D(lcd->clkcontrol); | ||
2828 | D(lcd->pwmdiv); | ||
2829 | D(lcd->pwmhi); | ||
2830 | D(lcd->outmask); | ||
2831 | D(lcd->fifoctrl); | ||
2832 | D(lcd->window[0].winctrl0); | ||
2833 | D(lcd->window[0].winctrl1); | ||
2834 | D(lcd->window[0].winctrl2); | ||
2835 | D(lcd->window[0].winbuf0); | ||
2836 | D(lcd->window[0].winbuf1); | ||
2837 | D(lcd->window[0].winbufctrl); | ||
2838 | D(lcd->window[1].winctrl0); | ||
2839 | D(lcd->window[1].winctrl1); | ||
2840 | D(lcd->window[1].winctrl2); | ||
2841 | D(lcd->window[1].winbuf0); | ||
2842 | D(lcd->window[1].winbuf1); | ||
2843 | D(lcd->window[1].winbufctrl); | ||
2844 | D(lcd->window[2].winctrl0); | ||
2845 | D(lcd->window[2].winctrl1); | ||
2846 | D(lcd->window[2].winctrl2); | ||
2847 | D(lcd->window[2].winbuf0); | ||
2848 | D(lcd->window[2].winbuf1); | ||
2849 | D(lcd->window[2].winbufctrl); | ||
2850 | D(lcd->window[3].winctrl0); | ||
2851 | D(lcd->window[3].winctrl1); | ||
2852 | D(lcd->window[3].winctrl2); | ||
2853 | D(lcd->window[3].winbuf0); | ||
2854 | D(lcd->window[3].winbuf1); | ||
2855 | D(lcd->window[3].winbufctrl); | ||
2856 | D(lcd->winenable); | ||
2857 | D(lcd->intenable); | ||
2858 | D(lcd->intstatus); | ||
2859 | D(lcd->backcolor); | ||
2860 | D(lcd->winenable); | ||
2861 | D(lcd->colorkey); | ||
2862 | D(lcd->colorkeymsk); | ||
2863 | D(lcd->hwc.cursorctrl); | ||
2864 | D(lcd->hwc.cursorpos); | ||
2865 | D(lcd->hwc.cursorcolor0); | ||
2866 | D(lcd->hwc.cursorcolor1); | ||
2867 | D(lcd->hwc.cursorcolor2); | ||
2868 | D(lcd->hwc.cursorcolor3); | ||
2869 | #endif | ||
2870 | } | ||
2871 | |||
2872 | static void au1200_setmode(struct au1200fb_device *fbdev) | ||
2873 | { | ||
2874 | int plane = fbdev->plane; | ||
2875 | /* Window/plane setup */ | ||
2876 | lcd->window[plane].winctrl1 = ( 0 | ||
2877 | | LCD_WINCTRL1_PRI_N(plane) | ||
2878 | | win->w[plane].mode_winctrl1 /* FRM,CCO,PO,PIPE */ | ||
2879 | ) ; | ||
2880 | |||
2881 | au1200_setlocation(fbdev, plane, win->w[plane].xpos, win->w[plane].ypos); | ||
2882 | |||
2883 | lcd->window[plane].winctrl2 = ( 0 | ||
2884 | | LCD_WINCTRL2_CKMODE_00 | ||
2885 | | LCD_WINCTRL2_DBM | ||
2886 | | LCD_WINCTRL2_BX_N( fbdev->fb_info.fix.line_length) | ||
2887 | | LCD_WINCTRL2_SCX_1 | ||
2888 | | LCD_WINCTRL2_SCY_1 | ||
2889 | ) ; | ||
2890 | lcd->winenable |= win->w[plane].mode_winenable; | ||
2891 | au_sync(); | ||
2892 | } | ||
2893 | |||
2894 | |||
2895 | /* Inline helpers */ | ||
2896 | |||
2897 | /*#define panel_is_dual(panel) ((panel->mode_screen & LCD_SCREEN_PT) == LCD_SCREEN_PT_010)*/ | ||
2898 | /*#define panel_is_active(panel)((panel->mode_screen & LCD_SCREEN_PT) == LCD_SCREEN_PT_010)*/ | ||
2899 | |||
2900 | #define panel_is_color(panel) ((panel->mode_screen & LCD_SCREEN_PT) <= LCD_SCREEN_PT_CDSTN) | ||
2901 | |||
2902 | /* Bitfields format supported by the controller. */ | ||
2903 | static struct fb_bitfield rgb_bitfields[][4] = { | ||
2904 | /* Red, Green, Blue, Transp */ | ||
2905 | [LCD_WINCTRL1_FRM_16BPP655 >> 25] = | ||
2906 | { { 10, 6, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, | ||
2907 | |||
2908 | [LCD_WINCTRL1_FRM_16BPP565 >> 25] = | ||
2909 | { { 11, 5, 0 }, { 5, 6, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, | ||
2910 | |||
2911 | [LCD_WINCTRL1_FRM_16BPP556 >> 25] = | ||
2912 | { { 11, 5, 0 }, { 6, 5, 0 }, { 0, 6, 0 }, { 0, 0, 0 } }, | ||
2913 | |||
2914 | [LCD_WINCTRL1_FRM_16BPPI1555 >> 25] = | ||
2915 | { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 0, 0, 0 } }, | ||
2916 | |||
2917 | [LCD_WINCTRL1_FRM_16BPPI5551 >> 25] = | ||
2918 | { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 0, 0 } }, | ||
2919 | |||
2920 | [LCD_WINCTRL1_FRM_16BPPA1555 >> 25] = | ||
2921 | { { 10, 5, 0 }, { 5, 5, 0 }, { 0, 5, 0 }, { 15, 1, 0 } }, | ||
2922 | |||
2923 | [LCD_WINCTRL1_FRM_16BPPA5551 >> 25] = | ||
2924 | { { 11, 5, 0 }, { 6, 5, 0 }, { 1, 5, 0 }, { 0, 1, 0 } }, | ||
2925 | |||
2926 | [LCD_WINCTRL1_FRM_24BPP >> 25] = | ||
2927 | { { 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 0, 0, 0 } }, | ||
2928 | |||
2929 | [LCD_WINCTRL1_FRM_32BPP >> 25] = | ||
2930 | { { 16, 8, 0 }, { 8, 8, 0 }, { 0, 8, 0 }, { 24, 0, 0 } }, | ||
2931 | }; | ||
2932 | |||
2933 | /*-------------------------------------------------------------------------*/ | ||
2934 | |||
2935 | /* Helpers */ | ||
2936 | |||
2937 | static void au1200fb_update_fbinfo(struct fb_info *fbi) | ||
2938 | { | ||
2939 | /* FIX!!!! This also needs to take the window pixel format into account!!! */ | ||
2940 | |||
2941 | /* Update var-dependent FB info */ | ||
2942 | if (panel_is_color(panel)) { | ||
2943 | if (fbi->var.bits_per_pixel <= 8) { | ||
2944 | /* palettized */ | ||
2945 | fbi->fix.visual = FB_VISUAL_PSEUDOCOLOR; | ||
2946 | fbi->fix.line_length = fbi->var.xres_virtual / | ||
2947 | (8/fbi->var.bits_per_pixel); | ||
2948 | } else { | ||
2949 | /* non-palettized */ | ||
2950 | fbi->fix.visual = FB_VISUAL_TRUECOLOR; | ||
2951 | fbi->fix.line_length = fbi->var.xres_virtual * (fbi->var.bits_per_pixel / 8); | ||
2952 | } | ||
2953 | } else { | ||
2954 | /* mono FIX!!! mono 8 and 4 bits */ | ||
2955 | fbi->fix.visual = FB_VISUAL_MONO10; | ||
2956 | fbi->fix.line_length = fbi->var.xres_virtual / 8; | ||
2957 | } | ||
2958 | |||
2959 | fbi->screen_size = fbi->fix.line_length * fbi->var.yres_virtual; | ||
2960 | print_dbg("line length: %d\n", fbi->fix.line_length); | ||
2961 | print_dbg("bits_per_pixel: %d\n", fbi->var.bits_per_pixel); | ||
2962 | } | ||
2963 | |||
2964 | /*-------------------------------------------------------------------------*/ | ||
2965 | |||
2966 | /* AU1200 framebuffer driver */ | ||
2967 | |||
2968 | /* fb_check_var | ||
2969 | * Validate var settings with hardware restrictions and modify it if necessary | ||
2970 | */ | ||
2971 | static int au1200fb_fb_check_var(struct fb_var_screeninfo *var, | ||
2972 | struct fb_info *fbi) | ||
2973 | { | ||
2974 | struct au1200fb_device *fbdev = (struct au1200fb_device *)fbi; | ||
2975 | u32 pixclock; | ||
2976 | int screen_size, plane; | ||
2977 | |||
2978 | plane = fbdev->plane; | ||
2979 | |||
2980 | /* Make sure that the mode respect all LCD controller and | ||
2981 | * panel restrictions. */ | ||
2982 | var->xres = win->w[plane].xres; | ||
2983 | var->yres = win->w[plane].yres; | ||
2984 | |||
2985 | /* No need for virtual resolution support */ | ||
2986 | var->xres_virtual = var->xres; | ||
2987 | var->yres_virtual = var->yres; | ||
2988 | |||
2989 | var->bits_per_pixel = winbpp(win->w[plane].mode_winctrl1); | ||
2990 | |||
2991 | screen_size = var->xres_virtual * var->yres_virtual; | ||
2992 | if (var->bits_per_pixel > 8) screen_size *= (var->bits_per_pixel / 8); | ||
2993 | else screen_size /= (8/var->bits_per_pixel); | ||
2994 | |||
2995 | if (fbdev->fb_len < screen_size) | ||
2996 | return -EINVAL; /* Virtual screen is to big, abort */ | ||
2997 | |||
2998 | /* FIX!!!! what are the implicaitons of ignoring this for windows ??? */ | ||
2999 | /* The max LCD clock is fixed to 48MHz (value of AUX_CLK). The pixel | ||
3000 | * clock can only be obtain by dividing this value by an even integer. | ||
3001 | * Fallback to a slower pixel clock if necessary. */ | ||
3002 | pixclock = max((u32)(PICOS2KHZ(var->pixclock) * 1000), fbi->monspecs.dclkmin); | ||
3003 | pixclock = min(pixclock, min(fbi->monspecs.dclkmax, (u32)AU1200_LCD_MAX_CLK/2)); | ||
3004 | |||
3005 | if (AU1200_LCD_MAX_CLK % pixclock) { | ||
3006 | int diff = AU1200_LCD_MAX_CLK % pixclock; | ||
3007 | pixclock -= diff; | ||
3008 | } | ||
3009 | |||
3010 | var->pixclock = KHZ2PICOS(pixclock/1000); | ||
3011 | #if 0 | ||
3012 | if (!panel_is_active(panel)) { | ||
3013 | int pcd = AU1200_LCD_MAX_CLK / (pixclock * 2) - 1; | ||
3014 | |||
3015 | if (!panel_is_color(panel) | ||
3016 | && (panel->control_base & LCD_CONTROL_MPI) && (pcd < 3)) { | ||
3017 | /* STN 8bit mono panel support is up to 6MHz pixclock */ | ||
3018 | var->pixclock = KHZ2PICOS(6000); | ||
3019 | } else if (!pcd) { | ||
3020 | /* Other STN panel support is up to 12MHz */ | ||
3021 | var->pixclock = KHZ2PICOS(12000); | ||
3022 | } | ||
3023 | } | ||
3024 | #endif | ||
3025 | /* Set bitfield accordingly */ | ||
3026 | switch (var->bits_per_pixel) { | ||
3027 | case 16: | ||
3028 | { | ||
3029 | /* 16bpp True color. | ||
3030 | * These must be set to MATCH WINCTRL[FORM] */ | ||
3031 | int idx; | ||
3032 | idx = (win->w[0].mode_winctrl1 & LCD_WINCTRL1_FRM) >> 25; | ||
3033 | var->red = rgb_bitfields[idx][0]; | ||
3034 | var->green = rgb_bitfields[idx][1]; | ||
3035 | var->blue = rgb_bitfields[idx][2]; | ||
3036 | var->transp = rgb_bitfields[idx][3]; | ||
3037 | break; | ||
3038 | } | ||
3039 | |||
3040 | case 32: | ||
3041 | { | ||
3042 | /* 32bpp True color. | ||
3043 | * These must be set to MATCH WINCTRL[FORM] */ | ||
3044 | int idx; | ||
3045 | idx = (win->w[0].mode_winctrl1 & LCD_WINCTRL1_FRM) >> 25; | ||
3046 | var->red = rgb_bitfields[idx][0]; | ||
3047 | var->green = rgb_bitfields[idx][1]; | ||
3048 | var->blue = rgb_bitfields[idx][2]; | ||
3049 | var->transp = rgb_bitfields[idx][3]; | ||
3050 | break; | ||
3051 | } | ||
3052 | default: | ||
3053 | print_dbg("Unsupported depth %dbpp", var->bits_per_pixel); | ||
3054 | return -EINVAL; | ||
3055 | } | ||
3056 | |||
3057 | return 0; | ||
3058 | } | ||
3059 | |||
3060 | /* fb_set_par | ||
3061 | * Set hardware with var settings. This will enable the controller with a | ||
3062 | * specific mode, normally validated with the fb_check_var method | ||
3063 | */ | ||
3064 | static int au1200fb_fb_set_par(struct fb_info *fbi) | ||
3065 | { | ||
3066 | struct au1200fb_device *fbdev = (struct au1200fb_device *)fbi; | ||
3067 | |||
3068 | au1200fb_update_fbinfo(fbi); | ||
3069 | au1200_setmode(fbdev); | ||
3070 | |||
3071 | return 0; | ||
3072 | } | ||
3073 | |||
3074 | /* fb_setcolreg | ||
3075 | * Set color in LCD palette. | ||
3076 | */ | ||
3077 | static int au1200fb_fb_setcolreg(unsigned regno, unsigned red, unsigned green, | ||
3078 | unsigned blue, unsigned transp, struct fb_info *fbi) | ||
3079 | { | ||
3080 | volatile u32 *palette = lcd->palette; | ||
3081 | u32 value; | ||
3082 | |||
3083 | if (regno > (AU1200_LCD_NBR_PALETTE_ENTRIES - 1)) | ||
3084 | return -EINVAL; | ||
3085 | |||
3086 | if (fbi->var.grayscale) { | ||
3087 | /* Convert color to grayscale */ | ||
3088 | red = green = blue = | ||
3089 | (19595 * red + 38470 * green + 7471 * blue) >> 16; | ||
3090 | } | ||
3091 | |||
3092 | if (fbi->fix.visual == FB_VISUAL_TRUECOLOR) { | ||
3093 | /* Place color in the pseudopalette */ | ||
3094 | if (regno > 16) | ||
3095 | return -EINVAL; | ||
3096 | |||
3097 | palette = (u32*) fbi->pseudo_palette; | ||
3098 | |||
3099 | red >>= (16 - fbi->var.red.length); | ||
3100 | green >>= (16 - fbi->var.green.length); | ||
3101 | blue >>= (16 - fbi->var.blue.length); | ||
3102 | |||
3103 | value = (red << fbi->var.red.offset) | | ||
3104 | (green << fbi->var.green.offset)| | ||
3105 | (blue << fbi->var.blue.offset); | ||
3106 | value &= 0xFFFF; | ||
3107 | |||
3108 | } else if (1 /*FIX!!! panel_is_active(fbdev->panel)*/) { | ||
3109 | /* COLOR TFT PALLETTIZED (use RGB 565) */ | ||
3110 | value = (red & 0xF800)|((green >> 5) & | ||
3111 | 0x07E0)|((blue >> 11) & 0x001F); | ||
3112 | value &= 0xFFFF; | ||
3113 | |||
3114 | } else if (0 /*panel_is_color(fbdev->panel)*/) { | ||
3115 | /* COLOR STN MODE */ | ||
3116 | value = 0x1234; | ||
3117 | value &= 0xFFF; | ||
3118 | } else { | ||
3119 | /* MONOCHROME MODE */ | ||
3120 | value = (green >> 12) & 0x000F; | ||
3121 | value &= 0xF; | ||
3122 | } | ||
3123 | |||
3124 | palette[regno] = value; | ||
3125 | |||
3126 | return 0; | ||
3127 | } | ||
3128 | |||
3129 | /* fb_blank | ||
3130 | * Blank the screen. Depending on the mode, the screen will be | ||
3131 | * activated with the backlight color, or desactivated | ||
3132 | */ | ||
3133 | static int au1200fb_fb_blank(int blank_mode, struct fb_info *fbi) | ||
3134 | { | ||
3135 | /* Short-circuit screen blanking */ | ||
3136 | if (noblanking) | ||
3137 | return 0; | ||
3138 | |||
3139 | switch (blank_mode) { | ||
3140 | |||
3141 | case FB_BLANK_UNBLANK: | ||
3142 | case FB_BLANK_NORMAL: | ||
3143 | /* printk("turn on panel\n"); */ | ||
3144 | au1200_setpanel(panel); | ||
3145 | break; | ||
3146 | case FB_BLANK_VSYNC_SUSPEND: | ||
3147 | case FB_BLANK_HSYNC_SUSPEND: | ||
3148 | case FB_BLANK_POWERDOWN: | ||
3149 | /* printk("turn off panel\n"); */ | ||
3150 | au1200_setpanel(NULL); | ||
3151 | break; | ||
3152 | default: | ||
3153 | break; | ||
3154 | |||
3155 | } | ||
3156 | |||
3157 | /* FB_BLANK_NORMAL is a soft blank */ | ||
3158 | return (blank_mode == FB_BLANK_NORMAL) ? -EINVAL : 0; | ||
3159 | } | ||
3160 | |||
3161 | /* fb_mmap | ||
3162 | * Map video memory in user space. We don't use the generic fb_mmap | ||
3163 | * method mainly to allow the use of the TLB streaming flag (CCA=6) | ||
3164 | */ | ||
3165 | static int au1200fb_fb_mmap(struct fb_info *info, struct vm_area_struct *vma) | ||
3166 | |||
3167 | { | ||
3168 | unsigned int len; | ||
3169 | unsigned long start=0, off; | ||
3170 | struct au1200fb_device *fbdev = (struct au1200fb_device *) info; | ||
3171 | |||
3172 | #ifdef CONFIG_PM | ||
3173 | au1xxx_pm_access(LCD_pm_dev); | ||
3174 | #endif | ||
3175 | |||
3176 | if (vma->vm_pgoff > (~0UL >> PAGE_SHIFT)) { | ||
3177 | return -EINVAL; | ||
3178 | } | ||
3179 | |||
3180 | start = fbdev->fb_phys & PAGE_MASK; | ||
3181 | len = PAGE_ALIGN((start & ~PAGE_MASK) + fbdev->fb_len); | ||
3182 | |||
3183 | off = vma->vm_pgoff << PAGE_SHIFT; | ||
3184 | |||
3185 | if ((vma->vm_end - vma->vm_start + off) > len) { | ||
3186 | return -EINVAL; | ||
3187 | } | ||
3188 | |||
3189 | off += start; | ||
3190 | vma->vm_pgoff = off >> PAGE_SHIFT; | ||
3191 | |||
3192 | vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); | ||
3193 | pgprot_val(vma->vm_page_prot) |= _CACHE_MASK; /* CCA=7 */ | ||
3194 | |||
3195 | vma->vm_flags |= VM_IO; | ||
3196 | |||
3197 | return io_remap_pfn_range(vma, vma->vm_start, off >> PAGE_SHIFT, | ||
3198 | vma->vm_end - vma->vm_start, | ||
3199 | vma->vm_page_prot); | ||
3200 | |||
3201 | return 0; | ||
3202 | } | ||
3203 | |||
3204 | static void set_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata) | ||
3205 | { | ||
3206 | |||
3207 | unsigned int hi1, divider; | ||
3208 | |||
3209 | /* SCREEN_SIZE: user cannot reset size, must switch panel choice */ | ||
3210 | |||
3211 | if (pdata->flags & SCREEN_BACKCOLOR) | ||
3212 | lcd->backcolor = pdata->backcolor; | ||
3213 | |||
3214 | if (pdata->flags & SCREEN_BRIGHTNESS) { | ||
3215 | |||
3216 | // limit brightness pwm duty to >= 30/1600 | ||
3217 | if (pdata->brightness < 30) { | ||
3218 | pdata->brightness = 30; | ||
3219 | } | ||
3220 | divider = (lcd->pwmdiv & 0x3FFFF) + 1; | ||
3221 | hi1 = (lcd->pwmhi >> 16) + 1; | ||
3222 | hi1 = (((pdata->brightness & 0xFF)+1) * divider >> 8); | ||
3223 | lcd->pwmhi &= 0xFFFF; | ||
3224 | lcd->pwmhi |= (hi1 << 16); | ||
3225 | } | ||
3226 | |||
3227 | if (pdata->flags & SCREEN_COLORKEY) | ||
3228 | lcd->colorkey = pdata->colorkey; | ||
3229 | |||
3230 | if (pdata->flags & SCREEN_MASK) | ||
3231 | lcd->colorkeymsk = pdata->mask; | ||
3232 | au_sync(); | ||
3233 | } | ||
3234 | |||
3235 | static void get_global(u_int cmd, struct au1200_lcd_global_regs_t *pdata) | ||
3236 | { | ||
3237 | unsigned int hi1, divider; | ||
3238 | |||
3239 | pdata->xsize = ((lcd->screen & LCD_SCREEN_SX) >> 19) + 1; | ||
3240 | pdata->ysize = ((lcd->screen & LCD_SCREEN_SY) >> 8) + 1; | ||
3241 | |||
3242 | pdata->backcolor = lcd->backcolor; | ||
3243 | pdata->colorkey = lcd->colorkey; | ||
3244 | pdata->mask = lcd->colorkeymsk; | ||
3245 | |||
3246 | // brightness | ||
3247 | hi1 = (lcd->pwmhi >> 16) + 1; | ||
3248 | divider = (lcd->pwmdiv & 0x3FFFF) + 1; | ||
3249 | pdata->brightness = ((hi1 << 8) / divider) - 1; | ||
3250 | au_sync(); | ||
3251 | } | ||
3252 | |||
3253 | static void set_window(unsigned int plane, | ||
3254 | struct au1200_lcd_window_regs_t *pdata) | ||
3255 | { | ||
3256 | unsigned int val, bpp; | ||
3257 | |||
3258 | /* Window control register 0 */ | ||
3259 | if (pdata->flags & WIN_POSITION) { | ||
3260 | val = lcd->window[plane].winctrl0 & ~(LCD_WINCTRL0_OX | | ||
3261 | LCD_WINCTRL0_OY); | ||
3262 | val |= ((pdata->xpos << 21) & LCD_WINCTRL0_OX); | ||
3263 | val |= ((pdata->ypos << 10) & LCD_WINCTRL0_OY); | ||
3264 | lcd->window[plane].winctrl0 = val; | ||
3265 | } | ||
3266 | if (pdata->flags & WIN_ALPHA_COLOR) { | ||
3267 | val = lcd->window[plane].winctrl0 & ~(LCD_WINCTRL0_A); | ||
3268 | val |= ((pdata->alpha_color << 2) & LCD_WINCTRL0_A); | ||
3269 | lcd->window[plane].winctrl0 = val; | ||
3270 | } | ||
3271 | if (pdata->flags & WIN_ALPHA_MODE) { | ||
3272 | val = lcd->window[plane].winctrl0 & ~(LCD_WINCTRL0_AEN); | ||
3273 | val |= ((pdata->alpha_mode << 1) & LCD_WINCTRL0_AEN); | ||
3274 | lcd->window[plane].winctrl0 = val; | ||
3275 | } | ||
3276 | |||
3277 | /* Window control register 1 */ | ||
3278 | if (pdata->flags & WIN_PRIORITY) { | ||
3279 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_PRI); | ||
3280 | val |= ((pdata->priority << 30) & LCD_WINCTRL1_PRI); | ||
3281 | lcd->window[plane].winctrl1 = val; | ||
3282 | } | ||
3283 | if (pdata->flags & WIN_CHANNEL) { | ||
3284 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_PIPE); | ||
3285 | val |= ((pdata->channel << 29) & LCD_WINCTRL1_PIPE); | ||
3286 | lcd->window[plane].winctrl1 = val; | ||
3287 | } | ||
3288 | if (pdata->flags & WIN_BUFFER_FORMAT) { | ||
3289 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_FRM); | ||
3290 | val |= ((pdata->buffer_format << 25) & LCD_WINCTRL1_FRM); | ||
3291 | lcd->window[plane].winctrl1 = val; | ||
3292 | } | ||
3293 | if (pdata->flags & WIN_COLOR_ORDER) { | ||
3294 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_CCO); | ||
3295 | val |= ((pdata->color_order << 24) & LCD_WINCTRL1_CCO); | ||
3296 | lcd->window[plane].winctrl1 = val; | ||
3297 | } | ||
3298 | if (pdata->flags & WIN_PIXEL_ORDER) { | ||
3299 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_PO); | ||
3300 | val |= ((pdata->pixel_order << 22) & LCD_WINCTRL1_PO); | ||
3301 | lcd->window[plane].winctrl1 = val; | ||
3302 | } | ||
3303 | if (pdata->flags & WIN_SIZE) { | ||
3304 | val = lcd->window[plane].winctrl1 & ~(LCD_WINCTRL1_SZX | | ||
3305 | LCD_WINCTRL1_SZY); | ||
3306 | val |= (((pdata->xsize << 11) - 1) & LCD_WINCTRL1_SZX); | ||
3307 | val |= (((pdata->ysize) - 1) & LCD_WINCTRL1_SZY); | ||
3308 | lcd->window[plane].winctrl1 = val; | ||
3309 | /* program buffer line width */ | ||
3310 | bpp = winbpp(val) / 8; | ||
3311 | val = lcd->window[plane].winctrl2 & ~(LCD_WINCTRL2_BX); | ||
3312 | val |= (((pdata->xsize * bpp) << 8) & LCD_WINCTRL2_BX); | ||
3313 | lcd->window[plane].winctrl2 = val; | ||
3314 | } | ||
3315 | |||
3316 | /* Window control register 2 */ | ||
3317 | if (pdata->flags & WIN_COLORKEY_MODE) { | ||
3318 | val = lcd->window[plane].winctrl2 & ~(LCD_WINCTRL2_CKMODE); | ||
3319 | val |= ((pdata->colorkey_mode << 24) & LCD_WINCTRL2_CKMODE); | ||
3320 | lcd->window[plane].winctrl2 = val; | ||
3321 | } | ||
3322 | if (pdata->flags & WIN_DOUBLE_BUFFER_MODE) { | ||
3323 | val = lcd->window[plane].winctrl2 & ~(LCD_WINCTRL2_DBM); | ||
3324 | val |= ((pdata->double_buffer_mode << 23) & LCD_WINCTRL2_DBM); | ||
3325 | lcd->window[plane].winctrl2 = val; | ||
3326 | } | ||
3327 | if (pdata->flags & WIN_RAM_ARRAY_MODE) { | ||
3328 | val = lcd->window[plane].winctrl2 & ~(LCD_WINCTRL2_RAM); | ||
3329 | val |= ((pdata->ram_array_mode << 21) & LCD_WINCTRL2_RAM); | ||
3330 | lcd->window[plane].winctrl2 = val; | ||
3331 | } | ||
3332 | |||
3333 | /* Buffer line width programmed with WIN_SIZE */ | ||
3334 | |||
3335 | if (pdata->flags & WIN_BUFFER_SCALE) { | ||
3336 | val = lcd->window[plane].winctrl2 & ~(LCD_WINCTRL2_SCX | | ||
3337 | LCD_WINCTRL2_SCY); | ||
3338 | val |= ((pdata->xsize << 11) & LCD_WINCTRL2_SCX); | ||
3339 | val |= ((pdata->ysize) & LCD_WINCTRL2_SCY); | ||
3340 | lcd->window[plane].winctrl2 = val; | ||
3341 | } | ||
3342 | |||
3343 | if (pdata->flags & WIN_ENABLE) { | ||
3344 | val = lcd->winenable; | ||
3345 | val &= ~(1<<plane); | ||
3346 | val |= (pdata->enable & 1) << plane; | ||
3347 | lcd->winenable = val; | ||
3348 | } | ||
3349 | au_sync(); | ||
3350 | } | ||
3351 | |||
3352 | static void get_window(unsigned int plane, | ||
3353 | struct au1200_lcd_window_regs_t *pdata) | ||
3354 | { | ||
3355 | /* Window control register 0 */ | ||
3356 | pdata->xpos = (lcd->window[plane].winctrl0 & LCD_WINCTRL0_OX) >> 21; | ||
3357 | pdata->ypos = (lcd->window[plane].winctrl0 & LCD_WINCTRL0_OY) >> 10; | ||
3358 | pdata->alpha_color = (lcd->window[plane].winctrl0 & LCD_WINCTRL0_A) >> 2; | ||
3359 | pdata->alpha_mode = (lcd->window[plane].winctrl0 & LCD_WINCTRL0_AEN) >> 1; | ||
3360 | |||
3361 | /* Window control register 1 */ | ||
3362 | pdata->priority = (lcd->window[plane].winctrl1& LCD_WINCTRL1_PRI) >> 30; | ||
3363 | pdata->channel = (lcd->window[plane].winctrl1 & LCD_WINCTRL1_PIPE) >> 29; | ||
3364 | pdata->buffer_format = (lcd->window[plane].winctrl1 & LCD_WINCTRL1_FRM) >> 25; | ||
3365 | pdata->color_order = (lcd->window[plane].winctrl1 & LCD_WINCTRL1_CCO) >> 24; | ||
3366 | pdata->pixel_order = (lcd->window[plane].winctrl1 & LCD_WINCTRL1_PO) >> 22; | ||
3367 | pdata->xsize = ((lcd->window[plane].winctrl1 & LCD_WINCTRL1_SZX) >> 11) + 1; | ||
3368 | pdata->ysize = (lcd->window[plane].winctrl1 & LCD_WINCTRL1_SZY) + 1; | ||
3369 | |||
3370 | /* Window control register 2 */ | ||
3371 | pdata->colorkey_mode = (lcd->window[plane].winctrl2 & LCD_WINCTRL2_CKMODE) >> 24; | ||
3372 | pdata->double_buffer_mode = (lcd->window[plane].winctrl2 & LCD_WINCTRL2_DBM) >> 23; | ||
3373 | pdata->ram_array_mode = (lcd->window[plane].winctrl2 & LCD_WINCTRL2_RAM) >> 21; | ||
3374 | |||
3375 | pdata->enable = (lcd->winenable >> plane) & 1; | ||
3376 | au_sync(); | ||
3377 | } | ||
3378 | |||
3379 | static int au1200fb_ioctl(struct fb_info *info, unsigned int cmd, | ||
3380 | unsigned long arg) | ||
3381 | { | ||
3382 | int plane; | ||
3383 | int val; | ||
3384 | |||
3385 | #ifdef CONFIG_PM | ||
3386 | au1xxx_pm_access(LCD_pm_dev); | ||
3387 | #endif | ||
3388 | |||
3389 | plane = fbinfo2index(info); | ||
3390 | print_dbg("au1200fb: ioctl %d on plane %d\n", cmd, plane); | ||
3391 | |||
3392 | if (cmd == AU1200_LCD_FB_IOCTL) { | ||
3393 | struct au1200_lcd_iodata_t iodata; | ||
3394 | |||
3395 | if (copy_from_user(&iodata, (void __user *) arg, sizeof(iodata))) | ||
3396 | return -EFAULT; | ||
3397 | |||
3398 | print_dbg("FB IOCTL called\n"); | ||
3399 | |||
3400 | switch (iodata.subcmd) { | ||
3401 | case AU1200_LCD_SET_SCREEN: | ||
3402 | print_dbg("AU1200_LCD_SET_SCREEN\n"); | ||
3403 | set_global(cmd, &iodata.global); | ||
3404 | break; | ||
3405 | |||
3406 | case AU1200_LCD_GET_SCREEN: | ||
3407 | print_dbg("AU1200_LCD_GET_SCREEN\n"); | ||
3408 | get_global(cmd, &iodata.global); | ||
3409 | break; | ||
3410 | |||
3411 | case AU1200_LCD_SET_WINDOW: | ||
3412 | print_dbg("AU1200_LCD_SET_WINDOW\n"); | ||
3413 | set_window(plane, &iodata.window); | ||
3414 | break; | ||
3415 | |||
3416 | case AU1200_LCD_GET_WINDOW: | ||
3417 | print_dbg("AU1200_LCD_GET_WINDOW\n"); | ||
3418 | get_window(plane, &iodata.window); | ||
3419 | break; | ||
3420 | |||
3421 | case AU1200_LCD_SET_PANEL: | ||
3422 | print_dbg("AU1200_LCD_SET_PANEL\n"); | ||
3423 | if ((iodata.global.panel_choice >= 0) && | ||
3424 | (iodata.global.panel_choice < | ||
3425 | NUM_PANELS)) | ||
3426 | { | ||
3427 | struct panel_settings *newpanel; | ||
3428 | panel_index = iodata.global.panel_choice; | ||
3429 | newpanel = &known_lcd_panels[panel_index]; | ||
3430 | au1200_setpanel(newpanel); | ||
3431 | } | ||
3432 | break; | ||
3433 | |||
3434 | case AU1200_LCD_GET_PANEL: | ||
3435 | print_dbg("AU1200_LCD_GET_PANEL\n"); | ||
3436 | iodata.global.panel_choice = panel_index; | ||
3437 | break; | ||
3438 | |||
3439 | default: | ||
3440 | return -EINVAL; | ||
3441 | } | ||
3442 | |||
3443 | val = copy_to_user((void __user *) arg, &iodata, sizeof(iodata)); | ||
3444 | if (val) { | ||
3445 | print_dbg("error: could not copy %d bytes\n", val); | ||
3446 | return -EFAULT; | ||
3447 | } | ||
3448 | } | ||
3449 | |||
3450 | return 0; | ||
3451 | } | ||
3452 | |||
3453 | |||
3454 | static struct fb_ops au1200fb_fb_ops = { | ||
3455 | .owner = THIS_MODULE, | ||
3456 | .fb_check_var = au1200fb_fb_check_var, | ||
3457 | .fb_set_par = au1200fb_fb_set_par, | ||
3458 | .fb_setcolreg = au1200fb_fb_setcolreg, | ||
3459 | .fb_blank = au1200fb_fb_blank, | ||
3460 | .fb_fillrect = cfb_fillrect, | ||
3461 | .fb_copyarea = cfb_copyarea, | ||
3462 | .fb_imageblit = cfb_imageblit, | ||
3463 | .fb_sync = NULL, | ||
3464 | .fb_ioctl = au1200fb_ioctl, | ||
3465 | .fb_mmap = au1200fb_fb_mmap, | ||
3466 | }; | ||
3467 | |||
3468 | /*-------------------------------------------------------------------------*/ | ||
3469 | |||
3470 | static irqreturn_t au1200fb_handle_irq(int irq, void* dev_id, struct pt_regs *regs) | ||
3471 | { | ||
3472 | /* Nothing to do for now, just clear any pending interrupt */ | ||
3473 | lcd->intstatus = lcd->intstatus; | ||
3474 | au_sync(); | ||
3475 | |||
3476 | return IRQ_HANDLED; | ||
3477 | } | ||
3478 | |||
3479 | /*-------------------------------------------------------------------------*/ | ||
3480 | |||
3481 | /* AU1200 LCD device probe helpers */ | ||
3482 | |||
3483 | static int au1200fb_init_fbinfo(struct au1200fb_device *fbdev) | ||
3484 | { | ||
3485 | struct fb_info *fbi = &fbdev->fb_info; | ||
3486 | int bpp; | ||
3487 | |||
3488 | memset(fbi, 0, sizeof(struct fb_info)); | ||
3489 | fbi->fbops = &au1200fb_fb_ops; | ||
3490 | |||
3491 | bpp = winbpp(win->w[fbdev->plane].mode_winctrl1); | ||
3492 | |||
3493 | /* Copy monitor specs from panel data */ | ||
3494 | /* fixme: we're setting up LCD controller windows, so these dont give a | ||
3495 | damn as to what the monitor specs are (the panel itself does, but that | ||
3496 | isnt done here...so maybe need a generic catchall monitor setting??? */ | ||
3497 | memcpy(&fbi->monspecs, &panel->monspecs, sizeof(struct fb_monspecs)); | ||
3498 | |||
3499 | /* We first try the user mode passed in argument. If that failed, | ||
3500 | * or if no one has been specified, we default to the first mode of the | ||
3501 | * panel list. Note that after this call, var data will be set */ | ||
3502 | if (!fb_find_mode(&fbi->var, | ||
3503 | fbi, | ||
3504 | NULL, /* drv_info.opt_mode, */ | ||
3505 | fbi->monspecs.modedb, | ||
3506 | fbi->monspecs.modedb_len, | ||
3507 | fbi->monspecs.modedb, | ||
3508 | bpp)) { | ||
3509 | |||
3510 | print_err("Cannot find valid mode for panel %s", panel->name); | ||
3511 | return -EFAULT; | ||
3512 | } | ||
3513 | |||
3514 | fbi->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); | ||
3515 | if (!fbi->pseudo_palette) { | ||
3516 | return -ENOMEM; | ||
3517 | } | ||
3518 | memset(fbi->pseudo_palette, 0, sizeof(u32) * 16); | ||
3519 | |||
3520 | if (fb_alloc_cmap(&fbi->cmap, AU1200_LCD_NBR_PALETTE_ENTRIES, 0) < 0) { | ||
3521 | print_err("Fail to allocate colormap (%d entries)", | ||
3522 | AU1200_LCD_NBR_PALETTE_ENTRIES); | ||
3523 | kfree(fbi->pseudo_palette); | ||
3524 | return -EFAULT; | ||
3525 | } | ||
3526 | |||
3527 | strncpy(fbi->fix.id, "AU1200", sizeof(fbi->fix.id)); | ||
3528 | fbi->fix.smem_start = fbdev->fb_phys; | ||
3529 | fbi->fix.smem_len = fbdev->fb_len; | ||
3530 | fbi->fix.type = FB_TYPE_PACKED_PIXELS; | ||
3531 | fbi->fix.xpanstep = 0; | ||
3532 | fbi->fix.ypanstep = 0; | ||
3533 | fbi->fix.mmio_start = 0; | ||
3534 | fbi->fix.mmio_len = 0; | ||
3535 | fbi->fix.accel = FB_ACCEL_NONE; | ||
3536 | |||
3537 | fbi->screen_base = (char __iomem *) fbdev->fb_mem; | ||
3538 | |||
3539 | au1200fb_update_fbinfo(fbi); | ||
3540 | |||
3541 | return 0; | ||
3542 | } | ||
3543 | |||
3544 | /*-------------------------------------------------------------------------*/ | ||
3545 | |||
3546 | /* AU1200 LCD controller device driver */ | ||
3547 | |||
3548 | static int au1200fb_drv_probe(struct device *dev) | ||
3549 | { | ||
3550 | struct au1200fb_device *fbdev; | ||
3551 | unsigned long page; | ||
3552 | int bpp, plane, ret; | ||
3553 | |||
3554 | if (!dev) | ||
3555 | return -EINVAL; | ||
3556 | |||
3557 | for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) { | ||
3558 | bpp = winbpp(win->w[plane].mode_winctrl1); | ||
3559 | if (win->w[plane].xres == 0) | ||
3560 | win->w[plane].xres = panel->Xres; | ||
3561 | if (win->w[plane].yres == 0) | ||
3562 | win->w[plane].yres = panel->Yres; | ||
3563 | |||
3564 | fbdev = &_au1200fb_devices[plane]; | ||
3565 | memset(fbdev, 0, sizeof(struct au1200fb_device)); | ||
3566 | fbdev->plane = plane; | ||
3567 | |||
3568 | /* Allocate the framebuffer to the maximum screen size */ | ||
3569 | fbdev->fb_len = (win->w[plane].xres * win->w[plane].yres * bpp) / 8; | ||
3570 | |||
3571 | fbdev->fb_mem = dma_alloc_noncoherent(dev, | ||
3572 | PAGE_ALIGN(fbdev->fb_len), | ||
3573 | &fbdev->fb_phys, GFP_KERNEL); | ||
3574 | if (!fbdev->fb_mem) { | ||
3575 | print_err("fail to allocate frambuffer (size: %dK))", | ||
3576 | fbdev->fb_len / 1024); | ||
3577 | return -ENOMEM; | ||
3578 | } | ||
3579 | |||
3580 | /* | ||
3581 | * Set page reserved so that mmap will work. This is necessary | ||
3582 | * since we'll be remapping normal memory. | ||
3583 | */ | ||
3584 | for (page = (unsigned long)fbdev->fb_phys; | ||
3585 | page < PAGE_ALIGN((unsigned long)fbdev->fb_phys + | ||
3586 | fbdev->fb_len); | ||
3587 | page += PAGE_SIZE) { | ||
3588 | SetPageReserved(pfn_to_page(page >> PAGE_SHIFT)); /* LCD DMA is NOT coherent on Au1200 */ | ||
3589 | } | ||
3590 | print_dbg("Framebuffer memory map at %p", fbdev->fb_mem); | ||
3591 | print_dbg("phys=0x%08x, size=%dK", fbdev->fb_phys, fbdev->fb_len / 1024); | ||
3592 | |||
3593 | /* Init FB data */ | ||
3594 | if ((ret = au1200fb_init_fbinfo(fbdev)) < 0) | ||
3595 | goto failed; | ||
3596 | |||
3597 | /* Register new framebuffer */ | ||
3598 | if ((ret = register_framebuffer(&fbdev->fb_info)) < 0) { | ||
3599 | print_err("cannot register new framebuffer"); | ||
3600 | goto failed; | ||
3601 | } | ||
3602 | |||
3603 | au1200fb_fb_set_par(&fbdev->fb_info); | ||
3604 | |||
3605 | #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) | ||
3606 | if (plane == 0) | ||
3607 | if (fb_prepare_logo(&fbdev->fb_info, FB_ROTATE_UR)) { | ||
3608 | /* Start display and show logo on boot */ | ||
3609 | fb_set_cmap(&fbdev->fb_info.cmap, | ||
3610 | &fbdev->fb_info); | ||
3611 | |||
3612 | fb_show_logo(&fbdev->fb_info, FB_ROTATE_UR); | ||
3613 | } | ||
3614 | #endif | ||
3615 | } | ||
3616 | |||
3617 | /* Now hook interrupt too */ | ||
3618 | if ((ret = request_irq(AU1200_LCD_INT, au1200fb_handle_irq, | ||
3619 | SA_INTERRUPT | SA_SHIRQ, "lcd", (void *)dev)) < 0) { | ||
3620 | print_err("fail to request interrupt line %d (err: %d)", | ||
3621 | AU1200_LCD_INT, ret); | ||
3622 | goto failed; | ||
3623 | } | ||
3624 | |||
3625 | return 0; | ||
3626 | |||
3627 | failed: | ||
3628 | /* NOTE: This only does the current plane/window that failed; others are still active */ | ||
3629 | if (fbdev->fb_mem) | ||
3630 | dma_free_noncoherent(dev, PAGE_ALIGN(fbdev->fb_len), | ||
3631 | fbdev->fb_mem, fbdev->fb_phys); | ||
3632 | if (fbdev->fb_info.cmap.len != 0) | ||
3633 | fb_dealloc_cmap(&fbdev->fb_info.cmap); | ||
3634 | if (fbdev->fb_info.pseudo_palette) | ||
3635 | kfree(fbdev->fb_info.pseudo_palette); | ||
3636 | if (plane == 0) | ||
3637 | free_irq(AU1200_LCD_INT, (void*)dev); | ||
3638 | return ret; | ||
3639 | } | ||
3640 | |||
3641 | static int au1200fb_drv_remove(struct device *dev) | ||
3642 | { | ||
3643 | struct au1200fb_device *fbdev; | ||
3644 | int plane; | ||
3645 | |||
3646 | if (!dev) | ||
3647 | return -ENODEV; | ||
3648 | |||
3649 | /* Turn off the panel */ | ||
3650 | au1200_setpanel(NULL); | ||
3651 | |||
3652 | for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) | ||
3653 | { | ||
3654 | fbdev = &_au1200fb_devices[plane]; | ||
3655 | |||
3656 | /* Clean up all probe data */ | ||
3657 | unregister_framebuffer(&fbdev->fb_info); | ||
3658 | if (fbdev->fb_mem) | ||
3659 | dma_free_noncoherent(dev, PAGE_ALIGN(fbdev->fb_len), | ||
3660 | fbdev->fb_mem, fbdev->fb_phys); | ||
3661 | if (fbdev->fb_info.cmap.len != 0) | ||
3662 | fb_dealloc_cmap(&fbdev->fb_info.cmap); | ||
3663 | if (fbdev->fb_info.pseudo_palette) | ||
3664 | kfree(fbdev->fb_info.pseudo_palette); | ||
3665 | } | ||
3666 | |||
3667 | free_irq(AU1200_LCD_INT, (void *)dev); | ||
3668 | |||
3669 | return 0; | ||
3670 | } | ||
3671 | |||
3672 | #ifdef CONFIG_PM | ||
3673 | static int au1200fb_drv_suspend(struct device *dev, u32 state, u32 level) | ||
3674 | { | ||
3675 | /* TODO */ | ||
3676 | return 0; | ||
3677 | } | ||
3678 | |||
3679 | static int au1200fb_drv_resume(struct device *dev, u32 level) | ||
3680 | { | ||
3681 | /* TODO */ | ||
3682 | return 0; | ||
3683 | } | ||
3684 | #endif /* CONFIG_PM */ | ||
3685 | |||
3686 | static struct device_driver au1200fb_driver = { | ||
3687 | .name = "au1200-lcd", | ||
3688 | .bus = &platform_bus_type, | ||
3689 | .probe = au1200fb_drv_probe, | ||
3690 | .remove = au1200fb_drv_remove, | ||
3691 | #ifdef CONFIG_PM | ||
3692 | .suspend = au1200fb_drv_suspend, | ||
3693 | .resume = au1200fb_drv_resume, | ||
3694 | #endif | ||
3695 | }; | ||
3696 | |||
3697 | /*-------------------------------------------------------------------------*/ | ||
3698 | |||
3699 | /* Kernel driver */ | ||
3700 | |||
3701 | static void au1200fb_setup(void) | ||
3702 | { | ||
3703 | char* options = NULL; | ||
3704 | char* this_opt; | ||
3705 | int num_panels = ARRAY_SIZE(known_lcd_panels); | ||
3706 | int panel_idx = -1; | ||
3707 | |||
3708 | fb_get_options(DRIVER_NAME, &options); | ||
3709 | |||
3710 | if (options) { | ||
3711 | while ((this_opt = strsep(&options,",")) != NULL) { | ||
3712 | /* Panel option - can be panel name, | ||
3713 | * "bs" for board-switch, or number/index */ | ||
3714 | if (!strncmp(this_opt, "panel:", 6)) { | ||
3715 | int i; | ||
3716 | long int li; | ||
3717 | char *endptr; | ||
3718 | this_opt += 6; | ||
3719 | /* First check for index, which allows | ||
3720 | * to short circuit this mess */ | ||
3721 | li = simple_strtol(this_opt, &endptr, 0); | ||
3722 | if (*endptr == '\0') { | ||
3723 | panel_idx = (int)li; | ||
3724 | } | ||
3725 | else if (strcmp(this_opt, "bs") == 0) { | ||
3726 | extern int board_au1200fb_panel(void); | ||
3727 | panel_idx = board_au1200fb_panel(); | ||
3728 | } | ||
3729 | |||
3730 | else | ||
3731 | for (i = 0; i < num_panels; i++) { | ||
3732 | if (!strcmp(this_opt, known_lcd_panels[i].name)) { | ||
3733 | panel_idx = i; | ||
3734 | break; | ||
3735 | } | ||
3736 | } | ||
3737 | |||
3738 | if ((panel_idx < 0) || (panel_idx >= num_panels)) { | ||
3739 | print_warn("Panel %s not supported!", this_opt); | ||
3740 | } | ||
3741 | else | ||
3742 | panel_index = panel_idx; | ||
3743 | } | ||
3744 | |||
3745 | else if (strncmp(this_opt, "nohwcursor", 10) == 0) { | ||
3746 | nohwcursor = 1; | ||
3747 | } | ||
3748 | |||
3749 | /* Unsupported option */ | ||
3750 | else { | ||
3751 | print_warn("Unsupported option \"%s\"", this_opt); | ||
3752 | } | ||
3753 | } | ||
3754 | } | ||
3755 | } | ||
3756 | |||
3757 | #ifdef CONFIG_PM | ||
3758 | static int au1200fb_pm_callback(au1xxx_power_dev_t *dev, | ||
3759 | au1xxx_request_t request, void *data) { | ||
3760 | int retval = -1; | ||
3761 | unsigned int d = 0; | ||
3762 | unsigned int brightness = 0; | ||
3763 | |||
3764 | if (request == AU1XXX_PM_SLEEP) { | ||
3765 | board_au1200fb_panel_shutdown(); | ||
3766 | } | ||
3767 | else if (request == AU1XXX_PM_WAKEUP) { | ||
3768 | if(dev->prev_state == SLEEP_STATE) | ||
3769 | { | ||
3770 | int plane; | ||
3771 | au1200_setpanel(panel); | ||
3772 | for (plane = 0; plane < CONFIG_FB_AU1200_DEVS; ++plane) { | ||
3773 | struct au1200fb_device *fbdev; | ||
3774 | fbdev = &_au1200fb_devices[plane]; | ||
3775 | au1200fb_fb_set_par(&fbdev->fb_info); | ||
3776 | } | ||
3777 | } | ||
3778 | |||
3779 | d = *((unsigned int*)data); | ||
3780 | if(d <=10) brightness = 26; | ||
3781 | else if(d<=20) brightness = 51; | ||
3782 | else if(d<=30) brightness = 77; | ||
3783 | else if(d<=40) brightness = 102; | ||
3784 | else if(d<=50) brightness = 128; | ||
3785 | else if(d<=60) brightness = 153; | ||
3786 | else if(d<=70) brightness = 179; | ||
3787 | else if(d<=80) brightness = 204; | ||
3788 | else if(d<=90) brightness = 230; | ||
3789 | else brightness = 255; | ||
3790 | set_brightness(brightness); | ||
3791 | } else if (request == AU1XXX_PM_GETSTATUS) { | ||
3792 | return dev->cur_state; | ||
3793 | } else if (request == AU1XXX_PM_ACCESS) { | ||
3794 | if (dev->cur_state != SLEEP_STATE) | ||
3795 | return retval; | ||
3796 | else { | ||
3797 | au1200_setpanel(panel); | ||
3798 | } | ||
3799 | } else if (request == AU1XXX_PM_IDLE) { | ||
3800 | } else if (request == AU1XXX_PM_CLEANUP) { | ||
3801 | } | ||
3802 | |||
3803 | return retval; | ||
3804 | } | ||
3805 | #endif | ||
3806 | |||
3807 | static int __init au1200fb_init(void) | ||
3808 | { | ||
3809 | print_info("" DRIVER_DESC ""); | ||
3810 | |||
3811 | /* Setup driver with options */ | ||
3812 | au1200fb_setup(); | ||
3813 | |||
3814 | /* Point to the panel selected */ | ||
3815 | panel = &known_lcd_panels[panel_index]; | ||
3816 | win = &windows[window_index]; | ||
3817 | |||
3818 | printk(DRIVER_NAME ": Panel %d %s\n", panel_index, panel->name); | ||
3819 | printk(DRIVER_NAME ": Win %d %s\n", window_index, win->name); | ||
3820 | |||
3821 | /* Kickstart the panel, the framebuffers/windows come soon enough */ | ||
3822 | au1200_setpanel(panel); | ||
3823 | |||
3824 | #ifdef CONFIG_PM | ||
3825 | LCD_pm_dev = new_au1xxx_power_device("LCD", &au1200fb_pm_callback, NULL); | ||
3826 | if ( LCD_pm_dev == NULL) | ||
3827 | printk(KERN_INFO "Unable to create a power management device entry for the au1200fb.\n"); | ||
3828 | else | ||
3829 | printk(KERN_INFO "Power management device entry for the au1200fb loaded.\n"); | ||
3830 | #endif | ||
3831 | |||
3832 | return driver_register(&au1200fb_driver); | ||
3833 | } | ||
3834 | |||
3835 | static void __exit au1200fb_cleanup(void) | ||
3836 | { | ||
3837 | driver_unregister(&au1200fb_driver); | ||
3838 | } | ||
3839 | |||
3840 | module_init(au1200fb_init); | ||
3841 | module_exit(au1200fb_cleanup); | ||
3842 | |||
3843 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
3844 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c index 8d8eadb64853..372aa1776827 100644 --- a/drivers/video/fbmem.c +++ b/drivers/video/fbmem.c | |||
@@ -674,13 +674,19 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
674 | total_size = info->fix.smem_len; | 674 | total_size = info->fix.smem_len; |
675 | 675 | ||
676 | if (p > total_size) | 676 | if (p > total_size) |
677 | return 0; | 677 | return -EFBIG; |
678 | 678 | ||
679 | if (count >= total_size) | 679 | if (count > total_size) { |
680 | err = -EFBIG; | ||
680 | count = total_size; | 681 | count = total_size; |
682 | } | ||
683 | |||
684 | if (count + p > total_size) { | ||
685 | if (!err) | ||
686 | err = -ENOSPC; | ||
681 | 687 | ||
682 | if (count + p > total_size) | ||
683 | count = total_size - p; | 688 | count = total_size - p; |
689 | } | ||
684 | 690 | ||
685 | buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, | 691 | buffer = kmalloc((count > PAGE_SIZE) ? PAGE_SIZE : count, |
686 | GFP_KERNEL); | 692 | GFP_KERNEL); |
@@ -722,7 +728,7 @@ fb_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | |||
722 | 728 | ||
723 | kfree(buffer); | 729 | kfree(buffer); |
724 | 730 | ||
725 | return (err) ? err : cnt; | 731 | return (cnt) ? cnt : err; |
726 | } | 732 | } |
727 | 733 | ||
728 | #ifdef CONFIG_KMOD | 734 | #ifdef CONFIG_KMOD |
diff --git a/drivers/video/fbsysfs.c b/drivers/video/fbsysfs.c index b72b05250a9d..34e07399756b 100644 --- a/drivers/video/fbsysfs.c +++ b/drivers/video/fbsysfs.c | |||
@@ -305,94 +305,6 @@ static ssize_t show_stride(struct class_device *class_device, char *buf) | |||
305 | return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); | 305 | return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->fix.line_length); |
306 | } | 306 | } |
307 | 307 | ||
308 | /* Format for cmap is "%02x%c%4x%4x%4x\n" */ | ||
309 | /* %02x entry %c transp %4x red %4x blue %4x green \n */ | ||
310 | /* 256 rows at 16 chars equals 4096, the normal page size */ | ||
311 | /* the code will automatically adjust for different page sizes */ | ||
312 | static ssize_t store_cmap(struct class_device *class_device, const char *buf, | ||
313 | size_t count) | ||
314 | { | ||
315 | struct fb_info *fb_info = class_get_devdata(class_device); | ||
316 | int rc, i, start, length, transp = 0; | ||
317 | |||
318 | if ((count > PAGE_SIZE) || ((count % 16) != 0)) | ||
319 | return -EINVAL; | ||
320 | |||
321 | if (!fb_info->fbops->fb_setcolreg && !fb_info->fbops->fb_setcmap) | ||
322 | return -EINVAL; | ||
323 | |||
324 | sscanf(buf, "%02x", &start); | ||
325 | length = count / 16; | ||
326 | |||
327 | for (i = 0; i < length; i++) | ||
328 | if (buf[i * 16 + 2] != ' ') | ||
329 | transp = 1; | ||
330 | |||
331 | /* If we can batch, do it */ | ||
332 | if (fb_info->fbops->fb_setcmap && length > 1) { | ||
333 | struct fb_cmap umap; | ||
334 | |||
335 | memset(&umap, 0, sizeof(umap)); | ||
336 | if ((rc = fb_alloc_cmap(&umap, length, transp))) | ||
337 | return rc; | ||
338 | |||
339 | umap.start = start; | ||
340 | for (i = 0; i < length; i++) { | ||
341 | sscanf(&buf[i * 16 + 3], "%4hx", &umap.red[i]); | ||
342 | sscanf(&buf[i * 16 + 7], "%4hx", &umap.blue[i]); | ||
343 | sscanf(&buf[i * 16 + 11], "%4hx", &umap.green[i]); | ||
344 | if (transp) | ||
345 | umap.transp[i] = (buf[i * 16 + 2] != ' '); | ||
346 | } | ||
347 | rc = fb_info->fbops->fb_setcmap(&umap, fb_info); | ||
348 | fb_copy_cmap(&umap, &fb_info->cmap); | ||
349 | fb_dealloc_cmap(&umap); | ||
350 | |||
351 | return rc ?: count; | ||
352 | } | ||
353 | for (i = 0; i < length; i++) { | ||
354 | u16 red, blue, green, tsp; | ||
355 | |||
356 | sscanf(&buf[i * 16 + 3], "%4hx", &red); | ||
357 | sscanf(&buf[i * 16 + 7], "%4hx", &blue); | ||
358 | sscanf(&buf[i * 16 + 11], "%4hx", &green); | ||
359 | tsp = (buf[i * 16 + 2] != ' '); | ||
360 | if ((rc = fb_info->fbops->fb_setcolreg(start++, | ||
361 | red, green, blue, tsp, fb_info))) | ||
362 | return rc; | ||
363 | |||
364 | fb_info->cmap.red[i] = red; | ||
365 | fb_info->cmap.blue[i] = blue; | ||
366 | fb_info->cmap.green[i] = green; | ||
367 | if (transp) | ||
368 | fb_info->cmap.transp[i] = tsp; | ||
369 | } | ||
370 | return count; | ||
371 | } | ||
372 | |||
373 | static ssize_t show_cmap(struct class_device *class_device, char *buf) | ||
374 | { | ||
375 | struct fb_info *fb_info = class_get_devdata(class_device); | ||
376 | unsigned int i; | ||
377 | |||
378 | if (!fb_info->cmap.red || !fb_info->cmap.blue || | ||
379 | !fb_info->cmap.green) | ||
380 | return -EINVAL; | ||
381 | |||
382 | if (fb_info->cmap.len > PAGE_SIZE / 16) | ||
383 | return -EINVAL; | ||
384 | |||
385 | /* don't mess with the format, the buffer is PAGE_SIZE */ | ||
386 | /* 256 entries at 16 chars per line equals 4096 = PAGE_SIZE */ | ||
387 | for (i = 0; i < fb_info->cmap.len; i++) { | ||
388 | snprintf(&buf[ i * 16], PAGE_SIZE - i * 16, "%02x%c%4x%4x%4x\n", i + fb_info->cmap.start, | ||
389 | ((fb_info->cmap.transp && fb_info->cmap.transp[i]) ? '*' : ' '), | ||
390 | fb_info->cmap.red[i], fb_info->cmap.blue[i], | ||
391 | fb_info->cmap.green[i]); | ||
392 | } | ||
393 | return 16 * fb_info->cmap.len; | ||
394 | } | ||
395 | |||
396 | static ssize_t store_blank(struct class_device *class_device, const char * buf, | 308 | static ssize_t store_blank(struct class_device *class_device, const char * buf, |
397 | size_t count) | 309 | size_t count) |
398 | { | 310 | { |
@@ -502,10 +414,12 @@ static ssize_t show_fbstate(struct class_device *class_device, char *buf) | |||
502 | return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); | 414 | return snprintf(buf, PAGE_SIZE, "%d\n", fb_info->state); |
503 | } | 415 | } |
504 | 416 | ||
417 | /* When cmap is added back in it should be a binary attribute | ||
418 | * not a text one. Consideration should also be given to converting | ||
419 | * fbdev to use configfs instead of sysfs */ | ||
505 | static struct class_device_attribute class_device_attrs[] = { | 420 | static struct class_device_attribute class_device_attrs[] = { |
506 | __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), | 421 | __ATTR(bits_per_pixel, S_IRUGO|S_IWUSR, show_bpp, store_bpp), |
507 | __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), | 422 | __ATTR(blank, S_IRUGO|S_IWUSR, show_blank, store_blank), |
508 | __ATTR(color_map, S_IRUGO|S_IWUSR, show_cmap, store_cmap), | ||
509 | __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console), | 423 | __ATTR(console, S_IRUGO|S_IWUSR, show_console, store_console), |
510 | __ATTR(cursor, S_IRUGO|S_IWUSR, show_cursor, store_cursor), | 424 | __ATTR(cursor, S_IRUGO|S_IWUSR, show_cursor, store_cursor), |
511 | __ATTR(mode, S_IRUGO|S_IWUSR, show_mode, store_mode), | 425 | __ATTR(mode, S_IRUGO|S_IWUSR, show_mode, store_mode), |
diff --git a/drivers/video/pm2fb.c b/drivers/video/pm2fb.c index 5fe197943deb..4e963930b50a 100644 --- a/drivers/video/pm2fb.c +++ b/drivers/video/pm2fb.c | |||
@@ -73,8 +73,8 @@ static char *mode __devinitdata = NULL; | |||
73 | * these flags allow the user to specify that requests for +ve sync | 73 | * these flags allow the user to specify that requests for +ve sync |
74 | * should be silently turned in -ve sync. | 74 | * should be silently turned in -ve sync. |
75 | */ | 75 | */ |
76 | static int lowhsync __devinitdata = 0; | 76 | static int lowhsync; |
77 | static int lowvsync __devinitdata = 0; | 77 | static int lowvsync; |
78 | 78 | ||
79 | /* | 79 | /* |
80 | * The hardware state of the graphics card that isn't part of the | 80 | * The hardware state of the graphics card that isn't part of the |
diff --git a/drivers/video/savage/savagefb_driver.c b/drivers/video/savage/savagefb_driver.c index 10e6b3aab9ea..0da624e6524f 100644 --- a/drivers/video/savage/savagefb_driver.c +++ b/drivers/video/savage/savagefb_driver.c | |||
@@ -73,7 +73,7 @@ | |||
73 | /* --------------------------------------------------------------------- */ | 73 | /* --------------------------------------------------------------------- */ |
74 | 74 | ||
75 | 75 | ||
76 | static char *mode_option __initdata = NULL; | 76 | static char *mode_option __devinitdata = NULL; |
77 | 77 | ||
78 | #ifdef MODULE | 78 | #ifdef MODULE |
79 | 79 | ||
@@ -1545,7 +1545,7 @@ static int __devinit savage_map_mmio (struct fb_info *info) | |||
1545 | return 0; | 1545 | return 0; |
1546 | } | 1546 | } |
1547 | 1547 | ||
1548 | static void __devinit savage_unmap_mmio (struct fb_info *info) | 1548 | static void savage_unmap_mmio (struct fb_info *info) |
1549 | { | 1549 | { |
1550 | struct savagefb_par *par = info->par; | 1550 | struct savagefb_par *par = info->par; |
1551 | DBG ("savage_unmap_mmio"); | 1551 | DBG ("savage_unmap_mmio"); |
@@ -1597,7 +1597,7 @@ static int __devinit savage_map_video (struct fb_info *info, | |||
1597 | return 0; | 1597 | return 0; |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | static void __devinit savage_unmap_video (struct fb_info *info) | 1600 | static void savage_unmap_video (struct fb_info *info) |
1601 | { | 1601 | { |
1602 | struct savagefb_par *par = info->par; | 1602 | struct savagefb_par *par = info->par; |
1603 | 1603 | ||
@@ -1614,7 +1614,7 @@ static void __devinit savage_unmap_video (struct fb_info *info) | |||
1614 | } | 1614 | } |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | static int __devinit savage_init_hw (struct savagefb_par *par) | 1617 | static int savage_init_hw (struct savagefb_par *par) |
1618 | { | 1618 | { |
1619 | unsigned char config1, m, n, n1, n2, sr8, cr3f, cr66 = 0, tmp; | 1619 | unsigned char config1, m, n, n1, n2, sr8, cr3f, cr66 = 0, tmp; |
1620 | 1620 | ||