media: rc: nuvoton: eliminate member pdev from struct nvt_dev
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 2/5 media: rc: nuvoton: eliminate member pdev from struct nvt_dev
Member pdev of struct nvt_dev is needed only to access &pdev->dev. We can get rid of this it by using rdev->dev.parent instead (both point to the same struct device).
Setting rdev->dev.parent can be removed from the probe function as this is done by devm_rc_allocate_device now.
--- drivers/media/rc/nuvoton-cir.c | 27 ++++++++++++++------------- drivers/media/rc/nuvoton-cir.h | 1 - 2 files changed, 14 insertions(+), 14 deletions(-)
drivers/media/rc/nuvoton-cir.c +14 -13
@@ -48,6 +48,11 @@ static const struct nvt_chip nvt_chips[] = { { "NCT6779D", NVT_6779D }, }; +static inline struct device *nvt_get_dev (const struct nvt_dev *nvt) +{ +return nvt->rdev->dev.parent; +} +static inline bool is_w83667hg (struct nvt_dev *nvt) {return nvt->chip_ver ==NVT_W83667HG ;
@@ -385,6 +390,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)/* detect hardware features */ static int nvt_hw_detect (struct nvt_dev *nvt) { +struct device *dev =nvt_get_dev (nvt);const char *chip_name;int chip_id;
@@ -405,8 +411,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt) chip_id = nvt->chip_major <<8 | nvt->chip_minor;if (chip_id ==NVT_INVALID ) { -dev_err (&nvt->pdev->dev, -"No device found on either EFM port\n" ); +dev_err (dev,"No device found on either EFM port\n" );return -ENODEV ; }
@@ -414,12 +419,11 @@ static int nvt_hw_detect(struct nvt_dev *nvt)/* warn, but still let the driver load, if we don't know this chip */ if (!chip_name) -dev_warn (&nvt->pdev->dev, +dev_warn (dev,"unknown chip, id: 0x%02x 0x%02x, it may not work..." , nvt->chip_major, nvt->chip_minor);else -dev_info (&nvt->pdev->dev, -"found %s or compatible: chip id: 0x%02x 0x%02x" , +dev_info (dev,"found %s or compatible: chip id: 0x%02x 0x%02x" , chip_name, nvt->chip_major, nvt->chip_minor);return 0 ;
@@ -616,7 +620,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) duration *=SAMPLE_PERIOD ;if (!count || !duration) { -dev_notice (&nvt->pdev->dev, +dev_notice (nvt_get_dev (nvt),"Unable to determine carrier! (c:%u, d:%u)" , count, duration);return 0 ;
@@ -781,7 +785,7 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt)static void nvt_handle_rx_fifo_overrun (struct nvt_dev *nvt) { -dev_warn (&nvt->pdev->dev,"RX FIFO overrun detected, flushing data!" ); +dev_warn (nvt_get_dev (nvt),"RX FIFO overrun detected, flushing data!" ); nvt->pkts =0 ;nvt_clear_cir_fifo (nvt);
@@ -976,9 +980,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)return -ENOMEM ;/* input device for IR remote (and tx) */ - rdev =devm_rc_allocate_device (&pdev->dev); -if (!rdev) + nvt->rdev =devm_rc_allocate_device (&pdev->dev); +if (!nvt->rdev)return -ENOMEM ; + rdev = nvt->rdev;/* activate pnp device */ ret =pnp_activate_dev (pdev);
@@ -1017,7 +1022,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)spin_lock_init (&nvt->tx.lock);pnp_set_drvdata (pdev, nvt); - nvt->pdev = pdev;init_waitqueue_head (&nvt->tx.queue);
@@ -1050,7 +1054,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) rdev->input_id.vendor =PCI_VENDOR_ID_WINBOND2 ; rdev->input_id.product = nvt->chip_major; rdev->input_id.version = nvt->chip_minor; - rdev->dev.parent = &pdev->dev; rdev->driver_name =NVT_DRIVER_NAME ; rdev->map_name =RC_MAP_RC6_MCE ; rdev->timeout =MS_TO_NS (100 );
@@ -1062,8 +1065,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)/* tx bits */ rdev->tx_resolution =XYZ ;#endif - nvt->rdev = rdev; - ret =devm_rc_register_device (&pdev->dev, rdev);if (ret)return ret;
drivers/media/rc/nuvoton-cir.h +0 -1
@@ -78,7 +78,6 @@ struct nvt_chip { };struct nvt_dev { -struct pnp_dev *pdev;struct rc_dev *rdev;spinlock_t nvt_lock;
Signature · 1 line
2.10.1
PATCH 3/5 media: rc: nuvoton: eliminate nvt->tx.lock
In reply to a message not in the archiveUsing a separate spinlock to protect access to substruct tx of struct nvt_dev doesn't provide any actual benefit. We can use spinlock nvt_lock to protect all access to struct nvt_dev and get rid of nvt->tx.lock.
--- drivers/media/rc/nuvoton-cir.c | 35 +++++++++-------------------------- drivers/media/rc/nuvoton-cir.h | 1 - 2 files changed, 9 insertions(+), 27 deletions(-)
drivers/media/rc/nuvoton-cir.c +9 -26
@@ -688,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)u8 iren;int ret; -spin_lock_irqsave (&nvt->tx.lock, flags); +spin_lock_irqsave (&nvt->nvt_lock, flags); ret =min ((unsigned )(TX_BUF_LEN /sizeof (unsigned )), n); nvt->tx.buf_count = (ret *sizeof (unsigned ));
@@ -712,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)for (i =0 ; i <9 ; i++)nvt_cir_reg_write (nvt,0x01 ,CIR_STXFIFO ); -spin_unlock_irqrestore (&nvt->tx.lock, flags); +spin_unlock_irqrestore (&nvt->nvt_lock, flags);wait_event (nvt->tx.queue, nvt->tx.tx_state ==ST_TX_REQUEST ); -spin_lock_irqsave (&nvt->tx.lock, flags); +spin_lock_irqsave (&nvt->nvt_lock, flags); nvt->tx.tx_state =ST_TX_NONE ; -spin_unlock_irqrestore (&nvt->tx.lock, flags); +spin_unlock_irqrestore (&nvt->nvt_lock, flags);/* restore enabled interrupts to prior state */ nvt_cir_reg_write (nvt, iren,CIR_IREN );
@@ -832,14 +832,7 @@ static void nvt_cir_log_irqs(u8 status, u8 iren)static bool nvt_cir_tx_inactive (struct nvt_dev *nvt) { -unsigned long flags; -u8 tx_state; - -spin_lock_irqsave (&nvt->tx.lock, flags); - tx_state = nvt->tx.tx_state; -spin_unlock_irqrestore (&nvt->tx.lock, flags); - -return tx_state ==ST_TX_NONE ; +return nvt->tx.tx_state ==ST_TX_NONE ; }/* interrupt service routine for incoming and outgoing CIR data */
@@ -902,8 +895,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)nvt_get_rx_ir_data (nvt); } -spin_unlock_irqrestore (&nvt->nvt_lock, flags); -if (status &CIR_IRSTS_TE )nvt_clear_tx_fifo (nvt);
@@ -911,8 +902,6 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)unsigned int pos, count;u8 tmp; -spin_lock_irqsave (&nvt->tx.lock, flags); - pos = nvt->tx.cur_buf_num; count = nvt->tx.buf_count;
@@ -925,20 +914,17 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) tmp =nvt_cir_reg_read (nvt,CIR_IREN );nvt_cir_reg_write (nvt, tmp & ~CIR_IREN_TTR ,CIR_IREN ); } - -spin_unlock_irqrestore (&nvt->tx.lock, flags); - }if (status &CIR_IRSTS_TFU ) { -spin_lock_irqsave (&nvt->tx.lock, flags);if (nvt->tx.tx_state ==ST_TX_REPLY ) { nvt->tx.tx_state =ST_TX_REQUEST ;wake_up (&nvt->tx.queue); } -spin_unlock_irqrestore (&nvt->tx.lock, flags); } +spin_unlock_irqrestore (&nvt->nvt_lock, flags); +nvt_dbg_verbose ("%s done" , __func__);return IRQ_HANDLED ; }
@@ -1019,7 +1005,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) nvt->cr_efdr =CR_EFDR ;spin_lock_init (&nvt->nvt_lock); -spin_lock_init (&nvt->tx.lock);pnp_set_drvdata (pdev, nvt);
@@ -1117,12 +1102,10 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)nvt_dbg ("%s called" , __func__); -spin_lock_irqsave (&nvt->tx.lock, flags); - nvt->tx.tx_state =ST_TX_NONE ; -spin_unlock_irqrestore (&nvt->tx.lock, flags); -spin_lock_irqsave (&nvt->nvt_lock, flags); + nvt->tx.tx_state =ST_TX_NONE ; +/* disable all CIR interrupts */ nvt_cir_reg_write (nvt,0 ,CIR_IREN );
drivers/media/rc/nuvoton-cir.h +0 -1
@@ -87,7 +87,6 @@ struct nvt_dev {unsigned int pkts;struct { -spinlock_t lock;u8 buf[TX_BUF_LEN ];unsigned int buf_count;unsigned int cur_buf_num;
Signature · 1 line
2.10.1
PATCH 4/5 media: rc: nuvoton: rename spinlock nvt_lock
In reply to a message not in the archiveSpinlock nvt_lock is a member of struct nvt_dev and there's no need to prefix it with nvt_. So remove this prefix.
--- drivers/media/rc/nuvoton-cir.c | 40 ++++++++++++++++++++-------------------- drivers/media/rc/nuvoton-cir.h | 2 +- 2 files changed, 21 insertions(+), 21 deletions(-)
drivers/media/rc/nuvoton-cir.c +20 -20
@@ -187,7 +187,7 @@ static ssize_t wakeup_data_show(struct device *dev,ssize_t buf_len =0 ;int i; -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags); fifo_len =nvt_cir_wake_reg_read (nvt,CIR_WAKE_FIFO_COUNT ); fifo_len =min (fifo_len,WAKEUP_MAX_SIZE );
@@ -204,7 +204,7 @@ static ssize_t wakeup_data_show(struct device *dev, } buf_len +=snprintf (buf + buf_len,PAGE_SIZE - buf_len,"\n" ); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);return buf_len; }
@@ -248,7 +248,7 @@ static ssize_t wakeup_data_store(struct device *dev,/* hardcode the tolerance to 10% */ tolerance =DIV_ROUND_UP (count,10 ); -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags);nvt_clear_cir_wake_fifo (nvt);nvt_cir_wake_reg_write (nvt, count,CIR_WAKE_FIFO_CMP_DEEP );
@@ -265,7 +265,7 @@ static ssize_t wakeup_data_store(struct device *dev,nvt_cir_wake_reg_write (nvt, config,CIR_WAKE_IRCON ); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags); ret = len; out:
@@ -590,7 +590,7 @@ static void nvt_enable_wake(struct nvt_dev *nvt)nvt_efm_disable (nvt); -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags); nvt_cir_wake_reg_write(nvt, CIR_WAKE_IRCON_MODE0 | CIR_WAKE_IRCON_RXEN | CIR_WAKE_IRCON_R | CIR_WAKE_IRCON_RXINV |
@@ -599,11 +599,11 @@ static void nvt_enable_wake(struct nvt_dev *nvt)nvt_cir_wake_reg_write (nvt,0xff ,CIR_WAKE_IRSTS );nvt_cir_wake_reg_write (nvt,0 ,CIR_WAKE_IREN ); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags); }#if 0 /* Currently unused */ -/* rx carrier detect only works in learning mode, must be called w/nvt_lock */ +/* rx carrier detect only works in learning mode, must be called w/lock */ static u32 nvt_rx_carrier_detect (struct nvt_dev *nvt) {u32 count, carrier, duration =0 ;
@@ -688,7 +688,7 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)u8 iren;int ret; -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags); ret =min ((unsigned )(TX_BUF_LEN /sizeof (unsigned )), n); nvt->tx.buf_count = (ret *sizeof (unsigned ));
@@ -712,13 +712,13 @@ static int nvt_tx_ir(struct rc_dev *dev, unsigned *txbuf, unsigned n)for (i =0 ; i <9 ; i++)nvt_cir_reg_write (nvt,0x01 ,CIR_STXFIFO ); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);wait_event (nvt->tx.queue, nvt->tx.tx_state ==ST_TX_REQUEST ); -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags); nvt->tx.tx_state =ST_TX_NONE ; -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);/* restore enabled interrupts to prior state */ nvt_cir_reg_write (nvt, iren,CIR_IREN );
@@ -844,7 +844,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)nvt_dbg_verbose ("%s firing" , __func__); -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags);/* * Get IR Status register contents. Write 1 to ack/clear
@@ -866,7 +866,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)* logical device is being disabled. */ if (status ==0xff && iren ==0xff ) { -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);nvt_dbg_verbose ("Spurious interrupt detected" );return IRQ_HANDLED ; }
@@ -875,7 +875,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)* status bit whether the related interrupt source is enabled */ if (!(status & iren)) { -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);nvt_dbg_verbose ("%s exiting, IRSTS 0x0" , __func__);return IRQ_NONE ; }
@@ -923,7 +923,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) } } -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);nvt_dbg_verbose ("%s done" , __func__);return IRQ_HANDLED ;
@@ -933,7 +933,7 @@ static void nvt_disable_cir(struct nvt_dev *nvt) {unsigned long flags; -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags);/* disable CIR interrupts */ nvt_cir_reg_write (nvt,0 ,CIR_IREN );
@@ -948,7 +948,7 @@ static void nvt_disable_cir(struct nvt_dev *nvt)nvt_clear_cir_fifo (nvt);nvt_clear_tx_fifo (nvt); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);/* disable the CIR logical device */ nvt_disable_logical_dev (nvt,LOGICAL_DEV_CIR );
@@ -1004,7 +1004,7 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) nvt->cr_efir =CR_EFIR ; nvt->cr_efdr =CR_EFDR ; -spin_lock_init (&nvt->nvt_lock); +spin_lock_init (&nvt->lock);pnp_set_drvdata (pdev, nvt);
@@ -1102,14 +1102,14 @@ static int nvt_suspend(struct pnp_dev *pdev, pm_message_t state)nvt_dbg ("%s called" , __func__); -spin_lock_irqsave (&nvt->nvt_lock, flags); +spin_lock_irqsave (&nvt->lock, flags); nvt->tx.tx_state =ST_TX_NONE ;/* disable all CIR interrupts */ nvt_cir_reg_write (nvt,0 ,CIR_IREN ); -spin_unlock_irqrestore (&nvt->nvt_lock, flags); +spin_unlock_irqrestore (&nvt->lock, flags);/* disable cir logical dev */ nvt_disable_logical_dev (nvt,LOGICAL_DEV_CIR );
drivers/media/rc/nuvoton-cir.h +1 -1
@@ -80,7 +80,7 @@ struct nvt_chip {struct nvt_dev {struct rc_dev *rdev; -spinlock_t nvt_lock; +spinlock_t lock;/* for rx */ u8 buf[RX_BUF_LEN ];
Signature · 1 line
2.10.1
PATCH 5/5 media: rc: nuvoton: replace usage of spin_lock_irqsave in ISR
In reply to a message not in the archiveKernel takes care that interrupts from one source are serialized. So there's no need to use spinlock_irq_save.
--- drivers/media/rc/nuvoton-cir.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/rc/nuvoton-cir.c +4 -5
@@ -840,11 +840,10 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) {struct nvt_dev *nvt = data;u8 status, iren; -unsigned long flags;nvt_dbg_verbose ("%s firing" , __func__); -spin_lock_irqsave (&nvt->lock, flags); +spin_lock (&nvt->lock);/* * Get IR Status register contents. Write 1 to ack/clear
@@ -866,7 +865,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)* logical device is being disabled. */ if (status ==0xff && iren ==0xff ) { -spin_unlock_irqrestore (&nvt->lock, flags); +spin_unlock (&nvt->lock);nvt_dbg_verbose ("Spurious interrupt detected" );return IRQ_HANDLED ; }
@@ -875,7 +874,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data)* status bit whether the related interrupt source is enabled */ if (!(status & iren)) { -spin_unlock_irqrestore (&nvt->lock, flags); +spin_unlock (&nvt->lock);nvt_dbg_verbose ("%s exiting, IRSTS 0x0" , __func__);return IRQ_NONE ; }
@@ -923,7 +922,7 @@ static irqreturn_t nvt_cir_isr(int irq, void *data) } } -spin_unlock_irqrestore (&nvt->lock, flags); +spin_unlock (&nvt->lock);nvt_dbg_verbose ("%s done" , __func__);return IRQ_HANDLED ;
Signature · 1 line
2.10.1