From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4602DC4361B for ; Wed, 9 Dec 2020 08:33:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF34223B97 for ; Wed, 9 Dec 2020 08:33:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727552AbgLIIdn (ORCPT ); Wed, 9 Dec 2020 03:33:43 -0500 Received: from mx2.suse.de ([195.135.220.15]:51364 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgLIIdn (ORCPT ); Wed, 9 Dec 2020 03:33:43 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 0507BAC94; Wed, 9 Dec 2020 08:33:01 +0000 (UTC) Date: Wed, 09 Dec 2020 09:33:00 +0100 Message-ID: From: Takashi Iwai To: Connor McAdams Cc: Jaroslav Kysela , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/5] ALSA: hda/ca0132 - Add 8051 exram helper functions. In-Reply-To: <20201208212546.428392-4-conmanx360@gmail.com> References: <20201208212546.428392-1-conmanx360@gmail.com> <20201208212546.428392-4-conmanx360@gmail.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 08 Dec 2020 22:25:43 +0100, Connor McAdams wrote: > > +static void chipio_8051_write_exram(struct hda_codec *codec, > + unsigned int addr, unsigned int data, bool use_mutex) > +{ > + struct ca0132_spec *spec = codec->spec; > + unsigned int tmp; > + > + if (use_mutex) > + mutex_lock(&spec->chipio_mutex); This can be better to split to two functions: a core helper function without mutex and a helper function to take the mutex lock and call the former function. Applying the lock conditionally is often error-prone. thanks, Takashi