Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32821C10DCE for ; Tue, 24 Mar 2020 05:35:28 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4807420663 for ; Tue, 24 Mar 2020 05:35:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4807420663 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=tagmaster.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.92.3) (envelope-from ) id 1jGcDF-000502-Rt; Tue, 24 Mar 2020 01:34:53 -0400 Received: from mail.tagmaster.com ([37.233.78.77]) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1jGcDE-0004zp-6g for kernelnewbies@kernelnewbies.org; Tue, 24 Mar 2020 01:34:52 -0400 Received: from TMEX01.tagmaster.com (10.10.55.12) by TMEX01.tagmaster.com (10.10.55.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.845.34; Tue, 24 Mar 2020 06:34:44 +0100 Received: from TMEX01.tagmaster.com ([fe80::e438:720a:793e:d353]) by TMEX01.tagmaster.com ([fe80::e438:720a:793e:d353%9]) with mapi id 15.01.0845.034; Tue, 24 Mar 2020 06:34:44 +0100 From: Pelle Windestam To: "kernelnewbies@kernelnewbies.org" Subject: Accessing rpmsg_device in sysfs attribute functions Thread-Topic: Accessing rpmsg_device in sysfs attribute functions Thread-Index: AdYBnSW219hf15rzRUqEMoRdMkyuZw== Date: Tue, 24 Mar 2020 05:34:44 +0000 Message-ID: <117a9e9d420f444ea814a37596fe5693@tagmaster.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.55.73] MIME-Version: 1.0 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org 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