diff options
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/bitops.h | 140 | ||||
-rw-r--r-- | include/linux/ide.h | 109 |
2 files changed, 202 insertions, 47 deletions
diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 40d54731de7e..48bde600a2db 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h | |||
@@ -112,4 +112,144 @@ static inline unsigned fls_long(unsigned long l) | |||
112 | return fls64(l); | 112 | return fls64(l); |
113 | } | 113 | } |
114 | 114 | ||
115 | #ifdef __KERNEL__ | ||
116 | #ifdef CONFIG_GENERIC_FIND_FIRST_BIT | ||
117 | extern unsigned long __find_first_bit(const unsigned long *addr, | ||
118 | unsigned long size); | ||
119 | |||
120 | /** | ||
121 | * find_first_bit - find the first set bit in a memory region | ||
122 | * @addr: The address to start the search at | ||
123 | * @size: The maximum size to search | ||
124 | * | ||
125 | * Returns the bit number of the first set bit. | ||
126 | */ | ||
127 | static __always_inline unsigned long | ||
128 | find_first_bit(const unsigned long *addr, unsigned long size) | ||
129 | { | ||
130 | /* Avoid a function call if the bitmap size is a constant */ | ||
131 | /* and not bigger than BITS_PER_LONG. */ | ||
132 | |||
133 | /* insert a sentinel so that __ffs returns size if there */ | ||
134 | /* are no set bits in the bitmap */ | ||
135 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) | ||
136 | return __ffs((*addr) | (1ul << size)); | ||
137 | |||
138 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
139 | /* handled separately */ | ||
140 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) | ||
141 | return ((*addr) == 0) ? BITS_PER_LONG : __ffs(*addr); | ||
142 | |||
143 | /* size is not constant or too big */ | ||
144 | return __find_first_bit(addr, size); | ||
145 | } | ||
146 | |||
147 | extern unsigned long __find_first_zero_bit(const unsigned long *addr, | ||
148 | unsigned long size); | ||
149 | |||
150 | /** | ||
151 | * find_first_zero_bit - find the first cleared bit in a memory region | ||
152 | * @addr: The address to start the search at | ||
153 | * @size: The maximum size to search | ||
154 | * | ||
155 | * Returns the bit number of the first cleared bit. | ||
156 | */ | ||
157 | static __always_inline unsigned long | ||
158 | find_first_zero_bit(const unsigned long *addr, unsigned long size) | ||
159 | { | ||
160 | /* Avoid a function call if the bitmap size is a constant */ | ||
161 | /* and not bigger than BITS_PER_LONG. */ | ||
162 | |||
163 | /* insert a sentinel so that __ffs returns size if there */ | ||
164 | /* are no set bits in the bitmap */ | ||
165 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
166 | return __ffs(~(*addr) | (1ul << size)); | ||
167 | } | ||
168 | |||
169 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
170 | /* handled separately */ | ||
171 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) | ||
172 | return (~(*addr) == 0) ? BITS_PER_LONG : __ffs(~(*addr)); | ||
173 | |||
174 | /* size is not constant or too big */ | ||
175 | return __find_first_zero_bit(addr, size); | ||
176 | } | ||
177 | #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ | ||
178 | |||
179 | #ifdef CONFIG_GENERIC_FIND_NEXT_BIT | ||
180 | extern unsigned long __find_next_bit(const unsigned long *addr, | ||
181 | unsigned long size, unsigned long offset); | ||
182 | |||
183 | /** | ||
184 | * find_next_bit - find the next set bit in a memory region | ||
185 | * @addr: The address to base the search on | ||
186 | * @offset: The bitnumber to start searching at | ||
187 | * @size: The bitmap size in bits | ||
188 | */ | ||
189 | static __always_inline unsigned long | ||
190 | find_next_bit(const unsigned long *addr, unsigned long size, | ||
191 | unsigned long offset) | ||
192 | { | ||
193 | unsigned long value; | ||
194 | |||
195 | /* Avoid a function call if the bitmap size is a constant */ | ||
196 | /* and not bigger than BITS_PER_LONG. */ | ||
197 | |||
198 | /* insert a sentinel so that __ffs returns size if there */ | ||
199 | /* are no set bits in the bitmap */ | ||
200 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
201 | value = (*addr) & ((~0ul) << offset); | ||
202 | value |= (1ul << size); | ||
203 | return __ffs(value); | ||
204 | } | ||
205 | |||
206 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
207 | /* handled separately */ | ||
208 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { | ||
209 | value = (*addr) & ((~0ul) << offset); | ||
210 | return (value == 0) ? BITS_PER_LONG : __ffs(value); | ||
211 | } | ||
212 | |||
213 | /* size is not constant or too big */ | ||
214 | return __find_next_bit(addr, size, offset); | ||
215 | } | ||
216 | |||
217 | extern unsigned long __find_next_zero_bit(const unsigned long *addr, | ||
218 | unsigned long size, unsigned long offset); | ||
219 | |||
220 | /** | ||
221 | * find_next_zero_bit - find the next cleared bit in a memory region | ||
222 | * @addr: The address to base the search on | ||
223 | * @offset: The bitnumber to start searching at | ||
224 | * @size: The bitmap size in bits | ||
225 | */ | ||
226 | static __always_inline unsigned long | ||
227 | find_next_zero_bit(const unsigned long *addr, unsigned long size, | ||
228 | unsigned long offset) | ||
229 | { | ||
230 | unsigned long value; | ||
231 | |||
232 | /* Avoid a function call if the bitmap size is a constant */ | ||
233 | /* and not bigger than BITS_PER_LONG. */ | ||
234 | |||
235 | /* insert a sentinel so that __ffs returns size if there */ | ||
236 | /* are no set bits in the bitmap */ | ||
237 | if (__builtin_constant_p(size) && (size < BITS_PER_LONG)) { | ||
238 | value = (~(*addr)) & ((~0ul) << offset); | ||
239 | value |= (1ul << size); | ||
240 | return __ffs(value); | ||
241 | } | ||
242 | |||
243 | /* the result of __ffs(0) is undefined, so it needs to be */ | ||
244 | /* handled separately */ | ||
245 | if (__builtin_constant_p(size) && (size == BITS_PER_LONG)) { | ||
246 | value = (~(*addr)) & ((~0ul) << offset); | ||
247 | return (value == 0) ? BITS_PER_LONG : __ffs(value); | ||
248 | } | ||
249 | |||
250 | /* size is not constant or too big */ | ||
251 | return __find_next_zero_bit(addr, size, offset); | ||
252 | } | ||
253 | #endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ | ||
254 | #endif /* __KERNEL__ */ | ||
115 | #endif | 255 | #endif |
diff --git a/include/linux/ide.h b/include/linux/ide.h index f20410dd4482..f0af504dfa42 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h | |||
@@ -387,6 +387,43 @@ typedef struct ide_drive_s { | |||
387 | 387 | ||
388 | struct ide_port_info; | 388 | struct ide_port_info; |
389 | 389 | ||
390 | struct ide_port_ops { | ||
391 | /* host specific initialization of devices on a port */ | ||
392 | void (*port_init_devs)(struct hwif_s *); | ||
393 | /* routine to program host for PIO mode */ | ||
394 | void (*set_pio_mode)(ide_drive_t *, const u8); | ||
395 | /* routine to program host for DMA mode */ | ||
396 | void (*set_dma_mode)(ide_drive_t *, const u8); | ||
397 | /* tweaks hardware to select drive */ | ||
398 | void (*selectproc)(ide_drive_t *); | ||
399 | /* chipset polling based on hba specifics */ | ||
400 | int (*reset_poll)(ide_drive_t *); | ||
401 | /* chipset specific changes to default for device-hba resets */ | ||
402 | void (*pre_reset)(ide_drive_t *); | ||
403 | /* routine to reset controller after a disk reset */ | ||
404 | void (*resetproc)(ide_drive_t *); | ||
405 | /* special host masking for drive selection */ | ||
406 | void (*maskproc)(ide_drive_t *, int); | ||
407 | /* check host's drive quirk list */ | ||
408 | void (*quirkproc)(ide_drive_t *); | ||
409 | |||
410 | u8 (*mdma_filter)(ide_drive_t *); | ||
411 | u8 (*udma_filter)(ide_drive_t *); | ||
412 | |||
413 | u8 (*cable_detect)(struct hwif_s *); | ||
414 | }; | ||
415 | |||
416 | struct ide_dma_ops { | ||
417 | void (*dma_host_set)(struct ide_drive_s *, int); | ||
418 | int (*dma_setup)(struct ide_drive_s *); | ||
419 | void (*dma_exec_cmd)(struct ide_drive_s *, u8); | ||
420 | void (*dma_start)(struct ide_drive_s *); | ||
421 | int (*dma_end)(struct ide_drive_s *); | ||
422 | int (*dma_test_irq)(struct ide_drive_s *); | ||
423 | void (*dma_lost_irq)(struct ide_drive_s *); | ||
424 | void (*dma_timeout)(struct ide_drive_s *); | ||
425 | }; | ||
426 | |||
390 | typedef struct hwif_s { | 427 | typedef struct hwif_s { |
391 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ | 428 | struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ |
392 | struct hwif_s *mate; /* other hwif from same PCI chip */ | 429 | struct hwif_s *mate; /* other hwif from same PCI chip */ |
@@ -420,38 +457,12 @@ typedef struct hwif_s { | |||
420 | 457 | ||
421 | struct device *dev; | 458 | struct device *dev; |
422 | 459 | ||
423 | const struct ide_port_info *cds; /* chipset device struct */ | ||
424 | |||
425 | ide_ack_intr_t *ack_intr; | 460 | ide_ack_intr_t *ack_intr; |
426 | 461 | ||
427 | void (*rw_disk)(ide_drive_t *, struct request *); | 462 | void (*rw_disk)(ide_drive_t *, struct request *); |
428 | 463 | ||
429 | #if 0 | 464 | const struct ide_port_ops *port_ops; |
430 | ide_hwif_ops_t *hwifops; | 465 | const struct ide_dma_ops *dma_ops; |
431 | #else | ||
432 | /* host specific initialization of devices on a port */ | ||
433 | void (*port_init_devs)(struct hwif_s *); | ||
434 | /* routine to program host for PIO mode */ | ||
435 | void (*set_pio_mode)(ide_drive_t *, const u8); | ||
436 | /* routine to program host for DMA mode */ | ||
437 | void (*set_dma_mode)(ide_drive_t *, const u8); | ||
438 | /* tweaks hardware to select drive */ | ||
439 | void (*selectproc)(ide_drive_t *); | ||
440 | /* chipset polling based on hba specifics */ | ||
441 | int (*reset_poll)(ide_drive_t *); | ||
442 | /* chipset specific changes to default for device-hba resets */ | ||
443 | void (*pre_reset)(ide_drive_t *); | ||
444 | /* routine to reset controller after a disk reset */ | ||
445 | void (*resetproc)(ide_drive_t *); | ||
446 | /* special host masking for drive selection */ | ||
447 | void (*maskproc)(ide_drive_t *, int); | ||
448 | /* check host's drive quirk list */ | ||
449 | void (*quirkproc)(ide_drive_t *); | ||
450 | #endif | ||
451 | u8 (*mdma_filter)(ide_drive_t *); | ||
452 | u8 (*udma_filter)(ide_drive_t *); | ||
453 | |||
454 | u8 (*cable_detect)(struct hwif_s *); | ||
455 | 466 | ||
456 | void (*ata_input_data)(ide_drive_t *, void *, u32); | 467 | void (*ata_input_data)(ide_drive_t *, void *, u32); |
457 | void (*ata_output_data)(ide_drive_t *, void *, u32); | 468 | void (*ata_output_data)(ide_drive_t *, void *, u32); |
@@ -459,15 +470,7 @@ typedef struct hwif_s { | |||
459 | void (*atapi_input_bytes)(ide_drive_t *, void *, u32); | 470 | void (*atapi_input_bytes)(ide_drive_t *, void *, u32); |
460 | void (*atapi_output_bytes)(ide_drive_t *, void *, u32); | 471 | void (*atapi_output_bytes)(ide_drive_t *, void *, u32); |
461 | 472 | ||
462 | void (*dma_host_set)(ide_drive_t *, int); | ||
463 | int (*dma_setup)(ide_drive_t *); | ||
464 | void (*dma_exec_cmd)(ide_drive_t *, u8); | ||
465 | void (*dma_start)(ide_drive_t *); | ||
466 | int (*ide_dma_end)(ide_drive_t *drive); | ||
467 | int (*ide_dma_test_irq)(ide_drive_t *drive); | ||
468 | void (*ide_dma_clear_irq)(ide_drive_t *drive); | 473 | void (*ide_dma_clear_irq)(ide_drive_t *drive); |
469 | void (*dma_lost_irq)(ide_drive_t *drive); | ||
470 | void (*dma_timeout)(ide_drive_t *drive); | ||
471 | 474 | ||
472 | void (*OUTB)(u8 addr, unsigned long port); | 475 | void (*OUTB)(u8 addr, unsigned long port); |
473 | void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); | 476 | void (*OUTBSYNC)(ide_drive_t *drive, u8 addr, unsigned long port); |
@@ -514,7 +517,6 @@ typedef struct hwif_s { | |||
514 | unsigned long extra_base; /* extra addr for dma ports */ | 517 | unsigned long extra_base; /* extra addr for dma ports */ |
515 | unsigned extra_ports; /* number of extra dma ports */ | 518 | unsigned extra_ports; /* number of extra dma ports */ |
516 | 519 | ||
517 | unsigned noprobe : 1; /* don't probe for this interface */ | ||
518 | unsigned present : 1; /* this interface exists */ | 520 | unsigned present : 1; /* this interface exists */ |
519 | unsigned serialized : 1; /* serialized all channel operation */ | 521 | unsigned serialized : 1; /* serialized all channel operation */ |
520 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ | 522 | unsigned sharing_irq: 1; /* 1 = sharing irq with another hwif */ |
@@ -1009,10 +1011,15 @@ void ide_pci_setup_ports(struct pci_dev *, const struct ide_port_info *, int, u8 | |||
1009 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); | 1011 | void ide_setup_pci_noise(struct pci_dev *, const struct ide_port_info *); |
1010 | 1012 | ||
1011 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI | 1013 | #ifdef CONFIG_BLK_DEV_IDEDMA_PCI |
1012 | void ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | 1014 | int ide_pci_set_master(struct pci_dev *, const char *); |
1015 | unsigned long ide_pci_dma_base(ide_hwif_t *, const struct ide_port_info *); | ||
1016 | int ide_hwif_setup_dma(ide_hwif_t *, const struct ide_port_info *); | ||
1013 | #else | 1017 | #else |
1014 | static inline void ide_hwif_setup_dma(ide_hwif_t *hwif, | 1018 | static inline int ide_hwif_setup_dma(ide_hwif_t *hwif, |
1015 | const struct ide_port_info *d) { } | 1019 | const struct ide_port_info *d) |
1020 | { | ||
1021 | return -EINVAL; | ||
1022 | } | ||
1016 | #endif | 1023 | #endif |
1017 | 1024 | ||
1018 | extern void default_hwif_iops(ide_hwif_t *); | 1025 | extern void default_hwif_iops(ide_hwif_t *); |
@@ -1084,6 +1091,8 @@ enum { | |||
1084 | /* unmask IRQs */ | 1091 | /* unmask IRQs */ |
1085 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), | 1092 | IDE_HFLAG_UNMASK_IRQS = (1 << 25), |
1086 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), | 1093 | IDE_HFLAG_ABUSE_SET_DMA_MODE = (1 << 26), |
1094 | /* serialize ports if DMA is possible (for sl82c105) */ | ||
1095 | IDE_HFLAG_SERIALIZE_DMA = (1 << 27), | ||
1087 | /* force host out of "simplex" mode */ | 1096 | /* force host out of "simplex" mode */ |
1088 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), | 1097 | IDE_HFLAG_CLEAR_SIMPLEX = (1 << 28), |
1089 | /* DSC overlap is unsupported */ | 1098 | /* DSC overlap is unsupported */ |
@@ -1105,10 +1114,14 @@ struct ide_port_info { | |||
1105 | unsigned int (*init_chipset)(struct pci_dev *, const char *); | 1114 | unsigned int (*init_chipset)(struct pci_dev *, const char *); |
1106 | void (*init_iops)(ide_hwif_t *); | 1115 | void (*init_iops)(ide_hwif_t *); |
1107 | void (*init_hwif)(ide_hwif_t *); | 1116 | void (*init_hwif)(ide_hwif_t *); |
1108 | void (*init_dma)(ide_hwif_t *, unsigned long); | 1117 | int (*init_dma)(ide_hwif_t *, |
1118 | const struct ide_port_info *); | ||
1119 | |||
1120 | const struct ide_port_ops *port_ops; | ||
1121 | const struct ide_dma_ops *dma_ops; | ||
1122 | |||
1109 | ide_pci_enablebit_t enablebits[2]; | 1123 | ide_pci_enablebit_t enablebits[2]; |
1110 | hwif_chipset_t chipset; | 1124 | hwif_chipset_t chipset; |
1111 | u8 extra; | ||
1112 | u32 host_flags; | 1125 | u32 host_flags; |
1113 | u8 pio_mask; | 1126 | u8 pio_mask; |
1114 | u8 swdma_mask; | 1127 | u8 swdma_mask; |
@@ -1155,13 +1168,16 @@ void ide_destroy_dmatable(ide_drive_t *); | |||
1155 | 1168 | ||
1156 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF | 1169 | #ifdef CONFIG_BLK_DEV_IDEDMA_SFF |
1157 | extern int ide_build_dmatable(ide_drive_t *, struct request *); | 1170 | extern int ide_build_dmatable(ide_drive_t *, struct request *); |
1158 | extern int ide_release_dma(ide_hwif_t *); | 1171 | int ide_allocate_dma_engine(ide_hwif_t *); |
1159 | extern void ide_setup_dma(ide_hwif_t *, unsigned long); | 1172 | void ide_release_dma_engine(ide_hwif_t *); |
1173 | void ide_setup_dma(ide_hwif_t *, unsigned long); | ||
1160 | 1174 | ||
1161 | void ide_dma_host_set(ide_drive_t *, int); | 1175 | void ide_dma_host_set(ide_drive_t *, int); |
1162 | extern int ide_dma_setup(ide_drive_t *); | 1176 | extern int ide_dma_setup(ide_drive_t *); |
1177 | void ide_dma_exec_cmd(ide_drive_t *, u8); | ||
1163 | extern void ide_dma_start(ide_drive_t *); | 1178 | extern void ide_dma_start(ide_drive_t *); |
1164 | extern int __ide_dma_end(ide_drive_t *); | 1179 | extern int __ide_dma_end(ide_drive_t *); |
1180 | int ide_dma_test_irq(ide_drive_t *); | ||
1165 | extern void ide_dma_lost_irq(ide_drive_t *); | 1181 | extern void ide_dma_lost_irq(ide_drive_t *); |
1166 | extern void ide_dma_timeout(ide_drive_t *); | 1182 | extern void ide_dma_timeout(ide_drive_t *); |
1167 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ | 1183 | #endif /* CONFIG_BLK_DEV_IDEDMA_SFF */ |
@@ -1179,7 +1195,7 @@ static inline void ide_check_dma_crc(ide_drive_t *drive) { ; } | |||
1179 | #endif /* CONFIG_BLK_DEV_IDEDMA */ | 1195 | #endif /* CONFIG_BLK_DEV_IDEDMA */ |
1180 | 1196 | ||
1181 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF | 1197 | #ifndef CONFIG_BLK_DEV_IDEDMA_SFF |
1182 | static inline void ide_release_dma(ide_hwif_t *drive) {;} | 1198 | static inline void ide_release_dma_engine(ide_hwif_t *hwif) { ; } |
1183 | #endif | 1199 | #endif |
1184 | 1200 | ||
1185 | #ifdef CONFIG_BLK_DEV_IDEACPI | 1201 | #ifdef CONFIG_BLK_DEV_IDEACPI |
@@ -1199,8 +1215,6 @@ static inline void ide_acpi_set_state(ide_hwif_t *hwif, int on) {} | |||
1199 | #endif | 1215 | #endif |
1200 | 1216 | ||
1201 | void ide_remove_port_from_hwgroup(ide_hwif_t *); | 1217 | void ide_remove_port_from_hwgroup(ide_hwif_t *); |
1202 | extern int ide_hwif_request_regions(ide_hwif_t *hwif); | ||
1203 | extern void ide_hwif_release_regions(ide_hwif_t* hwif); | ||
1204 | void ide_unregister(unsigned int); | 1218 | void ide_unregister(unsigned int); |
1205 | 1219 | ||
1206 | void ide_register_region(struct gendisk *); | 1220 | void ide_register_region(struct gendisk *); |
@@ -1210,6 +1224,7 @@ void ide_undecoded_slave(ide_drive_t *); | |||
1210 | 1224 | ||
1211 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); | 1225 | int ide_device_add_all(u8 *idx, const struct ide_port_info *); |
1212 | int ide_device_add(u8 idx[4], const struct ide_port_info *); | 1226 | int ide_device_add(u8 idx[4], const struct ide_port_info *); |
1227 | int ide_legacy_device_add(const struct ide_port_info *, unsigned long); | ||
1213 | void ide_port_unregister_devices(ide_hwif_t *); | 1228 | void ide_port_unregister_devices(ide_hwif_t *); |
1214 | void ide_port_scan(ide_hwif_t *); | 1229 | void ide_port_scan(ide_hwif_t *); |
1215 | 1230 | ||