Accessing rpmsg_device in sysfs attribute functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux