mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Victor <andrew@sanpeople.com>
To: Hans-Christian Egtvedt <hcegtvedt@atmel.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kernel-avr32 <kernel@avr32linux.org>,
	David Brownell <david-b@pacbell.net>,
	Patrice Vilchez <patrice.vilchez@rfo.atmel.com>,
	Nicolas Ferre <nicolas.ferre@rfo.atmel.com>,
	Hans-Christian Egtvedt <egtvedt@samfundet.no>
Subject: Re: [PATCH 1/1][RESEND] Driver for the Atmel on-chip SSC on AT32AP and AT91.
Date: 20 Jul 2007 08:55:42 +0200	[thread overview]
Message-ID: <1184914542.15002.113.camel@fuzzie.sanpeople.com> (raw)
In-Reply-To: <1184913868.16760.21.camel@localhost.localdomain>

hi Hans-Christian,

> Just an example from sound/soc/at91/at91-ssc.c
> 
> rcmr =	  (( ssc_p->rcmr_period		<< 24) & AT91_SSC_PERIOD)
> 			| (( 1				<< 16) & AT91_SSC_STTDLY)
> 			| (( AT91_SSC_START_FALLING_RF	     ) & AT91_SSC_START)
> 			| (( AT91_SSC_CK_RISING		     ) & AT91_SSC_CKI)
> 			| (( AT91_SSC_CKO_NONE		     ) & AT91_SSC_CKO)
> 			| (( AT91_SSC_CKS_DIV		     ) & AT91_SSC_CKS);

Well, I didn't write the above, so it's more complex than it needs to
be.

For bitfields where the user can input any value we would usually add to
the header:
   #define AT91_SSC_STTDLY_(x)   ((x) << 16)
   #define AT91_SSC_PERIOD_(x)   ((x) << 24)

Then it can simply be re-written as:

rcmr = AT91_SSC_PERIOD(ssc_p->rcmr_period)
	| AT91_SSC_STTDLY(1)
	| AT91_SSC_START_FALLING_RF
	| AT91_SSC_CK_RISING
	| AT91_SSC_CKO_NONE
	| AT91_SSC_CKS_DIV;


> Would with the header style for atmel-ssc be:
> 
> rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period)
> 		| SSC_BF(RCMR_STTDLY, 1)
> 		| SSC_BF(RCMR_START, 4)
> 		| SSC_BF(RCMR_CKI, 1)
> 		| SSC_BF(RCMR_CKO, 0)
> 		| SSC_BF(RCMR_CKS, 0);
> 
> I find the latter more readable and compact, the user also does not need
> to know the offset of the different bit-fields.

But the user does then constantly have to refer to the datasheet to
determine what CKI = 1 or CKS = 0 means.


Regards,
  Andrew Victor



  reply	other threads:[~2007-07-20  7:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-18 19:37 Hans-Christian Egtvedt
2007-07-19  8:29 ` Andrew Victor
2007-07-20  6:44   ` Hans-Christian Egtvedt
2007-07-20  6:55     ` Andrew Victor [this message]
2007-07-20 11:38       ` Hans-Christian Egtvedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1184914542.15002.113.camel@fuzzie.sanpeople.com \
    --to=andrew@sanpeople.com \
    --cc=david-b@pacbell.net \
    --cc=egtvedt@samfundet.no \
    --cc=hcegtvedt@atmel.com \
    --cc=kernel@avr32linux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@rfo.atmel.com \
    --cc=patrice.vilchez@rfo.atmel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®