diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 17:55:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-24 17:55:09 -0400 |
commit | b5684b83b1e1579bbbc80e703e990c0cccf5892c (patch) | |
tree | 3f1b62b2320bce4d658d2ad0d4b77856499ac533 /drivers/ide/ide-tape.c | |
parent | 1481b9109fe771ec8b035d7760f42e36d2bed5d4 (diff) | |
parent | 1b8ebad87b459e2e1333fbf28005977245ff5402 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/bart/ide-2.6: (76 commits)
ide: use proper printk() KERN_* levels in ide-probe.c
ide: fix for EATA SCSI HBA in ATA emulating mode
ide: remove stale comments from drivers/ide/Makefile
ide: enable local IRQs in all handlers for TASKFILE_NO_DATA data phase
ide-scsi: remove kmalloced struct request
ht6560b: remove old history
ht6560b: update email address
ide-cd: fix oops when using growisofs
gayle: release resources on ide_host_add() failure
palm_bk3710: add UltraDMA/100 support
ide: trivial sparse annotations
ide: ide-tape.c sparse annotations and unaligned access removal
ide: drop 'name' parameter from ->init_chipset method
ide: prefix messages from IDE PCI host drivers by driver name
it821x: remove DECLARE_ITE_DEV() macro
it8213: remove DECLARE_ITE_DEV() macro
ide: include PCI device name in messages from IDE PCI host drivers
ide: remove <asm/ide.h> for some archs
ide-generic: remove ide_default_{io_base,irq}() inlines (take 3)
ide-generic: is no longer needed on ppc32
...
Diffstat (limited to 'drivers/ide/ide-tape.c')
-rw-r--r-- | drivers/ide/ide-tape.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/drivers/ide/ide-tape.c b/drivers/ide/ide-tape.c index 6962ca4891a1..82c2afe4d28a 100644 --- a/drivers/ide/ide-tape.c +++ b/drivers/ide/ide-tape.c | |||
@@ -322,23 +322,29 @@ static struct class *idetape_sysfs_class; | |||
322 | #define ide_tape_g(disk) \ | 322 | #define ide_tape_g(disk) \ |
323 | container_of((disk)->private_data, struct ide_tape_obj, driver) | 323 | container_of((disk)->private_data, struct ide_tape_obj, driver) |
324 | 324 | ||
325 | static void ide_tape_release(struct kref *); | ||
326 | |||
325 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) | 327 | static struct ide_tape_obj *ide_tape_get(struct gendisk *disk) |
326 | { | 328 | { |
327 | struct ide_tape_obj *tape = NULL; | 329 | struct ide_tape_obj *tape = NULL; |
328 | 330 | ||
329 | mutex_lock(&idetape_ref_mutex); | 331 | mutex_lock(&idetape_ref_mutex); |
330 | tape = ide_tape_g(disk); | 332 | tape = ide_tape_g(disk); |
331 | if (tape) | 333 | if (tape) { |
332 | kref_get(&tape->kref); | 334 | kref_get(&tape->kref); |
335 | if (ide_device_get(tape->drive)) { | ||
336 | kref_put(&tape->kref, ide_tape_release); | ||
337 | tape = NULL; | ||
338 | } | ||
339 | } | ||
333 | mutex_unlock(&idetape_ref_mutex); | 340 | mutex_unlock(&idetape_ref_mutex); |
334 | return tape; | 341 | return tape; |
335 | } | 342 | } |
336 | 343 | ||
337 | static void ide_tape_release(struct kref *); | ||
338 | |||
339 | static void ide_tape_put(struct ide_tape_obj *tape) | 344 | static void ide_tape_put(struct ide_tape_obj *tape) |
340 | { | 345 | { |
341 | mutex_lock(&idetape_ref_mutex); | 346 | mutex_lock(&idetape_ref_mutex); |
347 | ide_device_put(tape->drive); | ||
342 | kref_put(&tape->kref, ide_tape_release); | 348 | kref_put(&tape->kref, ide_tape_release); |
343 | mutex_unlock(&idetape_ref_mutex); | 349 | mutex_unlock(&idetape_ref_mutex); |
344 | } | 350 | } |
@@ -649,10 +655,10 @@ static void ide_tape_callback(ide_drive_t *drive) | |||
649 | uptodate = 0; | 655 | uptodate = 0; |
650 | } else { | 656 | } else { |
651 | debug_log(DBG_SENSE, "Block Location - %u\n", | 657 | debug_log(DBG_SENSE, "Block Location - %u\n", |
652 | be32_to_cpu(*(u32 *)&readpos[4])); | 658 | be32_to_cpup((__be32 *)&readpos[4])); |
653 | 659 | ||
654 | tape->partition = readpos[1]; | 660 | tape->partition = readpos[1]; |
655 | tape->first_frame = be32_to_cpu(*(u32 *)&readpos[4]); | 661 | tape->first_frame = be32_to_cpup((__be32 *)&readpos[4]); |
656 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); | 662 | set_bit(IDE_AFLAG_ADDRESS_VALID, &drive->atapi_flags); |
657 | } | 663 | } |
658 | } | 664 | } |
@@ -2375,23 +2381,23 @@ static void idetape_get_mode_sense_results(ide_drive_t *drive) | |||
2375 | caps = pc.buf + 4 + pc.buf[3]; | 2381 | caps = pc.buf + 4 + pc.buf[3]; |
2376 | 2382 | ||
2377 | /* convert to host order and save for later use */ | 2383 | /* convert to host order and save for later use */ |
2378 | speed = be16_to_cpu(*(u16 *)&caps[14]); | 2384 | speed = be16_to_cpup((__be16 *)&caps[14]); |
2379 | max_speed = be16_to_cpu(*(u16 *)&caps[8]); | 2385 | max_speed = be16_to_cpup((__be16 *)&caps[8]); |
2380 | 2386 | ||
2381 | put_unaligned(max_speed, (u16 *)&caps[8]); | 2387 | *(u16 *)&caps[8] = max_speed; |
2382 | put_unaligned(be16_to_cpu(*(u16 *)&caps[12]), (u16 *)&caps[12]); | 2388 | *(u16 *)&caps[12] = be16_to_cpup((__be16 *)&caps[12]); |
2383 | put_unaligned(speed, (u16 *)&caps[14]); | 2389 | *(u16 *)&caps[14] = speed; |
2384 | put_unaligned(be16_to_cpu(*(u16 *)&caps[16]), (u16 *)&caps[16]); | 2390 | *(u16 *)&caps[16] = be16_to_cpup((__be16 *)&caps[16]); |
2385 | 2391 | ||
2386 | if (!speed) { | 2392 | if (!speed) { |
2387 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " | 2393 | printk(KERN_INFO "ide-tape: %s: invalid tape speed " |
2388 | "(assuming 650KB/sec)\n", drive->name); | 2394 | "(assuming 650KB/sec)\n", drive->name); |
2389 | put_unaligned(650, (u16 *)&caps[14]); | 2395 | *(u16 *)&caps[14] = 650; |
2390 | } | 2396 | } |
2391 | if (!max_speed) { | 2397 | if (!max_speed) { |
2392 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " | 2398 | printk(KERN_INFO "ide-tape: %s: invalid max_speed " |
2393 | "(assuming 650KB/sec)\n", drive->name); | 2399 | "(assuming 650KB/sec)\n", drive->name); |
2394 | put_unaligned(650, (u16 *)&caps[8]); | 2400 | *(u16 *)&caps[8] = 650; |
2395 | } | 2401 | } |
2396 | 2402 | ||
2397 | memcpy(&tape->caps, caps, 20); | 2403 | memcpy(&tape->caps, caps, 20); |