aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:39 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-03-27 07:46:39 -0400
commit0dfb991c6943c810175376b58d1c29cfe532541b (patch)
treec7b82d2ea9159e94c40f8df1a178dab4d2590ed3 /drivers/ide/ide-disk.c
parent04d09b0e62f2180a7e3fa8578ed778eca0c454fd (diff)
ide: use ata_tf_protocols enums
* Add IDE_TFLAG_MULTI_PIO taskfile flag and set it for commands using multi-PIO protocol. * Use ata_tf_protocols enums instead of TASKFILE_* defines to denote command's protocol and then rename ->data_phase field to ->protocol. * Remove no longer needed <linux/hdreg.h> includes. There should be no functional changes caused by this patch. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index d00d807c0f53..dae9d988de10 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -28,7 +28,6 @@
28#include <linux/mutex.h> 28#include <linux/mutex.h>
29#include <linux/leds.h> 29#include <linux/leds.h>
30#include <linux/ide.h> 30#include <linux/ide.h>
31#include <linux/hdreg.h>
32 31
33#include <asm/byteorder.h> 32#include <asm/byteorder.h>
34#include <asm/irq.h> 33#include <asm/irq.h>
@@ -53,15 +52,6 @@ static const u8 ide_rw_cmds[] = {
53 ATA_CMD_WRITE_EXT, 52 ATA_CMD_WRITE_EXT,
54}; 53};
55 54
56static const u8 ide_data_phases[] = {
57 TASKFILE_MULTI_IN,
58 TASKFILE_MULTI_OUT,
59 TASKFILE_IN,
60 TASKFILE_OUT,
61 TASKFILE_IN_DMA,
62 TASKFILE_OUT_DMA,
63};
64
65static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma) 55static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)
66{ 56{
67 u8 index, lba48, write; 57 u8 index, lba48, write;
@@ -69,17 +59,19 @@ static void ide_tf_set_cmd(ide_drive_t *drive, struct ide_cmd *cmd, u8 dma)
69 lba48 = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 2 : 0; 59 lba48 = (cmd->tf_flags & IDE_TFLAG_LBA48) ? 2 : 0;
70 write = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0; 60 write = (cmd->tf_flags & IDE_TFLAG_WRITE) ? 1 : 0;
71 61
72 if (dma) 62 if (dma) {
63 cmd->protocol = ATA_PROT_DMA;
73 index = 8; 64 index = 8;
74 else 65 } else {
75 index = drive->mult_count ? 0 : 4; 66 cmd->protocol = ATA_PROT_PIO;
67 if (drive->mult_count) {
68 cmd->tf_flags |= IDE_TFLAG_MULTI_PIO;
69 index = 0;
70 } else
71 index = 4;
72 }
76 73
77 cmd->tf.command = ide_rw_cmds[index + lba48 + write]; 74 cmd->tf.command = ide_rw_cmds[index + lba48 + write];
78
79 if (dma)
80 index = 8; /* fixup index */
81
82 cmd->data_phase = ide_data_phases[index / 2 + write];
83} 75}
84 76
85/* 77/*
@@ -401,9 +393,9 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
401 cmd->tf.command = ATA_CMD_FLUSH_EXT; 393 cmd->tf.command = ATA_CMD_FLUSH_EXT;
402 else 394 else
403 cmd->tf.command = ATA_CMD_FLUSH; 395 cmd->tf.command = ATA_CMD_FLUSH;
404 cmd->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE | 396 cmd->tf_flags = IDE_TFLAG_OUT_TF | IDE_TFLAG_OUT_DEVICE |
405 IDE_TFLAG_DYN; 397 IDE_TFLAG_DYN;
406 cmd->data_phase = TASKFILE_NO_DATA; 398 cmd->protocol = ATA_PROT_NODATA;
407 399
408 rq->cmd_type = REQ_TYPE_ATA_TASKFILE; 400 rq->cmd_type = REQ_TYPE_ATA_TASKFILE;
409 rq->cmd_flags |= REQ_SOFTBARRIER; 401 rq->cmd_flags |= REQ_SOFTBARRIER;
ppc">#include <linux/fs.h> #include <linux/workqueue.h> struct partition { unsigned char boot_ind; /* 0x80 - active */ unsigned char head; /* starting head */ unsigned char sector; /* starting sector */ unsigned char cyl; /* starting cylinder */ unsigned char sys_ind; /* What partition type */ unsigned char end_head; /* end head */ unsigned char end_sector; /* end sector */ unsigned char end_cyl; /* end cylinder */ __le32 start_sect; /* starting sector counting from 0 */ __le32 nr_sects; /* nr of sectors in partition */ } __attribute__((packed)); struct disk_stats { unsigned long sectors[2]; /* READs and WRITEs */ unsigned long ios[2]; unsigned long merges[2]; unsigned long ticks[2]; unsigned long io_ticks; unsigned long time_in_queue; }; #define PARTITION_META_INFO_VOLNAMELTH 64 /* * Enough for the string representation of any kind of UUID plus NULL. * EFI UUID is 36 characters. MSDOS UUID is 11 characters. */ #define PARTITION_META_INFO_UUIDLTH (UUID_STRING_LEN + 1) struct partition_meta_info { char uuid[PARTITION_META_INFO_UUIDLTH]; u8 volname[PARTITION_META_INFO_VOLNAMELTH]; }; struct hd_struct { sector_t start_sect; /* * nr_sects is protected by sequence counter. One might extend a * partition while IO is happening to it and update of nr_sects * can be non-atomic on 32bit machines with 64bit sector_t. */ sector_t nr_sects; seqcount_t nr_sects_seq; sector_t alignment_offset; unsigned int discard_alignment; struct device __dev; struct kobject *holder_dir; int policy, partno; struct partition_meta_info *info; #ifdef CONFIG_FAIL_MAKE_REQUEST int make_it_fail; #endif unsigned long stamp; atomic_t in_flight[2]; #ifdef CONFIG_SMP struct disk_stats __percpu *dkstats; #else struct disk_stats dkstats; #endif struct percpu_ref ref; struct rcu_head rcu_head; }; #define GENHD_FL_REMOVABLE 1 /* 2 is unused */ #define GENHD_FL_MEDIA_CHANGE_NOTIFY 4 #define GENHD_FL_CD 8 #define GENHD_FL_UP 16 #define GENHD_FL_SUPPRESS_PARTITION_INFO 32 #define GENHD_FL_EXT_DEVT 64 /* allow extended devt */ #define GENHD_FL_NATIVE_CAPACITY 128 #define GENHD_FL_BLOCK_EVENTS_ON_EXCL_WRITE 256 #define GENHD_FL_NO_PART_SCAN 512 enum { DISK_EVENT_MEDIA_CHANGE = 1 << 0, /* media changed */ DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */ }; #define BLK_SCSI_MAX_CMDS (256) #define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8)) struct blk_scsi_cmd_filter { unsigned long read_ok[BLK_SCSI_CMD_PER_LONG]; unsigned long write_ok[BLK_SCSI_CMD_PER_LONG]; struct kobject kobj; }; struct disk_part_tbl { struct rcu_head rcu_head; int len; struct hd_struct __rcu *last_lookup; struct hd_struct __rcu *part[]; }; struct disk_events; struct badblocks; #if defined(CONFIG_BLK_DEV_INTEGRITY) struct blk_integrity { struct blk_integrity_profile *profile; unsigned char flags; unsigned char tuple_size; unsigned char interval_exp; unsigned char tag_size; }; #endif /* CONFIG_BLK_DEV_INTEGRITY */ struct gendisk { /* major, first_minor and minors are input parameters only, * don't use directly. Use disk_devt() and disk_max_parts(). */ int major; /* major number of driver */ int first_minor; int minors; /* maximum number of minors, =1 for * disks that can't be partitioned. */ char disk_name[DISK_NAME_LEN]; /* name of major driver */ char *(*devnode)(struct gendisk *gd, umode_t *mode); unsigned int events; /* supported events */ unsigned int async_events; /* async events, subset of all */ /* Array of pointers to partitions indexed by partno. * Protected with matching bdev lock but stat and other * non-critical accesses use RCU. Always access through * helpers. */ struct disk_part_tbl __rcu *part_tbl; struct hd_struct part0; const struct block_device_operations *fops; struct request_queue *queue; void *private_data; int flags; struct kobject *slave_dir; struct timer_rand_state *random; atomic_t sync_io; /* RAID */ struct disk_events *ev; #ifdef CONFIG_BLK_DEV_INTEGRITY struct kobject integrity_kobj; #endif /* CONFIG_BLK_DEV_INTEGRITY */ int node_id; struct badblocks *bb; }; static inline struct gendisk *part_to_disk(struct hd_struct *part) { if (likely(part)) { if (part->partno) return dev_to_disk(part_to_dev(part)->parent); else return dev_to_disk(part_to_dev(part)); } return NULL; } static inline int blk_part_pack_uuid(const u8 *uuid_str, u8 *to) { uuid_be_to_bin(uuid_str, (uuid_be *)to); return 0; } static inline int disk_max_parts(struct gendisk *disk) { if (disk->flags & GENHD_FL_EXT_DEVT) return DISK_MAX_PARTS; return disk->minors; } static inline bool disk_part_scan_enabled(struct gendisk *disk) { return disk_max_parts(disk) > 1 && !(disk->flags & GENHD_FL_NO_PART_SCAN); } static inline dev_t disk_devt(struct gendisk *disk) { return disk_to_dev(disk)->devt; } static inline dev_t part_devt(struct hd_struct *part) { return part_to_dev(part)->devt; } extern struct hd_struct *disk_get_part(struct gendisk *disk, int partno); static inline void disk_put_part(struct hd_struct *part) { if (likely(part)) put_device(part_to_dev(part)); } /* * Smarter partition iterator without context limits. */ #define DISK_PITER_REVERSE (1 << 0) /* iterate in the reverse direction */ #define DISK_PITER_INCL_EMPTY (1 << 1) /* include 0-sized parts */ #define DISK_PITER_INCL_PART0 (1 << 2) /* include partition 0 */ #define DISK_PITER_INCL_EMPTY_PART0 (1 << 3) /* include empty partition 0 */ struct disk_part_iter { struct gendisk *disk; struct hd_struct *part; int idx; unsigned int flags; }; extern void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk, unsigned int flags); extern struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter); extern void disk_part_iter_exit(struct disk_part_iter *piter); extern struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector); /* * Macros to operate on percpu disk statistics: * * {disk|part|all}_stat_{add|sub|inc|dec}() modify the stat counters * and should be called between disk_stat_lock() and * disk_stat_unlock(). * * part_stat_read() can be called at any time. * * part_stat_{add|set_all}() and {init|free}_part_stats are for * internal use only. */ #ifdef CONFIG_SMP #define part_stat_lock() ({ rcu_read_lock(); get_cpu(); }) #define part_stat_unlock() do { put_cpu(); rcu_read_unlock(); } while (0) #define __part_stat_add(cpu, part, field, addnd) \ (per_cpu_ptr((part)->dkstats, (cpu))->field += (addnd)) #define part_stat_read(part, field) \ ({ \ typeof((part)->dkstats->field) res = 0; \ unsigned int _cpu; \ for_each_possible_cpu(_cpu) \ res += per_cpu_ptr((part)->dkstats, _cpu)->field; \ res; \ }) static inline void part_stat_set_all(struct hd_struct *part, int value) { int i; for_each_possible_cpu(i) memset(per_cpu_ptr(part->dkstats, i), value, sizeof(struct disk_stats)); } static inline int init_part_stats(struct hd_struct *part) { part->dkstats = alloc_percpu(struct disk_stats); if (!part->dkstats) return 0; return 1; } static inline void free_part_stats(struct hd_struct *part) { free_percpu(part->dkstats); } #else /* !CONFIG_SMP */ #define part_stat_lock() ({ rcu_read_lock(); 0; }) #define part_stat_unlock() rcu_read_unlock() #define __part_stat_add(cpu, part, field, addnd) \ ((part)->dkstats.field += addnd) #define part_stat_read(part, field) ((part)->dkstats.field) static inline void part_stat_set_all(struct hd_struct *part, int value) { memset(&part->dkstats, value, sizeof(struct disk_stats)); } static inline int init_part_stats(struct hd_struct *part) { return 1; } static inline void free_part_stats(struct hd_struct *part) { } #endif /* CONFIG_SMP */ #define part_stat_add(cpu, part, field, addnd) do { \ __part_stat_add((cpu), (part), field, addnd); \ if ((part)->partno) \ __part_stat_add((cpu), &part_to_disk((part))->part0, \ field, addnd); \ } while (0) #define part_stat_dec(cpu, gendiskp, field) \ part_stat_add(cpu, gendiskp, field, -1) #define part_stat_inc(cpu, gendiskp, field) \ part_stat_add(cpu, gendiskp, field, 1) #define part_stat_sub(cpu, gendiskp, field, subnd) \ part_stat_add(cpu, gendiskp, field, -subnd) static inline void part_inc_in_flight(struct hd_struct *part, int rw) { atomic_inc(&part->in_flight[rw]); if (part->partno) atomic_inc(&part_to_disk(part)->part0.in_flight[rw]); } static inline void part_dec_in_flight(struct hd_struct *part, int rw) { atomic_dec(&part->in_flight[rw]); if (part->partno) atomic_dec(&part_to_disk(part)->part0.in_flight[rw]); } static inline int part_in_flight(struct hd_struct *part) { return atomic_read(&part->in_flight[0]) + atomic_read(&part->in_flight[1]); } static inline struct partition_meta_info *alloc_part_info(struct gendisk *disk) { if (disk) return kzalloc_node(sizeof(struct partition_meta_info), GFP_KERNEL, disk->node_id); return kzalloc(sizeof(struct partition_meta_info), GFP_KERNEL); } static inline void free_part_info(struct hd_struct *part) { kfree(part->info); } /* block/blk-core.c */ extern void part_round_stats(int cpu, struct hd_struct *part); /* block/genhd.c */ extern void device_add_disk(struct device *parent, struct gendisk *disk); static inline void add_disk(struct gendisk *disk) { device_add_disk(NULL, disk); } extern void del_gendisk(struct gendisk *gp); extern struct gendisk *get_gendisk(dev_t dev, int *partno); extern struct block_device *bdget_disk(struct gendisk *disk, int partno); extern void set_device_ro(struct block_device *bdev, int flag); extern void set_disk_ro(struct gendisk *disk, int flag); static inline int get_disk_ro(struct gendisk *disk) { return disk->part0.policy; } extern void disk_block_events(struct gendisk *disk); extern void disk_unblock_events(struct gendisk *disk); extern void disk_flush_events(struct gendisk *disk, unsigned int mask); extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask); /* drivers/char/random.c */ extern void add_disk_randomness(struct gendisk *disk) __latent_entropy; extern void rand_initialize_disk(struct gendisk *disk); static inline sector_t get_start_sect(struct block_device *bdev) { return bdev->bd_part->start_sect; } static inline sector_t get_capacity(struct gendisk *disk) { return disk->part0.nr_sects; } static inline void set_capacity(struct gendisk *disk, sector_t size) { disk->part0.nr_sects = size; } #ifdef CONFIG_SOLARIS_X86_PARTITION #define SOLARIS_X86_NUMSLICE 16 #define SOLARIS_X86_VTOC_SANE (0x600DDEEEUL) struct solaris_x86_slice { __le16 s_tag; /* ID tag of partition */ __le16 s_flag; /* permission flags */ __le32 s_start; /* start sector no of partition */ __le32 s_size; /* # of blocks in partition */ }; struct solaris_x86_vtoc { unsigned int v_bootinfo[3]; /* info needed by mboot (unsupported) */ __le32 v_sanity; /* to verify vtoc sanity */ __le32 v_version; /* layout version */ char v_volume[8]; /* volume name */ __le16 v_sectorsz; /* sector size in bytes */ __le16 v_nparts; /* number of partitions */ unsigned int v_reserved[10]; /* free space */ struct solaris_x86_slice v_slice[SOLARIS_X86_NUMSLICE]; /* slice headers */ unsigned int timestamp[SOLARIS_X86_NUMSLICE]; /* timestamp (unsupported) */ char v_asciilabel[128]; /* for compatibility */ }; #endif /* CONFIG_SOLARIS_X86_PARTITION */ #ifdef CONFIG_BSD_DISKLABEL /* * BSD disklabel support by Yossi Gottlieb <yogo@math.tau.ac.il> * updated by Marc Espie <Marc.Espie@openbsd.org> */