ata: add missing ATA_CMD_* defines
PATCH 1/7 ata: add missing ATA_CMD_* defines
Add missing ATA_CMD_* defines to <linux/ata.h>. Also add ATA_EXABYTE_ENABLE_NEST, SETFEATURES_AAM_* and ATA_SMART_* defines while at it.
Partially based on earlier work by Chris Wedgwood.
--- include/linux/ata.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/linux/ata.h +20 -0
@@ -222,6 +222,13 @@ enum {ATA_CMD_PMP_WRITE =0xE8 ,ATA_CMD_CONF_OVERLAY =0xB1 ,ATA_CMD_SEC_FREEZE_LOCK =0xF5 , +ATA_CMD_SMART =0xB0 , +ATA_CMD_MEDIA_LOCK =0xDE , +ATA_CMD_MEDIA_UNLOCK =0xDF , +/* marked obsolete in the ATA/ATAPI-7 spec */ +ATA_CMD_RESTORE =0x10 , +/* EXABYTE specific */ +ATA_EXABYTE_ENABLE_NEST =0xF0 ,/* READ_LOG_EXT pages */ ATA_LOG_SATA_NCQ = 0x10,
@@ -262,6 +269,10 @@ enum {SETFEATURES_WC_ON =0x02 ,/* Enable write cache */ SETFEATURES_WC_OFF =0x82 ,/* Disable write cache */ +/* Enable/Disable Automatic Acoustic Management */ +SETFEATURES_AAM_ON =0x42 , +SETFEATURES_AAM_OFF =0xC2 , +SETFEATURES_SPINUP =0x07 ,/* Spin-up drive */ SETFEATURES_SATA_ENABLE = 0x10, /* Enable use of SATA feature */
@@ -284,6 +295,15 @@ enum {ATA_DCO_IDENTIFY =0xC2 ,ATA_DCO_SET =0xC3 , +/* feature values for SMART */ +ATA_SMART_ENABLE =0xD8 , +ATA_SMART_READ_VALUES =0xD0 , +ATA_SMART_READ_THRESHOLDS =0xD1 , + +/* password used in LBA Mid / LBA High for executing SMART commands */ +ATA_SMART_LBAM_PASS =0x4F , +ATA_SMART_LBAH_PASS =0xC2 , +/* ATAPI stuff */ ATAPI_PKT_DMA = (1 <<0 ), ATAPI_DMADIR = (1 << 2), /* ATAPI data dir:
Quoted 4 lines · Bartlomiej Zolnierkiewicz
Add missing ATA_CMD_* defines to <
linux/ata.h>. Also addATA_EXABYTE_ENABLE_NEST, SETFEATURES_AAM_* and ATA_SMART_* defines while at it.
Quoted 8 lines
Partially based on earlier work by Chris Wedgwood.
Cc Chris Wedgwood <[email protected]>Cc Jeff Garzik <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>--- include/linux/ata.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
ACK patches 1-2, feel free to send upstream alongside patches 3-7
PATCH 3/7 ide: WIN_* -> ATA_CMD_*
* Use ATA_CMD_* defines instead of WIN_* ones.
While at it:
* EXABYTE_ENABLE_NEXT -> ATA_EXABYTE_ENABLE_NEST
* SETFEATURES_{EN,DIS}_WCACHE -> SETFEATURES_WC_{ON,OFF}
* SETFEATURES_{EN,DIS}_AAM -> SETFEATURES_AAM_{ON,OFF}
* SMART_* -> ATA_SMART_*
* Remove stale comment from ide-proc.c.
Partially based on earlier work by Chris Wedgwood.
--- drivers/ide/ide-atapi.c | 2 - drivers/ide/ide-cd.c | 2 - drivers/ide/ide-disk.c | 68 ++++++++++++++++++++++----------------------- drivers/ide/ide-io.c | 27 +++++++++-------- drivers/ide/ide-iops.c | 10 +++--- drivers/ide/ide-probe.c | 34 ++++++++++------------ drivers/ide/ide-proc.c | 10 ------ drivers/ide/ide-taskfile.c | 27 ++++++++++------- drivers/scsi/ide-scsi.c | 2 - 9 files changed, 89 insertions(+), 93 deletions(-)
drivers/ide/ide-atapi.c +1 -1
@@ -303,7 +303,7 @@ ide_startstop_t ide_issue_pc(ide_drive_t/* Issue the packet command */ if (drive->atapi_flags &IDE_AFLAG_DRQ_INTERRUPT ) { -ide_execute_command (drive,WIN_PACKETCMD , handler, +ide_execute_command (drive,ATA_CMD_PACKET , handler, timeout,NULL );return ide_started; }else {
drivers/ide/ide-cd.c +1 -1
@@ -539,7 +539,7 @@ static ide_startstop_t cdrom_start_packe drive->waiting_for_dma =0 ;/* packet command */ -ide_execute_command (drive,WIN_PACKETCMD , handler, +ide_execute_command (drive,ATA_CMD_PACKET , handler,ATAPI_WAIT_PC , cdrom_timer_expiry);return ide_started; }else {
drivers/ide/ide-disk.c +34 -34
146 lines not on this page · raw message
drivers/ide/ide-io.c +14 -13
@@ -188,13 +188,13 @@ static ide_startstop_t ide_start_power_sreturn ide_stopped; }if (ide_id_has_flush_cache_ext (drive->id)) - args->tf.command =WIN_FLUSH_CACHE_EXT ; + args->tf.command =ATA_CMD_FLUSH_EXT ;else - args->tf.command =WIN_FLUSH_CACHE ; + args->tf.command =ATA_CMD_FLUSH ; goto out_do_tf;case idedisk_pm_standby:/* Suspend step 2 (standby) */ - args->tf.command =WIN_STANDBYNOW1 ; + args->tf.command =ATA_CMD_STANDBYNOW1 ; goto out_do_tf;case idedisk_pm_restore_pio:/* Resume step 1 (restore PIO) */
@@ -209,7 +209,7 @@ static ide_startstop_t ide_start_power_sreturn ide_stopped;case idedisk_pm_idle:/* Resume step 2 (idle) */ - args->tf.command =WIN_IDLEIMMEDIATE ; + args->tf.command =ATA_CMD_IDLEIMMEDIATE ; goto out_do_tf;case ide_pm_restore_dma:/* Resume step 3 (restore DMA) */
@@ -380,8 +380,8 @@ static ide_startstop_t ide_ata_error(ide/* err has different meaning on cdrom and tape */ if (err ==ABRT_ERR ) {if (drive->select.b.lba && -/* some newer drives don't support WIN_SPECIFY */ - hwif->tp_ops->read_status (hwif) ==WIN_SPECIFY ) +/* some newer drives don't support ATA_CMD_INIT_DEV_PARAMS */ + hwif->tp_ops->read_status (hwif) ==ATA_CMD_INIT_DEV_PARAMS )return ide_stopped; }else if ((err &BAD_CRC ) ==BAD_CRC ) {/* UDMA crc error, just retry the operation */
@@ -436,7 +436,7 @@ static ide_startstop_t ide_atapi_error(iif (hwif->tp_ops->read_status (hwif) & (BUSY_STAT |DRQ_STAT ))/* force an abort */ - hwif->tp_ops->exec_command (hwif,WIN_IDLEIMMEDIATE ); + hwif->tp_ops->exec_command (hwif,ATA_CMD_IDLEIMMEDIATE );if (rq->errors >=ERROR_MAX ) {ide_kill_rq (drive, rq);
@@ -509,19 +509,19 @@ static void ide_tf_set_specify_cmd(ide_d tf->lbam = drive->cyl; tf->lbah = drive->cyl >>8 ; tf->device = ((drive->head -1 ) | drive->select.all) & ~ATA_LBA ; - tf->command =WIN_SPECIFY ; + tf->command =ATA_CMD_INIT_DEV_PARAMS ; }static void ide_tf_set_restore_cmd (ide_drive_t *drive,struct ide_taskfile *tf) { tf->nsect = drive->sect; - tf->command =WIN_RESTORE ; + tf->command =ATA_CMD_RESTORE ; }static void ide_tf_set_setmult_cmd (ide_drive_t *drive,struct ide_taskfile *tf) { tf->nsect = drive->mult_req; - tf->command =WIN_SETMULT ; + tf->command =ATA_CMD_SET_MULTI ; }static ide_startstop_t ide_disk_special (ide_drive_t *drive)
@@ -584,9 +584,10 @@ static int set_pio_mode_abuse(ide_hwif_t* do_special - issue some special commands * @drive: drive the command is for * -* do_special() is used to issue WIN_SPECIFY, WIN_RESTORE, and WIN_SETMULT -* commands to a drive. It used to do much more, but has been scaled -* back. +* do_special() is used to issue ATA_CMD_INIT_DEV_PARAMS, +* ATA_CMD_RESTORE and ATA_CMD_SET_MULTI commands to a drive. +* +* It used to do much more, but has been scaled back. */ static ide_startstop_t do_special (ide_drive_t *drive)
drivers/ide/ide-iops.c +5 -5
@@ -418,7 +418,7 @@ void ide_fix_driveid(u16 *id)* ide_fixstring() cleans up and (optionally) byte-swaps a text string, * removing leading/trailing blanks and compressing internal blanks. * It is primarily used to tidy up the model name/number fields as -* returned by the WIN_[P]IDENTIFY commands. +* returned by the ATA_CMD_ID_ATA[PI] commands. */ void ide_fixstring (u8 *s,const int bytecount,const int byteswap)
@@ -675,7 +675,7 @@ int ide_driveid_update(ide_drive_t *drivSELECT_MASK (drive,1 ); tp_ops->set_irq (hwif,0 );msleep (50 ); - tp_ops->exec_command (hwif,WIN_IDENTIFY ); + tp_ops->exec_command (hwif,ATA_CMD_ID_ATA ); timeout = jiffies +WAIT_WORSTCASE ; do { if (time_after(jiffies, timeout)) {
@@ -770,7 +770,7 @@ int ide_config_drive_speed(ide_drive_t * tp_ops->tf_load (drive, &task); - tp_ops->exec_command (hwif,WIN_SETFEATURES ); + tp_ops->exec_command (hwif,ATA_CMD_SET_FEATURES );if (drive->quirk_list ==2 ) tp_ops->set_irq (hwif,1 );
@@ -890,7 +890,7 @@ void ide_execute_pkt_cmd(ide_drive_t *drunsigned long flags;spin_lock_irqsave (&ide_lock, flags); - hwif->tp_ops->exec_command (hwif,WIN_PACKETCMD ); + hwif->tp_ops->exec_command (hwif,ATA_CMD_PACKET );ndelay (400 );spin_unlock_irqrestore (&ide_lock, flags); }
@@ -1100,7 +1100,7 @@ static ide_startstop_t do_reset1 (ide_drpre_reset (drive);SELECT_DRIVE (drive);udelay (20 ); - tp_ops->exec_command (hwif,WIN_SRST ); + tp_ops->exec_command (hwif,ATA_CMD_DEV_RESET );ndelay (400 ); hwgroup->poll_timeout = jiffies +WAIT_WORSTCASE ; hwgroup->polling =1 ;
drivers/ide/ide-probe.c +16 -18
@@ -132,10 +132,10 @@ static inline void do_identify (ide_drivide_fix_driveid (id);/* -* WIN_IDENTIFY returns little-endian info, -* WIN_PIDENTIFY *usually* returns little-endian info. +* ATA_CMD_ID_ATA returns little-endian info, +* ATA_CMD_ID_ATAPI *usually* returns little-endian info. */ -if (cmd ==WIN_PIDENTIFY ) { +if (cmd ==ATA_CMD_ID_ATAPI ) {if ((m[0 ] =='N' && m[1 ] =='E' ) ||/* NEC */ (m[0 ] =='F' && m[1 ] =='X' ) ||/* Mitsumi */ (m[0 ] =='P' && m[1 ] =='i' ))/* Pioneer */
@@ -161,7 +161,7 @@ static inline void do_identify (ide_driv/* * Check for an ATAPI device */ -if (cmd ==WIN_PIDENTIFY ) { +if (cmd ==ATA_CMD_ID_ATAPI ) {u8 type = (id[ATA_ID_CONFIG ] >>8 ) &0x1f ;printk (KERN_CONT "ATAPI " );
@@ -277,7 +277,7 @@ static int actual_try_to_identify (ide_d/* set features register for atapi * identify command to be sure of reply */ -if (cmd ==WIN_PIDENTIFY ) { +if (cmd ==ATA_CMD_ID_ATAPI ) {ide_task_t task;memset (&task,0 ,sizeof (task));
@@ -290,7 +290,7 @@ static int actual_try_to_identify (ide_d/* ask drive for ID */ tp_ops->exec_command (hwif, cmd); - timeout = ((cmd ==WIN_IDENTIFY ) ?WAIT_WORSTCASE :WAIT_PIDENTIFY ) /2 ; + timeout = ((cmd ==ATA_CMD_ID_ATA ) ?WAIT_WORSTCASE :WAIT_PIDENTIFY ) /2 ; timeout += jiffies; do { if (time_after(jiffies, timeout)) {
@@ -440,13 +440,13 @@ static int do_probe (ide_drive_t *drive,if (drive->present) {/* avoid waiting for inappropriate probes */ -if ((drive->media != ide_disk) && (cmd ==WIN_IDENTIFY )) +if (drive->media != ide_disk && cmd ==ATA_CMD_ID_ATA )return 4 ; }#ifdef DEBUG printk (KERN_INFO "probing for %s: present=%d, media=%d, probetype=%s\n" , drive->name, drive->present, drive->media, - (cmd ==WIN_IDENTIFY ) ?"ATA" :"ATAPI" ); + (cmd ==ATA_CMD_ID_ATA ) ?"ATA" :"ATAPI" );#endif /* needed for some systems
@@ -470,7 +470,7 @@ static int do_probe (ide_drive_t *drive, stat = tp_ops->read_status (hwif);if (OK_STAT (stat,READY_STAT ,BUSY_STAT ) || - drive->present || cmd ==WIN_PIDENTIFY ) { + drive->present || cmd ==ATA_CMD_ID_ATAPI ) {/* send cmd and wait */ if ((rc =try_to_identify (drive, cmd))) {/* failed: try again */
@@ -482,13 +482,13 @@ static int do_probe (ide_drive_t *drive,if (stat == (BUSY_STAT |READY_STAT ))return 4 ; -if (rc ==1 && cmd ==WIN_PIDENTIFY ) { +if (rc ==1 && cmd ==ATA_CMD_ID_ATAPI ) {printk (KERN_ERR "%s: no response (status = 0x%02x), " "resetting drive\n" , drive->name, stat);msleep (50 );SELECT_DRIVE (drive);msleep (50 ); - tp_ops->exec_command (hwif,WIN_SRST ); + tp_ops->exec_command (hwif,ATA_CMD_DEV_RESET ); (void )ide_busy_sleep (hwif); rc =try_to_identify (drive, cmd); }
@@ -527,7 +527,7 @@ static void enable_nest (ide_drive_t *drSELECT_DRIVE (drive);msleep (50 ); - tp_ops->exec_command (hwif,EXABYTE_ENABLE_NEST ); + tp_ops->exec_command (hwif,ATA_EXABYTE_ENABLE_NEST );if (ide_busy_sleep (hwif)) {printk (KERN_CONT "failed (timeout)\n" );
@@ -544,10 +544,9 @@ static void enable_nest (ide_drive_t *drprintk (KERN_CONT "success\n" );/* if !(success||timed-out) */ -if (do_probe (drive,WIN_IDENTIFY ) >=2 ) { +if (do_probe (drive,ATA_CMD_ID_ATA ) >=2 )/* look for ATAPI device */ - (void )do_probe (drive,WIN_PIDENTIFY ); - } + (void )do_probe (drive,ATA_CMD_ID_ATAPI ); }/**
@@ -590,10 +589,9 @@ static inline u8 probe_for_drive (ide_drif (!drive->noprobe) {/* if !(success||timed-out) */ -if (do_probe (drive,WIN_IDENTIFY ) >=2 ) { +if (do_probe (drive,ATA_CMD_ID_ATA ) >=2 )/* look for ATAPI device */ - (void )do_probe (drive,WIN_PIDENTIFY ); - } + (void )do_probe (drive,ATA_CMD_ID_ATAPI );if (!drive->present)/* drive not found */ return 0 ;
drivers/ide/ide-proc.c +1 -9
@@ -12,14 +12,6 @@* "settings" files. e.g. "cat /proc/ide0/hda/settings" * To write a new value "val" into a specific setting "name", use: * echo "name:val" >/proc/ide/ide0/hda/settings -* -* Also useful, "cat /proc/ide0/hda/[identify, smart_values, -* smart_thresholds, capabilities]" will issue an IDENTIFY / -* PACKET_IDENTIFY / SMART_READ_VALUES / SMART_READ_THRESHOLDS / -* SENSE CAPABILITIES command to /dev/hda, and then dump out the -* returned data as 256 16-bit words. The "hdparm" utility will -* be updated someday soon to use this mechanism. -* */ #include <linux/module.h>
@@ -349,7 +341,7 @@ static int set_xfer_rate (ide_drive_t *dreturn -EINVAL ;memset (&task,0 ,sizeof (task)); - task.tf.command =WIN_SETFEATURES ; + task.tf.command =ATA_CMD_SET_FEATURES ; task.tf.feature =SETFEATURES_XFER ; task.tf.nsect = (u8 )arg; task.tf_flags = IDE_TFLAG_OUT_FEATURE | IDE_TFLAG_OUT_NSECT |
drivers/ide/ide-taskfile.c +16 -11
@@ -44,9 +44,9 @@ int taskfile_lib_get_identify (ide_drivememset (&args,0 ,sizeof (ide_task_t)); args.tf.nsect =0x01 ;if (drive->media == ide_disk) - args.tf.command =WIN_IDENTIFY ; + args.tf.command =ATA_CMD_ID_ATA ;else - args.tf.command =WIN_PIDENTIFY ; + args.tf.command =ATA_CMD_ID_ATAPI ; args.tf_flags =IDE_TFLAG_TF |IDE_TFLAG_DEVICE ; args.data_phase =TASKFILE_IN ;return ide_raw_taskfile (drive, &args, buf,1 );
@@ -99,12 +99,17 @@ ide_startstop_t do_rw_taskfile (ide_drivcase TASKFILE_NO_DATA :if (handler ==NULL ) handler = task_no_data_intr; -/* WIN_{SPECIFY,RESTORE,SETMULT} use custom handlers */ if (task->tf_flags &IDE_TFLAG_CUSTOM_HANDLER ) {switch (tf->command) { -case WIN_SPECIFY : handler = set_geometry_intr;break ; -case WIN_RESTORE : handler = recal_intr;break ; -case WIN_SETMULT : handler = set_multmode_intr;break ; +case ATA_CMD_INIT_DEV_PARAMS : + handler = set_geometry_intr; +break ; +case ATA_CMD_RESTORE : + handler = recal_intr; +break ; +case ATA_CMD_SET_MULTI : + handler = set_multmode_intr; +break ; } } ide_execute_command(drive, tf->command, handler,
@@ -121,7 +126,7 @@ ide_startstop_t do_rw_taskfile (ide_drivEXPORT_SYMBOL_GPL (do_rw_taskfile);/* -* set_multmode_intr() is invoked on completion of a WIN_SETMULT cmd. +* set_multmode_intr() is invoked on completion of a ATA_CMD_SET_MULTI cmd. */ static ide_startstop_t set_multmode_intr (ide_drive_t *drive) {
@@ -142,7 +147,7 @@ static ide_startstop_t set_multmode_intr }/* -* set_geometry_intr() is invoked on completion of a WIN_SPECIFY cmd. +* set_geometry_intr() is invoked on completion of a ATA_CMD_INIT_DEV_PARAMS cmd. */ static ide_startstop_t set_geometry_intr (ide_drive_t *drive) {
@@ -170,7 +175,7 @@ static ide_startstop_t set_geometry_intr }/* -* recal_intr() is invoked on completion of a WIN_RESTORE (recalibrate) cmd. +* recal_intr() is invoked on completion of a ATA_CMD_RESTORE (recalibrate) cmd. */ static ide_startstop_t recal_intr (ide_drive_t *drive) {
@@ -747,7 +752,7 @@ int ide_cmd_ioctl (ide_drive_t *drive, umemset (&tfargs,0 ,sizeof (ide_task_t)); tf->feature = args[2 ]; -if (args[0 ] ==WIN_SMART ) { +if (args[0 ] ==ATA_CMD_SMART ) { tf->nsect = args[3 ]; tf->lbal = args[1 ]; tf->lbam =0x4f ;
@@ -769,7 +774,7 @@ int ide_cmd_ioctl (ide_drive_t *drive, ureturn -ENOMEM ; } - if (tf->command == WIN_SETFEATURES && + if (tf->command == ATA_CMD_SET_FEATURES && tf->feature == SETFEATURES_XFER && tf->nsect >= XFER_SW_DMA_0 && (id[ATA_ID_UDMA_MODES] ||
drivers/scsi/ide-scsi.c +1 -1
@@ -245,7 +245,7 @@ idescsi_atapi_error(ide_drive_t *drive,if (hwif->tp_ops->read_status (hwif) & (BUSY_STAT |DRQ_STAT ))/* force an abort */ - hwif->tp_ops->exec_command (hwif,WIN_IDLEIMMEDIATE ); + hwif->tp_ops->exec_command (hwif,ATA_CMD_IDLEIMMEDIATE ); rq->errors++;
Quoted 5 lines · Bartlomiej Zolnierkiewicz
Add missing ATA_CMD_* defines to <
linux/ata.h>. Also addATA_EXABYTE_ENABLE_NEST, SETFEATURES_AAM_* and ATA_SMART_* defines while at it.Partially based on earlier work by Chris Wedgwood.
[...]
Quoted 8 lines · Bartlomiej Zolnierkiewicz
* Use ATA_CMD_* defines instead of WIN_* ones.
While at it:
*
EXABYTE_ENABLE_NEXT->ATA_EXABYTE_ENABLE_NEST* SETFEATURES_{EN,DIS}_WCACHE -> SETFEATURES_WC_{ON,OFF}
Quoted 7 lines
* SETFEATURES_{EN,DIS}_AAM -> SETFEATURES_AAM_{ON,OFF}
* SMART_* -> ATA_SMART_*
* Remove stale comment from
ide-proc.c.Partially based on earlier work by Chris Wedgwood.
ACK/signoff from me (in so far as it's relevant, my original patches are so old I'm sure Bart probably had to so it almost all again).
Quoted 22 lines · Chris Wedgwood
Quoted 5 lines · Bartlomiej Zolnierkiewicz
Add missing ATA_CMD_* defines to <
linux/ata.h>. Also addATA_EXABYTE_ENABLE_NEST, SETFEATURES_AAM_* and ATA_SMART_* defines while at it.Partially based on earlier work by Chris Wedgwood.
[...]
Quoted 10 lines · Bartlomiej Zolnierkiewicz
* Use ATA_CMD_* defines instead of WIN_* ones.
While at it:
*
EXABYTE_ENABLE_NEXT->ATA_EXABYTE_ENABLE_NEST* SETFEATURES_{EN,DIS}_WCACHE -> SETFEATURES_WC_{ON,OFF}
* SETFEATURES_{EN,DIS}_AAM -> SETFEATURES_AAM_{ON,OFF}
Quoted 8 lines
Quoted 5 lines
* SMART_* -> ATA_SMART_*
* Remove stale comment from
ide-proc.c.Partially based on earlier work by Chris Wedgwood.
ACK/signoff from me (in so far as it's relevant, my original patches are so old I'm sure Bart probably had to so it almost all again).
Thanks, added your ACK to #1/#3 and Jeff's to #1/#2.