media: saa7134: rc-core maintains users count, no need to duplicate
This simplifies the code a little. Tested with suspend and resume. Signed-off-by: Sean Young <sean@mess.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
87e25f4b2c
commit
2ad18d1d78
|
@ -1419,8 +1419,8 @@ static int saa7134_suspend(struct pci_dev *pci_dev , pm_message_t state)
|
||||||
del_timer(&dev->vbi_q.timeout);
|
del_timer(&dev->vbi_q.timeout);
|
||||||
del_timer(&dev->ts_q.timeout);
|
del_timer(&dev->ts_q.timeout);
|
||||||
|
|
||||||
if (dev->remote)
|
if (dev->remote && dev->remote->dev->users)
|
||||||
saa7134_ir_stop(dev);
|
saa7134_ir_close(dev->remote->dev);
|
||||||
|
|
||||||
pci_save_state(pci_dev);
|
pci_save_state(pci_dev);
|
||||||
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
|
pci_set_power_state(pci_dev, pci_choose_state(pci_dev, state));
|
||||||
|
@ -1447,8 +1447,8 @@ static int saa7134_resume(struct pci_dev *pci_dev)
|
||||||
saa7134_videoport_init(dev);
|
saa7134_videoport_init(dev);
|
||||||
if (card_has_mpeg(dev))
|
if (card_has_mpeg(dev))
|
||||||
saa7134_ts_init_hw(dev);
|
saa7134_ts_init_hw(dev);
|
||||||
if (dev->remote)
|
if (dev->remote && dev->remote->dev->users)
|
||||||
saa7134_ir_start(dev);
|
saa7134_ir_open(dev->remote->dev);
|
||||||
saa7134_hw_enable1(dev);
|
saa7134_hw_enable1(dev);
|
||||||
|
|
||||||
msleep(100);
|
msleep(100);
|
||||||
|
|
|
@ -448,17 +448,10 @@ static void saa7134_input_timer(struct timer_list *t)
|
||||||
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
|
mod_timer(&ir->timer, jiffies + msecs_to_jiffies(ir->polling));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __saa7134_ir_start(void *priv)
|
int saa7134_ir_open(struct rc_dev *rc)
|
||||||
{
|
{
|
||||||
struct saa7134_dev *dev = priv;
|
struct saa7134_dev *dev = rc->priv;
|
||||||
struct saa7134_card_ir *ir;
|
struct saa7134_card_ir *ir = dev->remote;
|
||||||
|
|
||||||
if (!dev || !dev->remote)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
ir = dev->remote;
|
|
||||||
if (ir->running)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Moved here from saa7134_input_init1() because the latter
|
/* Moved here from saa7134_input_init1() because the latter
|
||||||
* is not called on device resume */
|
* is not called on device resume */
|
||||||
|
@ -507,55 +500,15 @@ static int __saa7134_ir_start(void *priv)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __saa7134_ir_stop(void *priv)
|
void saa7134_ir_close(struct rc_dev *rc)
|
||||||
{
|
{
|
||||||
struct saa7134_dev *dev = priv;
|
struct saa7134_dev *dev = rc->priv;
|
||||||
struct saa7134_card_ir *ir;
|
struct saa7134_card_ir *ir = dev->remote;
|
||||||
|
|
||||||
if (!dev || !dev->remote)
|
|
||||||
return;
|
|
||||||
|
|
||||||
ir = dev->remote;
|
|
||||||
if (!ir->running)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (ir->polling)
|
if (ir->polling)
|
||||||
del_timer_sync(&ir->timer);
|
del_timer_sync(&ir->timer);
|
||||||
|
|
||||||
ir->running = false;
|
ir->running = false;
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int saa7134_ir_start(struct saa7134_dev *dev)
|
|
||||||
{
|
|
||||||
if (dev->remote->users)
|
|
||||||
return __saa7134_ir_start(dev);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void saa7134_ir_stop(struct saa7134_dev *dev)
|
|
||||||
{
|
|
||||||
if (dev->remote->users)
|
|
||||||
__saa7134_ir_stop(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int saa7134_ir_open(struct rc_dev *rc)
|
|
||||||
{
|
|
||||||
struct saa7134_dev *dev = rc->priv;
|
|
||||||
|
|
||||||
dev->remote->users++;
|
|
||||||
return __saa7134_ir_start(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void saa7134_ir_close(struct rc_dev *rc)
|
|
||||||
{
|
|
||||||
struct saa7134_dev *dev = rc->priv;
|
|
||||||
|
|
||||||
dev->remote->users--;
|
|
||||||
if (!dev->remote->users)
|
|
||||||
__saa7134_ir_stop(dev);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int saa7134_input_init1(struct saa7134_dev *dev)
|
int saa7134_input_init1(struct saa7134_dev *dev)
|
||||||
|
@ -624,7 +577,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
|
||||||
mask_keycode = 0x0007C8;
|
mask_keycode = 0x0007C8;
|
||||||
mask_keydown = 0x000010;
|
mask_keydown = 0x000010;
|
||||||
polling = 50; // ms
|
polling = 50; // ms
|
||||||
/* GPIO stuff moved to __saa7134_ir_start() */
|
/* GPIO stuff moved to saa7134_ir_open() */
|
||||||
break;
|
break;
|
||||||
case SAA7134_BOARD_AVERMEDIA_M135A:
|
case SAA7134_BOARD_AVERMEDIA_M135A:
|
||||||
ir_codes = RC_MAP_AVERMEDIA_M135A;
|
ir_codes = RC_MAP_AVERMEDIA_M135A;
|
||||||
|
@ -646,14 +599,14 @@ int saa7134_input_init1(struct saa7134_dev *dev)
|
||||||
mask_keycode = 0x02F200;
|
mask_keycode = 0x02F200;
|
||||||
mask_keydown = 0x000400;
|
mask_keydown = 0x000400;
|
||||||
polling = 50; // ms
|
polling = 50; // ms
|
||||||
/* GPIO stuff moved to __saa7134_ir_start() */
|
/* GPIO stuff moved to saa7134_ir_open() */
|
||||||
break;
|
break;
|
||||||
case SAA7134_BOARD_AVERMEDIA_A16D:
|
case SAA7134_BOARD_AVERMEDIA_A16D:
|
||||||
ir_codes = RC_MAP_AVERMEDIA_A16D;
|
ir_codes = RC_MAP_AVERMEDIA_A16D;
|
||||||
mask_keycode = 0x02F200;
|
mask_keycode = 0x02F200;
|
||||||
mask_keydown = 0x000400;
|
mask_keydown = 0x000400;
|
||||||
polling = 50; /* ms */
|
polling = 50; /* ms */
|
||||||
/* GPIO stuff moved to __saa7134_ir_start() */
|
/* GPIO stuff moved to saa7134_ir_open() */
|
||||||
break;
|
break;
|
||||||
case SAA7134_BOARD_KWORLD_TERMINATOR:
|
case SAA7134_BOARD_KWORLD_TERMINATOR:
|
||||||
ir_codes = RC_MAP_PIXELVIEW;
|
ir_codes = RC_MAP_PIXELVIEW;
|
||||||
|
@ -705,7 +658,7 @@ int saa7134_input_init1(struct saa7134_dev *dev)
|
||||||
mask_keycode = 0x0003CC;
|
mask_keycode = 0x0003CC;
|
||||||
mask_keydown = 0x000010;
|
mask_keydown = 0x000010;
|
||||||
polling = 5; /* ms */
|
polling = 5; /* ms */
|
||||||
/* GPIO stuff moved to __saa7134_ir_start() */
|
/* GPIO stuff moved to saa7134_ir_open() */
|
||||||
break;
|
break;
|
||||||
case SAA7134_BOARD_VIDEOMATE_TV_PVR:
|
case SAA7134_BOARD_VIDEOMATE_TV_PVR:
|
||||||
case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
|
case SAA7134_BOARD_VIDEOMATE_GOLD_PLUS:
|
||||||
|
@ -890,7 +843,6 @@ void saa7134_input_fini(struct saa7134_dev *dev)
|
||||||
if (NULL == dev->remote)
|
if (NULL == dev->remote)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
saa7134_ir_stop(dev);
|
|
||||||
rc_unregister_device(dev->remote->dev);
|
rc_unregister_device(dev->remote->dev);
|
||||||
kfree(dev->remote);
|
kfree(dev->remote);
|
||||||
dev->remote = NULL;
|
dev->remote = NULL;
|
||||||
|
|
|
@ -124,7 +124,6 @@ struct saa7134_card_ir {
|
||||||
struct rc_dev *dev;
|
struct rc_dev *dev;
|
||||||
|
|
||||||
char phys[32];
|
char phys[32];
|
||||||
unsigned users;
|
|
||||||
|
|
||||||
u32 polling;
|
u32 polling;
|
||||||
u32 last_gpio;
|
u32 last_gpio;
|
||||||
|
@ -922,13 +921,13 @@ int saa7134_input_init1(struct saa7134_dev *dev);
|
||||||
void saa7134_input_fini(struct saa7134_dev *dev);
|
void saa7134_input_fini(struct saa7134_dev *dev);
|
||||||
void saa7134_input_irq(struct saa7134_dev *dev);
|
void saa7134_input_irq(struct saa7134_dev *dev);
|
||||||
void saa7134_probe_i2c_ir(struct saa7134_dev *dev);
|
void saa7134_probe_i2c_ir(struct saa7134_dev *dev);
|
||||||
int saa7134_ir_start(struct saa7134_dev *dev);
|
int saa7134_ir_open(struct rc_dev *dev);
|
||||||
void saa7134_ir_stop(struct saa7134_dev *dev);
|
void saa7134_ir_close(struct rc_dev *dev);
|
||||||
#else
|
#else
|
||||||
#define saa7134_input_init1(dev) ((void)0)
|
#define saa7134_input_init1(dev) ((void)0)
|
||||||
#define saa7134_input_fini(dev) ((void)0)
|
#define saa7134_input_fini(dev) ((void)0)
|
||||||
#define saa7134_input_irq(dev) ((void)0)
|
#define saa7134_input_irq(dev) ((void)0)
|
||||||
#define saa7134_probe_i2c_ir(dev) ((void)0)
|
#define saa7134_probe_i2c_ir(dev) ((void)0)
|
||||||
#define saa7134_ir_start(dev) ((void)0)
|
#define saa7134_ir_open(dev) ((void)0)
|
||||||
#define saa7134_ir_stop(dev) ((void)0)
|
#define saa7134_ir_close(dev) ((void)0)
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue