Received: by 10.213.65.68 with SMTP id h4csp506150imn; Fri, 23 Mar 2018 09:12:50 -0700 (PDT) X-Google-Smtp-Source: AG47ELuzVb7d7kkUFtFQEuWXTjfjcLrjvLYELkjZjLlKJCAIlsNkuv8Yq3gKUYfkEGAodrFsv+FI X-Received: by 10.99.42.209 with SMTP id q200mr13526946pgq.379.1521821570613; Fri, 23 Mar 2018 09:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521821570; cv=none; d=google.com; s=arc-20160816; b=x8WXilNbCg/U1m/z6nBY+BcnE7ZAiTALg+4jzpZNSk6h9WohWzyR9wMt+vJpFVvV1o bT92WHTB0h3HiM6YsG31C/l2AeC3sm+spgbp0Kd/Wb2IwSanIema0yBZ4yb2vg8Hbr9S iXpm5BZXmqoZ9Ap2WeOIh/8JTeqkWnjtCkmT0r379QID8feQnOz87x01ssd4fbYAI0Ys AJyUjXZvd92amRwa/hDiSrxQ750dySrwgb8rV+F50HKPs3Uit8aH+gNCooT+Qa1/LPy+ n7mttUx3zvnGvobcW/flU/O96JTG2cnEp76vvJ+ieNz5+MXbGDNQPSDy02e66L/VdHi/ mnlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=SDDKIKJvOaO95L1DwrD7AIi0Ge2zJ6cwDgr+kkHakxg=; b=VgpX0juysb0XzK+cPwci1CBDNMgcWQhSEcYh3cL27X4apLT9qbwf48yMc+TV3PwA9Y vL+zBLPY30lCKecSTFl3iyQW+vb0CEtEGOLTRhR87UFwKxkYEv+kgxCvfwNYAZfDMUv9 JOMO2VtiHHhALS+aMlewGbhFMMY1Aa7wqT300/3IANMrcgPl4BGY02rYtopT4ZkRQu24 DTbWPigMEvOyMm/HfaeIcfDmPnTrIkRi5G1VuJ0gKNYlJ1zIii4tRpZ9MhfApima0j3+ hAKYDVezpNxzKiRzfrXFi6grc+nB6laZdpte/pO/zpN7UphiqXWPGzOrrSiPhSJEAyYL avtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=x0sVjdvj; 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 r22si449801pgo.323.2018.03.23.09.12.35; Fri, 23 Mar 2018 09:12:50 -0700 (PDT) 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=x0sVjdvj; 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 S1752112AbeCWQLq (ORCPT + 99 others); Fri, 23 Mar 2018 12:11:46 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:39483 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751831AbeCWQLo (ORCPT ); Fri, 23 Mar 2018 12:11:44 -0400 Received: by mail-pl0-f66.google.com with SMTP id k22-v6so7701765pls.6 for ; Fri, 23 Mar 2018 09:11:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=SDDKIKJvOaO95L1DwrD7AIi0Ge2zJ6cwDgr+kkHakxg=; b=x0sVjdvj/ZSVXxxBZSCQeAI6OGozC6N+mcyFBsbKVF9H4E6yUAZM8HtBcHDRZ9WzaQ U4uuctFji94hmwWUKtk3B+KqMmzibg+WYKh+ZB3MrEzxpIEwkmef5Ck3/gMT7pMnMRxG 7Pf1jU45OrBbgyxmqTM4Ty9QXjNeLYtIV2PMCHbo4Fa4UmYMspTBWw0eawiSckMAwVfl bjIkTchmPOcOLMpR0FA5z6Tq7i4ZKVvFFxNVyzR+guXDgoVgFWbNyal0YLrMWDvI3rMb WyXf4Wah7TpF9iDZd7shW+1mjKYEUhOElEArxXkWj7CV+nCXd6ESQ8+fCztdyDVIomEr 0Hxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=SDDKIKJvOaO95L1DwrD7AIi0Ge2zJ6cwDgr+kkHakxg=; b=QWWypzjce7HL/AL8uoXtZpCNj9sXnVf0erxSyvIoAq65b1tnB7wAXqSEC/dHfnwYJ1 UMSt20CC6Zfz/nNS4h27YmyDk0OWPu35sxZLJlFEchVYglRaK7f3SQM78CdhxZDdx/1c uh0AejwIkBf1nt5Enr+Epi2Hg/THkjdBheULRR6mZvawyxmqxiUUjkLlFME3/KJgdf2L pWsxD4EFwvHLQ3n+3im8+I50BLLWiEPQw4TOiXfN6Igc+JZ+wCxG7tzb3JBQgxYCrh3u a6b4XDRYqxdtdZuNxhpFNFlROcnx1mFkJIYHiIoHTAL0DwPZFYQYqNFkaalctY1fXiwa V6cw== X-Gm-Message-State: AElRT7FkC8sijFsG+VW/iTDfspiNA7gG5WEvVEIFLzF6xAKqZlyNKo63 pgtfpkrWUBNJYW7K+ftHdAH1hg== X-Received: by 2002:a17:902:9a8b:: with SMTP id w11-v6mr23599777plp.136.1521821503293; Fri, 23 Mar 2018 09:11:43 -0700 (PDT) Received: from localhost.localdomain ([106.51.27.252]) by smtp.googlemail.com with ESMTPSA id m185sm10715375pfc.132.2018.03.23.09.11.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 23 Mar 2018 09:11:42 -0700 (PDT) From: Anup Patel To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH v2] rpmsg: Add driver_override device attribute for rpmsg_device Date: Fri, 23 Mar 2018 21:41:17 +0530 Message-Id: <1521821477-31378-1-git-send-email-anup@brainfault.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Changes since v1: - Removed un-related changes from patch - Renamed "path" to "member" in rpmsg_string_attr() macro - Used strcspn() instead of strchr() in rpmsg_string_attr() macro --- Documentation/ABI/testing/sysfs-bus-rpmsg | 20 ++++++++++++++++ drivers/rpmsg/rpmsg_core.c | 39 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) 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: March 2018 +KernelVersion: 4.17 +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 5a08176..3e71976 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -333,11 +333,49 @@ field##_show(struct device *dev, \ } \ static DEVICE_ATTR_RO(field); +#define rpmsg_string_attr(field, member) \ +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; \ + \ + new = kstrndup(buf, sz, GFP_KERNEL); \ + if (!new) \ + return -ENOMEM; \ + new[strcspn(new, "\n")] = '\0'; \ + \ + device_lock(dev); \ + old = rpdev->member; \ + if (strlen(new)) { \ + rpdev->member = new; \ + } else { \ + kfree(new); \ + rpdev->member = 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->member); \ +} \ +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 +397,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