From patchwork Wed Nov 21 09:55:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13037 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 4BAFF23FC0 for ; Wed, 21 Nov 2012 10:02:12 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id CE51EA19641 for ; Wed, 21 Nov 2012 10:02:11 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so2360964iag.11 for ; Wed, 21 Nov 2012 02:02:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=IjmDAnQGjP4NtOjxhAJEGP9Q3XF3ImEQtWIc3ibLS1I=; b=DJLJoGFeZ7xO+is0dtlOANRAFXyVxoxnlmpvTNaYDOZq5yBPvOFAZQmLMa+SR5we5G 0/sEsujPcZ3UteMIkhrkYpFNlJiCODGErNSCrG0heoaU+rqyBZl3FG092knmfj61UL7u L6pTTDEboyg7pHHTLyHA6bObClY7SdJHxgieFXnhqVvdeEO4NG81dPcTHtDL4zsKyKKG J6MHRNbHANJndWTu/WVRb2sit5cUy9wZT63pVAs3GTJJpKr9SLb/szWe/HyXr6JEcF0h qyNMkvOT7qINpwDM4E3X/JQyYTBuwoeuhoOOQ6Yuj3kR69eTF1SePCoSEyBjWARLDijD KDGQ== Received: by 10.50.187.197 with SMTP id fu5mr12888550igc.70.1353492131282; Wed, 21 Nov 2012 02:02:11 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp3962igt; Wed, 21 Nov 2012 02:02:10 -0800 (PST) Received: by 10.68.209.136 with SMTP id mm8mr51542166pbc.146.1353492129150; Wed, 21 Nov 2012 02:02:09 -0800 (PST) Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by mx.google.com with ESMTPS id p7si21634876pay.177.2012.11.21.02.02.08 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 02:02:09 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.43; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.43 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pa0-f43.google.com with SMTP id fb10so2417069pad.30 for ; Wed, 21 Nov 2012 02:02:08 -0800 (PST) Received: by 10.68.234.167 with SMTP id uf7mr51639293pbc.20.1353492128567; Wed, 21 Nov 2012 02:02:08 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id nm2sm9681552pbc.43.2012.11.21.02.02.05 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 02:02:08 -0800 (PST) From: Sachin Kamat To: alsa-devel@alsa-project.org Cc: tiwai@suse.de, perex@perex.cz, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/1] ALSA: usb-audio: Return meaningful error codes instead of -1 in format.c Date: Wed, 21 Nov 2012 15:25:56 +0530 Message-Id: <1353491756-27558-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQkbSJ+LvFslGRDAfiwpzplCQXT2XVyq8IIXNkhGl3c3/y2DrflkzxDuFqiSpBshcwcRGa7V Also, silences the following smatch warning: sound/usb/format.c:170 parse_audio_format_rates_v1() warn: returning -1 instead of -ENOMEM is sloppy Signed-off-by: Sachin Kamat --- Build tested and based on linux-next 20121115. --- sound/usb/format.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sound/usb/format.c b/sound/usb/format.c index ddfef57..e831ee4 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c @@ -155,7 +155,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof if (fmt[0] < offset + 1 + 3 * (nr_rates ? nr_rates : 2)) { snd_printk(KERN_ERR "%d:%u:%d : invalid UAC_FORMAT_TYPE desc\n", chip->dev->devnum, fp->iface, fp->altsetting); - return -1; + return -EINVAL; } if (nr_rates) { @@ -167,7 +167,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); if (fp->rate_table == NULL) { snd_printk(KERN_ERR "cannot malloc\n"); - return -1; + return -ENOMEM; } fp->nr_rates = 0; @@ -198,7 +198,7 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof } if (!fp->nr_rates) { hwc_debug("All rates were zero. Skipping format!\n"); - return -1; + return -EINVAL; } } else { /* continuous rates */ @@ -383,7 +383,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, fp->formats = parse_audio_format_i_type(chip, fp, format, fmt, protocol); if (!fp->formats) - return -1; + return -EINVAL; } /* gather possible sample rates */ @@ -409,7 +409,7 @@ static int parse_audio_format_i(struct snd_usb_audio *chip, if (fp->channels < 1) { snd_printk(KERN_ERR "%d:%u:%d : invalid channels %d\n", chip->dev->devnum, fp->iface, fp->altsetting, fp->channels); - return -1; + return -EINVAL; } return ret;