kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Accessing rpmsg_device in sysfs attribute functions
@ 2020-03-24  5:34 Pelle Windestam
  2020-03-24  6:31 ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Pelle Windestam @ 2020-03-24  5:34 UTC (permalink / raw)
  To: kernelnewbies

Hi,

I am trying to develop a simple driver for the rpmsg bus, in order to send various commands from user space in Linux to a secondary CPU (A Cortex M4). I'm trying to keep things as simple as possible, so my idea was to create a driver that just has a few attributes which can be set in /sys which would trigger commands to be sent to the M4 CPU. I have the communication between the CPU:s up and running, but where I'm having trouble moving forward is how to access the "struct rpmsg_device *" that I need in order to communicate with the endpoint for the M4 CPU from the store/show function of the sysfs attributes. What my driver does is to register a rpmsg_driver in the init function:

register_rpmsg_driver(&pwm_rpmsg_driver);

the device_driver member of my rpmsg_driver struct has its groups member set to my driver attribute groups array:
static struct rpmsg_driver pwm_rpmsg_driver = {
	.probe = pwm_rpmsg_probe,
	.remove = pwm_rpmsg_remove,
	.callback = pwm_rpmsg_cb,
	.id_table = pwm_rpmsg_device_id_table,
	.drv = {
		.groups = driver_pwm_groups,
		.name = "pwm_rpmsg",
	},
};

My issue is that that I am not sure how to access the struct "rpmsg_device *" (i.e. from the probe() function) in the show/store functions for the sysfs attributes, which have a "struct device_driver *" argument:

static int pwm_rpmsg_probe(struct rpmsg_device *rpdev) /* rpmsg_device->ept is needed to send messages to the other CPU */

static ssize_t duty_cycle_store(struct device_driver *dev, const char *buf,
				      size_t count); /* Can I use the device_driver struct to somehow access the rpmsg_device? */

I am very much a novice when it comes to driver development, so I might be approaching this from a completely wrong direction. Any advice would be very much appreciated!

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

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

