Received: by 10.223.176.46 with SMTP id f43csp4188489wra; Tue, 23 Jan 2018 05:47:59 -0800 (PST) X-Google-Smtp-Source: AH8x226VmsJx2sYwKiuxYqqGmVAmsJvj/IHoiCvyQ9QET2zlS3ntZvRrU3vdbJ6c4ELN3oQUBW3l X-Received: by 2002:a17:902:4383:: with SMTP id j3-v6mr5550437pld.320.1516715279596; Tue, 23 Jan 2018 05:47:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516715279; cv=none; d=google.com; s=arc-20160816; b=FFkhuMyT5LQa3SljXN5s1z+1bB60KB5BTRaOheXis2+N1Whb4ZVcVptDVK8OkuOBfM Kj882Gng3stRglGkezQyEoKYpLLXzknzIRQjpEO+U7g4zQ1SaMSOGizljy4j8iE+KOSc JzJ4G6ch2K0YPHk9Ie+KXeXPJptt1FjT4UNlYOCs03uZr8f1lGnNUY7QQimBQkbYEQbX 5ISH+3GpLxxj6X7txk74wMuJWTNt72TUe+IGU0VwGDb/js3omB+0xynQfb5OTHJC6p3L +LVb7CjxPbjY1p1dPyZXzYVyc5thi9qm3pihduzVo5++S4iBUluV+Pstq+OX7eKuIgyR wF0w== 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=D2CZC/FaUdYmZwIoUkdLvmzb7UEzoJUZIgnoEXZO2WU=; b=ww2174e4RWtlg/7y7bmsAsK4FGdZCfmLO1RK/u/0iTKnOj36oXVnRV2we3tlz0sUpa bL5W8DENJh9GnbG1adwG7qWyWdVMKAThmBacUXi1G/DQRSXK3sr5d0Liv6glhwAv7bAg WnW+OJwve07v+Ji14Dh322ItFAFb+sUgbH6bey5jTDq8LNO/16CSDCBTnO3x48oTB0tv mcr7ug/j3Xpe43fYy0lHgbAoQJQyD8fZytekgi7jotwUgEdo2jfFovqbghWiZPEanaK6 40L6YJ6xQGLCs/aJsaESDkAtwp0rCQ6hiYkX18C0e8VfGMmCXpZbLd2yDUqDmifBUOM5 i8Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=iRkvoOzB; 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 ay6-v6si4740437plb.423.2018.01.23.05.47.44; Tue, 23 Jan 2018 05:47:59 -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=iRkvoOzB; 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 S1751785AbeAWNqk (ORCPT + 99 others); Tue, 23 Jan 2018 08:46:40 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:34219 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbeAWNqi (ORCPT ); Tue, 23 Jan 2018 08:46:38 -0500 Received: by mail-wm0-f65.google.com with SMTP id j21so13544851wmh.1 for ; Tue, 23 Jan 2018 05:46:38 -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=D2CZC/FaUdYmZwIoUkdLvmzb7UEzoJUZIgnoEXZO2WU=; b=iRkvoOzBsrEc1ct6mU8sWnhTp0w1suLS8FZruF4bumty6v4IEyQN66RqffNYjVfyqt P20XAhaNTBUsHm2l+bob1QGxfyYTLyO29Pb4k/PGyJm0xYAjMHiGFd3jhVYIrizM4YiM yKX5BKF7KJ6+5xf2FIs4bJS4NW/LXWurGaJmplyDxBNZ3qMABQ1Z9G/ex5r1bSUZFV/w b4BrQ1fhL1BZb7SwGVxqpfASWXVArIWdjUZjQZUY3Dp3oTKFyHGz9TrxYfa/1wkSNz2B dn7WHl1Vqe7Tpak4tuXnrvFfDuEDeVv/INn6Y/FrcaCXyX26EPvOcdgY5giC0hswP3xG FGoQ== 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=D2CZC/FaUdYmZwIoUkdLvmzb7UEzoJUZIgnoEXZO2WU=; b=foBQnmHmxl07QmhyK3DgUPXNCcQLL6DG2h2cTKWJHwUjIOmAWyeFf3OCaZZ05PTzTT UH+ny+dOCMUmSAixazQyKPPr3ajqwxMlix2Fzl48hDUOoLKq5S8U8OIpY6U5it5GC2/X p0Cy2bG+sr5FqbWbCXrW3Gke6AZ63pE5QhOsJ1anTGy5+ARt9e8Cm2qbdHLYdBqcG+9x W2hScwygZQJtI5JM3qHCyFVWZXOmkAnF5Jcmi5JM928hL0OpHMBk4Ije4HO7W3icb5yt 56aqfvuyMdafOCA2wDdA+2jSMp/kdVsaANIumME1rNfJOgGB5HYqQt1ST4IKeEgEucvg yDtA== X-Gm-Message-State: AKwxytd92moLHU36pGOkasfcfYoU40v2wCxj3Pw3G8XpEhVbjR7yepiZ iRRl+yE1xvIT1mFPkrEMwQnkmMoUvWXGI5SHXfX0lg== X-Received: by 10.28.172.130 with SMTP id v124mr2013629wme.16.1516715197520; Tue, 23 Jan 2018 05:46:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.223.199.65 with HTTP; Tue, 23 Jan 2018 05:46:36 -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: Tue, 23 Jan 2018 19:16:36 +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 All, Any comments on this?? Regards, Anup