From: Takashi Iwai Subject: Re: [PATCH 1/1] Added patch file and Makefile entry for CA0132 HDA codec Date: Fri, 03 Jun 2011 18:20:13 +0200 Message-ID: References: <1307045665-8084-1-git-send-email-ian_minett@creativelabs.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id A5CED24420 for ; Fri, 3 Jun 2011 18:20:17 +0200 (CEST) In-Reply-To: <1307045665-8084-1-git-send-email-ian_minett@creativelabs.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: alsa-devel-bounces@alsa-project.org Errors-To: alsa-devel-bounces@alsa-project.org To: Ian Minett Cc: alsa-devel@alsa-project.org List-Id: alsa-devel@alsa-project.org At Thu, 2 Jun 2011 13:14:25 -0700, Ian Minett wrote: > > Attached is a patch that adds support for the CA0132 HDA codec, > creating patch_ca0132.c in pci/hda. Thanks for the patch! > It also adds an entry to the pci/hda makefile that builds the codec > when SND_HDA_CODEC_CA0132 is defined. However, we are not sure > where to add the KConfig entry for SND_HDA_CODEC_CA0132, which is > below, or if we should even create such an entry for this > submission. Yes, at best, please include Kconfig change into the same patch. But I see now you are patching alsa-driver code instead of kernel tree, so it's not too trivial indeed. I recommend you to patch your driver in the kernel tree first, check it works, then submit the patch, instead of modifying alsa-driver tree. We can change alsa-driver tree later for the new stuff. About the code, see some quick reviews below. > +/* > + * CA0132 chip access stuffs > + */ > +static int chipio_acquire_mutex(struct hda_codec *codec) > +{ > + struct ca0132_spec *spec = codec->spec; > + > + mutex_lock(&spec->chipio_mutex); > + return 0; > +} > + > +static int chipio_release_mutex(struct hda_codec *codec) > +{ > + struct ca0132_spec *spec = codec->spec; > + > + mutex_unlock(&spec->chipio_mutex); > + return 0; > +} Avoid to introduce such wrappers. It's more readable to get spec in the function and call mutex_lock/unlock appropriately, in general. > +/* > + * Write chip address through the vendor widget -- NOT protected by the Mutex! > + */ > +static int chipio_write_address(struct hda_codec *codec, > + unsigned int chip_addx) > +{ > + unsigned int res = 0; > + int retry = 100; > + > + /* send low 16 bits of the address */ > + do { > + res = snd_hda_codec_read(codec, WIDGET_CHIP_CTRL, 0, > + HDA_SHORT_CMD_VENDOR_CHIP_IO_ADDRESS_LOW, > + chip_addx & 0xffff); > + retry--; > + } while (res != HDA_STATUS_VENDOR_CHIP_IO_OK && retry); 100 retries look fairly much. Do we really need so long access? thanks, Takashi