aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pps/pps.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pps/pps.c')
-rw-r--r--drivers/pps/pps.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index dc7e66cb2762..1922f27a52ac 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -204,12 +204,6 @@ static int pps_cdev_open(struct inode *inode, struct file *file)
204{ 204{
205 struct pps_device *pps = container_of(inode->i_cdev, 205 struct pps_device *pps = container_of(inode->i_cdev,
206 struct pps_device, cdev); 206 struct pps_device, cdev);
207 int found;
208
209 found = pps_get_source(pps->id) != 0;
210 if (!found)
211 return -ENODEV;
212
213 file->private_data = pps; 207 file->private_data = pps;
214 208
215 return 0; 209 return 0;
@@ -217,11 +211,6 @@ static int pps_cdev_open(struct inode *inode, struct file *file)
217 211
218static int pps_cdev_release(struct inode *inode, struct file *file) 212static int pps_cdev_release(struct inode *inode, struct file *file)
219{ 213{
220 struct pps_device *pps = file->private_data;
221
222 /* Free the PPS source and wake up (possible) deregistration */
223 pps_put_source(pps);
224
225 return 0; 214 return 0;
226} 215}
227 216
@@ -242,22 +231,23 @@ static const struct file_operations pps_cdev_fops = {
242int pps_register_cdev(struct pps_device *pps) 231int pps_register_cdev(struct pps_device *pps)
243{ 232{
244 int err; 233 int err;
234 dev_t devt;
235
236 devt = MKDEV(MAJOR(pps_devt), pps->id);
245 237
246 pps->devno = MKDEV(MAJOR(pps_devt), pps->id);
247 cdev_init(&pps->cdev, &pps_cdev_fops); 238 cdev_init(&pps->cdev, &pps_cdev_fops);
248 pps->cdev.owner = pps->info.owner; 239 pps->cdev.owner = pps->info.owner;
249 240
250 err = cdev_add(&pps->cdev, pps->devno, 1); 241 err = cdev_add(&pps->cdev, devt, 1);
251 if (err) { 242 if (err) {
252 printk(KERN_ERR "pps: %s: failed to add char device %d:%d\n", 243 printk(KERN_ERR "pps: %s: failed to add char device %d:%d\n",
253 pps->info.name, MAJOR(pps_devt), pps->id); 244 pps->info.name, MAJOR(pps_devt), pps->id);
254 return err; 245 return err;
255 } 246 }
256 pps->dev = device_create(pps_class, pps->info.dev, pps->devno, NULL, 247 pps->dev = device_create(pps_class, pps->info.dev, devt, pps,
257 "pps%d", pps->id); 248 "pps%d", pps->id);
258 if (IS_ERR(pps->dev)) 249 if (IS_ERR(pps->dev))
259 goto del_cdev; 250 goto del_cdev;
260 dev_set_drvdata(pps->dev, pps);
261 251
262 pr_debug("source %s got cdev (%d:%d)\n", pps->info.name, 252 pr_debug("source %s got cdev (%d:%d)\n", pps->info.name,
263 MAJOR(pps_devt), pps->id); 253 MAJOR(pps_devt), pps->id);
@@ -272,7 +262,7 @@ del_cdev:
272 262
273void pps_unregister_cdev(struct pps_device *pps) 263void pps_unregister_cdev(struct pps_device *pps)
274{ 264{
275 device_destroy(pps_class, pps->devno); 265 device_destroy(pps_class, pps->dev->devt);
276 cdev_del(&pps->cdev); 266 cdev_del(&pps->cdev);
277} 267}
278 268