Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aa429110 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by David S. Miller
Browse files

[IRDA]: use mutex instead of semaphore in VLSI 82C147 IrDA controller driver



The VLSI 82C147 IrDA controller driver uses a semaphore as mutex.  Use the
mutex API instead of the (binary) semaphore.

Signed-off-by: default avatarMatthias Kaehlcke <matthias.kaehlcke@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6f11df83
Loading
Loading
Loading
Loading
+14 −13
Original line number Original line Diff line number Diff line
@@ -44,6 +44,7 @@ MODULE_LICENSE("GPL");
#include <linux/time.h>
#include <linux/time.h>
#include <linux/proc_fs.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/seq_file.h>
#include <linux/mutex.h>
#include <asm/uaccess.h>
#include <asm/uaccess.h>
#include <asm/byteorder.h>
#include <asm/byteorder.h>


@@ -1660,8 +1661,8 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	idev = ndev->priv;
	idev = ndev->priv;


	spin_lock_init(&idev->lock);
	spin_lock_init(&idev->lock);
	init_MUTEX(&idev->sem);
	mutex_init(&idev->mtx);
	down(&idev->sem);
	mutex_lock(&idev->mtx);
	idev->pdev = pdev;
	idev->pdev = pdev;


	if (vlsi_irda_init(ndev) < 0)
	if (vlsi_irda_init(ndev) < 0)
@@ -1689,12 +1690,12 @@ vlsi_irda_probe(struct pci_dev *pdev, const struct pci_device_id *id)
	IRDA_MESSAGE("%s: registered device %s\n", drivername, ndev->name);
	IRDA_MESSAGE("%s: registered device %s\n", drivername, ndev->name);


	pci_set_drvdata(pdev, ndev);
	pci_set_drvdata(pdev, ndev);
	up(&idev->sem);
	mutex_unlock(&idev->mtx);


	return 0;
	return 0;


out_freedev:
out_freedev:
	up(&idev->sem);
	mutex_unlock(&idev->mtx);
	free_netdev(ndev);
	free_netdev(ndev);
out_disable:
out_disable:
	pci_disable_device(pdev);
	pci_disable_device(pdev);
@@ -1716,12 +1717,12 @@ static void __devexit vlsi_irda_remove(struct pci_dev *pdev)
	unregister_netdev(ndev);
	unregister_netdev(ndev);


	idev = ndev->priv;
	idev = ndev->priv;
	down(&idev->sem);
	mutex_lock(&idev->mtx);
	if (idev->proc_entry) {
	if (idev->proc_entry) {
		remove_proc_entry(ndev->name, vlsi_proc_root);
		remove_proc_entry(ndev->name, vlsi_proc_root);
		idev->proc_entry = NULL;
		idev->proc_entry = NULL;
	}
	}
	up(&idev->sem);
	mutex_unlock(&idev->mtx);


	free_netdev(ndev);
	free_netdev(ndev);


@@ -1751,7 +1752,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
		return 0;
		return 0;
	}
	}
	idev = ndev->priv;	
	idev = ndev->priv;	
	down(&idev->sem);
	mutex_lock(&idev->mtx);
	if (pdev->current_state != 0) {			/* already suspended */
	if (pdev->current_state != 0) {			/* already suspended */
		if (state.event > pdev->current_state) {	/* simply go deeper */
		if (state.event > pdev->current_state) {	/* simply go deeper */
			pci_set_power_state(pdev, pci_choose_state(pdev, state));
			pci_set_power_state(pdev, pci_choose_state(pdev, state));
@@ -1759,7 +1760,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
		}
		}
		else
		else
			IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, pci_name(pdev), pdev->current_state, state.event);
			IRDA_ERROR("%s - %s: invalid suspend request %u -> %u\n", __FUNCTION__, pci_name(pdev), pdev->current_state, state.event);
		up(&idev->sem);
		mutex_unlock(&idev->mtx);
		return 0;
		return 0;
	}
	}


@@ -1775,7 +1776,7 @@ static int vlsi_irda_suspend(struct pci_dev *pdev, pm_message_t state)
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
	pci_set_power_state(pdev, pci_choose_state(pdev, state));
	pdev->current_state = state.event;
	pdev->current_state = state.event;
	idev->resume_ok = 1;
	idev->resume_ok = 1;
	up(&idev->sem);
	mutex_unlock(&idev->mtx);
	return 0;
	return 0;
}
}


@@ -1790,9 +1791,9 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
		return 0;
		return 0;
	}
	}
	idev = ndev->priv;	
	idev = ndev->priv;	
	down(&idev->sem);
	mutex_lock(&idev->mtx);
	if (pdev->current_state == 0) {
	if (pdev->current_state == 0) {
		up(&idev->sem);
		mutex_unlock(&idev->mtx);
		IRDA_WARNING("%s - %s: already resumed\n",
		IRDA_WARNING("%s - %s: already resumed\n",
			     __FUNCTION__, pci_name(pdev));
			     __FUNCTION__, pci_name(pdev));
		return 0;
		return 0;
@@ -1814,7 +1815,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
		 * device and independently resume_ok should catch any garbage config.
		 * device and independently resume_ok should catch any garbage config.
		 */
		 */
		IRDA_WARNING("%s - hm, nothing to resume?\n", __FUNCTION__);
		IRDA_WARNING("%s - hm, nothing to resume?\n", __FUNCTION__);
		up(&idev->sem);
		mutex_unlock(&idev->mtx);
		return 0;
		return 0;
	}
	}


@@ -1824,7 +1825,7 @@ static int vlsi_irda_resume(struct pci_dev *pdev)
		netif_device_attach(ndev);
		netif_device_attach(ndev);
	}
	}
	idev->resume_ok = 0;
	idev->resume_ok = 0;
	up(&idev->sem);
	mutex_unlock(&idev->mtx);
	return 0;
	return 0;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -728,7 +728,7 @@ typedef struct vlsi_irda_dev {
	struct timeval		last_rx;
	struct timeval		last_rx;


	spinlock_t		lock;
	spinlock_t		lock;
	struct semaphore	sem;
	struct mutex		mtx;


	u8			resume_ok;	
	u8			resume_ok;	
	struct proc_dir_entry	*proc_entry;
	struct proc_dir_entry	*proc_entry;