diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2009-09-18 15:58:48 -0400 |
---|---|---|
committer | Jens Axboe <jens.axboe@oracle.com> | 2009-10-01 15:15:40 -0400 |
commit | d5d03eec9b36f861e9c97846348fb3b5759f2d82 (patch) | |
tree | f3f99a238f93da949b1629d34cebb5efd6a53e5a /drivers/block/DAC960.c | |
parent | ff2c3de305e2d06ae556e1a382ed75c5dd8f9dda (diff) |
dac960: switch to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Yang Hongyang <yanghy@cn.fujitsu.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'drivers/block/DAC960.c')
-rw-r--r-- | drivers/block/DAC960.c | 156 |
1 files changed, 71 insertions, 85 deletions
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 6fa7b0fdbdfd..eb4fa1943944 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | #include <linux/smp_lock.h> | 39 | #include <linux/smp_lock.h> |
40 | #include <linux/proc_fs.h> | 40 | #include <linux/proc_fs.h> |
41 | #include <linux/seq_file.h> | ||
41 | #include <linux/reboot.h> | 42 | #include <linux/reboot.h> |
42 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
43 | #include <linux/timer.h> | 44 | #include <linux/timer.h> |
@@ -6422,16 +6423,10 @@ static bool DAC960_V2_ExecuteUserCommand(DAC960_Controller_T *Controller, | |||
6422 | return true; | 6423 | return true; |
6423 | } | 6424 | } |
6424 | 6425 | ||
6425 | 6426 | static int dac960_proc_show(struct seq_file *m, void *v) | |
6426 | /* | ||
6427 | DAC960_ProcReadStatus implements reading /proc/rd/status. | ||
6428 | */ | ||
6429 | |||
6430 | static int DAC960_ProcReadStatus(char *Page, char **Start, off_t Offset, | ||
6431 | int Count, int *EOF, void *Data) | ||
6432 | { | 6427 | { |
6433 | unsigned char *StatusMessage = "OK\n"; | 6428 | unsigned char *StatusMessage = "OK\n"; |
6434 | int ControllerNumber, BytesAvailable; | 6429 | int ControllerNumber; |
6435 | for (ControllerNumber = 0; | 6430 | for (ControllerNumber = 0; |
6436 | ControllerNumber < DAC960_ControllerCount; | 6431 | ControllerNumber < DAC960_ControllerCount; |
6437 | ControllerNumber++) | 6432 | ControllerNumber++) |
@@ -6444,52 +6439,49 @@ static int DAC960_ProcReadStatus(char *Page, char **Start, off_t Offset, | |||
6444 | break; | 6439 | break; |
6445 | } | 6440 | } |
6446 | } | 6441 | } |
6447 | BytesAvailable = strlen(StatusMessage) - Offset; | 6442 | seq_puts(m, StatusMessage); |
6448 | if (Count >= BytesAvailable) | 6443 | return 0; |
6449 | { | ||
6450 | Count = BytesAvailable; | ||
6451 | *EOF = true; | ||
6452 | } | ||
6453 | if (Count <= 0) return 0; | ||
6454 | *Start = Page; | ||
6455 | memcpy(Page, &StatusMessage[Offset], Count); | ||
6456 | return Count; | ||
6457 | } | 6444 | } |
6458 | 6445 | ||
6446 | static int dac960_proc_open(struct inode *inode, struct file *file) | ||
6447 | { | ||
6448 | return single_open(file, dac960_proc_show, NULL); | ||
6449 | } | ||
6459 | 6450 | ||
6460 | /* | 6451 | static const struct file_operations dac960_proc_fops = { |
6461 | DAC960_ProcReadInitialStatus implements reading /proc/rd/cN/initial_status. | 6452 | .owner = THIS_MODULE, |
6462 | */ | 6453 | .open = dac960_proc_open, |
6454 | .read = seq_read, | ||
6455 | .llseek = seq_lseek, | ||
6456 | .release = single_release, | ||
6457 | }; | ||
6463 | 6458 | ||
6464 | static int DAC960_ProcReadInitialStatus(char *Page, char **Start, off_t Offset, | 6459 | static int dac960_initial_status_proc_show(struct seq_file *m, void *v) |
6465 | int Count, int *EOF, void *Data) | ||
6466 | { | 6460 | { |
6467 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data; | 6461 | DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->private; |
6468 | int BytesAvailable = Controller->InitialStatusLength - Offset; | 6462 | seq_printf(m, "%.*s", Controller->InitialStatusLength, Controller->CombinedStatusBuffer); |
6469 | if (Count >= BytesAvailable) | 6463 | return 0; |
6470 | { | ||
6471 | Count = BytesAvailable; | ||
6472 | *EOF = true; | ||
6473 | } | ||
6474 | if (Count <= 0) return 0; | ||
6475 | *Start = Page; | ||
6476 | memcpy(Page, &Controller->CombinedStatusBuffer[Offset], Count); | ||
6477 | return Count; | ||
6478 | } | 6464 | } |
6479 | 6465 | ||
6466 | static int dac960_initial_status_proc_open(struct inode *inode, struct file *file) | ||
6467 | { | ||
6468 | return single_open(file, dac960_initial_status_proc_show, PDE(inode)->data); | ||
6469 | } | ||
6480 | 6470 | ||
6481 | /* | 6471 | static const struct file_operations dac960_initial_status_proc_fops = { |
6482 | DAC960_ProcReadCurrentStatus implements reading /proc/rd/cN/current_status. | 6472 | .owner = THIS_MODULE, |
6483 | */ | 6473 | .open = dac960_initial_status_proc_open, |
6474 | .read = seq_read, | ||
6475 | .llseek = seq_lseek, | ||
6476 | .release = single_release, | ||
6477 | }; | ||
6484 | 6478 | ||
6485 | static int DAC960_ProcReadCurrentStatus(char *Page, char **Start, off_t Offset, | 6479 | static int dac960_current_status_proc_show(struct seq_file *m, void *v) |
6486 | int Count, int *EOF, void *Data) | ||
6487 | { | 6480 | { |
6488 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data; | 6481 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) m->private; |
6489 | unsigned char *StatusMessage = | 6482 | unsigned char *StatusMessage = |
6490 | "No Rebuild or Consistency Check in Progress\n"; | 6483 | "No Rebuild or Consistency Check in Progress\n"; |
6491 | int ProgressMessageLength = strlen(StatusMessage); | 6484 | int ProgressMessageLength = strlen(StatusMessage); |
6492 | int BytesAvailable; | ||
6493 | if (jiffies != Controller->LastCurrentStatusTime) | 6485 | if (jiffies != Controller->LastCurrentStatusTime) |
6494 | { | 6486 | { |
6495 | Controller->CurrentStatusLength = 0; | 6487 | Controller->CurrentStatusLength = 0; |
@@ -6513,49 +6505,41 @@ static int DAC960_ProcReadCurrentStatus(char *Page, char **Start, off_t Offset, | |||
6513 | } | 6505 | } |
6514 | Controller->LastCurrentStatusTime = jiffies; | 6506 | Controller->LastCurrentStatusTime = jiffies; |
6515 | } | 6507 | } |
6516 | BytesAvailable = Controller->CurrentStatusLength - Offset; | 6508 | seq_printf(m, "%.*s", Controller->CurrentStatusLength, Controller->CurrentStatusBuffer); |
6517 | if (Count >= BytesAvailable) | 6509 | return 0; |
6518 | { | ||
6519 | Count = BytesAvailable; | ||
6520 | *EOF = true; | ||
6521 | } | ||
6522 | if (Count <= 0) return 0; | ||
6523 | *Start = Page; | ||
6524 | memcpy(Page, &Controller->CurrentStatusBuffer[Offset], Count); | ||
6525 | return Count; | ||
6526 | } | 6510 | } |
6527 | 6511 | ||
6512 | static int dac960_current_status_proc_open(struct inode *inode, struct file *file) | ||
6513 | { | ||
6514 | return single_open(file, dac960_current_status_proc_show, PDE(inode)->data); | ||
6515 | } | ||
6528 | 6516 | ||
6529 | /* | 6517 | static const struct file_operations dac960_current_status_proc_fops = { |
6530 | DAC960_ProcReadUserCommand implements reading /proc/rd/cN/user_command. | 6518 | .owner = THIS_MODULE, |
6531 | */ | 6519 | .open = dac960_current_status_proc_open, |
6520 | .read = seq_read, | ||
6521 | .llseek = seq_lseek, | ||
6522 | .release = single_release, | ||
6523 | }; | ||
6532 | 6524 | ||
6533 | static int DAC960_ProcReadUserCommand(char *Page, char **Start, off_t Offset, | 6525 | static int dac960_user_command_proc_show(struct seq_file *m, void *v) |
6534 | int Count, int *EOF, void *Data) | ||
6535 | { | 6526 | { |
6536 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data; | 6527 | DAC960_Controller_T *Controller = (DAC960_Controller_T *)m->private; |
6537 | int BytesAvailable = Controller->UserStatusLength - Offset; | ||
6538 | if (Count >= BytesAvailable) | ||
6539 | { | ||
6540 | Count = BytesAvailable; | ||
6541 | *EOF = true; | ||
6542 | } | ||
6543 | if (Count <= 0) return 0; | ||
6544 | *Start = Page; | ||
6545 | memcpy(Page, &Controller->UserStatusBuffer[Offset], Count); | ||
6546 | return Count; | ||
6547 | } | ||
6548 | 6528 | ||
6529 | seq_printf(m, "%.*s", Controller->UserStatusLength, Controller->UserStatusBuffer); | ||
6530 | return 0; | ||
6531 | } | ||
6549 | 6532 | ||
6550 | /* | 6533 | static int dac960_user_command_proc_open(struct inode *inode, struct file *file) |
6551 | DAC960_ProcWriteUserCommand implements writing /proc/rd/cN/user_command. | 6534 | { |
6552 | */ | 6535 | return single_open(file, dac960_user_command_proc_show, PDE(inode)->data); |
6536 | } | ||
6553 | 6537 | ||
6554 | static int DAC960_ProcWriteUserCommand(struct file *file, | 6538 | static ssize_t dac960_user_command_proc_write(struct file *file, |
6555 | const char __user *Buffer, | 6539 | const char __user *Buffer, |
6556 | unsigned long Count, void *Data) | 6540 | size_t Count, loff_t *pos) |
6557 | { | 6541 | { |
6558 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) Data; | 6542 | DAC960_Controller_T *Controller = (DAC960_Controller_T *) PDE(file->f_path.dentry->d_inode)->data; |
6559 | unsigned char CommandBuffer[80]; | 6543 | unsigned char CommandBuffer[80]; |
6560 | int Length; | 6544 | int Length; |
6561 | if (Count > sizeof(CommandBuffer)-1) return -EINVAL; | 6545 | if (Count > sizeof(CommandBuffer)-1) return -EINVAL; |
@@ -6572,6 +6556,14 @@ static int DAC960_ProcWriteUserCommand(struct file *file, | |||
6572 | ? Count : -EBUSY); | 6556 | ? Count : -EBUSY); |
6573 | } | 6557 | } |
6574 | 6558 | ||
6559 | static const struct file_operations dac960_user_command_proc_fops = { | ||
6560 | .owner = THIS_MODULE, | ||
6561 | .open = dac960_user_command_proc_open, | ||
6562 | .read = seq_read, | ||
6563 | .llseek = seq_lseek, | ||
6564 | .release = single_release, | ||
6565 | .write = dac960_user_command_proc_write, | ||
6566 | }; | ||
6575 | 6567 | ||
6576 | /* | 6568 | /* |
6577 | DAC960_CreateProcEntries creates the /proc/rd/... entries for the | 6569 | DAC960_CreateProcEntries creates the /proc/rd/... entries for the |
@@ -6586,23 +6578,17 @@ static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller) | |||
6586 | 6578 | ||
6587 | if (DAC960_ProcDirectoryEntry == NULL) { | 6579 | if (DAC960_ProcDirectoryEntry == NULL) { |
6588 | DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL); | 6580 | DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL); |
6589 | StatusProcEntry = create_proc_read_entry("status", 0, | 6581 | StatusProcEntry = proc_create("status", 0, |
6590 | DAC960_ProcDirectoryEntry, | 6582 | DAC960_ProcDirectoryEntry, |
6591 | DAC960_ProcReadStatus, NULL); | 6583 | &dac960_proc_fops); |
6592 | } | 6584 | } |
6593 | 6585 | ||
6594 | sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber); | 6586 | sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber); |
6595 | ControllerProcEntry = proc_mkdir(Controller->ControllerName, | 6587 | ControllerProcEntry = proc_mkdir(Controller->ControllerName, |
6596 | DAC960_ProcDirectoryEntry); | 6588 | DAC960_ProcDirectoryEntry); |
6597 | create_proc_read_entry("initial_status", 0, ControllerProcEntry, | 6589 | proc_create_data("initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller); |
6598 | DAC960_ProcReadInitialStatus, Controller); | 6590 | proc_create_data("current_status", 0, ControllerProcEntry, &dac960_current_status_proc_fops, Controller); |
6599 | create_proc_read_entry("current_status", 0, ControllerProcEntry, | 6591 | UserCommandProcEntry = proc_create_data("user_command", S_IWUSR | S_IRUSR, ControllerProcEntry, &dac960_user_command_proc_fops, Controller); |
6600 | DAC960_ProcReadCurrentStatus, Controller); | ||
6601 | UserCommandProcEntry = | ||
6602 | create_proc_read_entry("user_command", S_IWUSR | S_IRUSR, | ||
6603 | ControllerProcEntry, DAC960_ProcReadUserCommand, | ||
6604 | Controller); | ||
6605 | UserCommandProcEntry->write_proc = DAC960_ProcWriteUserCommand; | ||
6606 | Controller->ControllerProcEntry = ControllerProcEntry; | 6592 | Controller->ControllerProcEntry = ControllerProcEntry; |
6607 | } | 6593 | } |
6608 | 6594 | ||