diff options
author | Naveen Jain <naveen_jain@ti.com> | 2010-06-09 04:45:33 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-06-18 15:39:38 -0400 |
commit | e2a53282859fab0e428a243cbe9ca8d727d9d840 (patch) | |
tree | c348e88a479d4ba7738595e5af962977d49eb484 /drivers/staging/ti-st | |
parent | b38fc2d965c3182c1855f868144a41a137e07983 (diff) |
Staging: ti-st: add version info to sysfs
Add version information to be available under the sysfs group
for kim.
Signed-off-by: Naveen Jain <naveen_jain@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/ti-st')
-rw-r--r-- | drivers/staging/ti-st/st_kim.c | 40 | ||||
-rw-r--r-- | drivers/staging/ti-st/st_kim.h | 11 |
2 files changed, 46 insertions, 5 deletions
diff --git a/drivers/staging/ti-st/st_kim.c b/drivers/staging/ti-st/st_kim.c index cfba5f88abe..d015ad3c460 100644 --- a/drivers/staging/ti-st/st_kim.c +++ b/drivers/staging/ti-st/st_kim.c | |||
@@ -56,12 +56,13 @@ static struct platform_driver kim_platform_driver = { | |||
56 | }; | 56 | }; |
57 | 57 | ||
58 | static ssize_t show_pid(struct device *dev, struct device_attribute | 58 | static ssize_t show_pid(struct device *dev, struct device_attribute |
59 | *attr, char *buf); | 59 | *attr, char *buf); |
60 | static ssize_t store_pid(struct device *dev, struct device_attribute | 60 | static ssize_t store_pid(struct device *dev, struct device_attribute |
61 | *devattr, char *buf, size_t count); | 61 | *devattr, char *buf, size_t count); |
62 | static ssize_t show_list(struct device *dev, struct device_attribute | 62 | static ssize_t show_list(struct device *dev, struct device_attribute |
63 | *attr, char *buf); | 63 | *attr, char *buf); |
64 | 64 | static ssize_t show_version(struct device *dev, struct device_attribute | |
65 | *attr, char *buf); | ||
65 | /* structures specific for sysfs entries */ | 66 | /* structures specific for sysfs entries */ |
66 | static struct kobj_attribute pid_attr = | 67 | static struct kobj_attribute pid_attr = |
67 | __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); | 68 | __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); |
@@ -69,10 +70,14 @@ __ATTR(pid, 0644, (void *)show_pid, (void *)store_pid); | |||
69 | static struct kobj_attribute list_protocols = | 70 | static struct kobj_attribute list_protocols = |
70 | __ATTR(protocols, 0444, (void *)show_list, NULL); | 71 | __ATTR(protocols, 0444, (void *)show_list, NULL); |
71 | 72 | ||
73 | static struct kobj_attribute chip_version = | ||
74 | __ATTR(version, 0444, (void *)show_version, NULL); | ||
75 | |||
72 | static struct attribute *uim_attrs[] = { | 76 | static struct attribute *uim_attrs[] = { |
73 | &pid_attr.attr, | 77 | &pid_attr.attr, |
74 | /* add more debug sysfs entries */ | 78 | /* add more debug sysfs entries */ |
75 | &list_protocols.attr, | 79 | &list_protocols.attr, |
80 | &chip_version.attr, | ||
76 | NULL, | 81 | NULL, |
77 | }; | 82 | }; |
78 | 83 | ||
@@ -251,7 +256,8 @@ static long read_local_version(char *bts_scr_name) | |||
251 | } | 256 | } |
252 | 257 | ||
253 | version = | 258 | version = |
254 | MAKEWORD(kim_gdata->resp_buffer[13], kim_gdata->resp_buffer[14]); | 259 | MAKEWORD(kim_gdata->resp_buffer[13], |
260 | kim_gdata->resp_buffer[14]); | ||
255 | chip = (version & 0x7C00) >> 10; | 261 | chip = (version & 0x7C00) >> 10; |
256 | min_ver = (version & 0x007F); | 262 | min_ver = (version & 0x007F); |
257 | maj_ver = (version & 0x0380) >> 7; | 263 | maj_ver = (version & 0x0380) >> 7; |
@@ -260,6 +266,13 @@ static long read_local_version(char *bts_scr_name) | |||
260 | maj_ver |= 0x0008; | 266 | maj_ver |= 0x0008; |
261 | 267 | ||
262 | sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); | 268 | sprintf(bts_scr_name, "TIInit_%d.%d.%d.bts", chip, maj_ver, min_ver); |
269 | |||
270 | /* to be accessed later via sysfs entry */ | ||
271 | kim_gdata->version.full = version; | ||
272 | kim_gdata->version.chip = chip; | ||
273 | kim_gdata->version.maj_ver = maj_ver; | ||
274 | kim_gdata->version.min_ver = min_ver; | ||
275 | |||
263 | pr_info("%s", bts_scr_name); | 276 | pr_info("%s", bts_scr_name); |
264 | return ST_SUCCESS; | 277 | return ST_SUCCESS; |
265 | } | 278 | } |
@@ -516,6 +529,16 @@ long st_kim_stop(void) | |||
516 | 529 | ||
517 | /**********************************************************************/ | 530 | /**********************************************************************/ |
518 | /* functions called from subsystems */ | 531 | /* functions called from subsystems */ |
532 | /* called when sysfs entry is read from */ | ||
533 | |||
534 | static ssize_t show_version(struct device *dev, struct device_attribute | ||
535 | *attr, char *buf) | ||
536 | { | ||
537 | sprintf(buf, "%04X %d.%d.%d", kim_gdata->version.full, | ||
538 | kim_gdata->version.chip, kim_gdata->version.maj_ver, | ||
539 | kim_gdata->version.min_ver); | ||
540 | return strlen(buf); | ||
541 | } | ||
519 | 542 | ||
520 | /* called when sysfs entry is written to */ | 543 | /* called when sysfs entry is written to */ |
521 | static ssize_t store_pid(struct device *dev, struct device_attribute | 544 | static ssize_t store_pid(struct device *dev, struct device_attribute |
@@ -656,6 +679,12 @@ static int kim_probe(struct platform_device *pdev) | |||
656 | } | 679 | } |
657 | pr_info("rfkill entry created for %ld", gpios[proto]); | 680 | pr_info("rfkill entry created for %ld", gpios[proto]); |
658 | } | 681 | } |
682 | |||
683 | if (sysfs_create_group(&pdev->dev.kobj, &uim_attr_grp)) { | ||
684 | pr_err(" sysfs entry creation failed"); | ||
685 | return -1; | ||
686 | } | ||
687 | pr_info(" sysfs entries created "); | ||
659 | return ST_SUCCESS; | 688 | return ST_SUCCESS; |
660 | } | 689 | } |
661 | 690 | ||
@@ -676,6 +705,7 @@ static int kim_remove(struct platform_device *pdev) | |||
676 | kim_gdata->rfkill[proto] = NULL; | 705 | kim_gdata->rfkill[proto] = NULL; |
677 | } | 706 | } |
678 | pr_info("kim: GPIO Freed"); | 707 | pr_info("kim: GPIO Freed"); |
708 | sysfs_remove_group(&pdev->dev.kobj, &uim_attr_grp); | ||
679 | kim_gdata->kim_pdev = NULL; | 709 | kim_gdata->kim_pdev = NULL; |
680 | st_core_exit(kim_gdata->core_data); | 710 | st_core_exit(kim_gdata->core_data); |
681 | return ST_SUCCESS; | 711 | return ST_SUCCESS; |
diff --git a/drivers/staging/ti-st/st_kim.h b/drivers/staging/ti-st/st_kim.h index 49c42aedb45..a5ea8d7c680 100644 --- a/drivers/staging/ti-st/st_kim.h +++ b/drivers/staging/ti-st/st_kim.h | |||
@@ -48,6 +48,16 @@ | |||
48 | * devices are created for the 3 gpios | 48 | * devices are created for the 3 gpios |
49 | * that ST has requested | 49 | * that ST has requested |
50 | */ | 50 | */ |
51 | |||
52 | /* chip version storage | ||
53 | */ | ||
54 | struct chip_version { | ||
55 | unsigned short full; | ||
56 | unsigned short chip; | ||
57 | unsigned short min_ver; | ||
58 | unsigned short maj_ver; | ||
59 | }; | ||
60 | |||
51 | /* | 61 | /* |
52 | * header file for ST provided by KIM | 62 | * header file for ST provided by KIM |
53 | */ | 63 | */ |
@@ -66,6 +76,7 @@ struct kim_data_s { | |||
66 | struct rfkill *rfkill[ST_MAX]; | 76 | struct rfkill *rfkill[ST_MAX]; |
67 | enum proto_type rf_protos[ST_MAX]; | 77 | enum proto_type rf_protos[ST_MAX]; |
68 | struct st_data_s *core_data; | 78 | struct st_data_s *core_data; |
79 | struct chip_version version; | ||
69 | }; | 80 | }; |
70 | 81 | ||
71 | long st_kim_start(void); | 82 | long st_kim_start(void); |