ide-disk: add proc_idedisk_read_smart() helper

* Factor out common code from proc_idedisk_read_smart_{thresholds,values}()
  to proc_idedisk_read_smart() helper.

* Rename proc_idedisk_read_smart_thresholds() to proc_idedisk_read_st()
  and proc_idedisk_read_smart_values() to proc_idedisk_read_sv().

There should be no functional changes caused by this patch.
Signed-off-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
上级 1a2f84ea
...@@ -540,13 +540,13 @@ static int proc_idedisk_read_capacity ...@@ -540,13 +540,13 @@ static int proc_idedisk_read_capacity
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
static int proc_idedisk_read_smart_thresholds static int proc_idedisk_read_smart(char *page, char **start, off_t off,
(char *page, char **start, off_t off, int count, int *eof, void *data) int count, int *eof, void *data, u8 sub_cmd)
{ {
ide_drive_t *drive = (ide_drive_t *)data; ide_drive_t *drive = (ide_drive_t *)data;
int len = 0, i = 0; int len = 0, i = 0;
if (get_smart_data(drive, page, SMART_READ_THRESHOLDS) == 0) { if (get_smart_data(drive, page, sub_cmd) == 0) {
unsigned short *val = (unsigned short *) page; unsigned short *val = (unsigned short *) page;
char *out = ((char *)val) + (SECTOR_WORDS * 4); char *out = ((char *)val) + (SECTOR_WORDS * 4);
page = out; page = out;
...@@ -559,31 +559,26 @@ static int proc_idedisk_read_smart_thresholds ...@@ -559,31 +559,26 @@ static int proc_idedisk_read_smart_thresholds
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
static int proc_idedisk_read_smart_values static int proc_idedisk_read_sv
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
ide_drive_t *drive = (ide_drive_t *)data; return proc_idedisk_read_smart(page, start, off, count, eof, data,
int len = 0, i = 0; SMART_READ_VALUES);
}
if (get_smart_data(drive, page, SMART_READ_VALUES) == 0) { static int proc_idedisk_read_st
unsigned short *val = (unsigned short *) page; (char *page, char **start, off_t off, int count, int *eof, void *data)
char *out = ((char *)val) + (SECTOR_WORDS * 4); {
page = out; return proc_idedisk_read_smart(page, start, off, count, eof, data,
do { SMART_READ_THRESHOLDS);
out += sprintf(out, "%04x%c", le16_to_cpu(*val), (++i & 7) ? ' ' : '\n');
val += 1;
} while (i < (SECTOR_WORDS * 2));
len = out - page;
}
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
} }
static ide_proc_entry_t idedisk_proc[] = { static ide_proc_entry_t idedisk_proc[] = {
{ "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL }, { "cache", S_IFREG|S_IRUGO, proc_idedisk_read_cache, NULL },
{ "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL }, { "capacity", S_IFREG|S_IRUGO, proc_idedisk_read_capacity, NULL },
{ "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL }, { "geometry", S_IFREG|S_IRUGO, proc_ide_read_geometry, NULL },
{ "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_smart_values, NULL }, { "smart_values", S_IFREG|S_IRUSR, proc_idedisk_read_sv, NULL },
{ "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_smart_thresholds, NULL }, { "smart_thresholds", S_IFREG|S_IRUSR, proc_idedisk_read_st, NULL },
{ NULL, 0, NULL, NULL } { NULL, 0, NULL, NULL }
}; };
#endif /* CONFIG_IDE_PROC_FS */ #endif /* CONFIG_IDE_PROC_FS */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册