Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f43f32c authored by Stephen M. Cameron's avatar Stephen M. Cameron Committed by Jens Axboe
Browse files

cciss: factor out cciss_setnodename

parent 25216109
Loading
Loading
Loading
Loading
+29 −36
Original line number Diff line number Diff line
@@ -1305,55 +1305,27 @@ static int cciss_getnodename(ctlr_info_t *h, void __user *argp)
	return 0;
}

static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
		       unsigned int cmd, unsigned long arg)
{
	struct gendisk *disk = bdev->bd_disk;
	ctlr_info_t *h = get_host(disk);
	drive_info_struct *drv = get_drv(disk);
	void __user *argp = (void __user *)arg;

	dev_dbg(&h->pdev->dev, "cciss_ioctl: Called with cmd=%x %lx\n",
		cmd, arg);
	switch (cmd) {
	case CCISS_GETPCIINFO:
		return cciss_getpciinfo(h, argp);
	case CCISS_GETINTINFO:
		return cciss_getintinfo(h, argp);
	case CCISS_SETINTINFO:
		return cciss_setintinfo(h, argp);
	case CCISS_GETNODENAME:
		return cciss_getnodename(h, argp);
	case CCISS_SETNODENAME:
static int cciss_setnodename(ctlr_info_t *h, void __user *argp)
{
	NodeName_type NodeName;
	unsigned long flags;
	int i;

			if (!arg)
	if (!argp)
		return -EINVAL;
	if (!capable(CAP_SYS_ADMIN))
		return -EPERM;

			if (copy_from_user
			    (NodeName, argp, sizeof(NodeName_type)))
	if (copy_from_user(NodeName, argp, sizeof(NodeName_type)))
		return -EFAULT;

	spin_lock_irqsave(&h->lock, flags);

	/* Update the field, and then ring the doorbell */
	for (i = 0; i < 16; i++)
				writeb(NodeName[i],
				       &h->cfgtable->ServerName[i]);

		writeb(NodeName[i], &h->cfgtable->ServerName[i]);
	writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);

	for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) {
				if (!(readl(h->vaddr + SA5_DOORBELL)
				      & CFGTBL_ChangeReq))
		if (!(readl(h->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq))
			break;
				/* delay and try again */
				udelay(1000);
		udelay(1000); /* delay and try again */
	}
	spin_unlock_irqrestore(&h->lock, flags);
	if (i >= MAX_IOCTL_CONFIG_WAIT)
@@ -1361,6 +1333,27 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
	return 0;
}

static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
		       unsigned int cmd, unsigned long arg)
{
	struct gendisk *disk = bdev->bd_disk;
	ctlr_info_t *h = get_host(disk);
	drive_info_struct *drv = get_drv(disk);
	void __user *argp = (void __user *)arg;

	dev_dbg(&h->pdev->dev, "cciss_ioctl: Called with cmd=%x %lx\n",
		cmd, arg);
	switch (cmd) {
	case CCISS_GETPCIINFO:
		return cciss_getpciinfo(h, argp);
	case CCISS_GETINTINFO:
		return cciss_getintinfo(h, argp);
	case CCISS_SETINTINFO:
		return cciss_setintinfo(h, argp);
	case CCISS_GETNODENAME:
		return cciss_getnodename(h, argp);
	case CCISS_SETNODENAME:
		return cciss_setnodename(h, argp);
	case CCISS_GETHEARTBEAT:
		{
			Heartbeat_type heartbeat;