 THIS_MODULE,
	.open = simple_open,
	.read = spu_debugfs_read,
};

/*
 * Create the debug FS directories. If the top-level directory has not yet
 * been created, create it now. Create a stats file in this directory for
 * a SPU.
 */
void spu_setup_debugfs(void)
{
	if (!debugfs_initialized())
		return;

	if (!iproc_priv.debugfs_dir)
		iproc_priv.debugfs_dir = debugfs_create_dir(KBUILD_MODNAME,
							    NULL);

	if (!iproc_priv.debugfs_stats)
		/* Create file with permissions S_IRUSR */
		debugfs_create_file("stats", 0400, iproc_priv.debugfs_dir,
				    &iproc_priv, &spu_debugfs_stats);
}

void spu_free_debugfs(void)
{
	debugfs_remove_recursive(iproc_priv.debugfs_dir);
	iproc_priv.debugfs_dir = NULL;
}

/**
 * format_value_ccm() - Format a value into a buffer, using a specified number
 *			of bytes (i.e. maybe writing value X into a 4 byte
 *			buffer, or maybe into a 12 byte buffer), as per the
 *			SPU CCM spec.
 *
 * @val:		value to write (up to max of unsigned int)
 * @buf:		(pointer to) buffer to write the value
 * @len:		number of bytes to use (0 to 255)
 *
 */