* Re: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24  5:34 Accessing rpmsg_device in sysfs attribute functions Pelle Windestam
@ 2020-03-24  6:31 ` Greg KH
  2020-03-24  9:49   ` Martin Kaiser
  2020-03-24 12:02   ` Pelle Windestam
  0 siblings, 2 replies; 9+ messages in thread
From: Greg KH @ 2020-03-24  6:31 UTC (permalink / raw)
  To: Pelle Windestam; +Cc: kernelnewbies

On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> Hi,
> 
> I am trying to develop a simple driver for the rpmsg bus, in order to send various commands from user space in Linux to a secondary CPU (A Cortex M4). I'm trying to keep things as simple as possible, so my idea was to create a driver that just has a few attributes which can be set in /sys which would trigger commands to be sent to the M4 CPU. I have the communication between the CPU:s up and running, but where I'm having trouble moving forward is how to access the "struct rpmsg_device *" that I need in order to communicate with the endpoint for the M4 CPU from the store/show function of the sysfs attributes. What my driver does is to register a rpmsg_driver in the init function:
> 
> register_rpmsg_driver(&pwm_rpmsg_driver);
> 
> the device_driver member of my rpmsg_driver struct has its groups member set to my driver attribute groups array:
> static struct rpmsg_driver pwm_rpmsg_driver = {
> 	.probe = pwm_rpmsg_probe,
> 	.remove = pwm_rpmsg_remove,
> 	.callback = pwm_rpmsg_cb,
> 	.id_table = pwm_rpmsg_device_id_table,
> 	.drv = {
> 		.groups = driver_pwm_groups,
> 		.name = "pwm_rpmsg",
> 	},
> };
> 
> My issue is that that I am not sure how to access the struct "rpmsg_device *" (i.e. from the probe() function) in the show/store functions for the sysfs attributes, which have a "struct device_driver *" argument:

That is because you have created a driver attribute, not a device
attribute.  Create device attributes and you should be fine, they bind
to the device your driver is passed.

good luck!

greg k-h

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

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

* Re: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24  6:31 ` Greg KH
@ 2020-03-24  9:49   ` Martin Kaiser
  2020-03-24 10:23     ` Greg KH
  2020-03-24 12:02   ` Pelle Windestam
  1 sibling, 1 reply; 9+ messages in thread
From: Martin Kaiser @ 2020-03-24  9:49 UTC (permalink / raw)
  To: kernelnewbies

Hi Greg,

Thus wrote Greg KH (greg@kroah.com):

> That is because you have created a driver attribute, not a device
> attribute.  Create device attributes and you should be fine, they bind
> to the device your driver is passed.

could you point me to an example in the kernel tree where this is done
correctly for a platform device?

I had a look at

http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

but I couldn't figure out how to create device attributes in a simple
platform driver that binds to a platform device.

Thanks a lot for your help,

   Martin

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

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

* Re: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24  9:49   ` Martin Kaiser
@ 2020-03-24 10:23     ` Greg KH
  0 siblings, 0 replies; 9+ messages in thread
From: Greg KH @ 2020-03-24 10:23 UTC (permalink / raw)
  To: kernelnewbies

On Tue, Mar 24, 2020 at 10:49:46AM +0100, Martin Kaiser wrote:
> Hi Greg,
> 
> Thus wrote Greg KH (greg@kroah.com):
> 
> > That is because you have created a driver attribute, not a device
> > attribute.  Create device attributes and you should be fine, they bind
> > to the device your driver is passed.
> 
> could you point me to an example in the kernel tree where this is done
> correctly for a platform device?
> 
> I had a look at
> 
> http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/
> 
> but I couldn't figure out how to create device attributes in a simple
> platform driver that binds to a platform device.

Look at commit d99995a4f0f1 ("Input: axp20x-pek - convert driver to use
dev_groups") in the 5.4 kernel as an example of how to use the correct
api here.

Hope this helps,

greg k-h

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

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

* RE: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24  6:31 ` Greg KH
  2020-03-24  9:49   ` Martin Kaiser
@ 2020-03-24 12:02   ` Pelle Windestam
  2020-03-24 12:31     ` Greg KH
  1 sibling, 1 reply; 9+ messages in thread
From: Pelle Windestam @ 2020-03-24 12:02 UTC (permalink / raw)
  To: Greg KH; +Cc: kernelnewbies

> On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> > Hi,
> >
> > I am trying to develop a simple driver for the rpmsg bus, in order to send
> various commands from user space in Linux to a secondary CPU (A Cortex M4).
> I'm trying to keep things as simple as possible, so my idea was to create a
> driver that just has a few attributes which can be set in /sys which would
> trigger commands to be sent to the M4 CPU. I have the communication between
> the CPU:s up and running, but where I'm having trouble moving forward is how
> to access the "struct rpmsg_device *" that I need in order to communicate
> with the endpoint for the M4 CPU from the store/show function of the sysfs
> attributes. What my driver does is to register a rpmsg_driver in the init
> function:
> >
> > register_rpmsg_driver(&pwm_rpmsg_driver);
> >
> > the device_driver member of my rpmsg_driver struct has its groups member
> set to my driver attribute groups array:
> > static struct rpmsg_driver pwm_rpmsg_driver = {
> > 	.probe = pwm_rpmsg_probe,
> > 	.remove = pwm_rpmsg_remove,
> > 	.callback = pwm_rpmsg_cb,
> > 	.id_table = pwm_rpmsg_device_id_table,
> > 	.drv = {
> > 		.groups = driver_pwm_groups,
> > 		.name = "pwm_rpmsg",
> > 	},
> > };
> >
> > My issue is that that I am not sure how to access the struct "rpmsg_device
> *" (i.e. from the probe() function) in the show/store functions for the sysfs
> attributes, which have a "struct device_driver *" argument:
> 
> That is because you have created a driver attribute, not a device attribute.
> Create device attributes and you should be fine, they bind to the device your
> driver is passed.

Thanks! Changing them to device attributes was a breeze. Now I am slightly confused about the "struct device *" argument to the store/show functions. I was under the impression that this would be the "struct device" in the struct rpmsg_device, (which would let me get the struct rpmsg_device using container_of()?), but it appears to be some completely other device (by looking at the pointer address). I have tried searching the kernel code for similar example, but I have not found anything so far. It feels like I am stumbling a bit in the dark here, looking for my rpmsg_device.

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

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

* Re: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24 12:02   ` Pelle Windestam
@ 2020-03-24 12:31     ` Greg KH
  2020-03-24 13:05       ` Pelle Windestam
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2020-03-24 12:31 UTC (permalink / raw)
  To: Pelle Windestam; +Cc: kernelnewbies

