From 75d58e71e83e609c76d60263a44532c822fa45a4 Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Wed, 10 Feb 2010 19:50:36 +0000 Subject: [PATCH] Fix SCT temperature table commands on big endian CPUs. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@3064 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/CHANGELOG | 2 ++ smartmontools/NEWS | 1 + smartmontools/atacmds.cpp | 16 ++++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 87d2b9d0a..d582fc824 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -43,6 +43,8 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] Fix SCT temperature table commands on big endian CPUs. + [MS] drivedb.h updates: - more Seagate Momentus 5400.6 drives - HP 500GB drive MM0500EANCR diff --git a/smartmontools/NEWS b/smartmontools/NEWS index 35fee538a..b01a77a83 100644 --- a/smartmontools/NEWS +++ b/smartmontools/NEWS @@ -13,6 +13,7 @@ Summary: smartmontools release 5.40 - Drive database is in a separate source file 'drivedb.h' which can be downloaded from SVN. - smartd libcap-ng support, option '-C, --capabilities'. +- Fix SCT temperature table commands on big endian CPUs. Date 2010-01-28 Summary: smartmontools release 5.39.1 diff --git a/smartmontools/atacmds.cpp b/smartmontools/atacmds.cpp index 1abc9f9e8..68f4c5d09 100644 --- a/smartmontools/atacmds.cpp +++ b/smartmontools/atacmds.cpp @@ -2214,6 +2214,13 @@ int ataReadSCTTempHist(ata_device * device, ata_sct_temperature_history_table * cmd.function_code = 1; // Read table cmd.table_id = 2; // Temperature History Table + // swap endian order if needed + if (isbigendian()) { + swapx(&cmd.action_code); + swapx(&cmd.function_code); + swapx(&cmd.table_id); + } + // write command via SMART log page 0xe0 if (smartcommandhandler(device, WRITE_LOG, 0xe0, (char *)&cmd)){ syserror("Error Write SCT Data Table command failed"); @@ -2276,6 +2283,15 @@ int ataSetSCTTempInterval(ata_device * device, unsigned interval, bool persisten cmd.state = interval; cmd.option_flags = (persistent ? 0x01 : 0x00); + // swap endian order if needed + if (isbigendian()) { + swapx(&cmd.action_code); + swapx(&cmd.function_code); + swapx(&cmd.feature_code); + swapx(&cmd.state); + swapx(&cmd.option_flags); + } + // write command via SMART log page 0xe0 if (smartcommandhandler(device, WRITE_LOG, 0xe0, (char *)&cmd)){ syserror("Error Write SCT Feature Control Command failed"); -- GitLab