ASoC: msm: avoid negative time stamp check
Time stamp is unsigned. There is no need to check for
negative value.
Change-Id: I15e380f81e46908f6a9fe8d29c174de1b7c33173
CRs-fixed: 423372
Signed-off-by: Patrick Lai <plai@codeaurora.org>
diff --git a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c b/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
index ba66358..a03f6eb 100644
--- a/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
+++ b/arch/arm/mach-msm/qdsp6v2/audio_lpa.c
@@ -2,7 +2,7 @@
*
* Copyright (C) 2008 Google, Inc.
* Copyright (C) 2008 HTC Corporation
- * Copyright (c) 2009-2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
@@ -744,8 +744,8 @@
pr_debug("%s: AUDIO_GET_STATS cmd\n", __func__);
memset(&stats, 0, sizeof(stats));
- timestamp = q6asm_get_session_time(audio->ac);
- if (timestamp < 0) {
+ rc = q6asm_get_session_time(audio->ac, ×tamp);
+ if (rc < 0) {
pr_err("%s: Get Session Time return value =%lld\n",
__func__, timestamp);
return -EAGAIN;
diff --git a/include/sound/q6asm-v2.h b/include/sound/q6asm-v2.h
index cf0c4d4..ba340f6 100644
--- a/include/sound/q6asm-v2.h
+++ b/include/sound/q6asm-v2.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -294,7 +294,7 @@
/* Enable Mute/unmute flag */
int q6asm_set_mute(struct audio_client *ac, int muteflag);
-uint64_t q6asm_get_session_time(struct audio_client *ac);
+int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
/* Client can set the IO mode to either AIO/SIO mode */
int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
diff --git a/include/sound/q6asm.h b/include/sound/q6asm.h
index 579f5e1..b5ab268 100644
--- a/include/sound/q6asm.h
+++ b/include/sound/q6asm.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -320,7 +320,7 @@
/* Enable Mute/unmute flag */
int q6asm_set_mute(struct audio_client *ac, int muteflag);
-uint64_t q6asm_get_session_time(struct audio_client *ac);
+int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp);
/* Client can set the IO mode to either AIO/SIO mode */
int q6asm_set_io_mode(struct audio_client *ac, uint32_t mode);
diff --git a/sound/soc/msm/msm-compr-q6.c b/sound/soc/msm/msm-compr-q6.c
index 2725299..e36a8ca 100644
--- a/sound/soc/msm/msm-compr-q6.c
+++ b/sound/soc/msm/msm-compr-q6.c
@@ -1054,11 +1054,10 @@
pr_debug("SNDRV_COMPRESS_TSTAMP\n");
memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
- timestamp = q6asm_get_session_time(prtd->audio_client);
- if (timestamp < 0) {
- pr_err("%s: Get Session Time return value =%lld\n",
- __func__, timestamp);
- return -EAGAIN;
+ rc = q6asm_get_session_time(prtd->audio_client, ×tamp);
+ if (rc < 0) {
+ pr_err("%s: fail to get session tstamp\n", __func__);
+ return rc;
}
temp = (timestamp * 2 * runtime->channels);
temp = temp * (runtime->rate/1000);
diff --git a/sound/soc/msm/msm-pcm-lpa.c b/sound/soc/msm/msm-pcm-lpa.c
index 5de8a4a..bd9b486 100644
--- a/sound/soc/msm/msm-pcm-lpa.c
+++ b/sound/soc/msm/msm-pcm-lpa.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -561,11 +561,10 @@
pr_debug("SNDRV_COMPRESS_TSTAMP\n");
memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
- timestamp = q6asm_get_session_time(prtd->audio_client);
- if (timestamp < 0) {
- pr_err("%s: Get Session Time return value =%lld\n",
- __func__, timestamp);
- return -EAGAIN;
+ rc = q6asm_get_session_time(prtd->audio_client, ×tamp);
+ if (rc < 0) {
+ pr_err("%s: fail to get session tstamp\n", __func__);
+ return rc;
}
temp = (timestamp * 2 * runtime->channels);
temp = temp * (runtime->rate/1000);
diff --git a/sound/soc/msm/qdsp6/q6asm.c b/sound/soc/msm/qdsp6/q6asm.c
index a053063..82b2188 100644
--- a/sound/soc/msm/qdsp6/q6asm.c
+++ b/sound/soc/msm/qdsp6/q6asm.c
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2010-2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
@@ -3651,13 +3650,13 @@
return -EINVAL;
}
-uint64_t q6asm_get_session_time(struct audio_client *ac)
+int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp)
{
struct apr_hdr hdr;
int rc;
- if (!ac || ac->apr == NULL) {
- pr_err("APR handle NULL\n");
+ if (!ac || ac->apr == NULL || tstamp == NULL) {
+ pr_err("APR handle or tstamp NULL\n");
return -EINVAL;
}
q6asm_add_hdr(ac, &hdr, sizeof(hdr), FALSE);
@@ -3679,7 +3678,9 @@
__func__);
goto fail_cmd;
}
- return ac->time_stamp;
+
+ *tstamp = ac->time_stamp;
+ return 0;
fail_cmd:
return -EINVAL;
diff --git a/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
index 5b7a740..68f12e0 100644
--- a/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-compr-q6-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -524,8 +524,8 @@
pr_debug("SNDRV_COMPRESS_TSTAMP\n");
memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
- timestamp = q6asm_get_session_time(prtd->audio_client);
- if (timestamp < 0) {
+ rc = q6asm_get_session_time(prtd->audio_client, ×tamp);
+ if (rc < 0) {
pr_err("%s: Get Session Time return value =%lld\n",
__func__, timestamp);
return -EAGAIN;
diff --git a/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c b/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
index 70dbb6a..a6c8f16 100644
--- a/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
+++ b/sound/soc/msm/qdsp6v2/msm-pcm-lpa-v2.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -502,8 +502,8 @@
pr_debug("SNDRV_COMPRESS_TSTAMP\n");
memset(&tstamp, 0x0, sizeof(struct snd_compr_tstamp));
- timestamp = q6asm_get_session_time(prtd->audio_client);
- if (timestamp < 0) {
+ rc = q6asm_get_session_time(prtd->audio_client, ×tamp);
+ if (rc < 0) {
pr_err("%s: Get Session Time return value =%lld\n",
__func__, timestamp);
return -EAGAIN;
diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c
index 6d76490..e60691b 100644
--- a/sound/soc/msm/qdsp6v2/q6asm.c
+++ b/sound/soc/msm/qdsp6v2/q6asm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
* Author: Brian Swetland <swetland@google.com>
*
* This software is licensed under the terms of the GNU General Public
@@ -3191,13 +3191,13 @@
return -EINVAL;
}
-uint64_t q6asm_get_session_time(struct audio_client *ac)
+int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp)
{
struct apr_hdr hdr;
int rc;
- if (!ac || ac->apr == NULL) {
- pr_err("APR handle NULL\n");
+ if (!ac || ac->apr == NULL || tstamp == NULL) {
+ pr_err("APR handle NULL or tstamp NULL\n");
return -EINVAL;
}
q6asm_add_hdr(ac, &hdr, sizeof(hdr), TRUE);
@@ -3219,7 +3219,9 @@
__func__);
goto fail_cmd;
}
- return ac->time_stamp;
+
+ *tstamp = ac->time_stamp;
+ return 0;
fail_cmd:
return -EINVAL;