lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1184914542.15002.113.camel@fuzzie.sanpeople.com>
Date:	20 Jul 2007 08:55:42 +0200
From:	Andrew Victor <andrew@...people.com>
To:	Hans-Christian Egtvedt <hcegtvedt@...el.com>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	kernel-avr32 <kernel@...32linux.org>,
	David Brownell <david-b@...bell.net>,
	Patrice Vilchez <patrice.vilchez@....atmel.com>,
	Nicolas Ferre <nicolas.ferre@....atmel.com>,
	Hans-Christian Egtvedt <egtvedt@...fundet.no>
Subject: Re: [PATCH 1/1][RESEND] Driver for the Atmel on-chip SSC on AT32AP
	and AT91.

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


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