All of lore.kernel.org
 help / color / mirror / Atom feed
* Accessing a pdev or its members
@ 2021-09-25  2:30 Drew Abbott
  2021-09-25  6:31 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Drew Abbott @ 2021-09-25  2:30 UTC (permalink / raw)
  To: kernelnewbies

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,
Drew

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Accessing a pdev or its members
  2021-09-25  2:30 Accessing a pdev or its members Drew Abbott
@ 2021-09-25  6:31 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2021-09-25  6:31 UTC (permalink / raw)
  To: Drew Abbott; +Cc: kernelnewbies

On Fri, Sep 24, 2021 at 09:30:55PM -0500, Drew Abbott wrote:
> 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?

You can not, it is not owned by your driver and the lifetime rules
should not give you access to it.

Why would you want to poke around in a platform device that is
controlled by a different driver?  What does your driver want to do?

> 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.

Why not move your functionality into the existing driver if you need to
talk to the same hardware device?

thanks,

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-25  6:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-25  2:30 Accessing a pdev or its members Drew Abbott
2021-09-25  6:31 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.