Unified · Split
| @@ -44,8 +44,8 @@ extern void oss_nubus_init(void); · 43 unmodified lines | ||
| 44 | 44 | |
| 45 | 45 | /* Globals */ |
| 46 | 46 | |
| 47 | −struct nubus_dev* nubus_devices; | |
| 48 | −struct nubus_board* nubus_boards; | |
| 47 | +struct nubus_dev *nubus_devices; | |
| 48 | +struct nubus_board *nubus_boards; | |
| 49 | 49 | |
| 50 | 50 | /* Meaning of "bytelanes": |
| 51 | 51 | |
| @@ -69,26 +69,26 @@ struct nubus_board* nubus_boards; · 17 unmodified lines | ||
| 69 | 69 | |
| 70 | 70 | Etcetera, etcetera. Hopefully this clears up some confusion over |
| 71 | 71 | what the following code actually does. */ |
| 72 | − | |
| 72 | + | |
| 73 | 73 | static inline int not_useful(void *p, int map) |
| 74 | 74 | { |
| 75 | − unsigned long pv=(unsigned long)p; | |
| 75 | + unsigned long pv = (unsigned long)p; | |
| 76 | + | |
| 76 | 77 | pv &= 3; |
| 77 | − if(map & (1<<pv)) | |
| 78 | + if (map & (1 << pv)) | |
| 78 | 79 | return 0; |
| 79 | 80 | return 1; |
| 80 | 81 | } |
| 81 | − | |
| 82 | + | |
| 82 | 83 | static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map) |
| 83 | 84 | { |
| 84 | 85 | /* This will hold the result */ |
| 85 | 86 | unsigned long v = 0; |
| 86 | 87 | unsigned char *p = *ptr; |
| 87 | 88 | |
| 88 | − while(len) | |
| 89 | − { | |
| 89 | + while (len) { | |
| 90 | 90 | v <<= 8; |
| 91 | − while(not_useful(p,map)) | |
| 91 | + while (not_useful(p, map)) | |
| 92 | 92 | p++; |
| 93 | 93 | v |= *p++; |
| 94 | 94 | len--; |
| @@ -99,31 +99,28 @@ static unsigned long nubus_get_rom(unsigned char **ptr, int len, int map) · 4 unmodified lines | ||
| 99 | 99 | |
| 100 | 100 | static void nubus_rewind(unsigned char **ptr, int len, int map) |
| 101 | 101 | { |
| 102 | − unsigned char *p=*ptr; | |
| 102 | + unsigned char *p = *ptr; | |
| 103 | 103 | |
| 104 | 104 | /* Sanity check */ |
| 105 | − if(len > 65536) | |
| 105 | + if (len > 65536) | |
| 106 | 106 | pr_err("rewind of 0x%08x!\n", len); |
| 107 | − while(len) | |
| 108 | − { | |
| 109 | − do | |
| 110 | − { | |
| 107 | + while (len) { | |
| 108 | + do { | |
| 111 | 109 | p--; |
| 112 | − } | |
| 113 | − while(not_useful(p, map)); | |
| 110 | + } while (not_useful(p, map)); | |
| 114 | 111 | len--; |
| 115 | 112 | } |
| 116 | − *ptr=p; | |
| 113 | + *ptr = p; | |
| 117 | 114 | } |
| 118 | 115 | |
| 119 | 116 | static void nubus_advance(unsigned char **ptr, int len, int map) |
| 120 | 117 | { |
| 121 | 118 | unsigned char *p = *ptr; |
| 122 | − if(len>65536) | |
| 119 | + | |
| 120 | + if (len > 65536) | |
| 123 | 121 | pr_err("advance of 0x%08x!\n", len); |
| 124 | − while(len) | |
| 125 | − { | |
| 126 | − while(not_useful(p,map)) | |
| 122 | + while (len) { | |
| 123 | + while (not_useful(p, map)) | |
| 127 | 124 | p++; |
| 128 | 125 | p++; |
| 129 | 126 | len--; |
| @@ -133,9 +130,9 @@ static void nubus_advance(unsigned char **ptr, int len, int map) · 3 unmodified lines | ||
| 133 | 130 | |
| 134 | 131 | static void nubus_move(unsigned char **ptr, int len, int map) |
| 135 | 132 | { |
| 136 | − if(len > 0) | |
| 133 | + if (len > 0) | |
| 137 | 134 | nubus_advance(ptr, len, map); |
| 138 | − else if(len < 0) | |
| 135 | + else if (len < 0) | |
| 139 | 136 | nubus_rewind(ptr, -len, map); |
| 140 | 137 | } |
| 141 | 138 | |
| @@ -148,23 +145,24 @@ static void nubus_move(unsigned char **ptr, int len, int map) · 6 unmodified lines | ||
| 148 | 145 | |
| 149 | 146 | static inline long nubus_expand32(long foo) |
| 150 | 147 | { |
| 151 | − if(foo & 0x00800000) /* 24bit negative */ | |
| 148 | + if (foo & 0x00800000) /* 24bit negative */ | |
| 152 | 149 | foo |= 0xFF000000; |
| 153 | 150 | return foo; |
| 154 | 151 | } |
| 155 | 152 | |
| 156 | 153 | static inline void *nubus_rom_addr(int slot) |
| 157 | −{ | |
| 154 | +{ | |
| 158 | 155 | /* |
| 159 | 156 | * Returns the first byte after the card. We then walk |
| 160 | 157 | * backwards to get the lane register and the config |
| 161 | 158 | */ |
| 162 | − return (void *)(0xF1000000+(slot<<24)); | |
| 159 | + return (void *)(0xF1000000 + (slot << 24)); | |
| 163 | 160 | } |
| 164 | 161 | |
| 165 | 162 | static unsigned char *nubus_dirptr(const struct nubus_dirent *nd) |
| 166 | 163 | { |
| 167 | 164 | unsigned char *p = nd->base; |
| 165 | + | |
| 168 | 166 | /* Essentially, just step over the bytelanes using whatever |
| 169 | 167 | offset we might have found */ |
| 170 | 168 | nubus_move(&p, nubus_expand32(nd->data), nd->mask); |
| @@ -175,36 +173,36 @@ static unsigned char *nubus_dirptr(const struct nubus_dirent *nd) · 4 unmodified lines | ||
| 175 | 173 | /* These two are for pulling resource data blocks (i.e. stuff that's |
| 176 | 174 | pointed to with offsets) out of the card ROM. */ |
| 177 | 175 | |
| 178 | −void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent* dirent, | |
| 176 | +void nubus_get_rsrc_mem(void *dest, const struct nubus_dirent *dirent, | |
| 179 | 177 | int len) |
| 180 | 178 | { |
| 181 | 179 | unsigned char *t = (unsigned char *)dest; |
| 182 | 180 | unsigned char *p = nubus_dirptr(dirent); |
| 183 | − while(len) | |
| 184 | − { | |
| 181 | + | |
| 182 | + while (len) { | |
| 185 | 183 | *t++ = nubus_get_rom(&p, 1, dirent->mask); |
| 186 | 184 | len--; |
| 187 | 185 | } |
| 188 | 186 | } |
| 189 | 187 | EXPORT_SYMBOL(nubus_get_rsrc_mem); |
| 190 | 188 | |
| 191 | −void nubus_get_rsrc_str(void *dest, const struct nubus_dirent* dirent, | |
| 189 | +void nubus_get_rsrc_str(void *dest, const struct nubus_dirent *dirent, | |
| 192 | 190 | int len) |
| 193 | 191 | { |
| 194 | − unsigned char *t=(unsigned char *)dest; | |
| 192 | + unsigned char *t = (unsigned char *)dest; | |
| 195 | 193 | unsigned char *p = nubus_dirptr(dirent); |
| 196 | − while(len) | |
| 197 | − { | |
| 194 | + | |
| 195 | + while (len) { | |
| 198 | 196 | *t = nubus_get_rom(&p, 1, dirent->mask); |
| 199 | − if(!*t++) | |
| 197 | + if (!*t++) | |
| 200 | 198 | break; |
| 201 | 199 | len--; |
| 202 | 200 | } |
| 203 | 201 | } |
| 204 | 202 | EXPORT_SYMBOL(nubus_get_rsrc_str); |
| 205 | 203 | |
| 206 | −int nubus_get_root_dir(const struct nubus_board* board, | |
| 207 | − struct nubus_dir* dir) | |
| 204 | +int nubus_get_root_dir(const struct nubus_board *board, | |
| 205 | + struct nubus_dir *dir) | |
| 208 | 206 | { |
| 209 | 207 | dir->ptr = dir->base = board->directory; |
| 210 | 208 | dir->done = 0; |
| @@ -214,8 +212,8 @@ int nubus_get_root_dir(const struct nubus_board* board, · 3 unmodified lines | ||
| 214 | 212 | EXPORT_SYMBOL(nubus_get_root_dir); |
| 215 | 213 | |
| 216 | 214 | /* This is a slyly renamed version of the above */ |
| 217 | −int nubus_get_func_dir(const struct nubus_dev* dev, | |
| 218 | − struct nubus_dir* dir) | |
| 215 | +int nubus_get_func_dir(const struct nubus_dev *dev, | |
| 216 | + struct nubus_dir *dir) | |
| 219 | 217 | { |
| 220 | 218 | dir->ptr = dir->base = dev->directory; |
| 221 | 219 | dir->done = 0; |
| @@ -224,11 +222,11 @@ int nubus_get_func_dir(const struct nubus_dev* dev, · 2 unmodified lines | ||
| 224 | 222 | } |
| 225 | 223 | EXPORT_SYMBOL(nubus_get_func_dir); |
| 226 | 224 | |
| 227 | −int nubus_get_board_dir(const struct nubus_board* board, | |
| 228 | − struct nubus_dir* dir) | |
| 225 | +int nubus_get_board_dir(const struct nubus_board *board, | |
| 226 | + struct nubus_dir *dir) | |
| 229 | 227 | { |
| 230 | 228 | struct nubus_dirent ent; |
| 231 | − | |
| 229 | + | |
| 232 | 230 | dir->ptr = dir->base = board->directory; |
| 233 | 231 | dir->done = 0; |
| 234 | 232 | dir->mask = board->lanes; |
| @@ -256,6 +254,7 @@ EXPORT_SYMBOL(nubus_get_subdir); · 21 unmodified lines | ||
| 256 | 254 | int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent) |
| 257 | 255 | { |
| 258 | 256 | u32 resid; |
| 257 | + | |
| 259 | 258 | if (nd->done) |
| 260 | 259 | return -1; |
| 261 | 260 | |
| @@ -266,27 +265,25 @@ int nubus_readdir(struct nubus_dir *nd, struct nubus_dirent *ent) · 4 unmodified lines | ||
| 266 | 265 | resid = nubus_get_rom(&nd->ptr, 4, nd->mask); |
| 267 | 266 | |
| 268 | 267 | /* EOL marker, as per the Apple docs */ |
| 269 | − if((resid&0xff000000) == 0xff000000) | |
| 270 | − { | |
| 268 | + if ((resid & 0xff000000) == 0xff000000) { | |
| 271 | 269 | /* Mark it as done */ |
| 272 | 270 | nd->done = 1; |
| 273 | 271 | return -1; |
| 274 | 272 | } |
| 275 | 273 | |
| 276 | 274 | /* First byte is the resource ID */ |
| 277 | − ent->type = resid >> 24; | |
| 275 | + ent->type = resid >> 24; | |
| 278 | 276 | /* Low 3 bytes might contain data (or might not) */ |
| 279 | 277 | ent->data = resid & 0xffffff; |
| 280 | − ent->mask = nd->mask; | |
| 278 | + ent->mask = nd->mask; | |
| 281 | 279 | return 0; |
| 282 | 280 | } |
| 283 | 281 | EXPORT_SYMBOL(nubus_readdir); |
| 284 | 282 | |
| 285 | −int nubus_rewinddir(struct nubus_dir* dir) | |
| 283 | +int nubus_rewinddir(struct nubus_dir *dir) | |
| 286 | 284 | { |
| 287 | 285 | dir->ptr = dir->base; |
| 288 | 286 | dir->done = 0; |
| 289 | − | |
| 290 | 287 | return 0; |
| 291 | 288 | } |
| 292 | 289 | EXPORT_SYMBOL(nubus_rewinddir); |
| @@ -294,20 +291,15 @@ EXPORT_SYMBOL(nubus_rewinddir); · 1 unmodified line | ||
| 294 | 291 | /* Driver interface functions, more or less like in pci.c */ |
| 295 | 292 | |
| 296 | 293 | struct nubus_dev* |
| 297 | −nubus_find_device(unsigned short category, | |
| 298 | − unsigned short type, | |
| 299 | − unsigned short dr_hw, | |
| 300 | − unsigned short dr_sw, | |
| 301 | − const struct nubus_dev* from) | |
| 294 | +nubus_find_device(unsigned short category, unsigned short type, | |
| 295 | + unsigned short dr_hw, unsigned short dr_sw, | |
| 296 | + const struct nubus_dev *from) | |
| 302 | 297 | { |
| 303 | − struct nubus_dev* itor = | |
| 304 | − from ? from->next : nubus_devices; | |
| 298 | + struct nubus_dev *itor = from ? from->next : nubus_devices; | |
| 305 | 299 | |
| 306 | 300 | while (itor) { |
| 307 | − if (itor->category == category | |
| 308 | − && itor->type == type | |
| 309 | − && itor->dr_hw == dr_hw | |
| 310 | − && itor->dr_sw == dr_sw) | |
| 301 | + if (itor->category == category && itor->type == type && | |
| 302 | + itor->dr_hw == dr_hw && itor->dr_sw == dr_sw) | |
| 311 | 303 | return itor; |
| 312 | 304 | itor = itor->next; |
| 313 | 305 | } |
| @@ -316,16 +308,13 @@ nubus_find_device(unsigned short category, · 2 unmodified lines | ||
| 316 | 308 | EXPORT_SYMBOL(nubus_find_device); |
| 317 | 309 | |
| 318 | 310 | struct nubus_dev* |
| 319 | −nubus_find_type(unsigned short category, | |
| 320 | − unsigned short type, | |
| 321 | − const struct nubus_dev* from) | |
| 311 | +nubus_find_type(unsigned short category, unsigned short type, | |
| 312 | + const struct nubus_dev *from) | |
| 322 | 313 | { |
| 323 | − struct nubus_dev* itor = | |
| 324 | − from ? from->next : nubus_devices; | |
| 314 | + struct nubus_dev *itor = from ? from->next : nubus_devices; | |
| 325 | 315 | |
| 326 | 316 | while (itor) { |
| 327 | − if (itor->category == category | |
| 328 | − && itor->type == type) | |
| 317 | + if (itor->category == category && itor->type == type) | |
| 329 | 318 | return itor; |
| 330 | 319 | itor = itor->next; |
| 331 | 320 | } |
| @@ -334,12 +323,10 @@ nubus_find_type(unsigned short category, · 2 unmodified lines | ||
| 334 | 323 | EXPORT_SYMBOL(nubus_find_type); |
| 335 | 324 | |
| 336 | 325 | struct nubus_dev* |
| 337 | −nubus_find_slot(unsigned int slot, | |
| 338 | − const struct nubus_dev* from) | |
| 326 | +nubus_find_slot(unsigned int slot, const struct nubus_dev *from) | |
| 339 | 327 | { |
| 340 | − struct nubus_dev* itor = | |
| 341 | − from ? from->next : nubus_devices; | |
| 342 | − | |
| 328 | + struct nubus_dev *itor = from ? from->next : nubus_devices; | |
| 329 | + | |
| 343 | 330 | while (itor) { |
| 344 | 331 | if (itor->board->slot == slot) |
| 345 | 332 | return itor; |
| @@ -350,13 +337,13 @@ nubus_find_slot(unsigned int slot, · 4 unmodified lines | ||
| 350 | 337 | EXPORT_SYMBOL(nubus_find_slot); |
| 351 | 338 | |
| 352 | 339 | int |
| 353 | −nubus_find_rsrc(struct nubus_dir* dir, unsigned char rsrc_type, | |
| 354 | − struct nubus_dirent* ent) | |
| 340 | +nubus_find_rsrc(struct nubus_dir *dir, unsigned char rsrc_type, | |
| 341 | + struct nubus_dirent *ent) | |
| 355 | 342 | { |
| 356 | 343 | while (nubus_readdir(dir, ent) != -1) { |
| 357 | 344 | if (ent->type == rsrc_type) |
| 358 | 345 | return 0; |
| 359 | − } | |
| 346 | + } | |
| 360 | 347 | return -1; |
| 361 | 348 | } |
| 362 | 349 | EXPORT_SYMBOL(nubus_find_rsrc); |
| @@ -370,8 +357,8 @@ EXPORT_SYMBOL(nubus_find_rsrc); · 7 unmodified lines | ||
| 370 | 357 | among other things. The rest of it should go in the /proc code. |
| 371 | 358 | For now, we just use it to give verbose boot logs. */ |
| 372 | 359 | |
| 373 | −static int __init nubus_show_display_resource(struct nubus_dev* dev, | |
| 374 | − const struct nubus_dirent* ent) | |
| 360 | +static int __init nubus_show_display_resource(struct nubus_dev *dev, | |
| 361 | + const struct nubus_dirent *ent) | |
| 375 | 362 | { |
| 376 | 363 | switch (ent->type) { |
| 377 | 364 | case NUBUS_RESID_GAMMADIR: |
| @@ -388,14 +375,14 @@ static int __init nubus_show_display_resource(struct nubus_dev* dev, · 10 unmodified lines | ||
| 388 | 375 | return 0; |
| 389 | 376 | } |
| 390 | 377 | |
| 391 | −static int __init nubus_show_network_resource(struct nubus_dev* dev, | |
| 392 | − const struct nubus_dirent* ent) | |
| 378 | +static int __init nubus_show_network_resource(struct nubus_dev *dev, | |
| 379 | + const struct nubus_dirent *ent) | |
| 393 | 380 | { |
| 394 | 381 | switch (ent->type) { |
| 395 | 382 | case NUBUS_RESID_MAC_ADDRESS: |
| 396 | 383 | { |
| 397 | 384 | char addr[6]; |
| 398 | − | |
| 385 | + | |
| 399 | 386 | nubus_get_rsrc_mem(addr, ent, 6); |
| 400 | 387 | pr_info(" MAC address: %pM\n", addr); |
| 401 | 388 | break; |
| @@ -407,13 +394,14 @@ static int __init nubus_show_network_resource(struct nubus_dev* dev, · 5 unmodified lines | ||
| 407 | 394 | return 0; |
| 408 | 395 | } |
| 409 | 396 | |
| 410 | −static int __init nubus_show_cpu_resource(struct nubus_dev* dev, | |
| 411 | − const struct nubus_dirent* ent) | |
| 397 | +static int __init nubus_show_cpu_resource(struct nubus_dev *dev, | |
| 398 | + const struct nubus_dirent *ent) | |
| 412 | 399 | { |
| 413 | 400 | switch (ent->type) { |
| 414 | 401 | case NUBUS_RESID_MEMINFO: |
| 415 | 402 | { |
| 416 | 403 | unsigned long meminfo[2]; |
| 404 | + | |
| 417 | 405 | nubus_get_rsrc_mem(&meminfo, ent, 8); |
| 418 | 406 | pr_info(" memory: [ 0x%08lx 0x%08lx ]\n", |
| 419 | 407 | meminfo[0], meminfo[1]); |
| @@ -422,6 +410,7 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev, · 2 unmodified lines | ||
| 422 | 410 | case NUBUS_RESID_ROMINFO: |
| 423 | 411 | { |
| 424 | 412 | unsigned long rominfo[2]; |
| 413 | + | |
| 425 | 414 | nubus_get_rsrc_mem(&rominfo, ent, 8); |
| 426 | 415 | pr_info(" ROM: [ 0x%08lx 0x%08lx ]\n", |
| 427 | 416 | rominfo[0], rominfo[1]); |
| @@ -434,8 +423,8 @@ static int __init nubus_show_cpu_resource(struct nubus_dev* dev, · 6 unmodified lines | ||
| 434 | 423 | return 0; |
| 435 | 424 | } |
| 436 | 425 | |
| 437 | −static int __init nubus_show_private_resource(struct nubus_dev* dev, | |
| 438 | − const struct nubus_dirent* ent) | |
| 426 | +static int __init nubus_show_private_resource(struct nubus_dev *dev, | |
| 427 | + const struct nubus_dirent *ent) | |
| 439 | 428 | { |
| 440 | 429 | switch (dev->category) { |
| 441 | 430 | case NUBUS_CAT_DISPLAY: |
| @@ -454,39 +443,37 @@ static int __init nubus_show_private_resource(struct nubus_dev* dev, · 12 unmodified lines | ||
| 454 | 443 | return 0; |
| 455 | 444 | } |
| 456 | 445 | |
| 457 | −static struct nubus_dev* __init | |
| 458 | − nubus_get_functional_resource(struct nubus_board* board, | |
| 459 | − int slot, | |
| 460 | − const struct nubus_dirent* parent) | |
| 446 | +static struct nubus_dev * __init | |
| 447 | +nubus_get_functional_resource(struct nubus_board *board, int slot, | |
| 448 | + const struct nubus_dirent *parent) | |
| 461 | 449 | { |
| 462 | − struct nubus_dir dir; | |
| 450 | + struct nubus_dir dir; | |
| 463 | 451 | struct nubus_dirent ent; |
| 464 | − struct nubus_dev* dev; | |
| 465 | − | |
| 452 | + struct nubus_dev *dev; | |
| 453 | + | |
| 466 | 454 | pr_info(" Function 0x%02x:\n", parent->type); |
| 467 | 455 | nubus_get_subdir(parent, &dir); |
| 468 | 456 | |
| 469 | 457 | /* Apple seems to have botched the ROM on the IIx */ |
| 470 | 458 | if (slot == 0 && (unsigned long)dir.base % 2) |
| 471 | 459 | dir.base += 1; |
| 472 | − | |
| 460 | + | |
| 473 | 461 | pr_debug("%s: parent is 0x%p, dir is 0x%p\n", |
| 474 | 462 | __func__, parent->base, dir.base); |
| 475 | 463 | |
| 476 | 464 | /* Actually we should probably panic if this fails */ |
| 477 | 465 | if ((dev = kzalloc(sizeof(*dev), GFP_ATOMIC)) == NULL) |
| 478 | − return NULL; | |
| 466 | + return NULL; | |
| 479 | 467 | dev->resid = parent->type; |
| 480 | 468 | dev->directory = dir.base; |
| 481 | 469 | dev->board = board; |
| 482 | − | |
| 483 | − while (nubus_readdir(&dir, &ent) != -1) | |
| 484 | − { | |
| 485 | − switch(ent.type) | |
| 486 | − { | |
| 470 | + | |
| 471 | + while (nubus_readdir(&dir, &ent) != -1) { | |
| 472 | + switch (ent.type) { | |
| 487 | 473 | case NUBUS_RESID_TYPE: |
| 488 | 474 | { |
| 489 | 475 | unsigned short nbtdata[4]; |
| 476 | + | |
| 490 | 477 | nubus_get_rsrc_mem(nbtdata, &ent, 8); |
| 491 | 478 | dev->category = nbtdata[0]; |
| 492 | 479 | dev->type = nbtdata[1]; |
| @@ -508,6 +495,7 @@ static struct nubus_dev* __init · 15 unmodified lines | ||
| 508 | 495 | use this :-) */ |
| 509 | 496 | struct nubus_dir drvr_dir; |
| 510 | 497 | struct nubus_dirent drvr_ent; |
| 498 | + | |
| 511 | 499 | nubus_get_subdir(&ent, &drvr_dir); |
| 512 | 500 | nubus_readdir(&drvr_dir, &drvr_ent); |
| 513 | 501 | dev->driver = nubus_dirptr(&drvr_ent); |
| @@ -525,7 +513,7 @@ static struct nubus_dev* __init · 11 unmodified lines | ||
| 525 | 513 | /* Ditto */ |
| 526 | 514 | nubus_get_rsrc_mem(&dev->iosize, &ent, 4); |
| 527 | 515 | pr_info(" memory length: 0x%08lx\n", dev->iosize); |
| 528 | − break; | |
| 516 | + break; | |
| 529 | 517 | case NUBUS_RESID_FLAGS: |
| 530 | 518 | dev->flags = ent.data; |
| 531 | 519 | pr_info(" flags: 0x%06x\n", dev->flags); |
| @@ -540,16 +528,17 @@ static struct nubus_dev* __init · 8 unmodified lines | ||
| 540 | 528 | nubus_show_private_resource(dev, &ent); |
| 541 | 529 | } |
| 542 | 530 | } |
| 543 | − | |
| 531 | + | |
| 544 | 532 | return dev; |
| 545 | 533 | } |
| 546 | 534 | |
| 547 | 535 | /* This is cool. */ |
| 548 | −static int __init nubus_get_vidnames(struct nubus_board* board, | |
| 549 | − const struct nubus_dirent* parent) | |
| 536 | +static int __init nubus_get_vidnames(struct nubus_board *board, | |
| 537 | + const struct nubus_dirent *parent) | |
| 550 | 538 | { |
| 551 | − struct nubus_dir dir; | |
| 539 | + struct nubus_dir dir; | |
| 552 | 540 | struct nubus_dirent ent; |
| 541 | + | |
| 553 | 542 | /* FIXME: obviously we want to put this in a header file soon */ |
| 554 | 543 | struct vidmode { |
| 555 | 544 | u32 size; |
| @@ -564,14 +553,13 @@ static int __init nubus_get_vidnames(struct nubus_board* board, · 8 unmodified lines | ||
| 564 | 553 | pr_debug("%s: parent is 0x%p, dir is 0x%p\n", |
| 565 | 554 | __func__, parent->base, dir.base); |
| 566 | 555 | |
| 567 | − while(nubus_readdir(&dir, &ent) != -1) | |
| 568 | − { | |
| 556 | + while (nubus_readdir(&dir, &ent) != -1) { | |
| 569 | 557 | struct vidmode mode; |
| 570 | 558 | u32 size; |
| 571 | 559 | |
| 572 | 560 | /* First get the length */ |
| 573 | 561 | nubus_get_rsrc_mem(&size, &ent, 4); |
| 574 | − | |
| 562 | + | |
| 575 | 563 | /* Now clobber the whole thing */ |
| 576 | 564 | if (size > sizeof(mode) - 1) |
| 577 | 565 | size = sizeof(mode) - 1; |
| @@ -584,13 +572,13 @@ static int __init nubus_get_vidnames(struct nubus_board* board, · 6 unmodified lines | ||
| 584 | 572 | } |
| 585 | 573 | |
| 586 | 574 | /* This is *really* cool. */ |
| 587 | −static int __init nubus_get_icon(struct nubus_board* board, | |
| 588 | − const struct nubus_dirent* ent) | |
| 575 | +static int __init nubus_get_icon(struct nubus_board *board, | |
| 576 | + const struct nubus_dirent *ent) | |
| 589 | 577 | { |
| 590 | 578 | /* Should be 32x32 if my memory serves me correctly */ |
| 591 | 579 | unsigned char icon[128]; |
| 592 | 580 | int x, y; |
| 593 | − | |
| 581 | + | |
| 594 | 582 | nubus_get_rsrc_mem(&icon, ent, 128); |
| 595 | 583 | pr_info(" icon:\n"); |
| 596 | 584 | |
| @@ -600,8 +588,7 @@ static int __init nubus_get_icon(struct nubus_board* board, · 3 unmodified lines | ||
| 600 | 588 | for (y = 0; y < 32; y++) { |
| 601 | 589 | pr_info(" "); |
| 602 | 590 | for (x = 0; x < 32; x++) { |
| 603 | − if (icon[y*4 + x/8] | |
| 604 | − & (0x80 >> (x%8))) | |
| 591 | + if (icon[y * 4 + x / 8] & (0x80 >> (x % 8))) | |
| 605 | 592 | pr_cont("*"); |
| 606 | 593 | else |
| 607 | 594 | pr_cont(" "); |
| @@ -611,23 +598,22 @@ static int __init nubus_get_icon(struct nubus_board* board, · 3 unmodified lines | ||
| 611 | 598 | return 0; |
| 612 | 599 | } |
| 613 | 600 | |
| 614 | −static int __init nubus_get_vendorinfo(struct nubus_board* board, | |
| 615 | − const struct nubus_dirent* parent) | |
| 601 | +static int __init nubus_get_vendorinfo(struct nubus_board *board, | |
| 602 | + const struct nubus_dirent *parent) | |
| 616 | 603 | { |
| 617 | − struct nubus_dir dir; | |
| 604 | + struct nubus_dir dir; | |
| 618 | 605 | struct nubus_dirent ent; |
| 619 | − static char* vendor_fields[6] = {"ID", "serial", "revision", | |
| 620 | − "part", "date", "unknown field"}; | |
| 606 | + static char *vendor_fields[6] = { "ID", "serial", "revision", | |
| 607 | + "part", "date", "unknown field" }; | |
| 621 | 608 | |
| 622 | 609 | pr_info(" vendor info:\n"); |
| 623 | 610 | nubus_get_subdir(parent, &dir); |
| 624 | 611 | pr_debug("%s: parent is 0x%p, dir is 0x%p\n", |
| 625 | 612 | __func__, parent->base, dir.base); |
| 626 | 613 | |
| 627 | − while(nubus_readdir(&dir, &ent) != -1) | |
| 628 | − { | |
| 614 | + while (nubus_readdir(&dir, &ent) != -1) { | |
| 629 | 615 | char name[64]; |
| 630 | − | |
| 616 | + | |
| 631 | 617 | /* These are all strings, we think */ |
| 632 | 618 | nubus_get_rsrc_str(name, &ent, 64); |
| 633 | 619 | if (ent.type > 5) |
| @@ -637,18 +623,17 @@ static int __init nubus_get_vendorinfo(struct nubus_board* board, · 3 unmodified lines | ||
| 637 | 623 | return 0; |
| 638 | 624 | } |
| 639 | 625 | |
| 640 | −static int __init nubus_get_board_resource(struct nubus_board* board, int slot, | |
| 641 | − const struct nubus_dirent* parent) | |
| 626 | +static int __init nubus_get_board_resource(struct nubus_board *board, int slot, | |
| 627 | + const struct nubus_dirent *parent) | |
| 642 | 628 | { |
| 643 | − struct nubus_dir dir; | |
| 629 | + struct nubus_dir dir; | |
| 644 | 630 | struct nubus_dirent ent; |
| 645 | − | |
| 631 | + | |
| 646 | 632 | nubus_get_subdir(parent, &dir); |
| 647 | 633 | pr_debug("%s: parent is 0x%p, dir is 0x%p\n", |
| 648 | 634 | __func__, parent->base, dir.base); |
| 649 | 635 | |
| 650 | − while(nubus_readdir(&dir, &ent) != -1) | |
| 651 | − { | |
| 636 | + while (nubus_readdir(&dir, &ent) != -1) { | |
| 652 | 637 | switch (ent.type) { |
| 653 | 638 | case NUBUS_RESID_TYPE: |
| 654 | 639 | { |
| @@ -689,7 +674,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, · 34 unmodified lines | ||
| 689 | 674 | case NUBUS_RESID_SECONDINIT: |
| 690 | 675 | pr_info(" secondary init offset: 0x%06x\n", ent.data); |
| 691 | 676 | break; |
| 692 | − /* WTF isn't this in the functional resources? */ | |
| 677 | + /* WTF isn't this in the functional resources? */ | |
| 693 | 678 | case NUBUS_RESID_VIDNAMES: |
| 694 | 679 | nubus_get_vidnames(board, &ent); |
| 695 | 680 | break; |
| @@ -697,7 +682,7 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, · 1 unmodified line | ||
| 697 | 682 | case NUBUS_RESID_VIDMODES: |
| 698 | 683 | pr_info(" video mode parameter directory offset: 0x%06x\n", |
| 699 | 684 | ent.data); |
| 700 | − break; | |
| 685 | + break; | |
| 701 | 686 | default: |
| 702 | 687 | pr_info(" unknown resource %02X, data 0x%06x\n", |
| 703 | 688 | ent.type, ent.data); |
| @@ -710,8 +695,8 @@ static int __init nubus_get_board_resource(struct nubus_board* board, int slot, · 6 unmodified lines | ||
| 710 | 695 | sResources in the motherboard ROM */ |
| 711 | 696 | static void __init nubus_find_rom_dir(struct nubus_board* board) |
| 712 | 697 | { |
| 713 | − unsigned char* rp; | |
| 714 | − unsigned char* romdir; | |
| 698 | + unsigned char *rp; | |
| 699 | + unsigned char *romdir; | |
| 715 | 700 | struct nubus_dir dir; |
| 716 | 701 | struct nubus_dirent ent; |
| 717 | 702 | |
| @@ -744,14 +729,14 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) · 26 unmodified lines | ||
| 744 | 729 | if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) |
| 745 | 730 | printk(KERN_INFO "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data); |
| 746 | 731 | /* This one takes us to where we want to go. */ |
| 747 | − if (nubus_readdir(&dir, &ent) == -1) | |
| 732 | + if (nubus_readdir(&dir, &ent) == -1) | |
| 748 | 733 | goto badrom; |
| 749 | 734 | if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) |
| 750 | 735 | printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data); |
| 751 | 736 | nubus_get_subdir(&ent, &dir); |
| 752 | 737 | |
| 753 | 738 | /* Resource ID 01, also an "Unknown Macintosh" */ |
| 754 | − if (nubus_readdir(&dir, &ent) == -1) | |
| 739 | + if (nubus_readdir(&dir, &ent) == -1) | |
| 755 | 740 | goto badrom; |
| 756 | 741 | if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) |
| 757 | 742 | printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data); |
| @@ -770,12 +755,12 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) · 12 unmodified lines | ||
| 770 | 755 | goto badrom; |
| 771 | 756 | if (console_loglevel >= CONSOLE_LOGLEVEL_DEBUG) |
| 772 | 757 | printk(KERN_DEBUG "nubus_get_rom_dir: entry %02x %06x\n", ent.type, ent.data); |
| 773 | − | |
| 758 | + | |
| 774 | 759 | /* Bwahahahaha... */ |
| 775 | 760 | nubus_get_subdir(&ent, &dir); |
| 776 | 761 | board->directory = dir.base; |
| 777 | 762 | return; |
| 778 | − | |
| 763 | + | |
| 779 | 764 | /* Even more evil laughter... */ |
| 780 | 765 | badrom: |
| 781 | 766 | board->directory = board->fblock; |
| @@ -784,23 +769,22 @@ static void __init nubus_find_rom_dir(struct nubus_board* board) · 2 unmodified lines | ||
| 784 | 769 | } |
| 785 | 770 | |
| 786 | 771 | /* Add a board (might be many devices) to the list */ |
| 787 | −static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) | |
| 772 | +static struct nubus_board * __init nubus_add_board(int slot, int bytelanes) | |
| 788 | 773 | { |
| 789 | − struct nubus_board* board; | |
| 790 | − struct nubus_board** boardp; | |
| 791 | − | |
| 774 | + struct nubus_board *board; | |
| 775 | + struct nubus_board **boardp; | |
| 792 | 776 | unsigned char *rp; |
| 793 | 777 | unsigned long dpat; |
| 794 | 778 | struct nubus_dir dir; |
| 795 | 779 | struct nubus_dirent ent; |
| 796 | 780 | |
| 797 | 781 | /* Move to the start of the format block */ |
| 798 | − rp = nubus_rom_addr(slot); | |
| 782 | + rp = nubus_rom_addr(slot); | |
| 799 | 783 | nubus_rewind(&rp, FORMAT_BLOCK_SIZE, bytelanes); |
| 800 | 784 | |
| 801 | 785 | /* Actually we should probably panic if this fails */ |
| 802 | 786 | if ((board = kzalloc(sizeof(*board), GFP_ATOMIC)) == NULL) |
| 803 | − return NULL; | |
| 787 | + return NULL; | |
| 804 | 788 | board->fblock = rp; |
| 805 | 789 | |
| 806 | 790 | /* Dump the format block for debugging purposes */ |
| @@ -816,7 +800,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 9 unmodified lines | ||
| 816 | 800 | rp = board->fblock; |
| 817 | 801 | |
| 818 | 802 | board->slot = slot; |
| 819 | − board->slot_addr = (unsigned long) nubus_slot_addr(slot); | |
| 803 | + board->slot_addr = (unsigned long)nubus_slot_addr(slot); | |
| 820 | 804 | board->doffset = nubus_get_rom(&rp, 4, bytelanes); |
| 821 | 805 | /* rom_length is *supposed* to be the total length of the |
| 822 | 806 | * ROM. In practice it is the "amount of ROM used to compute |
| @@ -827,16 +811,16 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 4 unmodified lines | ||
| 827 | 811 | board->rom_length = nubus_get_rom(&rp, 4, bytelanes); |
| 828 | 812 | board->crc = nubus_get_rom(&rp, 4, bytelanes); |
| 829 | 813 | board->rev = nubus_get_rom(&rp, 1, bytelanes); |
| 830 | − board->format = nubus_get_rom(&rp,1, bytelanes); | |
| 814 | + board->format = nubus_get_rom(&rp, 1, bytelanes); | |
| 831 | 815 | board->lanes = bytelanes; |
| 832 | 816 | |
| 833 | 817 | /* Directory offset should be small and negative... */ |
| 834 | − if(!(board->doffset & 0x00FF0000)) | |
| 818 | + if (!(board->doffset & 0x00FF0000)) | |
| 835 | 819 | pr_warn("Dodgy doffset!\n"); |
| 836 | 820 | dpat = nubus_get_rom(&rp, 4, bytelanes); |
| 837 | − if(dpat != NUBUS_TEST_PATTERN) | |
| 821 | + if (dpat != NUBUS_TEST_PATTERN) | |
| 838 | 822 | pr_warn("Wrong test pattern %08lx!\n", dpat); |
| 839 | − | |
| 823 | + | |
| 840 | 824 | /* |
| 841 | 825 | * I wonder how the CRC is meant to work - |
| 842 | 826 | * any takers ? |
| @@ -846,7 +830,7 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 3 unmodified lines | ||
| 846 | 830 | |
| 847 | 831 | /* Attempt to work around slot zero weirdness */ |
| 848 | 832 | nubus_find_rom_dir(board); |
| 849 | − nubus_get_root_dir(board, &dir); | |
| 833 | + nubus_get_root_dir(board, &dir); | |
| 850 | 834 | |
| 851 | 835 | /* We're ready to rock */ |
| 852 | 836 | pr_info("Slot %X:\n", slot); |
| @@ -869,8 +853,9 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 16 unmodified lines | ||
| 869 | 853 | resources. I have no idea WTF to do about this. */ |
| 870 | 854 | |
| 871 | 855 | while (nubus_readdir(&dir, &ent) != -1) { |
| 872 | − struct nubus_dev* dev; | |
| 873 | − struct nubus_dev** devp; | |
| 856 | + struct nubus_dev *dev; | |
| 857 | + struct nubus_dev **devp; | |
| 858 | + | |
| 874 | 859 | dev = nubus_get_functional_resource(board, slot, &ent); |
| 875 | 860 | if (dev == NULL) |
| 876 | 861 | continue; |
| @@ -878,32 +863,33 @@ static struct nubus_board* __init nubus_add_board(int slot, int bytelanes) · 1 unmodified line | ||
| 878 | 863 | /* We zeroed this out above */ |
| 879 | 864 | if (board->first_dev == NULL) |
| 880 | 865 | board->first_dev = dev; |
| 881 | − | |
| 866 | + | |
| 882 | 867 | /* Put it on the global NuBus device chain. Keep entries in order. */ |
| 883 | − for (devp=&nubus_devices; *devp!=NULL; devp=&((*devp)->next)) | |
| 868 | + for (devp = &nubus_devices; *devp != NULL; | |
| 869 | + devp = &((*devp)->next)) | |
| 884 | 870 | /* spin */; |
| 885 | 871 | *devp = dev; |
| 886 | − dev->next = NULL; | |
| 872 | + dev->next = NULL; | |
| 887 | 873 | } |
| 888 | 874 | |
| 889 | 875 | /* Put it on the global NuBus board chain. Keep entries in order. */ |
| 890 | − for (boardp=&nubus_boards; *boardp!=NULL; boardp=&((*boardp)->next)) | |
| 876 | + for (boardp = &nubus_boards; *boardp != NULL; | |
| 877 | + boardp = &((*boardp)->next)) | |
| 891 | 878 | /* spin */; |
| 892 | 879 | *boardp = board; |
| 893 | 880 | board->next = NULL; |
| 894 | − | |
| 881 | + | |
| 895 | 882 | return board; |
| 896 | 883 | } |
| 897 | 884 | |
| 898 | 885 | void __init nubus_probe_slot(int slot) |
| 899 | 886 | { |
| 900 | 887 | unsigned char dp; |
| 901 | − unsigned char* rp; | |
| 888 | + unsigned char *rp; | |
| 902 | 889 | int i; |
| 903 | 890 | |
| 904 | − rp = nubus_rom_addr(slot); | |
| 905 | − for(i = 4; i; i--) | |
| 906 | − { | |
| 891 | + rp = nubus_rom_addr(slot); | |
| 892 | + for (i = 4; i; i--) { | |
| 907 | 893 | int card_present; |
| 908 | 894 | |
| 909 | 895 | rp--; |
| @@ -918,11 +904,11 @@ void __init nubus_probe_slot(int slot) · 8 unmodified lines | ||
| 918 | 904 | /* The last byte of the format block consists of two |
| 919 | 905 | nybbles which are "mirror images" of each other. |
| 920 | 906 | These show us the valid bytelanes */ |
| 921 | − if ((((dp>>4) ^ dp) & 0x0F) != 0x0F) | |
| 907 | + if ((((dp >> 4) ^ dp) & 0x0F) != 0x0F) | |
| 922 | 908 | continue; |
| 923 | 909 | /* Check that this value is actually *on* one of the |
| 924 | 910 | bytelanes it claims are valid! */ |
| 925 | − if ((dp & 0x0F) >= (1<<i)) | |
| 911 | + if ((dp & 0x0F) >= (1 << i)) | |
| 926 | 912 | continue; |
| 927 | 913 | |
| 928 | 914 | /* Looks promising. Let's put it on the list. */ |
| @@ -935,19 +921,19 @@ void __init nubus_probe_slot(int slot) · 6 unmodified lines | ||
| 935 | 921 | void __init nubus_scan_bus(void) |
| 936 | 922 | { |
| 937 | 923 | int slot; |
| 924 | + | |
| 938 | 925 | /* This might not work on your machine */ |
| 939 | 926 | #ifdef I_WANT_TO_PROBE_SLOT_ZERO |
| 940 | 927 | nubus_probe_slot(0); |
| 941 | 928 | #endif |
| 942 | − for(slot = 9; slot < 15; slot++) | |
| 943 | − { | |
| 929 | + for (slot = 9; slot < 15; slot++) { | |
| 944 | 930 | nubus_probe_slot(slot); |
| 945 | 931 | } |
| 946 | 932 | } |
| 947 | 933 | |
| 948 | 934 | static int __init nubus_init(void) |
| 949 | 935 | { |
| 950 | − if (!MACH_IS_MAC) | |
| 936 | + if (!MACH_IS_MAC) | |
| 951 | 937 | return 0; |
| 952 | 938 | |
| 953 | 939 | /* Initialize the NuBus interrupts */ |
| @@ -963,11 +949,11 @@ static int __init nubus_init(void) · 9 unmodified lines | ||
| 963 | 949 | gurus can fix the real cause of the problem. */ |
| 964 | 950 | mdelay(1000); |
| 965 | 951 | #endif |
| 966 | − | |
| 952 | + | |
| 967 | 953 | /* And probe */ |
| 968 | 954 | pr_info("NuBus: Scanning NuBus slots.\n"); |
| 969 | 955 | nubus_devices = NULL; |
| 970 | − nubus_boards = NULL; | |
| 956 | + nubus_boards = NULL; | |
| 971 | 957 | nubus_scan_bus(); |
| 972 | 958 | nubus_proc_init(); |
| 973 | 959 | return 0; |