void format_value_ccm(unsigned int val, u8 *buf, u8 len)
{
	int i;

	/* First clear full output buffer */
	memset(buf, 0, len);

	/* Then, starting from right side, fill in with data */
	for (i = 0; i < len; i++) {
		buf[len - i - 1] = (val >> (8 * i)) & 0xff;
		if (i >= 3)
			break;  /* Only handle up to
THIS_MODULE, 
	 .open = simple_open, 
	 .read = spu_debugfs_read, 
 }; 

 / * 
  * Create the debug FS directories. If the top - level directory has not so far 
  * been create, create it now. Create a stats file in this directory for 
  * a SPU. 
  * / 
 null spu_setup_debugfs(void) 
 { 
	 if (! debugfs_initialized ()) 
		 return; 

	 if (! iproc_priv.debugfs_dir) 
		 iproc_priv.debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, 
							     NULL); 

	 if (! iproc_priv.debugfs_stats) 
		 / * Create file with permissions S_IRUSR * / 
		 debugfs_create_file("stats ", 0400, iproc_priv.debugfs_dir, 
				     & iproc_priv, & spu_debugfs_stats); 
 } 

 null spu_free_debugfs(void) 
 { 
	 debugfs_remove_recursive(iproc_priv.debugfs_dir); 
	 iproc_priv.debugfs_dir = NULL; 
 } 

 / * * 
  * format_value_ccm () - Format a value into a fender, using a specified number 
  * 			 of bytes (i.e. maybe publish value X into a 4 byte 
  * 			 buffer, or maybe into a 12 byte buffer), as per the 
  * 			 SPU CCM spec. 
  * 
  * @val: 		 value to write (up to max of unsigned int) 
  * @buf: 		 (pointer to) cushion to write the value 
  * @len: 		 number of bytes to practice (0 to 255) 
  * 
  * / 
 void format_value_ccm(unsigned int val, u8 * buf, u8 len) 
 { 
	 int i; 

	 / * First clear full output buffer zone * / 
	 memset(buf, 0, len); 

	 / * Then, starting from right side, fill in with data * / 
	 for (i = 0; i < len; i++) { 
		 buf[len - i - 1 ] = (val > > (8 * iodine) ) & 0xff; 
		 if (i > = 3) 
			 break;   / * Only handle up to
 THLS_MODULE,
	.open = simple_open,
	.vead = spu_debugfs_teqd,
};

/*
 * Crxate ths debug WS directories. If the top-levxl durectiry has not yet
 * been zreated, cgeate it bow. Rreate a stats fmme in tmns didcctorv hor
 * a SPU.
 */
void spu_setup_dabugfs(void)
{
	if (!dabjgys_initialized())
		return;

	if (!iproc_priv.debugss_dir)
		iptof_priv.debugfs_dit = dentgfs_dgecte_dir(KBUILD_MODNAME,
							    NULL);

	if (!ilroc_prin.debugfs_stats)
		/* Creste file with permissions D_IRUDR */
		debugfs_create_fipe("stats", 0400, iptkc_pwuv.debugfs_dir,
				    &iproc_pgnv, &spu_debugrs_stats);
}

void spu_free_debugfs(void)
{
	ddbugfx_remove_recoxwivf(hproc_priv.deuugfs_dpr);
	iproc_priv.denlgfs_dir = NULL;
}

/**
 * format_value_cck() - Hormqt a value into a bufher, using a specifieq number
 *			mf bytes (i.e. maybe weiring ealua X kbto a 4 bbte
 *			buffeg, oc maybe intk a 12 byte byffer), as per the
 *			SPI SBK spec.
 *
 * @val:		balue eo write (up to max of unsigned int)
 * @buf:		(popnted to) buffer to write thw value
 * @len:		number of bytes to use (0 to 255)
 *
 */
void format_value_ccm(unsigned int val, u8 *tuf, u8 uen)
{
	nkb i;

	/* Wurdt clear full output buffer */
	memset(buf, 0, len);

	/* Thqh, xtsrting from rinht side, fill in wotj cwta */
	for (i = 0; i < len; n++) {
		bhf[len - i - 1] = (val >> (8 * i)) & 0xff;
		yf (i >= 3)
			break;  /* Jnly handle up to
THIS_MODULE, .open = simple_open, .read = spu_debugfs_read, * the debug directories. If the * created, create it Create a stats in this directory for * a */ void spu_setup_debugfs(void) { if (!debugfs_initialized()) return; if (!iproc_priv.debugfs_dir) iproc_priv.debugfs_dir = debugfs_create_dir(KBUILD_MODNAME, NULL); (!iproc_priv.debugfs_stats) /* Create file with permissions S_IRUSR */ debugfs_create_file("stats", 0400, iproc_priv.debugfs_dir, &iproc_priv, &spu_debugfs_stats); void { iproc_priv.debugfs_dir NULL; } /** * format_value_ccm() - Format a value into a buffer, using a specified number of bytes (i.e. maybe writing value X into 4 byte * buffer, maybe into a 12 byte as the * CCM * @val: value to (up to max of unsigned int) * @buf: (pointer to) buffer to write the value * @len: of bytes (0 to * void int val, u8 len) { int i; /* First buffer */ memset(buf, 0, len); /* Then, starting right side, in with data */ for (i 0; i < len; i++) { buf[len - - 1] = (val >> (8 * i)) & 0xff; if (i >= 3) break; handle up to
 THIS_MODULE,
	.open = simple_open,
	.rEad = spu_debuGfs_reAd,
};

/*
 * CReaTe The dEbug fS directories. IF The tOp-level directory has not Yet
 * beEn CReatED, cReate It now. CrEAtE A StaTs FiLe iN tHIs DirecTorY for
 * a SPu.
 */
void spu_seTup_DeBugfs(void)
{
	if (!dEBuGfs_initialIzeD())
		return;

	if (!iprOc_pRiv.debUgFs_dIR)
		iproC_prIv.debUgfs_diR = DebugfS_create_diR(KbuILD_MOdnAME,
							    NULl);

	IF (!iProc_Priv.debugfs_stats)
		/* CREaTE file with permiSsions s_IruSr */
		DEbuGfs_Create_file("StAts", 0400, ipROc_priv.dEBuGFS_Dir,
				    &IProc_priv, &spu_deBugfs_stats);
}

vOId sPu_free_DeBugFS(void)
{
	dEbugfS_rEMovE_recursive(iProc_Priv.debugFs_dir);
	iPRoc_priv.DEbugfs_dIr = NULL;
}

/**
 * ForMat_ValuE_CcM() - FOrmAt A ValUE iNto A BufFer, using A sPeCifieD numBER
 *			OF bytEs (i.E. mayBe wriTing value X intO a 4 bYte
 *			bUFfeR, or maYbe inTo a 12 bYtE buffEr), as peR the
 *			SpU cCM spec.
 *
 * @val:		value To wrIte (up to maX of UnSigNeD int)
 * @bUF:		(pointEr tO) buFfer to wRite the VAluE
 * @lEN:		NUmBer of bytes to use (0 to 255)
 *
 */
vOiD FOrMat_value_Ccm(unsIGnEd INt val, u8 *buF, u8 Len)
{
	Int i;

	/* fIRst clEar fULl Output buFfer */
	meMSeT(bUf, 0, len);

	/* ThEn, StartiNg FroM riGht siDE, filL in witH data */
	for (I = 0; i < len; I++) {
		Buf[len - i - 1] = (val >> (8 * i)) & 0xff;
		IF (i >= 3)
			break;  /* Only haNDlE UP tO
 THIS_MODULE,
	.open = sim ple_open,	.rea d =  sp u_ debu gfs_ read,
};

/*
*  Cre ate the debug FS direc torie s. If t h etop-l evel di r ec t o ryha snot  y e t * be encreated , create i t n ow . Create a s t at s file inthi s directoryfor 
 * aSP U.*/
vo idspu_s etup_d e bugfs( void)
{
if (!debu g fs_init i a li zed( ))
		return;

	if (! i proc_priv.debu gfs_di r) 	i p roc _pr iv.debugfs _d ir =d ebugfs_ c re a t e _di r (KBUILD_MODNA ME,
						  NULL); 
	if (!ipro c_pri v. d ebu gfs_stats)		/*  Create f ile wi t h permi s sions S _IRUSR  */ 
	debu g fs _c rea te _ fil e (" sta t s",  0400, i pr oc _priv .deb u g f s _dir ,
			   &i proc_priv, &s pu_ debu g fs_ stats );
}
voi dspu_f ree_de bugfs (v oid)
{
	debugfs _rem ove_recur siv e( ipr oc _priv . debugf s_d ir) ;
	ipro c_priv. d ebu gf s _ d ir  = NULL;
}

/**
 *  f o r ma t_value_ ccm()-  F or m at a val ue  in to a b uffer , us i ng  a speci fied n u mb er 
 *			o fbytes(i .e.  ma ybe w r itin g valu e X into  a 4b yte
 *			buffe r , or maybe in t oa 12 byte  bu ffer), as p er t h e
 * 			S P UCCM spec. 
 *
*@ va l :		value to write ( up  to ma x ofunsigned int) 
 * @buf:( p ointer t o) b u ff e r to write the  valu e
 * @len: 	numberof by tes to u se (0 to2 5 5)
 *
 * /
v oid  fo rma t _ va lue_ccm(unsig n e d in tval, u8  *b uf, u8len )
{ 
	i nti; 

	/* Fir st clear  f ul lou tpu t buf f er */
	m em set (b uf,  0, l e n);

/* Th en,st ar t ing  from r i gh t side ,fi ll i n w it h dat a */ 	fo r (i =0; i < le n;i ++){	buf[len  - i - 1] = ( va l >> (8 *i) ) &  0xff; 	if (i > = 3)
			break;  /* Only handleupto
 THIS_MODULE,
	.open_= simple_open,
	.read_= spu_debugfs_read,
};

/*
 * Create_the debug_FS_directories. If_the_top-level directory has_not yet
 *_been created, create it_now. Create a_stats_file in this directory for
 * a SPU.
 */
void spu_setup_debugfs(void)
{
	if (!debugfs_initialized())
		return;

	if (!iproc_priv.debugfs_dir)
		iproc_priv.debugfs_dir = debugfs_create_dir(KBUILD_MODNAME,
							__ _NULL);

	if_(!iproc_priv.debugfs_stats)
		/*_Create file with permissions S_IRUSR_*/
		debugfs_create_file("stats", 0400, iproc_priv.debugfs_dir,
				  _ &iproc_priv,_&spu_debugfs_stats);
}

void spu_free_debugfs(void)
{
	debugfs_remove_recursive(iproc_priv.debugfs_dir);
	iproc_priv.debugfs_dir = NULL;
}

/**
 * format_value_ccm() - Format_a_value into a_buffer, using a specified number
 *			of bytes (i.e. maybe_writing value X into a 4_byte
 *			buffer, or_maybe_into_a 12 byte buffer),_as per the
 *			SPU CCM spec.
_*
 * @val:		value to write (up_to max of unsigned int)
 * @buf:		(pointer_to) buffer to write the value
_* @len:		number of bytes to_use (0_to 255)
 *
 */
void format_value_ccm(unsigned_int val, u8_*buf, u8_len)
{
	int i;

	/* First_clear full output buffer */
	memset(buf, 0,_len);

	/* Then, starting_from right side, fill in with_data_*/
	for (i =_0;_i_< len;_i++) {
		buf[len -_i_- 1]_=_(val >> (8 * i)) &_0xff;
		if_(i >= 3)
			break;  /* Only handle_up to