OSDN Git Service

staging: kpc2000: simplified kp2000_device retrieval in device attribute call-backs.
authorJeremy Sowden <jeremy@azazel.net>
Tue, 21 May 2019 10:35:23 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 May 2019 12:44:22 +0000 (14:44 +0200)
commite416dad158f289ef2af48bf21fca53acc3935353
treee130ef86eb55c775b9d470485f0e23793b036c41
parentf731540813474de5d371d650ef00443aa7811b92
staging: kpc2000: simplified kp2000_device retrieval in device attribute call-backs.

All the call-backs used the same formula to retrieve the pcard from dev:

  struct pci_dev *pdev = to_pci_dev(dev);
  struct kp2000_device *pcard;

  if (!pdev)
    return NULL;

  pcard = pci_get_drvdata(pdev);

Since to_pci_dev is a wrapper for container_of, it will not return NULL,
and since pci_get_drvdata just calls dev_get_drvdata on the dev member
of pdev, this is equivalent to:

  struct kp2000_device *pcard = dev_get_drvdata(&(container_of(dev, struct pci_dev, dev)->dev));

and we can simplify it to:

  struct kp2000_device *pcard = dev_get_drvdata(dev);

Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/kpc2000/kpc2000/core.c