Blame view
drivers/ide/ide-disk_proc.c
4.59 KB
06b89518f
|
1 2 |
#include <linux/kernel.h> #include <linux/ide.h> |
5a0e3ad6a
|
3 |
#include <linux/slab.h> |
6d703a81a
|
4 |
#include <linux/seq_file.h> |
06b89518f
|
5 6 7 8 9 |
#include "ide-disk.h" static int smart_enable(ide_drive_t *drive) { |
22aa4b32a
|
10 11 |
struct ide_cmd cmd; struct ide_taskfile *tf = &cmd.tf; |
06b89518f
|
12 |
|
22aa4b32a
|
13 |
memset(&cmd, 0, sizeof(cmd)); |
06b89518f
|
14 15 16 17 |
tf->feature = ATA_SMART_ENABLE; tf->lbam = ATA_SMART_LBAM_PASS; tf->lbah = ATA_SMART_LBAH_PASS; tf->command = ATA_CMD_SMART; |
60f85019c
|
18 19 |
cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; |
22aa4b32a
|
20 21 |
return ide_no_data_taskfile(drive, &cmd); |
06b89518f
|
22 23 24 25 |
} static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd) { |
22aa4b32a
|
26 27 |
struct ide_cmd cmd; struct ide_taskfile *tf = &cmd.tf; |
06b89518f
|
28 |
|
22aa4b32a
|
29 |
memset(&cmd, 0, sizeof(cmd)); |
06b89518f
|
30 31 32 33 34 |
tf->feature = sub_cmd; tf->nsect = 0x01; tf->lbam = ATA_SMART_LBAM_PASS; tf->lbah = ATA_SMART_LBAH_PASS; tf->command = ATA_CMD_SMART; |
60f85019c
|
35 36 |
cmd.valid.out.tf = IDE_VALID_OUT_TF | IDE_VALID_DEVICE; cmd.valid.in.tf = IDE_VALID_IN_TF | IDE_VALID_DEVICE; |
0dfb991c6
|
37 |
cmd.protocol = ATA_PROT_PIO; |
39375853d
|
38 |
|
22aa4b32a
|
39 |
return ide_raw_taskfile(drive, &cmd, buf, 1); |
06b89518f
|
40 |
} |
6d703a81a
|
41 |
static int idedisk_cache_proc_show(struct seq_file *m, void *v) |
06b89518f
|
42 |
{ |
6d703a81a
|
43 |
ide_drive_t *drive = (ide_drive_t *) m->private; |
06b89518f
|
44 45 |
if (drive->dev_flags & IDE_DFLAG_ID_READ) |
6d703a81a
|
46 47 |
seq_printf(m, "%i ", drive->id[ATA_ID_BUF_SIZE] / 2); |
06b89518f
|
48 |
else |
6d703a81a
|
49 50 51 52 |
seq_printf(m, "(none) "); return 0; } |
06b89518f
|
53 |
|
6d703a81a
|
54 55 56 |
static int idedisk_cache_proc_open(struct inode *inode, struct file *file) { return single_open(file, idedisk_cache_proc_show, PDE(inode)->data); |
06b89518f
|
57 |
} |
6d703a81a
|
58 59 60 61 62 63 64 65 66 |
static const struct file_operations idedisk_cache_proc_fops = { .owner = THIS_MODULE, .open = idedisk_cache_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int idedisk_capacity_proc_show(struct seq_file *m, void *v) |
06b89518f
|
67 |
{ |
6d703a81a
|
68 |
ide_drive_t*drive = (ide_drive_t *)m->private; |
06b89518f
|
69 |
|
6d703a81a
|
70 71 72 73 |
seq_printf(m, "%llu ", (long long)ide_gd_capacity(drive)); return 0; } |
06b89518f
|
74 |
|
6d703a81a
|
75 76 77 |
static int idedisk_capacity_proc_open(struct inode *inode, struct file *file) { return single_open(file, idedisk_capacity_proc_show, PDE(inode)->data); |
06b89518f
|
78 |
} |
6d703a81a
|
79 80 81 82 83 84 85 86 87 |
static const struct file_operations idedisk_capacity_proc_fops = { .owner = THIS_MODULE, .open = idedisk_capacity_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int __idedisk_proc_show(struct seq_file *m, ide_drive_t *drive, u8 sub_cmd) |
06b89518f
|
88 |
{ |
6d703a81a
|
89 90 91 92 93 |
u8 *buf; buf = kmalloc(SECTOR_SIZE, GFP_KERNEL); if (!buf) return -ENOMEM; |
06b89518f
|
94 |
|
39375853d
|
95 |
(void)smart_enable(drive); |
6d703a81a
|
96 97 98 99 100 101 102 103 104 |
if (get_smart_data(drive, buf, sub_cmd) == 0) { __le16 *val = (__le16 *)buf; int i; for (i = 0; i < SECTOR_SIZE / 2; i++) { seq_printf(m, "%04x%c", le16_to_cpu(val[i]), (i % 8) == 7 ? ' ' : ' '); } |
06b89518f
|
105 |
} |
6d703a81a
|
106 107 108 |
kfree(buf); return 0; } |
06b89518f
|
109 |
|
6d703a81a
|
110 111 112 |
static int idedisk_sv_proc_show(struct seq_file *m, void *v) { return __idedisk_proc_show(m, m->private, ATA_SMART_READ_VALUES); |
06b89518f
|
113 |
} |
6d703a81a
|
114 |
static int idedisk_sv_proc_open(struct inode *inode, struct file *file) |
06b89518f
|
115 |
{ |
6d703a81a
|
116 |
return single_open(file, idedisk_sv_proc_show, PDE(inode)->data); |
06b89518f
|
117 |
} |
6d703a81a
|
118 119 120 121 122 123 124 125 126 |
static const struct file_operations idedisk_sv_proc_fops = { .owner = THIS_MODULE, .open = idedisk_sv_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; static int idedisk_st_proc_show(struct seq_file *m, void *v) |
06b89518f
|
127 |
{ |
6d703a81a
|
128 |
return __idedisk_proc_show(m, m->private, ATA_SMART_READ_THRESHOLDS); |
06b89518f
|
129 |
} |
6d703a81a
|
130 131 132 133 134 135 136 137 138 139 140 141 |
static int idedisk_st_proc_open(struct inode *inode, struct file *file) { return single_open(file, idedisk_st_proc_show, PDE(inode)->data); } static const struct file_operations idedisk_st_proc_fops = { .owner = THIS_MODULE, .open = idedisk_st_proc_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; |
06b89518f
|
142 |
ide_proc_entry_t ide_disk_proc[] = { |
6d703a81a
|
143 144 145 146 147 148 |
{ "cache", S_IFREG|S_IRUGO, &idedisk_cache_proc_fops }, { "capacity", S_IFREG|S_IRUGO, &idedisk_capacity_proc_fops }, { "geometry", S_IFREG|S_IRUGO, &ide_geometry_proc_fops }, { "smart_values", S_IFREG|S_IRUSR, &idedisk_sv_proc_fops }, { "smart_thresholds", S_IFREG|S_IRUSR, &idedisk_st_proc_fops }, {} |
06b89518f
|
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
}; ide_devset_rw_field(bios_cyl, bios_cyl); ide_devset_rw_field(bios_head, bios_head); ide_devset_rw_field(bios_sect, bios_sect); ide_devset_rw_field(failures, failures); ide_devset_rw_field(lun, lun); ide_devset_rw_field(max_failures, max_failures); const struct ide_proc_devset ide_disk_settings[] = { IDE_PROC_DEVSET(acoustic, 0, 254), IDE_PROC_DEVSET(address, 0, 2), IDE_PROC_DEVSET(bios_cyl, 0, 65535), IDE_PROC_DEVSET(bios_head, 0, 255), IDE_PROC_DEVSET(bios_sect, 0, 63), IDE_PROC_DEVSET(failures, 0, 65535), IDE_PROC_DEVSET(lun, 0, 7), IDE_PROC_DEVSET(max_failures, 0, 65535), IDE_PROC_DEVSET(multcount, 0, 16), IDE_PROC_DEVSET(nowerr, 0, 1), IDE_PROC_DEVSET(wcache, 0, 1), |
71bfc7a7c
|
170 |
{ NULL }, |
06b89518f
|
171 |
}; |