[alsa-devel] [PATCH] ASoC: MAX9860: new driver

Mark Brown broonie at kernel.org
Thu May 12 12:53:01 CEST 2016


On Thu, May 12, 2016 at 10:24:11AM +0200, Peter Rosin wrote:
> On 2016-05-11 22:53, Mark Brown wrote:

> > The code needs to make it clear that this is an intentional fallthrough,
> > an explicit default case would help a lot.

> There was this comment above the two if statements leading into the switch
> statement:

> +	/*
> +	 * Check if Integer Clock Mode is possible, but avoid it in slave mode
> +	 * since we then do not know if lrclk is derived from pclk and the
> +	 * datasheet mentions that the frequencies have to match exactly in
> +	 * order for this to work.
> +	 */
> +	if (params_rate(params) == 8000 || params_rate(params) == 16000) {
> +		if (master) {
> +			switch (max9860->pclk_rate) {

> Maybe it wasn't clear that this comment applied to the whole if-if-switch
> block? Will it be good enough to extend that comment like this:

Not only is that not clear it's also not clear that we intentionally
handle the case where they don't match by falling through - missing
default cases just look like bugs.  Tweaking the comment helps a bit the
reader will still see a pattern that usually looks like a bug and need
to think about if it's OK, a default case means it's clear that it is OK.

> > It will disable the regulators but that's not going to end well if
> > you're including core supplies required to maintain the register map,
> > it'll disable before runtime suspend and enable after runtime resume.
> > The regulator supply widget is intended for supplies that power
> > particular components on the CODEC.

> It is the DVDDIO supply that kills register content. I carefully left
> that one out, and only added widgets for the AVDD and DVDD supplies.
> If/when someone adds DVDDIO it indeed needs to be handled like you
> suggest. Is DVDDIO support required to have an acceptable driver?

You should really manage all the supplies.

> > That still doesn't explain the bouncing on and off here.

> I just read the comment for clk_get_rate() in include/linux/clk.h

>  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
>  *                This is only valid once the clock source has been enabled.

> The driver needs to know the mclk rate, and it only needs the clock to
> be running when the codec is in use, so do you suggest instead?

I don't think that restriction on the part of the clock API is
reasonable TBH, you need to be able to tell what the clock is doing
before turning it on so you don't misdrive the part.  I suspect that
it'll do the right thing almost all the time anyway...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20160512/6be91f6b/attachment.sig>


More information about the Alsa-devel mailing list