diff options
author | Sudip Mukherjee <sudipm.mukherjee@gmail.com> | 2015-07-20 07:57:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-08-05 16:36:49 -0400 |
commit | 4edd70c133f3921c594883d8f9da31a7261f8b4f (patch) | |
tree | 99461ce0e9d52b41aafcc41df8c31a3ea4294990 /drivers/auxdisplay/ks0108.c | |
parent | c9efdbe63410984668a4983cc46e31a7b3f0c74e (diff) |
auxdisplay: ks0108: use new parport device model
Modify auxdisplay driver to use the new parallel port device model.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/auxdisplay/ks0108.c')
-rw-r--r-- | drivers/auxdisplay/ks0108.c | 76 |
1 files changed, 47 insertions, 29 deletions
diff --git a/drivers/auxdisplay/ks0108.c b/drivers/auxdisplay/ks0108.c index ce00e95040bf..4c471bd8c2f7 100644 --- a/drivers/auxdisplay/ks0108.c +++ b/drivers/auxdisplay/ks0108.c | |||
@@ -125,51 +125,69 @@ unsigned char ks0108_isinited(void) | |||
125 | } | 125 | } |
126 | EXPORT_SYMBOL_GPL(ks0108_isinited); | 126 | EXPORT_SYMBOL_GPL(ks0108_isinited); |
127 | 127 | ||
128 | /* | 128 | static void ks0108_parport_attach(struct parport *port) |
129 | * Module Init & Exit | ||
130 | */ | ||
131 | |||
132 | static int __init ks0108_init(void) | ||
133 | { | 129 | { |
134 | int result; | 130 | struct pardev_cb ks0108_cb; |
135 | int ret = -EINVAL; | ||
136 | 131 | ||
137 | ks0108_parport = parport_find_base(ks0108_port); | 132 | if (port->base != ks0108_port) |
138 | if (ks0108_parport == NULL) { | 133 | return; |
139 | pr_err("ERROR: parport didn't find %i port\n", ks0108_port); | ||
140 | goto none; | ||
141 | } | ||
142 | 134 | ||
143 | ks0108_pardevice = parport_register_device(ks0108_parport, KS0108_NAME, | 135 | memset(&ks0108_cb, 0, sizeof(ks0108_cb)); |
144 | NULL, NULL, NULL, PARPORT_DEV_EXCL, NULL); | 136 | ks0108_cb.flags = PARPORT_DEV_EXCL; |
145 | parport_put_port(ks0108_parport); | 137 | ks0108_pardevice = parport_register_dev_model(port, KS0108_NAME, |
146 | if (ks0108_pardevice == NULL) { | 138 | &ks0108_cb, 0); |
139 | if (!ks0108_pardevice) { | ||
147 | pr_err("ERROR: parport didn't register new device\n"); | 140 | pr_err("ERROR: parport didn't register new device\n"); |
148 | goto none; | 141 | return; |
149 | } | 142 | } |
150 | 143 | if (parport_claim(ks0108_pardevice)) { | |
151 | result = parport_claim(ks0108_pardevice); | 144 | pr_err("could not claim access to parport %i. Aborting.\n", |
152 | if (result != 0) { | ||
153 | pr_err("ERROR: can't claim %i parport, maybe in use\n", | ||
154 | ks0108_port); | 145 | ks0108_port); |
155 | ret = result; | 146 | goto err_unreg_device; |
156 | goto registered; | ||
157 | } | 147 | } |
158 | 148 | ||
159 | ks0108_inited = 1; | 149 | ks0108_inited = 1; |
160 | return 0; | 150 | return; |
161 | 151 | ||
162 | registered: | 152 | err_unreg_device: |
163 | parport_unregister_device(ks0108_pardevice); | 153 | parport_unregister_device(ks0108_pardevice); |
164 | 154 | ks0108_pardevice = NULL; | |
165 | none: | ||
166 | return ret; | ||
167 | } | 155 | } |
168 | 156 | ||
169 | static void __exit ks0108_exit(void) | 157 | static void ks0108_parport_detach(struct parport *port) |
170 | { | 158 | { |
159 | if (port->base != ks0108_port) | ||
160 | return; | ||
161 | |||
162 | if (!ks0108_pardevice) { | ||
163 | pr_err("%s: already unregistered.\n", KS0108_NAME); | ||
164 | return; | ||
165 | } | ||
166 | |||
171 | parport_release(ks0108_pardevice); | 167 | parport_release(ks0108_pardevice); |
172 | parport_unregister_device(ks0108_pardevice); | 168 | parport_unregister_device(ks0108_pardevice); |
169 | ks0108_pardevice = NULL; | ||
170 | } | ||
171 | |||
172 | /* | ||
173 | * Module Init & Exit | ||
174 | */ | ||
175 | |||
176 | static struct parport_driver ks0108_parport_driver = { | ||
177 | .name = "ks0108", | ||
178 | .match_port = ks0108_parport_attach, | ||
179 | .detach = ks0108_parport_detach, | ||
180 | .devmodel = true, | ||
181 | }; | ||
182 | |||
183 | static int __init ks0108_init(void) | ||
184 | { | ||
185 | return parport_register_driver(&ks0108_parport_driver); | ||
186 | } | ||
187 | |||
188 | static void __exit ks0108_exit(void) | ||
189 | { | ||
190 | parport_unregister_driver(&ks0108_parport_driver); | ||
173 | } | 191 | } |
174 | 192 | ||
175 | module_init(ks0108_init); | 193 | module_init(ks0108_init); |