diff options
author | Ingo Molnar <mingo@elte.hu> | 2006-01-13 11:10:24 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-13 11:10:24 -0500 |
commit | bd5f0ac930168899003952110c45d110958a5c55 (patch) | |
tree | 24be938817ec7ae68fb0f7f585c8af117a3160bb | |
parent | 9b565eb794eec1ccd9edcc7263ebe5b3245a1e65 (diff) |
V4L/DVB (3354e): bttv semaphore to mutex conversion
Semaphore to mutex conversion.
The conversion was generated via scripts, and the result was validated
automatically via a script as well.
build-tested.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/bttv-driver.c | 60 | ||||
-rw-r--r-- | drivers/media/video/bttvp.h | 5 |
2 files changed, 33 insertions, 32 deletions
diff --git a/drivers/media/video/bttv-driver.c b/drivers/media/video/bttv-driver.c index 1c6cfe954548..aa4c4c521880 100644 --- a/drivers/media/video/bttv-driver.c +++ b/drivers/media/video/bttv-driver.c | |||
@@ -684,16 +684,16 @@ int check_alloc_btres(struct bttv *btv, struct bttv_fh *fh, int bit) | |||
684 | return 1; | 684 | return 1; |
685 | 685 | ||
686 | /* is it free? */ | 686 | /* is it free? */ |
687 | down(&btv->reslock); | 687 | mutex_lock(&btv->reslock); |
688 | if (btv->resources & bit) { | 688 | if (btv->resources & bit) { |
689 | /* no, someone else uses it */ | 689 | /* no, someone else uses it */ |
690 | up(&btv->reslock); | 690 | mutex_unlock(&btv->reslock); |
691 | return 0; | 691 | return 0; |
692 | } | 692 | } |
693 | /* it's free, grab it */ | 693 | /* it's free, grab it */ |
694 | fh->resources |= bit; | 694 | fh->resources |= bit; |
695 | btv->resources |= bit; | 695 | btv->resources |= bit; |
696 | up(&btv->reslock); | 696 | mutex_unlock(&btv->reslock); |
697 | return 1; | 697 | return 1; |
698 | } | 698 | } |
699 | 699 | ||
@@ -716,10 +716,10 @@ void free_btres(struct bttv *btv, struct bttv_fh *fh, int bits) | |||
716 | /* trying to free ressources not allocated by us ... */ | 716 | /* trying to free ressources not allocated by us ... */ |
717 | printk("bttv: BUG! (btres)\n"); | 717 | printk("bttv: BUG! (btres)\n"); |
718 | } | 718 | } |
719 | down(&btv->reslock); | 719 | mutex_lock(&btv->reslock); |
720 | fh->resources &= ~bits; | 720 | fh->resources &= ~bits; |
721 | btv->resources &= ~bits; | 721 | btv->resources &= ~bits; |
722 | up(&btv->reslock); | 722 | mutex_unlock(&btv->reslock); |
723 | } | 723 | } |
724 | 724 | ||
725 | /* ----------------------------------------------------------------------- */ | 725 | /* ----------------------------------------------------------------------- */ |
@@ -1536,12 +1536,12 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1536 | case VIDIOCSFREQ: | 1536 | case VIDIOCSFREQ: |
1537 | { | 1537 | { |
1538 | unsigned long *freq = arg; | 1538 | unsigned long *freq = arg; |
1539 | down(&btv->lock); | 1539 | mutex_lock(&btv->lock); |
1540 | btv->freq=*freq; | 1540 | btv->freq=*freq; |
1541 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); | 1541 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,freq); |
1542 | if (btv->has_matchbox && btv->radio_user) | 1542 | if (btv->has_matchbox && btv->radio_user) |
1543 | tea5757_set_freq(btv,*freq); | 1543 | tea5757_set_freq(btv,*freq); |
1544 | up(&btv->lock); | 1544 | mutex_unlock(&btv->lock); |
1545 | return 0; | 1545 | return 0; |
1546 | } | 1546 | } |
1547 | 1547 | ||
@@ -1571,10 +1571,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1571 | if (v->mode >= BTTV_TVNORMS) | 1571 | if (v->mode >= BTTV_TVNORMS) |
1572 | return -EINVAL; | 1572 | return -EINVAL; |
1573 | 1573 | ||
1574 | down(&btv->lock); | 1574 | mutex_lock(&btv->lock); |
1575 | set_tvnorm(btv,v->mode); | 1575 | set_tvnorm(btv,v->mode); |
1576 | bttv_call_i2c_clients(btv,cmd,v); | 1576 | bttv_call_i2c_clients(btv,cmd,v); |
1577 | up(&btv->lock); | 1577 | mutex_unlock(&btv->lock); |
1578 | return 0; | 1578 | return 0; |
1579 | } | 1579 | } |
1580 | 1580 | ||
@@ -1611,17 +1611,17 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1611 | if (v->norm >= BTTV_TVNORMS) | 1611 | if (v->norm >= BTTV_TVNORMS) |
1612 | return -EINVAL; | 1612 | return -EINVAL; |
1613 | 1613 | ||
1614 | down(&btv->lock); | 1614 | mutex_lock(&btv->lock); |
1615 | if (channel == btv->input && | 1615 | if (channel == btv->input && |
1616 | v->norm == btv->tvnorm) { | 1616 | v->norm == btv->tvnorm) { |
1617 | /* nothing to do */ | 1617 | /* nothing to do */ |
1618 | up(&btv->lock); | 1618 | mutex_unlock(&btv->lock); |
1619 | return 0; | 1619 | return 0; |
1620 | } | 1620 | } |
1621 | 1621 | ||
1622 | btv->tvnorm = v->norm; | 1622 | btv->tvnorm = v->norm; |
1623 | set_input(btv,v->channel); | 1623 | set_input(btv,v->channel); |
1624 | up(&btv->lock); | 1624 | mutex_unlock(&btv->lock); |
1625 | return 0; | 1625 | return 0; |
1626 | } | 1626 | } |
1627 | 1627 | ||
@@ -1634,14 +1634,14 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1634 | v->flags |= VIDEO_AUDIO_MUTABLE; | 1634 | v->flags |= VIDEO_AUDIO_MUTABLE; |
1635 | v->mode = VIDEO_SOUND_MONO; | 1635 | v->mode = VIDEO_SOUND_MONO; |
1636 | 1636 | ||
1637 | down(&btv->lock); | 1637 | mutex_lock(&btv->lock); |
1638 | bttv_call_i2c_clients(btv,cmd,v); | 1638 | bttv_call_i2c_clients(btv,cmd,v); |
1639 | 1639 | ||
1640 | /* card specific hooks */ | 1640 | /* card specific hooks */ |
1641 | if (btv->audio_hook) | 1641 | if (btv->audio_hook) |
1642 | btv->audio_hook(btv,v,0); | 1642 | btv->audio_hook(btv,v,0); |
1643 | 1643 | ||
1644 | up(&btv->lock); | 1644 | mutex_unlock(&btv->lock); |
1645 | return 0; | 1645 | return 0; |
1646 | } | 1646 | } |
1647 | case VIDIOCSAUDIO: | 1647 | case VIDIOCSAUDIO: |
@@ -1652,7 +1652,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1652 | if (audio >= bttv_tvcards[btv->c.type].audio_inputs) | 1652 | if (audio >= bttv_tvcards[btv->c.type].audio_inputs) |
1653 | return -EINVAL; | 1653 | return -EINVAL; |
1654 | 1654 | ||
1655 | down(&btv->lock); | 1655 | mutex_lock(&btv->lock); |
1656 | audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE); | 1656 | audio_mux(btv, (v->flags&VIDEO_AUDIO_MUTE) ? AUDIO_MUTE : AUDIO_UNMUTE); |
1657 | bttv_call_i2c_clients(btv,cmd,v); | 1657 | bttv_call_i2c_clients(btv,cmd,v); |
1658 | 1658 | ||
@@ -1660,7 +1660,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1660 | if (btv->audio_hook) | 1660 | if (btv->audio_hook) |
1661 | btv->audio_hook(btv,v,1); | 1661 | btv->audio_hook(btv,v,1); |
1662 | 1662 | ||
1663 | up(&btv->lock); | 1663 | mutex_unlock(&btv->lock); |
1664 | return 0; | 1664 | return 0; |
1665 | } | 1665 | } |
1666 | 1666 | ||
@@ -1694,10 +1694,10 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1694 | if (i == BTTV_TVNORMS) | 1694 | if (i == BTTV_TVNORMS) |
1695 | return -EINVAL; | 1695 | return -EINVAL; |
1696 | 1696 | ||
1697 | down(&btv->lock); | 1697 | mutex_lock(&btv->lock); |
1698 | set_tvnorm(btv,i); | 1698 | set_tvnorm(btv,i); |
1699 | i2c_vidiocschan(btv); | 1699 | i2c_vidiocschan(btv); |
1700 | up(&btv->lock); | 1700 | mutex_unlock(&btv->lock); |
1701 | return 0; | 1701 | return 0; |
1702 | } | 1702 | } |
1703 | case VIDIOC_QUERYSTD: | 1703 | case VIDIOC_QUERYSTD: |
@@ -1755,9 +1755,9 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1755 | 1755 | ||
1756 | if (*i > bttv_tvcards[btv->c.type].video_inputs) | 1756 | if (*i > bttv_tvcards[btv->c.type].video_inputs) |
1757 | return -EINVAL; | 1757 | return -EINVAL; |
1758 | down(&btv->lock); | 1758 | mutex_lock(&btv->lock); |
1759 | set_input(btv,*i); | 1759 | set_input(btv,*i); |
1760 | up(&btv->lock); | 1760 | mutex_unlock(&btv->lock); |
1761 | return 0; | 1761 | return 0; |
1762 | } | 1762 | } |
1763 | 1763 | ||
@@ -1769,7 +1769,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1769 | return -EINVAL; | 1769 | return -EINVAL; |
1770 | if (0 != t->index) | 1770 | if (0 != t->index) |
1771 | return -EINVAL; | 1771 | return -EINVAL; |
1772 | down(&btv->lock); | 1772 | mutex_lock(&btv->lock); |
1773 | memset(t,0,sizeof(*t)); | 1773 | memset(t,0,sizeof(*t)); |
1774 | strcpy(t->name, "Television"); | 1774 | strcpy(t->name, "Television"); |
1775 | t->type = V4L2_TUNER_ANALOG_TV; | 1775 | t->type = V4L2_TUNER_ANALOG_TV; |
@@ -1804,7 +1804,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1804 | } | 1804 | } |
1805 | } | 1805 | } |
1806 | /* FIXME: fill capability+audmode */ | 1806 | /* FIXME: fill capability+audmode */ |
1807 | up(&btv->lock); | 1807 | mutex_unlock(&btv->lock); |
1808 | return 0; | 1808 | return 0; |
1809 | } | 1809 | } |
1810 | case VIDIOC_S_TUNER: | 1810 | case VIDIOC_S_TUNER: |
@@ -1815,7 +1815,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1815 | return -EINVAL; | 1815 | return -EINVAL; |
1816 | if (0 != t->index) | 1816 | if (0 != t->index) |
1817 | return -EINVAL; | 1817 | return -EINVAL; |
1818 | down(&btv->lock); | 1818 | mutex_lock(&btv->lock); |
1819 | { | 1819 | { |
1820 | struct video_audio va; | 1820 | struct video_audio va; |
1821 | memset(&va, 0, sizeof(struct video_audio)); | 1821 | memset(&va, 0, sizeof(struct video_audio)); |
@@ -1832,7 +1832,7 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1832 | if (btv->audio_hook) | 1832 | if (btv->audio_hook) |
1833 | btv->audio_hook(btv,&va,1); | 1833 | btv->audio_hook(btv,&va,1); |
1834 | } | 1834 | } |
1835 | up(&btv->lock); | 1835 | mutex_unlock(&btv->lock); |
1836 | return 0; | 1836 | return 0; |
1837 | } | 1837 | } |
1838 | 1838 | ||
@@ -1853,12 +1853,12 @@ static int bttv_common_ioctls(struct bttv *btv, unsigned int cmd, void *arg) | |||
1853 | return -EINVAL; | 1853 | return -EINVAL; |
1854 | if (unlikely (f->type != V4L2_TUNER_ANALOG_TV)) | 1854 | if (unlikely (f->type != V4L2_TUNER_ANALOG_TV)) |
1855 | return -EINVAL; | 1855 | return -EINVAL; |
1856 | down(&btv->lock); | 1856 | mutex_lock(&btv->lock); |
1857 | btv->freq = f->frequency; | 1857 | btv->freq = f->frequency; |
1858 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq); | 1858 | bttv_call_i2c_clients(btv,VIDIOCSFREQ,&btv->freq); |
1859 | if (btv->has_matchbox && btv->radio_user) | 1859 | if (btv->has_matchbox && btv->radio_user) |
1860 | tea5757_set_freq(btv,btv->freq); | 1860 | tea5757_set_freq(btv,btv->freq); |
1861 | up(&btv->lock); | 1861 | mutex_unlock(&btv->lock); |
1862 | return 0; | 1862 | return 0; |
1863 | } | 1863 | } |
1864 | case VIDIOC_LOG_STATUS: | 1864 | case VIDIOC_LOG_STATUS: |
@@ -3156,7 +3156,7 @@ static int radio_open(struct inode *inode, struct file *file) | |||
3156 | return -ENODEV; | 3156 | return -ENODEV; |
3157 | 3157 | ||
3158 | dprintk("bttv%d: open called (radio)\n",btv->c.nr); | 3158 | dprintk("bttv%d: open called (radio)\n",btv->c.nr); |
3159 | down(&btv->lock); | 3159 | mutex_lock(&btv->lock); |
3160 | 3160 | ||
3161 | btv->radio_user++; | 3161 | btv->radio_user++; |
3162 | 3162 | ||
@@ -3165,7 +3165,7 @@ static int radio_open(struct inode *inode, struct file *file) | |||
3165 | bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); | 3165 | bttv_call_i2c_clients(btv,AUDC_SET_RADIO,&btv->tuner_type); |
3166 | audio_mux(btv,AUDIO_RADIO); | 3166 | audio_mux(btv,AUDIO_RADIO); |
3167 | 3167 | ||
3168 | up(&btv->lock); | 3168 | mutex_unlock(&btv->lock); |
3169 | return 0; | 3169 | return 0; |
3170 | } | 3170 | } |
3171 | 3171 | ||
@@ -3920,8 +3920,8 @@ static int __devinit bttv_probe(struct pci_dev *dev, | |||
3920 | sprintf(btv->c.name,"bttv%d",btv->c.nr); | 3920 | sprintf(btv->c.name,"bttv%d",btv->c.nr); |
3921 | 3921 | ||
3922 | /* initialize structs / fill in defaults */ | 3922 | /* initialize structs / fill in defaults */ |
3923 | init_MUTEX(&btv->lock); | 3923 | mutex_init(&btv->lock); |
3924 | init_MUTEX(&btv->reslock); | 3924 | mutex_init(&btv->reslock); |
3925 | spin_lock_init(&btv->s_lock); | 3925 | spin_lock_init(&btv->s_lock); |
3926 | spin_lock_init(&btv->gpio_lock); | 3926 | spin_lock_init(&btv->gpio_lock); |
3927 | init_waitqueue_head(&btv->gpioq); | 3927 | init_waitqueue_head(&btv->gpioq); |
diff --git a/drivers/media/video/bttvp.h b/drivers/media/video/bttvp.h index dd00c20ab95e..9cb72f176f7d 100644 --- a/drivers/media/video/bttvp.h +++ b/drivers/media/video/bttvp.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/videodev.h> | 35 | #include <linux/videodev.h> |
36 | #include <linux/pci.h> | 36 | #include <linux/pci.h> |
37 | #include <linux/input.h> | 37 | #include <linux/input.h> |
38 | #include <linux/mutex.h> | ||
38 | #include <asm/scatterlist.h> | 39 | #include <asm/scatterlist.h> |
39 | #include <asm/io.h> | 40 | #include <asm/io.h> |
40 | 41 | ||
@@ -309,9 +310,9 @@ struct bttv { | |||
309 | 310 | ||
310 | /* locking */ | 311 | /* locking */ |
311 | spinlock_t s_lock; | 312 | spinlock_t s_lock; |
312 | struct semaphore lock; | 313 | struct mutex lock; |
313 | int resources; | 314 | int resources; |
314 | struct semaphore reslock; | 315 | struct mutex reslock; |
315 | #ifdef VIDIOC_G_PRIORITY | 316 | #ifdef VIDIOC_G_PRIORITY |
316 | struct v4l2_prio_state prio; | 317 | struct v4l2_prio_state prio; |
317 | #endif | 318 | #endif |