Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 213080
b: refs/heads/master
c: 4f43f32
h: refs/heads/master
v: v3
  • Loading branch information
Stephen M. Cameron authored and Jens Axboe committed Sep 10, 2010
1 parent c16c3e1 commit b0cd52b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 37 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 252161094255ffdc277b8a0e5e12b0a8ff67b10f
refs/heads/master: 4f43f32cd3f65cfee5f30d7e6be55854cf33809b
65 changes: 29 additions & 36 deletions trunk/drivers/block/cciss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,6 +1305,34 @@ static int cciss_getnodename(ctlr_info_t *h, void __user *argp)
return 0;
}

static int cciss_setnodename(ctlr_info_t *h, void __user *argp)
{
NodeName_type NodeName;
unsigned long flags;
int i;

if (!argp)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
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]);
writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);
for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) {
if (!(readl(h->vaddr + SA5_DOORBELL) & CFGTBL_ChangeReq))
break;
udelay(1000); /* delay and try again */
}
spin_unlock_irqrestore(&h->lock, flags);
if (i >= MAX_IOCTL_CONFIG_WAIT)
return -EAGAIN;
return 0;
}

static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
Expand All @@ -1325,42 +1353,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode,
case CCISS_GETNODENAME:
return cciss_getnodename(h, argp);
case CCISS_SETNODENAME:
{
NodeName_type NodeName;
unsigned long flags;
int i;

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

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]);

writel(CFGTBL_ChangeReq, h->vaddr + SA5_DOORBELL);

for (i = 0; i < MAX_IOCTL_CONFIG_WAIT; i++) {
if (!(readl(h->vaddr + SA5_DOORBELL)
& CFGTBL_ChangeReq))
break;
/* delay and try again */
udelay(1000);
}
spin_unlock_irqrestore(&h->lock, flags);
if (i >= MAX_IOCTL_CONFIG_WAIT)
return -EAGAIN;
return 0;
}

return cciss_setnodename(h, argp);
case CCISS_GETHEARTBEAT:
{
Heartbeat_type heartbeat;
Expand Down

0 comments on commit b0cd52b

Please sign in to comment.