diff options
author | Mike Isely <isely@pobox.com> | 2008-08-31 19:57:54 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:57 -0400 |
commit | 0b7c2c9598e7447ad6a9d157491e6c5459ae56de (patch) | |
tree | 0ff641d7efe5edd7597efe5a1372458809e1b262 | |
parent | 26dd1c57a05f5c6d339d55d5317d47576fd2fbc5 (diff) |
V4L/DVB (8899): pvrusb2: Implement default value retrieval in sysfs interface
Signed-off-by: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/pvrusb2/pvrusb2-sysfs.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c index 46a8c39ba030..ac01b11f7b99 100644 --- a/drivers/media/video/pvrusb2/pvrusb2-sysfs.c +++ b/drivers/media/video/pvrusb2/pvrusb2-sysfs.c | |||
@@ -65,6 +65,7 @@ struct pvr2_sysfs_ctl_item { | |||
65 | struct device_attribute attr_type; | 65 | struct device_attribute attr_type; |
66 | struct device_attribute attr_min; | 66 | struct device_attribute attr_min; |
67 | struct device_attribute attr_max; | 67 | struct device_attribute attr_max; |
68 | struct device_attribute attr_def; | ||
68 | struct device_attribute attr_enum; | 69 | struct device_attribute attr_enum; |
69 | struct device_attribute attr_bits; | 70 | struct device_attribute attr_bits; |
70 | struct device_attribute attr_val; | 71 | struct device_attribute attr_val; |
@@ -145,6 +146,24 @@ static ssize_t show_max(struct device *class_dev, | |||
145 | return scnprintf(buf, PAGE_SIZE, "%ld\n", val); | 146 | return scnprintf(buf, PAGE_SIZE, "%ld\n", val); |
146 | } | 147 | } |
147 | 148 | ||
149 | static ssize_t show_def(struct device *class_dev, | ||
150 | struct device_attribute *attr, | ||
151 | char *buf) | ||
152 | { | ||
153 | struct pvr2_sysfs_ctl_item *cip; | ||
154 | int val; | ||
155 | int ret; | ||
156 | cip = container_of(attr, struct pvr2_sysfs_ctl_item, attr_def); | ||
157 | ret = pvr2_ctrl_get_def(cip->cptr, &val); | ||
158 | pvr2_sysfs_trace("pvr2_sysfs(%p) show_def(cid=%d) is %d, stat=%d", | ||
159 | cip->chptr, cip->ctl_id, val, ret); | ||
160 | if (ret < 0) { | ||
161 | /* Keep checkpatch.pl quiet */ | ||
162 | return ret; | ||
163 | } | ||
164 | return scnprintf(buf, PAGE_SIZE, "%d\n", val); | ||
165 | } | ||
166 | |||
148 | static ssize_t show_val_norm(struct device *class_dev, | 167 | static ssize_t show_val_norm(struct device *class_dev, |
149 | struct device_attribute *attr, | 168 | struct device_attribute *attr, |
150 | char *buf) | 169 | char *buf) |
@@ -320,6 +339,10 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
320 | cip->attr_max.attr.mode = S_IRUGO; | 339 | cip->attr_max.attr.mode = S_IRUGO; |
321 | cip->attr_max.show = show_max; | 340 | cip->attr_max.show = show_max; |
322 | 341 | ||
342 | cip->attr_def.attr.name = "def_val"; | ||
343 | cip->attr_def.attr.mode = S_IRUGO; | ||
344 | cip->attr_def.show = show_def; | ||
345 | |||
323 | cip->attr_val.attr.name = "cur_val"; | 346 | cip->attr_val.attr.name = "cur_val"; |
324 | cip->attr_val.attr.mode = S_IRUGO; | 347 | cip->attr_val.attr.mode = S_IRUGO; |
325 | 348 | ||
@@ -343,6 +366,7 @@ static void pvr2_sysfs_add_control(struct pvr2_sysfs *sfp,int ctl_id) | |||
343 | cip->attr_gen[acnt++] = &cip->attr_name.attr; | 366 | cip->attr_gen[acnt++] = &cip->attr_name.attr; |
344 | cip->attr_gen[acnt++] = &cip->attr_type.attr; | 367 | cip->attr_gen[acnt++] = &cip->attr_type.attr; |
345 | cip->attr_gen[acnt++] = &cip->attr_val.attr; | 368 | cip->attr_gen[acnt++] = &cip->attr_val.attr; |
369 | cip->attr_gen[acnt++] = &cip->attr_def.attr; | ||
346 | cip->attr_val.show = show_val_norm; | 370 | cip->attr_val.show = show_val_norm; |
347 | cip->attr_val.store = store_val_norm; | 371 | cip->attr_val.store = store_val_norm; |
348 | if (pvr2_ctrl_has_custom_symbols(cptr)) { | 372 | if (pvr2_ctrl_has_custom_symbols(cptr)) { |