[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: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
Heiner Kallweit 2016-10-25 17:23:37 -02:00 committed by Mauro Carvalho Chehab
parent e7cd17a29d
commit b24ccccaee
2 changed files with 14 additions and 14 deletions

View File

@ -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)
/* 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)
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)
/* 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)
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)
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)
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)
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)
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)
/* 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;

View File

@ -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;