diff options
| author | Pavan Savoy <pavan_savoy@ti.com> | 2010-10-12 16:27:38 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-14 15:41:10 -0400 |
| commit | 73f12e8d3d94828b9efe2b8b8a34b4ad6d14ee47 (patch) | |
| tree | 42b4dad70d74feccd5c6c802eef6837606096ffe | |
| parent | da6830ac3969c9480e05ed2b21eee64e21a101d2 (diff) | |
drivers: misc: ti-st: fix review comments
Based on comments from Jiri Slaby, drop the register
storage specifier, remove the unused code, cleanup
the const to non-const type casting.
Also make the line discipline ops structure static, since
its a singleton, unmodified structure which need not be
in heap.
Reported-by: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Pavan Savoy <pavan_savoy@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
| -rw-r--r-- | drivers/misc/ti-st/st_core.c | 73 | ||||
| -rw-r--r-- | drivers/misc/ti-st/st_kim.c | 15 | ||||
| -rw-r--r-- | include/linux/ti_wilink_st.h | 2 |
3 files changed, 25 insertions, 65 deletions
diff --git a/drivers/misc/ti-st/st_core.c b/drivers/misc/ti-st/st_core.c index 9bae0eb26b96..f9aad06d1ae5 100644 --- a/drivers/misc/ti-st/st_core.c +++ b/drivers/misc/ti-st/st_core.c | |||
| @@ -31,15 +31,6 @@ | |||
| 31 | #include <net/bluetooth/hci.h> | 31 | #include <net/bluetooth/hci.h> |
| 32 | #include <linux/ti_wilink_st.h> | 32 | #include <linux/ti_wilink_st.h> |
| 33 | 33 | ||
| 34 | /* strings to be used for rfkill entries and by | ||
| 35 | * ST Core to be used for sysfs debug entry | ||
| 36 | */ | ||
| 37 | #define PROTO_ENTRY(type, name) name | ||
| 38 | const unsigned char *protocol_strngs[] = { | ||
| 39 | PROTO_ENTRY(ST_BT, "Bluetooth"), | ||
| 40 | PROTO_ENTRY(ST_FM, "FM"), | ||
| 41 | PROTO_ENTRY(ST_GPS, "GPS"), | ||
| 42 | }; | ||
| 43 | /* function pointer pointing to either, | 34 | /* function pointer pointing to either, |
| 44 | * st_kim_recv during registration to receive fw download responses | 35 | * st_kim_recv during registration to receive fw download responses |
| 45 | * st_int_recv after registration to receive proto stack responses | 36 | * st_int_recv after registration to receive proto stack responses |
| @@ -144,7 +135,7 @@ void st_reg_complete(struct st_data_s *st_gdata, char err) | |||
| 144 | static inline int st_check_data_len(struct st_data_s *st_gdata, | 135 | static inline int st_check_data_len(struct st_data_s *st_gdata, |
| 145 | int protoid, int len) | 136 | int protoid, int len) |
| 146 | { | 137 | { |
| 147 | register int room = skb_tailroom(st_gdata->rx_skb); | 138 | int room = skb_tailroom(st_gdata->rx_skb); |
| 148 | 139 | ||
| 149 | pr_debug("len %d room %d", len, room); | 140 | pr_debug("len %d room %d", len, room); |
| 150 | 141 | ||
| @@ -187,7 +178,7 @@ static inline int st_check_data_len(struct st_data_s *st_gdata, | |||
| 187 | static inline void st_wakeup_ack(struct st_data_s *st_gdata, | 178 | static inline void st_wakeup_ack(struct st_data_s *st_gdata, |
| 188 | unsigned char cmd) | 179 | unsigned char cmd) |
| 189 | { | 180 | { |
| 190 | register struct sk_buff *waiting_skb; | 181 | struct sk_buff *waiting_skb; |
| 191 | unsigned long flags = 0; | 182 | unsigned long flags = 0; |
| 192 | 183 | ||
| 193 | spin_lock_irqsave(&st_gdata->lock, flags); | 184 | spin_lock_irqsave(&st_gdata->lock, flags); |
| @@ -216,13 +207,13 @@ static inline void st_wakeup_ack(struct st_data_s *st_gdata, | |||
| 216 | void st_int_recv(void *disc_data, | 207 | void st_int_recv(void *disc_data, |
| 217 | const unsigned char *data, long count) | 208 | const unsigned char *data, long count) |
| 218 | { | 209 | { |
| 219 | register char *ptr; | 210 | char *ptr; |
| 220 | struct hci_event_hdr *eh; | 211 | struct hci_event_hdr *eh; |
| 221 | struct hci_acl_hdr *ah; | 212 | struct hci_acl_hdr *ah; |
| 222 | struct hci_sco_hdr *sh; | 213 | struct hci_sco_hdr *sh; |
| 223 | struct fm_event_hdr *fm; | 214 | struct fm_event_hdr *fm; |
| 224 | struct gps_event_hdr *gps; | 215 | struct gps_event_hdr *gps; |
| 225 | register int len = 0, type = 0, dlen = 0; | 216 | int len = 0, type = 0, dlen = 0; |
| 226 | static enum proto_type protoid = ST_MAX; | 217 | static enum proto_type protoid = ST_MAX; |
| 227 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; | 218 | struct st_data_s *st_gdata = (struct st_data_s *)disc_data; |
| 228 | 219 | ||
| @@ -918,34 +909,27 @@ static void st_tty_flush_buffer(struct tty_struct *tty) | |||
| 918 | return; | 909 | return; |
| 919 | } | 910 | } |
| 920 | 911 | ||
| 912 | static struct tty_ldisc_ops st_ldisc_ops = { | ||
| 913 | .magic = TTY_LDISC_MAGIC, | ||
| 914 | .name = "n_st", | ||
| 915 | .open = st_tty_open, | ||
| 916 | .close = st_tty_close, | ||
| 917 | .receive_buf = st_tty_receive, | ||
| 918 | .write_wakeup = st_tty_wakeup, | ||
| 919 | .flush_buffer = st_tty_flush_buffer, | ||
| 920 | .owner = THIS_MODULE | ||
| 921 | }; | ||
| 922 | |||
| 921 | /********************************************************************/ | 923 | /********************************************************************/ |
| 922 | int st_core_init(struct st_data_s **core_data) | 924 | int st_core_init(struct st_data_s **core_data) |
| 923 | { | 925 | { |
| 924 | struct st_data_s *st_gdata; | 926 | struct st_data_s *st_gdata; |
| 925 | long err; | 927 | long err; |
| 926 | static struct tty_ldisc_ops *st_ldisc_ops; | ||
| 927 | |||
| 928 | /* populate and register to TTY line discipline */ | ||
| 929 | st_ldisc_ops = kzalloc(sizeof(*st_ldisc_ops), GFP_KERNEL); | ||
| 930 | if (!st_ldisc_ops) { | ||
| 931 | pr_err("no mem to allocate"); | ||
| 932 | return -ENOMEM; | ||
| 933 | } | ||
| 934 | 928 | ||
| 935 | st_ldisc_ops->magic = TTY_LDISC_MAGIC; | 929 | err = tty_register_ldisc(N_TI_WL, &st_ldisc_ops); |
| 936 | st_ldisc_ops->name = "n_st"; /*"n_hci"; */ | ||
| 937 | st_ldisc_ops->open = st_tty_open; | ||
| 938 | st_ldisc_ops->close = st_tty_close; | ||
| 939 | st_ldisc_ops->receive_buf = st_tty_receive; | ||
| 940 | st_ldisc_ops->write_wakeup = st_tty_wakeup; | ||
| 941 | st_ldisc_ops->flush_buffer = st_tty_flush_buffer; | ||
| 942 | st_ldisc_ops->owner = THIS_MODULE; | ||
| 943 | |||
| 944 | err = tty_register_ldisc(N_TI_WL, st_ldisc_ops); | ||
| 945 | if (err) { | 930 | if (err) { |
| 946 | pr_err("error registering %d line discipline %ld", | 931 | pr_err("error registering %d line discipline %ld", |
| 947 | N_TI_WL, err); | 932 | N_TI_WL, err); |
| 948 | kfree(st_ldisc_ops); | ||
| 949 | return err; | 933 | return err; |
| 950 | } | 934 | } |
| 951 | pr_debug("registered n_shared line discipline"); | 935 | pr_debug("registered n_shared line discipline"); |
| @@ -956,7 +940,6 @@ int st_core_init(struct st_data_s **core_data) | |||
| 956 | err = tty_unregister_ldisc(N_TI_WL); | 940 | err = tty_unregister_ldisc(N_TI_WL); |
| 957 | if (err) | 941 | if (err) |
| 958 | pr_err("unable to un-register ldisc %ld", err); | 942 | pr_err("unable to un-register ldisc %ld", err); |
| 959 | kfree(st_ldisc_ops); | ||
| 960 | err = -ENOMEM; | 943 | err = -ENOMEM; |
| 961 | return err; | 944 | return err; |
| 962 | } | 945 | } |
| @@ -970,22 +953,6 @@ int st_core_init(struct st_data_s **core_data) | |||
| 970 | /* Locking used in st_int_enqueue() to avoid multiple execution */ | 953 | /* Locking used in st_int_enqueue() to avoid multiple execution */ |
| 971 | spin_lock_init(&st_gdata->lock); | 954 | spin_lock_init(&st_gdata->lock); |
| 972 | 955 | ||
| 973 | /* ldisc_ops ref to be only used in __exit of module */ | ||
| 974 | st_gdata->ldisc_ops = st_ldisc_ops; | ||
| 975 | |||
| 976 | #if 0 | ||
| 977 | err = st_kim_init(); | ||
| 978 | if (err) { | ||
| 979 | pr_err("error during kim initialization(%ld)", err); | ||
| 980 | kfree(st_gdata); | ||
| 981 | err = tty_unregister_ldisc(N_TI_WL); | ||
| 982 | if (err) | ||
| 983 | pr_err("unable to un-register ldisc"); | ||
| 984 | kfree(st_ldisc_ops); | ||
| 985 | return -1; | ||
| 986 | } | ||
| 987 | #endif | ||
| 988 | |||
| 989 | err = st_ll_init(st_gdata); | 956 | err = st_ll_init(st_gdata); |
| 990 | if (err) { | 957 | if (err) { |
| 991 | pr_err("error during st_ll initialization(%ld)", err); | 958 | pr_err("error during st_ll initialization(%ld)", err); |
| @@ -993,7 +960,6 @@ int st_core_init(struct st_data_s **core_data) | |||
| 993 | err = tty_unregister_ldisc(N_TI_WL); | 960 | err = tty_unregister_ldisc(N_TI_WL); |
| 994 | if (err) | 961 | if (err) |
| 995 | pr_err("unable to un-register ldisc"); | 962 | pr_err("unable to un-register ldisc"); |
| 996 | kfree(st_ldisc_ops); | ||
| 997 | return -1; | 963 | return -1; |
| 998 | } | 964 | } |
| 999 | *core_data = st_gdata; | 965 | *core_data = st_gdata; |
| @@ -1007,11 +973,7 @@ void st_core_exit(struct st_data_s *st_gdata) | |||
| 1007 | err = st_ll_deinit(st_gdata); | 973 | err = st_ll_deinit(st_gdata); |
| 1008 | if (err) | 974 | if (err) |
| 1009 | pr_err("error during deinit of ST LL %ld", err); | 975 | pr_err("error during deinit of ST LL %ld", err); |
| 1010 | #if 0 | 976 | |
| 1011 | err = st_kim_deinit(); | ||
| 1012 | if (err) | ||
| 1013 | pr_err("error during deinit of ST KIM %ld", err); | ||
| 1014 | #endif | ||
| 1015 | if (st_gdata != NULL) { | 977 | if (st_gdata != NULL) { |
| 1016 | /* Free ST Tx Qs and skbs */ | 978 | /* Free ST Tx Qs and skbs */ |
| 1017 | skb_queue_purge(&st_gdata->txq); | 979 | skb_queue_purge(&st_gdata->txq); |
| @@ -1022,7 +984,6 @@ void st_core_exit(struct st_data_s *st_gdata) | |||
| 1022 | err = tty_unregister_ldisc(N_TI_WL); | 984 | err = tty_unregister_ldisc(N_TI_WL); |
| 1023 | if (err) | 985 | if (err) |
| 1024 | pr_err("unable to un-register ldisc %ld", err); | 986 | pr_err("unable to un-register ldisc %ld", err); |
| 1025 | kfree(st_gdata->ldisc_ops); | ||
| 1026 | /* free the global data pointer */ | 987 | /* free the global data pointer */ |
