Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755558AbdLORKO (ORCPT ); Fri, 15 Dec 2017 12:10:14 -0500 Received: from mx2.suse.de ([195.135.220.15]:41770 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755222AbdLORKL (ORCPT ); Fri, 15 Dec 2017 12:10:11 -0500 Date: Fri, 15 Dec 2017 18:10:09 +0100 Message-ID: From: Takashi Iwai To: Richard Cochran Cc: Sagar Arun Kamble , linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Vinod Koul , Thomas Gleixner Subject: Re: [alsa-devel] [PATCH 15/27] ALSA: hda - Use timecounter_initialize interface In-Reply-To: <20171215165125.avkz25eek56i5md4@localhost> References: <1513323522-15021-1-git-send-email-sagar.a.kamble@intel.com> <1513323522-15021-16-git-send-email-sagar.a.kamble@intel.com> <20171215165125.avkz25eek56i5md4@localhost> 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1330 Lines: 42 On Fri, 15 Dec 2017 17:51:25 +0100, Richard Cochran wrote: > > On Fri, Dec 15, 2017 at 12:10:47PM +0100, Takashi Iwai wrote: > > > > - struct cyclecounter *cc = &azx_dev->tc.cc; > > > > - cc->read = azx_cc_read; > > > - cc->mask = CLOCKSOURCE_MASK(32); > > > > - cc->mult = 125; /* saturation after 195 years */ > > > - cc->shift = 0; > > I want to get away from this mess of open coded structure > initialization and use a proper functional interface instead. I agree that a proper functional interface would be better, too. But not a form like foo(501, 21, 10, 499, 5678). In C syntax, you may more easily pass a wrong value than open codes. > > > nsec = 0; /* audio time is elapsed time since trigger */ > > > - timecounter_init(tc, nsec); > > > + timecounter_initialize(tc, > > > + azx_cc_read, > > > + CLOCKSOURCE_MASK(32), > > > + 125, /* saturation after 195 years */ > > > + 0, > > > + nsec); > > > > Hmm, a function with so many arguments is difficult to remember and is > > often error-prone. By this transition, it becomes harder to read > > through. > > Please suggest a better way. I have no good idea ATM, sorry. Or can we provide simpler versions for covering some defaults? At least reducing the number of arguments would make things easier. Takashi