From patchwork Tue Feb 21 08:29:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feng Wei X-Patchwork-Id: 6857 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 0C61623DEE for ; Tue, 21 Feb 2012 08:29:36 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id AAF04A185EF for ; Tue, 21 Feb 2012 08:29:35 +0000 (UTC) Received: by iabz7 with SMTP id z7so12047790iab.11 for ; Tue, 21 Feb 2012 00:29:35 -0800 (PST) Received: from mr.google.com ([10.42.131.129]) by 10.42.131.129 with SMTP id z1mr25508388ics.53.1329812975112 (num_hops = 1); Tue, 21 Feb 2012 00:29:35 -0800 (PST) Received: by 10.42.131.129 with SMTP id z1mr20354352ics.53.1329812975068; Tue, 21 Feb 2012 00:29:35 -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.231.11.10 with SMTP id r10csp83089ibr; Tue, 21 Feb 2012 00:29:33 -0800 (PST) Received: by 10.229.136.144 with SMTP id r16mr15674623qct.62.1329812972647; Tue, 21 Feb 2012 00:29:32 -0800 (PST) Received: from mail-qw0-f49.google.com (mail-qw0-f49.google.com [209.85.216.49]) by mx.google.com with ESMTPS id hl3si20838197qab.87.2012.02.21.00.29.32 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Feb 2012 00:29:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.49 is neither permitted nor denied by best guess record for domain of feng.wei@linaro.org) client-ip=209.85.216.49; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.49 is neither permitted nor denied by best guess record for domain of feng.wei@linaro.org) smtp.mail=feng.wei@linaro.org Received: by qadc14 with SMTP id c14so6944117qad.15 for ; Tue, 21 Feb 2012 00:29:32 -0800 (PST) Received-SPF: pass (google.com: domain of feng.wei@linaro.org designates 10.229.137.66 as permitted sender) client-ip=10.229.137.66; Received: from mr.google.com ([10.229.137.66]) by 10.229.137.66 with SMTP id v2mr18217423qct.35.1329812972351 (num_hops = 1); Tue, 21 Feb 2012 00:29:32 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.137.66 with SMTP id v2mr15347816qct.35.1329812972197; Tue, 21 Feb 2012 00:29:32 -0800 (PST) Received: by 10.229.121.201 with HTTP; Tue, 21 Feb 2012 00:29:32 -0800 (PST) Date: Tue, 21 Feb 2012 16:29:32 +0800 Message-ID: Subject: [alsa-devel][PATCH] UCM: check device/modifier status before update From: Feng Wei To: David Henningsson , alsa-devel@alsa-project.org Cc: Patch Tracking X-Gm-Message-State: ALoCoQkZsLPe5LceqlOcmiWcVwY5GYC25F974yKHw5g6KvDFe0OLKQC8fvfRlTM1nerdpPfJBSex Index: alsa-lib-1.0.25/src/ucm/main.c =================================================================== --- alsa-lib-1.0.25.orig/src/ucm/main.c 2012-02-21 14:37:25.465485002 +0800 +++ alsa-lib-1.0.25/src/ucm/main.c 2012-02-21 14:38:41.309485042 +0800 @@ -1468,12 +1468,16 @@ int enable) { struct use_case_device *device; + long status; if (uc_mgr->active_verb == NULL) return -ENOENT; device = find_device(uc_mgr, uc_mgr->active_verb, device_name, 1); if (device == NULL) return -ENOENT; + status = device_status(uc_mgr, device_name); + if ((!status && !enable) || (status && enable)) + return 0; return set_device(uc_mgr, device, enable); } @@ -1482,6 +1486,7 @@ int enable) { struct use_case_modifier *modifier; + long status; if (uc_mgr->active_verb == NULL) return -ENOENT; @@ -1489,6 +1494,9 @@ modifier = find_modifier(uc_mgr, uc_mgr->active_verb, modifier_name, 1); if (modifier == NULL) return -ENOENT; + status = modifier_status(uc_mgr, modifier_name); + if ((!status && !enable) || (status && enable)) + return 0; return set_modifier(uc_mgr, modifier, enable); }