aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pnp/manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pnp/manager.c')
-rw-r--r--drivers/pnp/manager.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/pnp/manager.c b/drivers/pnp/manager.c
index c6b3d4e63ccc..c28caf272c11 100644
--- a/drivers/pnp/manager.c
+++ b/drivers/pnp/manager.c
@@ -12,9 +12,10 @@
12#include <linux/pnp.h> 12#include <linux/pnp.h>
13#include <linux/slab.h> 13#include <linux/slab.h>
14#include <linux/bitmap.h> 14#include <linux/bitmap.h>
15#include <linux/mutex.h>
15#include "base.h" 16#include "base.h"
16 17
17DECLARE_MUTEX(pnp_res_mutex); 18DEFINE_MUTEX(pnp_res_mutex);
18 19
19static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx) 20static int pnp_assign_port(struct pnp_dev *dev, struct pnp_port *rule, int idx)
20{ 21{
@@ -297,7 +298,7 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
297 if (!pnp_can_configure(dev)) 298 if (!pnp_can_configure(dev))
298 return -ENODEV; 299 return -ENODEV;
299 300
300 down(&pnp_res_mutex); 301 mutex_lock(&pnp_res_mutex);
301 pnp_clean_resource_table(&dev->res); /* start with a fresh slate */ 302 pnp_clean_resource_table(&dev->res); /* start with a fresh slate */
302 if (dev->independent) { 303 if (dev->independent) {
303 port = dev->independent->port; 304 port = dev->independent->port;
@@ -366,12 +367,12 @@ static int pnp_assign_resources(struct pnp_dev *dev, int depnum)
366 } else if (dev->dependent) 367 } else if (dev->dependent)
367 goto fail; 368 goto fail;
368 369
369 up(&pnp_res_mutex); 370 mutex_unlock(&pnp_res_mutex);
370 return 1; 371 return 1;
371 372
372fail: 373fail:
373 pnp_clean_resource_table(&dev->res); 374 pnp_clean_resource_table(&dev->res);
374 up(&pnp_res_mutex); 375 mutex_unlock(&pnp_res_mutex);
375 return 0; 376 return 0;
376} 377}
377 378
@@ -396,7 +397,7 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
396 return -ENOMEM; 397 return -ENOMEM;
397 *bak = dev->res; 398 *bak = dev->res;
398 399
399 down(&pnp_res_mutex); 400 mutex_lock(&pnp_res_mutex);
400 dev->res = *res; 401 dev->res = *res;
401 if (!(mode & PNP_CONFIG_FORCE)) { 402 if (!(mode & PNP_CONFIG_FORCE)) {
402 for (i = 0; i < PNP_MAX_PORT; i++) { 403 for (i = 0; i < PNP_MAX_PORT; i++) {
@@ -416,14 +417,14 @@ int pnp_manual_config_dev(struct pnp_dev *dev, struct pnp_resource_table *res,
416 goto fail; 417 goto fail;
417 } 418 }
418 } 419 }
419 up(&pnp_res_mutex); 420 mutex_unlock(&pnp_res_mutex);
420 421
421 kfree(bak); 422 kfree(bak);
422 return 0; 423 return 0;
423 424
424fail: 425fail:
425 dev->res = *bak; 426 dev->res = *bak;
426 up(&pnp_res_mutex); 427 mutex_unlock(&pnp_res_mutex);
427 kfree(bak); 428 kfree(bak);
428 return -EINVAL; 429 return -EINVAL;
429} 430}
@@ -513,7 +514,7 @@ int pnp_activate_dev(struct pnp_dev *dev)
513 int error; 514 int error;
514 515
515 if (dev->active) 516 if (dev->active)
516 return 0; /* the device is already active */ 517 return 0;
517 518
518 /* ensure resources are allocated */ 519 /* ensure resources are allocated */
519 if (pnp_auto_config_dev(dev)) 520 if (pnp_auto_config_dev(dev))
@@ -524,7 +525,7 @@ int pnp_activate_dev(struct pnp_dev *dev)
524 return error; 525 return error;
525 526
526 dev->active = 1; 527 dev->active = 1;
527 return 1; 528 return 0;
528} 529}
529 530
530/** 531/**
@@ -538,7 +539,7 @@ int pnp_disable_dev(struct pnp_dev *dev)
538 int error; 539 int error;
539 540
540 if (!dev->active) 541 if (!dev->active)
541 return 0; /* the device is already disabled */ 542 return 0;
542 543
543 error = pnp_stop_dev(dev); 544 error = pnp_stop_dev(dev);
544 if (error) 545 if (error)
@@ -547,11 +548,11 @@ int pnp_disable_dev(struct pnp_dev *dev)
547 dev->active = 0; 548 dev->active = 0;
548 549
549 /* release the resources so that other devices can use them */ 550 /* release the resources so that other devices can use them */
550 down(&pnp_res_mutex); 551 mutex_lock(&pnp_res_mutex);
551 pnp_clean_resource_table(&dev->res); 552 pnp_clean_resource_table(&dev->res);
552 up(&pnp_res_mutex); 553 mutex_unlock(&pnp_res_mutex);
553 554
554 return 1; 555 return 0;
555} 556}
556 557
557/** 558/**