On Tue, Mar 24, 2020 at 12:02:15PM +0000, Pelle Windestam wrote:
> > On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> > > Hi,
> > >
> > > I am trying to develop a simple driver for the rpmsg bus, in order to send
> > various commands from user space in Linux to a secondary CPU (A Cortex M4).
> > I'm trying to keep things as simple as possible, so my idea was to create a
> > driver that just has a few attributes which can be set in /sys which would
> > trigger commands to be sent to the M4 CPU. I have the communication between
> > the CPU:s up and running, but where I'm having trouble moving forward is how
> > to access the "struct rpmsg_device *" that I need in order to communicate
> > with the endpoint for the M4 CPU from the store/show function of the sysfs
> > attributes. What my driver does is to register a rpmsg_driver in the init
> > function:
> > >
> > > register_rpmsg_driver(&pwm_rpmsg_driver);
> > >
> > > the device_driver member of my rpmsg_driver struct has its groups member
> > set to my driver attribute groups array:
> > > static struct rpmsg_driver pwm_rpmsg_driver = {
> > > 	.probe = pwm_rpmsg_probe,
> > > 	.remove = pwm_rpmsg_remove,
> > > 	.callback = pwm_rpmsg_cb,
> > > 	.id_table = pwm_rpmsg_device_id_table,
> > > 	.drv = {
> > > 		.groups = driver_pwm_groups,
> > > 		.name = "pwm_rpmsg",
> > > 	},
> > > };
> > >
> > > My issue is that that I am not sure how to access the struct "rpmsg_device
> > *" (i.e. from the probe() function) in the show/store functions for the sysfs
> > attributes, which have a "struct device_driver *" argument:
> > 
> > That is because you have created a driver attribute, not a device attribute.
> > Create device attributes and you should be fine, they bind to the device your
> > driver is passed.
> 
> Thanks! Changing them to device attributes was a breeze. Now I am
> slightly confused about the "struct device *" argument to the
> store/show functions. I was under the impression that this would be
> the "struct device" in the struct rpmsg_device, (which would let me
> get the struct rpmsg_device using container_of()?), but it appears to
> be some completely other device (by looking at the pointer address). I
> have tried searching the kernel code for similar example, but I have
> not found anything so far. It feels like I am stumbling a bit in the
> dark here, looking for my rpmsg_device.

It's a bit hard to figure out what exactly you are doing here without a
pointer to the code itself :)

Are you sure you aren't pointing the platform device accidentally?

thanks,

greg k-h

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

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

