Received: by 10.223.185.116 with SMTP id b49csp586918wrg; Wed, 21 Feb 2018 03:41:04 -0800 (PST) X-Google-Smtp-Source: AH8x227r2sQBl2G6NQ7u12DA4KAj4b1ZGLnrPZ+Ss7a1Jk9FvGVDlcffzOzDhP9vuXWWqCnmlSya X-Received: by 10.98.108.65 with SMTP id h62mr3082449pfc.32.1519213264305; Wed, 21 Feb 2018 03:41:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519213264; cv=none; d=google.com; s=arc-20160816; b=XABsHpd9RkCQ68HZfOuTga7xR97kc85oslU5Wbo3zNLnwtpuWemJhdwepDLpkN92CM USG7xEVfxSVdBaV3wE2zKHkIirGrQ3GDvteR1HHyJqxmARPDeM17YBPINMv768z3tz76 8lBnOPvv8H6fXw3ESlv1hTskS26r8eEDU4KC2zlvY636+Cm37fzFo991EvGgTmjdTQkS +arzkvRaMu7lTIJ6C5sbPHmq3JENb3WQhgYxSwfHb6N8ezi50pQ35QF07rChXB8KMKlG 03+JXgBWluRELCLTLwfziXCfaZJkGtgnXXOy8gZwEHfHPWkKUynq5QiKev/EGZDsGDtN K9ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=//lSOLSSSGLAMcrs694MhucDPy5sMBXxZwgWwh8Kmy4=; b=kZACdkam39yfFYNl7bASKJCYTj2gNOdsHWrFDs6312Xg2hS8ooKGI3Ytr0XwYsHEyQ r5CdfHadNx3P5dRNWSeQo9qQQ2hkeGe4a5dUvl1/k5TzC8FvtuHcR2yUo+/kTjDmcTId fCxnQW8gfCaBgDxUDmYscJngW+DOHVjalWDjf4epIIup7f63SHqwQL3LG05BeObhje8U jzPP8C7B0bidLnHYTM9J2/lQysQOjcGtTyLuKA3eKJqpIgvWXq6GVNNvm3OCaJyjpGsN lPoOQwVG91OveioTFAjyLS8fudLZ36C/hn6B34hvj1Lt6h4TooDcuzrmmY8cR5QkaKFK rLOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=TU6aKMj5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10-v6si1467533plk.706.2018.02.21.03.40.50; Wed, 21 Feb 2018 03:41:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=TU6aKMj5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933569AbeBULkH (ORCPT + 99 others); Wed, 21 Feb 2018 06:40:07 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34875 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933558AbeBULkE (ORCPT ); Wed, 21 Feb 2018 06:40:04 -0500 Received: by mail-wr0-f196.google.com with SMTP id l43so3580483wrc.2 for ; Wed, 21 Feb 2018 03:40:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=//lSOLSSSGLAMcrs694MhucDPy5sMBXxZwgWwh8Kmy4=; b=TU6aKMj5iZa7BFCCyAKMducDldjGh/GuSX0+nkx7CtazOHGWwh42bpgYy/vdrZ+j+W 68B0EqvNnDvVZHdpt1ynM8HCmk6TMcKcH+YsoKnuVcup3RlJgrAjqKpB94u1VFy/gu07 ttNWB8W9Eg6mU83xb7iibE/5gwxWRLUR892ltrXueJx0fWsRvkkOhKKW50ZRT0y//7DK cZXC24PZ1N0e4fd2HVz3sXlCLmVS4hmILSs2AbcT8dwD7pEeggU9/UNris81lZAIrgFd 7S+a9KwXbFWfB29aKbRw0M0UEE8f3xBebsYbjl1+EvDvQzoAycHc6b/bSnb/gePwWc4c GYuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=//lSOLSSSGLAMcrs694MhucDPy5sMBXxZwgWwh8Kmy4=; b=drswSlyDHXUUukmHW1g/KPCP/AA9w4Nmx6DoRaBivg9Mwyjh2FobWLvN7P66luhcQq 5sb4DPXS+MiCAW9+xhx0XHn2KeWm/xsu85cI0vWGNB4eid+HpyDqB11Wl9kjv0CUn1Rk xZ1SJM/pJ6GNwuuryrZZ5lDvWKu+NtmySf8JHWH3NFwiS3eToOMiPoaAZpLnMSKSiPer SRcgssrgyMTNgjkfmuBnxToLJLkQJo1G+snKhWFlOr0RB56UXj6omQLP5l03v2d8jGat Alo2fMcqu+OxPZdzRTzkraVWhAkSZkXM02CF2GEWWIik1D9ZoPAaZ+rGsRmxc2iiTxX3 GcIQ== X-Gm-Message-State: APf1xPCaPrZUOUYXnx4xwxxuOTqFEfwWJY/Fc2BUYapoYVov2hVH5j5l EKvuRExfkELf1kOdLsD0Z33MsOTlgMzmuSEklbadwg== X-Received: by 10.28.137.14 with SMTP id l14mr761168wmd.137.1519213202911; Wed, 21 Feb 2018 03:40:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.134.170 with HTTP; Wed, 21 Feb 2018 03:40:02 -0800 (PST) In-Reply-To: <1515590259-24304-1-git-send-email-anup@brainfault.org> References: <1515590259-24304-1-git-send-email-anup@brainfault.org> From: Anup Patel Date: Wed, 21 Feb 2018 17:10:02 +0530 Message-ID: Subject: Re: [PATCH RESEND] rpmsg: Add driver_override device attribute for rpmsg_device To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, "linux-kernel@vger.kernel.org List" , Anup Patel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 10, 2018 at 6:47 PM, Anup Patel wrote: > This patch adds "driver_override" device attribute for rpmsg_device which > will allow users to explicitly specify the rpmsg_driver to be used via > sysfs entry. > > The "driver_override" device attribute implemented here is very similar > to "driver_override" implemented for platform, pci, and amba bus types. > > One important use-case of "driver_override" device attribute is to force > use of rpmsg_chrdev driver for certain rpmsg_device instances. > > Signed-off-by: Anup Patel > --- > Documentation/ABI/testing/sysfs-bus-rpmsg | 20 ++++++++++++++ > drivers/rpmsg/rpmsg_core.c | 46 +++++++++++++++++++++++++++++-- > 2 files changed, 64 insertions(+), 2 deletions(-) > > diff --git a/Documentation/ABI/testing/sysfs-bus-rpmsg b/Documentation/ABI/testing/sysfs-bus-rpmsg > index 189e419..1c8599e 100644 > --- a/Documentation/ABI/testing/sysfs-bus-rpmsg > +++ b/Documentation/ABI/testing/sysfs-bus-rpmsg > @@ -73,3 +73,23 @@ Description: > This sysfs entry tells us whether the channel is a local > server channel that is announced (values are either > true or false). > + > +What: /sys/bus/rpmsg/devices/.../driver_override > +Date: January 2018 > +KernelVersion: 4.16 > +Contact: Ohad Ben-Cohen > +Description: > + Every rpmsg device is a communication channel with a remote > + processor. Channels are identified by a textual name (see > + /sys/bus/rpmsg/devices/.../name above) and have a local > + ("source") rpmsg address, and remote ("destination") rpmsg > + address. > + > + The listening entity (or client) which communicates with a > + remote processor is referred as rpmsg driver. The rpmsg device > + and rpmsg driver are matched based on rpmsg device name and > + rpmsg driver ID table. > + > + This sysfs entry allows the rpmsg driver for a rpmsg device > + to be specified which will override standard OF, ID table > + and name matching. > diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c > index dffa3aa..9a25e42 100644 > --- a/drivers/rpmsg/rpmsg_core.c > +++ b/drivers/rpmsg/rpmsg_core.c > @@ -321,11 +321,11 @@ struct device *rpmsg_find_device(struct device *parent, > } > EXPORT_SYMBOL(rpmsg_find_device); > > -/* sysfs show configuration fields */ > +/* sysfs configuration fields */ > #define rpmsg_show_attr(field, path, format_string) \ > static ssize_t \ > field##_show(struct device *dev, \ > - struct device_attribute *attr, char *buf) \ > + struct device_attribute *attr, char *buf) \ > { \ > struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ > \ > @@ -333,11 +333,52 @@ field##_show(struct device *dev, \ > } \ > static DEVICE_ATTR_RO(field); > > +#define rpmsg_string_attr(field, path) \ > +static ssize_t \ > +field##_store(struct device *dev, \ > + struct device_attribute *attr, const char *buf, size_t sz)\ > +{ \ > + struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ > + char *new, *old, *cp; \ > + \ > + new = kstrndup(buf, sz, GFP_KERNEL); \ > + if (!new) \ > + return -ENOMEM; \ > + \ > + cp = strchr(new, '\n'); \ > + if (cp) \ > + *cp = '\0'; \ > + \ > + device_lock(dev); \ > + old = rpdev->path; \ > + if (strlen(new)) { \ > + rpdev->path = new; \ > + } else { \ > + kfree(new); \ > + rpdev->path = NULL; \ > + } \ > + device_unlock(dev); \ > + \ > + kfree(old); \ > + \ > + return sz; \ > +} \ > +static ssize_t \ > +field##_show(struct device *dev, \ > + struct device_attribute *attr, char *buf) \ > +{ \ > + struct rpmsg_device *rpdev = to_rpmsg_device(dev); \ > + \ > + return sprintf(buf, "%s\n", rpdev->path); \ > +} \ > +static DEVICE_ATTR_RW(field) > + > /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */ > rpmsg_show_attr(name, id.name, "%s\n"); > rpmsg_show_attr(src, src, "0x%x\n"); > rpmsg_show_attr(dst, dst, "0x%x\n"); > rpmsg_show_attr(announce, announce ? "true" : "false", "%s\n"); > +rpmsg_string_attr(driver_override, driver_override); > > static ssize_t modalias_show(struct device *dev, > struct device_attribute *attr, char *buf) > @@ -359,6 +400,7 @@ static struct attribute *rpmsg_dev_attrs[] = { > &dev_attr_dst.attr, > &dev_attr_src.attr, > &dev_attr_announce.attr, > + &dev_attr_driver_override.attr, > NULL, > }; > ATTRIBUTE_GROUPS(rpmsg_dev); > -- > 2.7.4 > Hi Bjorn, Can you please review this patch? Regards, Anup