OSDN Git Service

staging: kpc2000: added a helper to get struct kp2000_device from struct device.
authorJeremy Sowden <jeremy@azazel.net>
Tue, 21 May 2019 10:35:20 +0000 (11:35 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 May 2019 12:44:21 +0000 (14:44 +0200)
commita986d796395c18e607703af11e1afc1d3a8a5908
tree4d439b5a9ee614a6247b9660a5ad39ff46050fe6
parentd8ac35939632f25d6b1465a921f8a4d63064e3ae
staging: kpc2000: added a helper to get struct kp2000_device from struct device.

The attribute call-backs all use the same formula to get the pcard from
dev:

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

  if (!pdev)
    return -ENXIO;
  pcard = pci_get_drvdata(pdev);
  if (!pcard)
    return -ENXIO;

Added a function to reduce the duplicated code.

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