* RE: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24 12:31     ` Greg KH
@ 2020-03-24 13:05       ` Pelle Windestam
  2020-03-24 13:15         ` Greg KH
  0 siblings, 1 reply; 9+ messages in thread
From: Pelle Windestam @ 2020-03-24 13:05 UTC (permalink / raw)
  To: Greg KH; +Cc: kernelnewbies

> From: Greg KH <greg@kroah.com>
> Sent: Tuesday, 24 March 2020 13:31
> To: Pelle Windestam <Pelle.Windestam@tagmaster.com>
> Cc: kernelnewbies@kernelnewbies.org
> Subject: Re: Accessing rpmsg_device in sysfs attribute functions
> 
> On Tue, Mar 24, 2020 at 12:02:15PM +0000, Pelle Windestam wrote:
> > > On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> > > > Hi,
> > > >
> > > > I am trying to develop a simple driver for the rpmsg bus, in order
> > > > to send
> > > various commands from user space in Linux to a secondary CPU (A Cortex
> M4).
> > > I'm trying to keep things as simple as possible, so my idea was to
> > > create a driver that just has a few attributes which can be set in
> > > /sys which would trigger commands to be sent to the M4 CPU. I have
> > > the communication between the CPU:s up and running, but where I'm
> > > having trouble moving forward is how to access the "struct
> > > rpmsg_device *" that I need in order to communicate with the
> > > endpoint for the M4 CPU from the store/show function of the sysfs
> > > attributes. What my driver does is to register a rpmsg_driver in the
> > > init
> > > function:
> > > >
> > > > register_rpmsg_driver(&pwm_rpmsg_driver);
> > > >
> > > > the device_driver member of my rpmsg_driver struct has its groups
> > > > member
> > > set to my driver attribute groups array:
> > > > static struct rpmsg_driver pwm_rpmsg_driver = {
> > > > 	.probe = pwm_rpmsg_probe,
> > > > 	.remove = pwm_rpmsg_remove,
> > > > 	.callback = pwm_rpmsg_cb,
> > > > 	.id_table = pwm_rpmsg_device_id_table,
> > > > 	.drv = {
> > > > 		.groups = driver_pwm_groups,
> > > > 		.name = "pwm_rpmsg",
> > > > 	},
> > > > };
> > > >
> > > > My issue is that that I am not sure how to access the struct
> > > > "rpmsg_device
> > > *" (i.e. from the probe() function) in the show/store functions for
> > > the sysfs attributes, which have a "struct device_driver *" argument:
> > >
> > > That is because you have created a driver attribute, not a device
> attribute.
> > > Create device attributes and you should be fine, they bind to the
> > > device your driver is passed.
> >
> > Thanks! Changing them to device attributes was a breeze. Now I am
> > slightly confused about the "struct device *" argument to the
> > store/show functions. I was under the impression that this would be
> > the "struct device" in the struct rpmsg_device, (which would let me
> > get the struct rpmsg_device using container_of()?), but it appears to
> > be some completely other device (by looking at the pointer address). I
> > have tried searching the kernel code for similar example, but I have
> > not found anything so far. It feels like I am stumbling a bit in the
> > dark here, looking for my rpmsg_device.
> 
> It's a bit hard to figure out what exactly you are doing here without a
> pointer to the code itself :)
> 
> Are you sure you aren't pointing the platform device accidentally?
> 
> thanks,
> 
> greg k-h

I suppose anything is possible 😊 Here is the actual code if you want to have a look:
https://gist.github.com/iceaway/9900a9c2dd221eb836c5acda49f5d688

//Pelle

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

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

* Re: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24 13:05       ` Pelle Windestam
@ 2020-03-24 13:15         ` Greg KH
  2020-03-24 13:35           ` Pelle Windestam
  0 siblings, 1 reply; 9+ messages in thread
From: Greg KH @ 2020-03-24 13:15 UTC (permalink / raw)
  To: Pelle Windestam; +Cc: kernelnewbies

