NEXT UP previous
Next: My Home Page

ioctl Function

The ioctl() function for this driver is very simple but it does serve to illustrate the idea. Two new ioctl() calls are provided by this driver to switch the trace facilities on and off. This is done using the TDD_TRON and TDD_TROFF commands to ioctl() respectively:

	static int tdd_ioctl(struct mode *inode, struct file *file,
			unsigned int cmd, unsigned long arg)
	{
		TRACE_TXT ( "tdd_ioctl")

		switch(cmd)
		{
			case TDD_TRON:
				tdd_trace = TRUE; 
				return 0;

			case TDD_TROFF:
				tdd_trace = FALSE; 
				return 0;

			default:
				return -EINVAL;
		}
	}

The cmd and arg parameters to tdd_ioctl() are the same values as were passed in the user process to the ioctl() system call. In this case, the value of arg is not significant. Only the two values TDD_TRON and TDD_TROFF have any special significance to this driver and that is when they are used as cmd values. The only action performed by these ioctl() commands is to set and reset the tdd_trace flag.


NEXT UP previous
Next: My Home Page