public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [alsa-devel] [PATCH v2] ASoC: da7210: Add support for PLL and SRM
       [not found] <1327313241.31594.12.camel@matrix>
@ 2012-01-23 11:21 ` Mark Brown
       [not found]   ` <1327320561.31594.23.camel@matrix>
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-01-23 11:21 UTC (permalink / raw)
  To: Ashish Chavan
  Cc: lrg, alsa-devel, David Dajun Chen, kuninori.morimoto.gx,
	linux-kernel

On Mon, Jan 23, 2012 at 03:37:21PM +0530, Ashish Chavan wrote:

> +/* PLL out frequency values */
> +#define FOUT_2822400		2822400
> +#define FOUT_3072000		3072000

It's difficult to see what these defines are adding.

> +static const u32 da7210_fout_2822400_div[][DIV_CNT + 1] = {
> +	{ 12000000, 0xE8, 0x6C, 0x2, },		/* MCLK=12Mhz    Fs=44.1Khz */

You're still using magic numbers to find the dividers, and clearly the
same rate comment should apply to the whole table not specific entries.

> +		/* In PLL master mode, use master mode PLL dividers */
> +		if (fout == FOUT_2822400) {


> +		} else if (fout == FOUT_3072000) {

This looks like a switch statement and...

> +			for (row_idx = 0; row_idx < FREF_CNT; row_idx++) {

ARRAY_SIZE()

> +				if (fref == da7210_fout_3072000_div[row_idx]
> +								[FREF_IDX]) {
> +					pll_div1 =
> +						da7210_fout_3072000_div[row_idx]
> +						[DIV1_IDX];

...this code is shared between both branches (as well as the SRM case)
and should be factored out between them.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [alsa-devel] [PATCH v2] ASoC: da7210: Add support for PLL and SRM
       [not found]   ` <1327320561.31594.23.camel@matrix>
@ 2012-01-23 12:03     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-01-23 12:03 UTC (permalink / raw)
  To: Ashish Chavan
  Cc: lrg, alsa-devel, David Dajun Chen, kuninori.morimoto.gx,
	linux-kernel

On Mon, Jan 23, 2012 at 05:39:21PM +0530, Ashish Chavan wrote:
> On Mon, 2012-01-23 at 11:21 +0000, Mark Brown wrote:
> > On Mon, Jan 23, 2012 at 03:37:21PM +0530, Ashish Chavan wrote:

> > ...this code is shared between both branches (as well as the SRM case)
> > and should be factored out between them.

> We are picking values from three different tables in three cases. Even
> if we factor out this code, we will need a switch or if-else to identify
> correct table. As we are already checking those conditions, I put the
> code there. Can you please elaborate a bit, in case if I misunderstood
> your point?

The only difference between these relatively large chunks of code is the
table that's being referenced.  Either use a single table or factor
things out so that you're sharing all the code that doesn't pick the
table.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [alsa-devel] [PATCH v2] ASoC: da7210: Add support for PLL and SRM
       [not found] <1334666046.32225.8.camel@matrix>
@ 2012-04-17 13:43 ` Mark Brown
       [not found]   ` <1334672460.13279.3.camel@matrix>
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2012-04-17 13:43 UTC (permalink / raw)
  To: Ashish Chavan
  Cc: lrg, alsa-devel, David Dajun Chen, kuninori.morimoto.gx,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 495 bytes --]

On Tue, Apr 17, 2012 at 06:04:06PM +0530, Ashish Chavan wrote:

> +	/* Search pll div array for correct divisors */
> +	for (cnt = 0; cnt < ARRAY_SIZE(da7210_pll_div); cnt++) {
> +		/* check fref */
> +		if (fref == da7210_pll_div[cnt].fref) {
> +			/* check mode */
> +			 if (da7210->master ==  da7210_pll_div[cnt].mode) {
> +				/* check fout */
> +				if (fout == da7210_pll_div[cnt].fout) {

I've applied but this would be a lot clearer if it were writen as a
single if statement with &&s.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [alsa-devel] [PATCH v2] ASoC: da7210: Add support for PLL and SRM
       [not found]   ` <1334672460.13279.3.camel@matrix>
@ 2012-04-17 14:11     ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2012-04-17 14:11 UTC (permalink / raw)
  To: Ashish Chavan
  Cc: lrg, alsa-devel, David Dajun Chen, kuninori.morimoto.gx,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 595 bytes --]

On Tue, Apr 17, 2012 at 07:51:00PM +0530, Ashish Chavan wrote:
> On Tue, 2012-04-17 at 14:43 +0100, Mark Brown wrote:

> > I've applied but this would be a lot clearer if it were writen as a
> > single if statement with &&s.

> Actually I implemented it like that first. But then realized that
> because of the 80 chars limit and long conditions, readability was
> hampered. Let me submit a patch to convert it to single if, if that is
> preferred way of doing it.

Hrm?  The major problem with multiple if statements is that it introduces
massive levels of indentation which are hard to parse.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-04-17 14:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1327313241.31594.12.camel@matrix>
2012-01-23 11:21 ` [alsa-devel] [PATCH v2] ASoC: da7210: Add support for PLL and SRM Mark Brown
     [not found]   ` <1327320561.31594.23.camel@matrix>
2012-01-23 12:03     ` Mark Brown
     [not found] <1334666046.32225.8.camel@matrix>
2012-04-17 13:43 ` Mark Brown
     [not found]   ` <1334672460.13279.3.camel@matrix>
2012-04-17 14:11     ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox