some smaller updates.
This commit is contained in:
		
							parent
							
								
									46b296ff92
								
							
						
					
					
						commit
						ee5bc62c1e
					
				
							
								
								
									
										2
									
								
								fpgafs.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								fpgafs.h
									
									
									
									
									
								
							@ -31,7 +31,7 @@ enum {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
struct fpga_context {
 | 
					struct fpga_context {
 | 
				
			||||||
	char *load_buf;
 | 
						char *load_buf;
 | 
				
			||||||
	unsigned int lldrv;
 | 
						int lldrv;
 | 
				
			||||||
	int bla;
 | 
						int bla;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -29,7 +29,7 @@
 | 
				
			|||||||
static char *mem;
 | 
					static char *mem;
 | 
				
			||||||
static unsigned int stat;
 | 
					static unsigned int stat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int do_cmd(u32 cmd, u32 data)
 | 
					static int do_cmd(uint32_t cmd, uint32_t data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	switch(cmd) {
 | 
						switch(cmd) {
 | 
				
			||||||
		case BLA:
 | 
							case BLA:
 | 
				
			||||||
@ -44,7 +44,7 @@ static int do_cmd(u32 cmd, u32 data)
 | 
				
			|||||||
static int fpgafs_stat_dbg(struct fpga_context *ctx, unsigned char *buf, int len)
 | 
					static int fpgafs_stat_dbg(struct fpga_context *ctx, unsigned char *buf, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	//struct fpga_context *ctx = file->private_data;
 | 
						//struct fpga_context *ctx = file->private_data;
 | 
				
			||||||
	u32 data;
 | 
						uint32_t data;
 | 
				
			||||||
	data=stat;
 | 
						data=stat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (copy_to_user(buf, &data, sizeof(data)))
 | 
						if (copy_to_user(buf, &data, sizeof(data)))
 | 
				
			||||||
@ -55,7 +55,7 @@ static int fpgafs_stat_dbg(struct fpga_context *ctx, unsigned char *buf, int len
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int fpgafs_cmd_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
					static int fpgafs_cmd_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 data, __user *udata;
 | 
						uint32_t data, __user *udata;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (len < 4)
 | 
						if (len < 4)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
@ -73,8 +73,8 @@ static int fpgafs_cmd_dbg(struct fpga_context *ctx, const char __user *buf, int
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int fpgafs_send_data_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
					static int fpgafs_send_data_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 cp = 0;
 | 
						uint32_t cp = 0;
 | 
				
			||||||
	u8 __user *usr;
 | 
						uint8_t __user *usr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (mem == NULL)
 | 
						if (mem == NULL)
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
@ -88,7 +88,7 @@ static int fpgafs_send_data_dbg(struct fpga_context *ctx, const char __user *buf
 | 
				
			|||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (cp < len) {
 | 
						while (cp < len) {
 | 
				
			||||||
		usr = (u8*)&buf[cp];
 | 
							usr = (uint8_t*)&buf[cp];
 | 
				
			||||||
		if (__get_user(mem[cp], usr))
 | 
							if (__get_user(mem[cp], usr))
 | 
				
			||||||
			return -EFAULT;
 | 
								return -EFAULT;
 | 
				
			||||||
		cp++;
 | 
							cp++;
 | 
				
			||||||
@ -122,9 +122,8 @@ static int fpgafs_read_load_dbg(struct fpga_context *ctx, unsigned char *buf, in
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int fpgafs_write_load_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
					static int fpgafs_write_load_dbg(struct fpga_context *ctx, const char __user *buf, int len)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	u32 cp = 0;
 | 
						uint32_t cp = 0;
 | 
				
			||||||
	u8 __user *usr;
 | 
						uint8_t __user *usr;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (ctx->load_buf != NULL)
 | 
						if (ctx->load_buf != NULL)
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -134,10 +133,10 @@ static int fpgafs_write_load_dbg(struct fpga_context *ctx, const char __user *bu
 | 
				
			|||||||
	if (!access_ok(VERIFY_READ, buf, len))
 | 
						if (!access_ok(VERIFY_READ, buf, len))
 | 
				
			||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->load_buf = kmalloc(len,GFP_USER);
 | 
						ctx->load_buf = kmalloc(len, GFP_USER);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	while (cp < len) {
 | 
						while (cp < len) {
 | 
				
			||||||
		usr = (u8*)&buf[cp];
 | 
							usr = (uint8_t*)&buf[cp];
 | 
				
			||||||
		if (__get_user(ctx->load_buf[cp], usr))
 | 
							if (__get_user(ctx->load_buf[cp], usr))
 | 
				
			||||||
			return -EFAULT;
 | 
								return -EFAULT;
 | 
				
			||||||
		cp++;
 | 
							cp++;
 | 
				
			||||||
@ -149,7 +148,7 @@ static int fpgafs_write_load_dbg(struct fpga_context *ctx, const char __user *bu
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
static int fpgafs_init_dbg(void)
 | 
					static int fpgafs_init_dbg(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	mem = kmalloc(MEM_SIZE,GFP_USER);
 | 
						mem = kmalloc(MEM_SIZE, GFP_USER);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										9
									
								
								llmgmt.c
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								llmgmt.c
									
									
									
									
									
								
							@ -101,7 +101,7 @@ ssize_t fpgafs_read_lldrv(struct file *file, char __user *buf,
 | 
				
			|||||||
	struct fpga_context *fcur = (struct fpga_context*)file->private_data;
 | 
						struct fpga_context *fcur = (struct fpga_context*)file->private_data;
 | 
				
			||||||
	size_t l = (len > 5)?5:len;
 | 
						size_t l = (len > 5)?5:len;
 | 
				
			||||||
	if (fcur->lldrv > -1) {
 | 
						if (fcur->lldrv > -1) {
 | 
				
			||||||
		if (copy_to_user(buf, lldrv[fcur->lldrv]->name, l))
 | 
							if (copy_to_user(buf, lldrv[fcur->lldrv]->name, l) < 0)
 | 
				
			||||||
			return -EFAULT;
 | 
								return -EFAULT;
 | 
				
			||||||
	} else {
 | 
						} else {
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
@ -130,11 +130,13 @@ ssize_t fpgafs_write_lldrv(struct file *file, const char __user *buf,
 | 
				
			|||||||
	for(i=0; i < FPGAFS_MAX_LLDRV; i++)
 | 
						for(i=0; i < FPGAFS_MAX_LLDRV; i++)
 | 
				
			||||||
		if (lldrv[i] != NULL) {
 | 
							if (lldrv[i] != NULL) {
 | 
				
			||||||
			for (cp = 0; cp < l; cp++) {
 | 
								for (cp = 0; cp < l; cp++) {
 | 
				
			||||||
 | 
									printk("%d: %c %c\n", cp, lldrv[i]->name[cp], tmp[cp]);
 | 
				
			||||||
				if (lldrv[i]->name[cp] != tmp[cp])
 | 
									if (lldrv[i]->name[cp] != tmp[cp])
 | 
				
			||||||
					break;
 | 
										break;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (cp == l) {
 | 
								if (cp == l) {
 | 
				
			||||||
				fcur->lldrv = i;
 | 
									fcur->lldrv = i;
 | 
				
			||||||
 | 
									printk("lldrv = %d\n", i);
 | 
				
			||||||
				return l;
 | 
									return l;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@ -165,10 +167,9 @@ ssize_t fpgafs_write_cmd(struct file *file, const char __user *buf,
 | 
				
			|||||||
/* low level un-/register functions */
 | 
					/* low level un-/register functions */
 | 
				
			||||||
int fpgafs_register_lldrv(struct fpgafs_lldrv *drv)
 | 
					int fpgafs_register_lldrv(struct fpgafs_lldrv *drv)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	unsigned long flags;
 | 
					 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_lock_irqsave(&fpgafs_lldrv_lock, flags);
 | 
						spin_lock(&fpgafs_lldrv_lock);
 | 
				
			||||||
	if (lldrv_count == FPGAFS_MAX_LLDRV)
 | 
						if (lldrv_count == FPGAFS_MAX_LLDRV)
 | 
				
			||||||
		return -EBUSY;
 | 
							return -EBUSY;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -186,7 +187,7 @@ int fpgafs_register_lldrv(struct fpgafs_lldrv *drv)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	lldrv_count++;
 | 
						lldrv_count++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	spin_unlock_irqrestore(&fpgafs_lldrv_lock, flags);
 | 
						spin_unlock(&fpgafs_lldrv_lock);
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL_GPL(fpgafs_register_lldrv);
 | 
					EXPORT_SYMBOL_GPL(fpgafs_register_lldrv);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user