Butterfly / Stout: Change the return code of 'mosys storage set phy_speed'.
'mosys storage set phy_speed' is used for SanDisk-U100 PHY tuning.
We add it into factory test but it shows failure for non-SanDisk-U100 SSDs.
Fix the failure by changing the default return code to 0.
TEST=Manual.
1. "mosys storage set phy_speed SATA3 -vvv" commands on Butterfly.
2. "echo $?", it should show 0.
BUG=chrome-os-partner:18647
BRANCH=butterfly, stout.
Change-Id: I62f0ab8cd2f18be1de9bd6e52150d06651b8a6a6
Reviewed-on: https://gerrit.chromium.org/gerrit/47556
Tested-by: Bowgo Tsai <bowgotsai@chromium.org>
Reviewed-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Commit-Queue: Bowgo Tsai <bowgotsai@chromium.org>
diff --git a/core/command/storage.c b/core/command/storage.c
index cdf8816..693ecfe 100644
--- a/core/command/storage.c
+++ b/core/command/storage.c
@@ -114,6 +114,7 @@
{
enum storage_phy_speed phy_speed;
char *phy = NULL;
+ int ret;
if (argc == 1)
phy = argv[0];
@@ -137,7 +138,12 @@
return -1;
}
- return intf->cb->storage->set_phy_speed(intf, phy_speed);
+ ret = intf->cb->storage->set_phy_speed(intf, phy_speed);
+ /* Don't return error if no supported is found. */
+ if (ret == -ENOTSUP)
+ return 0;
+ else
+ return ret;
}
struct platform_cmd storage_print_cmds[] = {
diff --git a/platform/hp/butterfly/storage.c b/platform/hp/butterfly/storage.c
index 48a34ab..9e4f058 100644
--- a/platform/hp/butterfly/storage.c
+++ b/platform/hp/butterfly/storage.c
@@ -29,6 +29,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <errno.h>
+
#include "mosys/alloc.h"
#include "mosys/log.h"
#include "mosys/platform.h"
@@ -88,13 +90,15 @@
enum storage_phy_speed phy_speed)
{
char *model_name = (char*)butterfly_get_ssd_model_name(intf);
- int ret = -1;
+ int ret;
lprintf(LOG_DEBUG, "%s: SSD model name %s\n", __func__, model_name);
if (strcmp(model_name, SANDISK_U100_MODEL_NAME) == 0 ||
strcmp(model_name, SANDISK_SDSA5GK_MODEL_NAME) == 0)
ret = sandisk_u100_set_phy_speed(BUTTERFLY_SSD_DEVICE_PATH,
phy_speed);
+ else
+ ret = -ENOTSUP;
if (model_name != NULL)
free(model_name);
diff --git a/platform/lenovo/stout/storage.c b/platform/lenovo/stout/storage.c
index 9df4ea3..d3c8d3e 100644
--- a/platform/lenovo/stout/storage.c
+++ b/platform/lenovo/stout/storage.c
@@ -29,6 +29,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <errno.h>
+
#include "mosys/alloc.h"
#include "mosys/log.h"
#include "mosys/platform.h"
@@ -86,12 +88,14 @@
enum storage_phy_speed phy_speed)
{
char *model_name = (char*)stout_get_ssd_model_name(intf);
- int ret = -1;
+ int ret;
lprintf(LOG_DEBUG, "%s: SSD model name %s\n", __func__, model_name);
if (strcmp(model_name, SANDISK_U100_MODEL_NAME) == 0)
ret = sandisk_u100_set_phy_speed(STOUT_SSD_DEVICE_PATH,
phy_speed);
+ else
+ ret = -ENOTSUP;
if (model_name != NULL)
free(model_name);