[Cbe-oss-dev] [RFC/PATCH 2/2] spufs: Add a "capabilities" file to spu contexts

Benjamin Herrenschmidt benh at kernel.crashing.org
Fri Jun 1 10:26:31 EST 2007


> Attaching the patch might be appreciated, so here it is:

Looks good, I must have had a brain fart and totally forgot about
seq_file. Thanks.

Ben.
 
> 
> Index: linux-cell/arch/powerpc/platforms/cell/spufs/file.c
> ===================================================================
> --- linux-cell.orig/arch/powerpc/platforms/cell/spufs/file.c	2007-05-31 21:12:29.000000000 +0200
> +++ linux-cell/arch/powerpc/platforms/cell/spufs/file.c	2007-05-31 21:17:29.000000000 +0200
> @@ -1799,33 +1799,29 @@ static int spufs_info_open(struct inode 
>  	return 0;
>  }
>  
> -#define CAPS_BUF_LEN		64
> -#define ADD_ONE_CAP(name)	\
> -  do { p += snprintf(p, CAPS_BUF_LEN - 3 - (p - buffer), "%s ", #name); \
> -     } while(0)
> -
> -static ssize_t spufs_caps_read(struct file *file, char __user *buf,
> -			       size_t len, loff_t *pos)
> +static int spufs_caps_show(struct seq_file *s, void *private)
>  {
> -	struct spu_context *ctx = file->private_data;
> -	char buffer[CAPS_BUF_LEN];
> -	char *p = buffer;
> +	struct spu_context *ctx = s->private;
>  
>  	if (!(ctx->flags & SPU_CREATE_NOSCHED))
> -		ADD_ONE_CAP(sched);
> +		seq_puts(s, "sched ");
>  	if (!(ctx->flags & SPU_CREATE_ISOLATE))
> -		ADD_ONE_CAP(step);
> +		seq_puts(s, "step ");
>  
> -	/* remove last space and add newline */
> -	if (p != buffer)
> -		p--;
> -	*(p++) = '\n';
> -	return simple_read_from_buffer(buf, len, pos, buffer, p - buffer);
> +	seq_puts(s, "\n");
> +	return 0;
> +}
> +
> +static int spufs_caps_open(struct inode *inode, struct file *file)
> +{
> +	return single_open(file, spufs_caps_show, SPUFS_I(inode)->i_ctx);
>  }
>  
>  static const struct file_operations spufs_caps_fops = {
> -	.open = spufs_info_open,
> -	.read = spufs_caps_read,
> +	.open		= spufs_caps_open,
> +	.read		= seq_read,
> +	.llseek		= seq_lseek,
> +	.release	= single_release,
>  };
>  
>  static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,




More information about the cbe-oss-dev mailing list