aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb')
-rw-r--r--drivers/media/dvb/dvb-core/dvb_frontend.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/drivers/media/dvb/dvb-core/dvb_frontend.c b/drivers/media/dvb/dvb-core/dvb_frontend.c
index 55ea260572bf..6932def4d266 100644
--- a/drivers/media/dvb/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb/dvb-core/dvb_frontend.c
@@ -95,6 +95,10 @@ MODULE_PARM_DESC(dvb_mfe_wait_time, "Wait up to <mfe_wait_time> seconds on open(
95 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again. 95 * FESTATE_LOSTLOCK. When the lock has been lost, and we're searching it again.
96 */ 96 */
97 97
98#define DVB_FE_NO_EXIT 0
99#define DVB_FE_NORMAL_EXIT 1
100#define DVB_FE_DEVICE_REMOVED 2
101
98static DEFINE_MUTEX(frontend_mutex); 102static DEFINE_MUTEX(frontend_mutex);
99 103
100struct dvb_frontend_private { 104struct dvb_frontend_private {
@@ -497,7 +501,7 @@ static int dvb_frontend_is_exiting(struct dvb_frontend *fe)
497{ 501{
498 struct dvb_frontend_private *fepriv = fe->frontend_priv; 502 struct dvb_frontend_private *fepriv = fe->frontend_priv;
499 503
500 if (fepriv->exit) 504 if (fepriv->exit != DVB_FE_NO_EXIT)
501 return 1; 505 return 1;
502 506
503 if (fepriv->dvbdev->writers == 1) 507 if (fepriv->dvbdev->writers == 1)
@@ -559,7 +563,7 @@ restart:
559 563
560 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) { 564 if (kthread_should_stop() || dvb_frontend_is_exiting(fe)) {
561 /* got signal or quitting */ 565 /* got signal or quitting */
562 fepriv->exit = 1; 566 fepriv->exit = DVB_FE_NORMAL_EXIT;
563 break; 567 break;
564 } 568 }
565 569
@@ -673,7 +677,10 @@ restart:
673 } 677 }
674 678
675 fepriv->thread = NULL; 679 fepriv->thread = NULL;
676 fepriv->exit = 0; 680 if (kthread_should_stop())
681 fepriv->exit = DVB_FE_DEVICE_REMOVED;
682 else
683 fepriv->exit = DVB_FE_NO_EXIT;
677 mb(); 684 mb();
678 685
679 dvb_frontend_wakeup(fe); 686 dvb_frontend_wakeup(fe);
@@ -686,7 +693,7 @@ static void dvb_frontend_stop(struct dvb_frontend *fe)
686 693
687 dprintk ("%s\n", __func__); 694 dprintk ("%s\n", __func__);
688 695
689 fepriv->exit = 1; 696 fepriv->exit = DVB_FE_NORMAL_EXIT;
690 mb(); 697 mb();
691 698
692 if (!fepriv->thread) 699 if (!fepriv->thread)
@@ -755,7 +762,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
755 dprintk ("%s\n", __func__); 762 dprintk ("%s\n", __func__);
756 763
757 if (fepriv->thread) { 764 if (fepriv->thread) {
758 if (!fepriv->exit) 765 if (fepriv->exit == DVB_FE_NO_EXIT)
759 return 0; 766 return 0;
760 else 767 else
761 dvb_frontend_stop (fe); 768 dvb_frontend_stop (fe);
@@ -767,7 +774,7 @@ static int dvb_frontend_start(struct dvb_frontend *fe)
767 return -EINTR; 774 return -EINTR;
768 775
769 fepriv->state = FESTATE_IDLE; 776 fepriv->state = FESTATE_IDLE;
770 fepriv->exit = 0; 777 fepriv->exit = DVB_FE_NO_EXIT;
771 fepriv->thread = NULL; 778 fepriv->thread = NULL;
772 mb(); 779 mb();
773 780
@@ -1490,7 +1497,7 @@ static int dvb_frontend_ioctl(struct inode *inode, struct file *file,
1490 1497
1491 dprintk("%s (%d)\n", __func__, _IOC_NR(cmd)); 1498 dprintk("%s (%d)\n", __func__, _IOC_NR(cmd));
1492 1499
1493 if (fepriv->exit) 1500 if (fepriv->exit != DVB_FE_NO_EXIT)
1494 return -ENODEV; 1501 return -ENODEV;
1495 1502
1496 if ((file->f_flags & O_ACCMODE) == O_RDONLY && 1503 if ((file->f_flags & O_ACCMODE) == O_RDONLY &&
@@ -1916,6 +1923,8 @@ static int dvb_frontend_open(struct inode *inode, struct file *file)
1916 int ret; 1923 int ret;
1917 1924
1918 dprintk ("%s\n", __func__); 1925 dprintk ("%s\n", __func__);
1926 if (fepriv->exit == DVB_FE_DEVICE_REMOVED)
1927 return -ENODEV;
1919 1928
1920 if (adapter->mfe_shared) { 1929 if (adapter->mfe_shared) {
1921 mutex_lock (&adapter->mfe_lock); 1930 mutex_lock (&adapter->mfe_lock);
@@ -2008,7 +2017,7 @@ static int dvb_frontend_release(struct inode *inode, struct file *file)
2008 ret = dvb_generic_release (inode, file); 2017 ret = dvb_generic_release (inode, file);
2009 2018
2010 if (dvbdev->users == -1) { 2019 if (dvbdev->users == -1) {
2011 if (fepriv->exit == 1) { 2020 if (fepriv->exit != DVB_FE_NO_EXIT) {
2012 fops_put(file->f_op); 2021 fops_put(file->f_op);
2013 file->f_op = NULL; 2022 file->f_op = NULL;
2014 wake_up(&dvbdev->wait_queue); 2023 wake_up(&dvbdev->wait_queue);