Commit b24cccca authored by Heiner Kallweit's avatar Heiner Kallweit Committed by Mauro Carvalho Chehab

[media] 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.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent e7cd17a2
...@@ -48,6 +48,11 @@ static const struct nvt_chip nvt_chips[] = { ...@@ -48,6 +48,11 @@ static const struct nvt_chip nvt_chips[] = {
{ "NCT6779D", NVT_6779D }, { "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) static inline bool is_w83667hg(struct nvt_dev *nvt)
{ {
return nvt->chip_ver == NVT_W83667HG; return nvt->chip_ver == NVT_W83667HG;
...@@ -385,6 +390,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id) ...@@ -385,6 +390,7 @@ static inline const char *nvt_find_chip(struct nvt_dev *nvt, int id)
/* detect hardware features */ /* detect hardware features */
static int nvt_hw_detect(struct nvt_dev *nvt) static int nvt_hw_detect(struct nvt_dev *nvt)
{ {
struct device *dev = nvt_get_dev(nvt);
const char *chip_name; const char *chip_name;
int chip_id; int chip_id;
...@@ -405,8 +411,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt) ...@@ -405,8 +411,7 @@ static int nvt_hw_detect(struct nvt_dev *nvt)
chip_id = nvt->chip_major << 8 | nvt->chip_minor; chip_id = nvt->chip_major << 8 | nvt->chip_minor;
if (chip_id == NVT_INVALID) { if (chip_id == NVT_INVALID) {
dev_err(&nvt->pdev->dev, dev_err(dev, "No device found on either EFM port\n");
"No device found on either EFM port\n");
return -ENODEV; return -ENODEV;
} }
...@@ -414,12 +419,11 @@ static int nvt_hw_detect(struct nvt_dev *nvt) ...@@ -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 */ /* warn, but still let the driver load, if we don't know this chip */
if (!chip_name) if (!chip_name)
dev_warn(&nvt->pdev->dev, dev_warn(dev,
"unknown chip, id: 0x%02x 0x%02x, it may not work...", "unknown chip, id: 0x%02x 0x%02x, it may not work...",
nvt->chip_major, nvt->chip_minor); nvt->chip_major, nvt->chip_minor);
else else
dev_info(&nvt->pdev->dev, dev_info(dev, "found %s or compatible: chip id: 0x%02x 0x%02x",
"found %s or compatible: chip id: 0x%02x 0x%02x",
chip_name, nvt->chip_major, nvt->chip_minor); chip_name, nvt->chip_major, nvt->chip_minor);
return 0; return 0;
...@@ -616,7 +620,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt) ...@@ -616,7 +620,7 @@ static u32 nvt_rx_carrier_detect(struct nvt_dev *nvt)
duration *= SAMPLE_PERIOD; duration *= SAMPLE_PERIOD;
if (!count || !duration) { if (!count || !duration) {
dev_notice(&nvt->pdev->dev, dev_notice(nvt_get_dev(nvt),
"Unable to determine carrier! (c:%u, d:%u)", "Unable to determine carrier! (c:%u, d:%u)",
count, duration); count, duration);
return 0; return 0;
...@@ -781,7 +785,7 @@ static void nvt_process_rx_ir_data(struct nvt_dev *nvt) ...@@ -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) 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->pkts = 0;
nvt_clear_cir_fifo(nvt); nvt_clear_cir_fifo(nvt);
...@@ -1009,9 +1013,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ...@@ -1009,9 +1013,10 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
return -ENOMEM; return -ENOMEM;
/* input device for IR remote (and tx) */ /* input device for IR remote (and tx) */
rdev = devm_rc_allocate_device(&pdev->dev); nvt->rdev = devm_rc_allocate_device(&pdev->dev);
if (!rdev) if (!nvt->rdev)
return -ENOMEM; return -ENOMEM;
rdev = nvt->rdev;
/* activate pnp device */ /* activate pnp device */
ret = pnp_activate_dev(pdev); ret = pnp_activate_dev(pdev);
...@@ -1050,7 +1055,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ...@@ -1050,7 +1055,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
spin_lock_init(&nvt->tx.lock); spin_lock_init(&nvt->tx.lock);
pnp_set_drvdata(pdev, nvt); pnp_set_drvdata(pdev, nvt);
nvt->pdev = pdev;
init_waitqueue_head(&nvt->tx.queue); init_waitqueue_head(&nvt->tx.queue);
...@@ -1085,7 +1089,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ...@@ -1085,7 +1089,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.vendor = PCI_VENDOR_ID_WINBOND2;
rdev->input_id.product = nvt->chip_major; rdev->input_id.product = nvt->chip_major;
rdev->input_id.version = nvt->chip_minor; rdev->input_id.version = nvt->chip_minor;
rdev->dev.parent = &pdev->dev;
rdev->driver_name = NVT_DRIVER_NAME; rdev->driver_name = NVT_DRIVER_NAME;
rdev->map_name = RC_MAP_RC6_MCE; rdev->map_name = RC_MAP_RC6_MCE;
rdev->timeout = MS_TO_NS(100); rdev->timeout = MS_TO_NS(100);
...@@ -1097,8 +1100,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id) ...@@ -1097,8 +1100,6 @@ static int nvt_probe(struct pnp_dev *pdev, const struct pnp_device_id *dev_id)
/* tx bits */ /* tx bits */
rdev->tx_resolution = XYZ; rdev->tx_resolution = XYZ;
#endif #endif
nvt->rdev = rdev;
ret = devm_rc_register_device(&pdev->dev, rdev); ret = devm_rc_register_device(&pdev->dev, rdev);
if (ret) if (ret)
return ret; return ret;
......
...@@ -78,7 +78,6 @@ struct nvt_chip { ...@@ -78,7 +78,6 @@ struct nvt_chip {
}; };
struct nvt_dev { struct nvt_dev {
struct pnp_dev *pdev;
struct rc_dev *rdev; struct rc_dev *rdev;
spinlock_t nvt_lock; spinlock_t nvt_lock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment