Accessing a pdev or its members

Drew Abbott abbotta4 at
Fri Sep 24 22:30:55 EDT 2021

Hello all,

A third party driver has a probe function foo_probe(struct
platform_device) that ends up allocating and initializing a list of
various device structs:

struct device *dev = &pdev->dev;
struct ucsi_dev *udev;
udev = devm_kzalloc(dev, sizeof(*udev), GFP_KERNEL);
/* initialize udev to important data */
platform_set_drvdata(pdev, udev);

I have my own driver that I would like to use to access the *udev that
is created when the other device is probed. How would I access a pdev?
Or is there a way I can add a function to this driver to expose a
*udev? I can't seem to get to it without having a pointer to the pdev,
the udev, or some other device struct related to the hardware.

Thanks for the help,

More information about the Kernelnewbies mailing list