On Fri, 15 Dec 2017 17:51:25 +0100,Thought about specifying 1. cyclecounter read func 2. frequency 3. width of counter as parameters here
Richard Cochran wrote:
On Fri, Dec 15, 2017 at 12:10:47PM +0100, Takashi Iwai wrote:I agree that a proper functional interface would be better, too.
I want to get away from this mess of open coded structure- 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;
initialization and use a proper functional interface instead.
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.
I have no good idea ATM, sorry.Please suggest a better way.nsec = 0; /* audio time is elapsed time since trigger */Hmm, a function with so many arguments is difficult to remember and is
- timecounter_init(tc, nsec);
+ timecounter_initialize(tc,
+ azx_cc_read,
+ CLOCKSOURCE_MASK(32),
+ 125, /* saturation after 195 years */
+ 0,
+ nsec);
often error-prone. By this transition, it becomes harder to read
through.
Or can we provide simpler versions for covering some defaults? At
least reducing the number of arguments would make things easier.
Takashi