On Tue, Mar 24, 2020 at 01:05:48PM +0000, Pelle Windestam wrote:
> > From: Greg KH <greg@kroah.com>
> > Sent: Tuesday, 24 March 2020 13:31
> > To: Pelle Windestam <Pelle.Windestam@tagmaster.com>
> > Cc: kernelnewbies@kernelnewbies.org
> > Subject: Re: Accessing rpmsg_device in sysfs attribute functions
> > 
> > On Tue, Mar 24, 2020 at 12:02:15PM +0000, Pelle Windestam wrote:
> > > > On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> > > > > Hi,
> > > > >
> > > > > I am trying to develop a simple driver for the rpmsg bus, in order
> > > > > to send
> > > > various commands from user space in Linux to a secondary CPU (A Cortex
> > M4).
> > > > I'm trying to keep things as simple as possible, so my idea was to
> > > > create a driver that just has a few attributes which can be set in
> > > > /sys which would trigger commands to be sent to the M4 CPU. I have
> > > > the communication between the CPU:s up and running, but where I'm
> > > > having trouble moving forward is how to access the "struct
> > > > rpmsg_device *" that I need in order to communicate with the
> > > > endpoint for the M4 CPU from the store/show function of the sysfs
> > > > attributes. What my driver does is to register a rpmsg_driver in the
> > > > init
> > > > function:
> > > > >
> > > > > register_rpmsg_driver(&pwm_rpmsg_driver);
> > > > >
> > > > > the device_driver member of my rpmsg_driver struct has its groups
> > > > > member
> > > > set to my driver attribute groups array:
> > > > > static struct rpmsg_driver pwm_rpmsg_driver = {
> > > > > 	.probe = pwm_rpmsg_probe,
> > > > > 	.remove = pwm_rpmsg_remove,
> > > > > 	.callback = pwm_rpmsg_cb,
> > > > > 	.id_table = pwm_rpmsg_device_id_table,
> > > > > 	.drv = {
> > > > > 		.groups = driver_pwm_groups,
> > > > > 		.name = "pwm_rpmsg",
> > > > > 	},
> > > > > };
> > > > >
> > > > > My issue is that that I am not sure how to access the struct
> > > > > "rpmsg_device
> > > > *" (i.e. from the probe() function) in the show/store functions for
> > > > the sysfs attributes, which have a "struct device_driver *" argument:
> > > >
> > > > That is because you have created a driver attribute, not a device
> > attribute.
> > > > Create device attributes and you should be fine, they bind to the
> > > > device your driver is passed.
> > >
> > > Thanks! Changing them to device attributes was a breeze. Now I am
> > > slightly confused about the "struct device *" argument to the
> > > store/show functions. I was under the impression that this would be
> > > the "struct device" in the struct rpmsg_device, (which would let me
> > > get the struct rpmsg_device using container_of()?), but it appears to
> > > be some completely other device (by looking at the pointer address). I
> > > have tried searching the kernel code for similar example, but I have
> > > not found anything so far. It feels like I am stumbling a bit in the
> > > dark here, looking for my rpmsg_device.
> > 
> > It's a bit hard to figure out what exactly you are doing here without a
> > pointer to the code itself :)
> > 
> > Are you sure you aren't pointing the platform device accidentally?
> > 
> > thanks,
> > 
> > greg k-h
> 
> I suppose anything is possible 😊 Here is the actual code if you want to have a look:
> https://gist.github.com/iceaway/9900a9c2dd221eb836c5acda49f5d688

Odd, that "should" work.  But the pwm core is strange, I suggest posting
it to the pwm driver mailing list and asking for help there, as there
might be some odd "wrapper" structures involved here as can be seen by
the pwm core sysfs file accesses.

good luck!

greg k-h

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

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

* RE: Accessing rpmsg_device in sysfs attribute functions
  2020-03-24 13:15         ` Greg KH
@ 2020-03-24 13:35           ` Pelle Windestam
  0 siblings, 0 replies; 9+ messages in thread
From: Pelle Windestam @ 2020-03-24 13:35 UTC (permalink / raw)
  To: Greg KH; +Cc: kernelnewbies

