rv = 0; break; } 
break; }  case IPMICTL_SET_MY_CHANNEL_LUN_CMD: { struct ipmi_channel_lun_address_set val;  if (copy_from_user(&val, arg, sizeof(val))) { rv = -EFAULT; break; }  rv = ipmi_set_my_LUN(priv->user, val.channel, val.value); break; }  case IPMICTL_GET_MY_CHANNEL_LUN_CMD: { struct ipmi_channel_lun_address_set val;  if (copy_from_user(&val, arg, sizeof(val))) { rv = -EFAULT; break; }  rv = ipmi_get_my_LUN(priv->user, val.channel, &val.value); if (rv) break;  if (copy_to_user(arg, &val, sizeof(val))) { rv = -EFAULT; break; } break; }  
static int ipmi_ioctl(struct inode  *inode,		      struct file   *file,		      unsigned int  cmd,		      unsigned long data){	int                      rv = -EINVAL;	struct ipmi_file_private *priv = file->private_data;	void __user *arg = (void __user *)data;	switch (cmd) 	{	case IPMICTL_SEND_COMMAND:	{		struct ipmi_req req;		if (copy_from_user(&req, arg, sizeof(req))) {			rv = -EFAULT;			break;		}		rv = handle_send_req(priv->user,				     &req,				     priv->default_retries,				     priv->default_retry_time_ms);		break;	}	case IPMICTL_SEND_COMMAND_SETTIME:	{		struct ipmi_req_settime req;		if (copy_from_user(&req, arg, sizeof(req))) {			rv = -EFAULT;			break;		}		rv = handle_send_req(priv->user,				     &req.req,				     req.retries,				     req.retry_time_ms);		break;	}	case IPMICTL_RECEIVE_MSG:	case IPMICTL_RECEIVE_MSG_TRUNC:	{		struct ipmi_recv      rsp;		int              addr_len;		struct list_head *entry;		struct ipmi_recv_msg  *msg;		unsigned long    flags;				rv = 0;		if (copy_from_user(&rsp, arg, sizeof(rsp))) {			rv = -EFAULT;			break;		}		/* We claim a semaphore because we don't want two                   users getting something from the queue at a time.                   Since we have to release the spinlock before we can                   copy the data to the user, it's possible another                   user will grab something from the queue, too.  Then                   the messages might get out of order if something                   fails and the message gets put back onto the                   queue.  This semaphore prevents that problem. */		down(&(priv->recv_sem));		/* Grab the message off the list. */		spin_lock_irqsave(&(priv->recv_msg_lock), flags);		if (list_empty(&(priv->recv_msgs))) {			spin_unlock_irqrestore(&(priv->recv_msg_lock), flags);			rv = -EAGAIN;			goto recv_err;		}		entry = priv->recv_msgs.next;		msg = list_entry(entry, struct ipmi_recv_msg, link);		list_del(entry);		spin_unlock_irqrestore(&(priv->recv_msg_lock), flags);		addr_len = ipmi_addr_length(msg->addr.addr_type);		if (rsp.addr_len < addr_len)		{			rv = -EINVAL;			goto recv_putback_on_err;		}		if (copy_to_user(rsp.addr, &(msg->addr), addr_len)) {			rv = -EFAULT;			goto recv_putback_on_err;		}		rsp.addr_len = addr_len;		rsp.recv_type = msg->recv_type;		rsp.msgid = msg->msgid;		rsp.msg.netfn = msg->msg.netfn;		rsp.msg.cmd = msg->msg.cmd;		if (msg->msg.data_len > 0) {			if (rsp.msg.data_len < msg->msg.data_len) {				rv = -EMSGSIZE;				if (cmd == IPMICTL_RECEIVE_MSG_TRUNC) {					msg->msg.data_len = rsp.msg.data_len;				} else {					goto recv_putback_on_err;				}			}			if (copy_to_user(rsp.msg.data,					 msg->msg.data,					 msg->msg.data_len))			{				rv = -EFAULT;				goto recv_putback_on_err;			}			rsp.msg.data_len = msg->msg.data_len;		} else {			rsp.msg.data_len = 0;		}		if (copy_to_user(arg, &rsp, sizeof(rsp))) {			rv = -EFAULT;			goto recv_putback_on_err;		}		up(&(priv->recv_sem));		ipmi_free_recv_msg(msg);		break;	recv_putback_on_err:		/* If we got an error, put the message back onto		   the head of the queue. */		spin_lock_irqsave(&(priv->recv_msg_lock), flags);		list_add(entry, &(priv->recv_msgs));		spin_unlock_irqrestore(&(priv->recv_msg_lock), flags);		up(&(priv->recv_sem));		break;	recv_err:		up(&(priv->recv_sem));		break;	}	case IPMICTL_REGISTER_FOR_CMD:	{		struct ipmi_cmdspec val;		if (copy_from_user(&val, arg, sizeof(val))) {			rv = -EFAULT;			break;		}		rv = ipmi_register_for_cmd(priv->user, val.netfn, val.cmd);		break;	}	case IPMICTL_UNREGISTER_FOR_CMD:	{		struct ipmi_cmdspec   val;		if (copy_from_user(&val, arg, sizeof(val))) {			rv = -EFAULT;			break;		}		rv = ipmi_unregister_for_cmd(priv->user, val.netfn, val.cmd);		break;	}	case IPMICTL_SET_GETS_EVENTS_CMD:	{		int val;		if (copy_from_user(&val, arg, sizeof(val))) {			rv = -EFAULT;			break;		}		rv = ipmi_set_gets_events(priv->user, val);		break;	}	case IPMICTL_SET_MY_ADDRESS_CMD:	{		unsigned int val;		if (copy_from_user(&val, arg, sizeof(val))) {			rv = -EFAULT;			break;		}		ipmi_set_my_address(priv->user, val);		rv = 0;		break;	}	case IPMICTL_GET_MY_ADDRESS_CMD:	{		unsigned int val;		val = ipmi_get_my_address(priv->user);		if (copy_to_user(arg, &val, sizeof(val))) {			rv = -EFAULT;			break;		}		rv = 0;		break;	}	case IPMICTL_SET_MY_LUN_CMD:	{		unsigned int val;		if (copy_from_user(&val, arg, sizeof(val))) {			rv = -EFAULT;			break;		}		ipmi_set_my_LUN(priv->user, val);		rv = 0;		break;	}	case IPMICTL_GET_MY_LUN_CMD:	{		unsigned int val;		val = ipmi_get_my_LUN(priv->user);		if (copy_to_user(arg, &val, sizeof(val))) {			rv = -EFAULT;			break;		}		rv = 0;		break;	}	case IPMICTL_SET_TIMING_PARMS_CMD:	{		struct ipmi_timing_parms parms;		if (copy_from_user(&parms, arg, sizeof(parms))) {			rv = -EFAULT;			break;		}		priv->default_retries = parms.retries;		priv->default_retry_time_ms = parms.retry_time_ms;		rv = 0;		break;	}	case IPMICTL_GET_TIMING_PARMS_CMD:	{		struct ipmi_timing_parms parms;		parms.retries = priv->default_retries;		parms.retry_time_ms = priv->default_retry_time_ms;		if (copy_to_user(arg, &parms, sizeof(parms))) {			rv = -EFAULT;			break;		}		rv = 0;		break;	}	}  	return rv;}
4520	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4520/c14979b993021377228958498937bcdd9539cbce/ipmi_devintf.c/clean/drivers/char/ipmi/ipmi_devintf.c