> To: Pelle Windestam <Pelle.Windestam@tagmaster.com>
> Cc: kernelnewbies@kernelnewbies.org
> Subject: Re: Accessing rpmsg_device in sysfs attribute functions
> 
> On Tue, Mar 24, 2020 at 01:05:48PM +0000, Pelle Windestam wrote:
> > > From: Greg KH <greg@kroah.com>
> > > Sent: Tuesday, 24 March 2020 13:31
> > > To: Pelle Windestam <Pelle.Windestam@tagmaster.com>
> > > Cc: kernelnewbies@kernelnewbies.org
> > > Subject: Re: Accessing rpmsg_device in sysfs attribute functions
> > >
> > > On Tue, Mar 24, 2020 at 12:02:15PM +0000, Pelle Windestam wrote:
> > > > > On Tue, Mar 24, 2020 at 05:34:44AM +0000, Pelle Windestam wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I am trying to develop a simple driver for the rpmsg bus, in
> > > > > > order to send
> > > > > various commands from user space in Linux to a secondary CPU (A
> > > > > Cortex
> > > M4).
> > > > > I'm trying to keep things as simple as possible, so my idea was
> > > > > to create a driver that just has a few attributes which can be
> > > > > set in /sys which would trigger commands to be sent to the M4
> > > > > CPU. I have the communication between the CPU:s up and running,
> > > > > but where I'm having trouble moving forward is how to access the
> > > > > "struct rpmsg_device *" that I need in order to communicate with
> > > > > the endpoint for the M4 CPU from the store/show function of the
> > > > > sysfs attributes. What my driver does is to register a
> > > > > rpmsg_driver in the init
> > > > > function:
> > > > > >
> > > > > > register_rpmsg_driver(&pwm_rpmsg_driver);
> > > > > >
> > > > > > the device_driver member of my rpmsg_driver struct has its
> > > > > > groups member
> > > > > set to my driver attribute groups array:
> > > > > > static struct rpmsg_driver pwm_rpmsg_driver = {
> > > > > > 	.probe = pwm_rpmsg_probe,
> > > > > > 	.remove = pwm_rpmsg_remove,
> > > > > > 	.callback = pwm_rpmsg_cb,
> > > > > > 	.id_table = pwm_rpmsg_device_id_table,
> > > > > > 	.drv = {
> > > > > > 		.groups = driver_pwm_groups,
> > > > > > 		.name = "pwm_rpmsg",
> > > > > > 	},
> > > > > > };
> > > > > >
> > > > > > My issue is that that I am not sure how to access the struct
> > > > > > "rpmsg_device
> > > > > *" (i.e. from the probe() function) in the show/store functions
> > > > > for the sysfs attributes, which have a "struct device_driver *"
> argument:
> > > > >
> > > > > That is because you have created a driver attribute, not a
> > > > > device
> > > attribute.
> > > > > Create device attributes and you should be fine, they bind to
> > > > > the device your driver is passed.
> > > >
> > > > Thanks! Changing them to device attributes was a breeze. Now I am
> > > > slightly confused about the "struct device *" argument to the
> > > > store/show functions. I was under the impression that this would
> > > > be the "struct device" in the struct rpmsg_device, (which would
> > > > let me get the struct rpmsg_device using container_of()?), but it
> > > > appears to be some completely other device (by looking at the
> > > > pointer address). I have tried searching the kernel code for
> > > > similar example, but I have not found anything so far. It feels
> > > > like I am stumbling a bit in the dark here, looking for my
> rpmsg_device.
> > >
> > > It's a bit hard to figure out what exactly you are doing here
> > > without a pointer to the code itself :)
> > >
> > > Are you sure you aren't pointing the platform device accidentally?
> > >
> > > thanks,
> > >
> > > greg k-h
> >
> > I suppose anything is possible 😊 Here is the actual code if you want to
> have a look:
> > https://gist.github.com/iceaway/9900a9c2dd221eb836c5acda49f5d688
> 
> Odd, that "should" work.  But the pwm core is strange, I suggest posting it
> to the pwm driver mailing list and asking for help there, as there might be
> some odd "wrapper" structures involved here as can be seen by the pwm core
> sysfs file accesses.
> 
> good luck!
> 

I do no think that the PWM subsystem actually has anything to do with it, I only have "pwm" in the name because it will control a PWM signal via the M4 CPU. Otherwise it's all via the rpmsg driver. Rpmsg does not seem to have a mailing list of its own.

I will do some more digging. Thanks for the help!

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

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

end of thread, other threads:[~2020-03-24 13:36 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24  5:34 Accessing rpmsg_device in sysfs attribute functions Pelle Windestam
2020-03-24  6:31 ` Greg KH
2020-03-24  9:49   ` Martin Kaiser
2020-03-24 10:23     ` Greg KH
2020-03-24 12:02   ` Pelle Windestam
2020-03-24 12:31     ` Greg KH
2020-03-24 13:05       ` Pelle Windestam
2020-03-24 13:15         ` Greg KH
2020-03-24 13:35           ` Pelle Windestam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).