Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp948256pxb; Thu, 4 Feb 2021 00:52:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJyf+77AecGQ7+5fMZucXdDI0wq/QOPm0665VZReXQhzVFvs7ilHR00vx4f+sU1EvSfT6Ole X-Received: by 2002:a05:6402:11c7:: with SMTP id j7mr6904041edw.290.1612428737117; Thu, 04 Feb 2021 00:52:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612428737; cv=none; d=google.com; s=arc-20160816; b=Rvm7qx9QzgQ0zBgniva3LeZ6GomoE42/ejycDdK6t/27A7+gA/3yWsQQJQtXnFL8Ud twZ8iZasGYWYoQy4QeZGkwW+fFEa4rcrj+k9cr/5PbFEKuspJPLyWBjkcFWKP3/CyPiH cWOfeoZIqCSGYEytbRKrkum4QYrDkl6vyBdbb37mRXU0bPSEfB9SQ7014PoYxpiHRn5E 9kT1+vvDvODTTCLXjq4t7JDJ5InUdog69HGdr4f4KNbpPE+F4dojL4I1npj/aFEIJffO qcazFIuP1gGtuy7mobhzX3GBTfoqJJJVH1xVBXNcX04XVeTGCaJmJYpRzvcyJopdVXaP 2trQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=CRnSbQdFwvKmyMc039keRokTHONUmSL8dsL/yTFkE0w=; b=lc3hAuZhVsgO5//cvJXaHl3XxIk46Q8uLg7yjJrmI2uY2DHf8hOlsAvo3n/JBYDxSh IiIs2bGTNdfxismLF6dqGsOcLK6UgLeOp2g4NzgJeUTnP3CMc2TndBVpr9j7FHt36Zsf XioIrWHA/d7qRteiO1kk+kLjvCRwcAHbmUwU4sEU48N06jIFltjGfstLYydem4YdCPRy P2C2s1tNXY/UWSGBcpFqqWComjtwn32yCS+VRJ9Xbm+329ZFq5XbBKjn1btGJpyhNJEP BZOU7LQ66c342U/t4bWJjUlgf5p3e42zEuzaHvN+ft60o94KFyFnQxpWR+bpXVdElojK nXUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ePxY2HbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a1si3085646edq.48.2021.02.04.00.51.53; Thu, 04 Feb 2021 00:52:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ePxY2HbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235189AbhBDIrs (ORCPT + 99 others); Thu, 4 Feb 2021 03:47:48 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:48710 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S235172AbhBDIrf (ORCPT ); Thu, 4 Feb 2021 03:47:35 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1148hBSl031731; Thu, 4 Feb 2021 09:46:48 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=CRnSbQdFwvKmyMc039keRokTHONUmSL8dsL/yTFkE0w=; b=ePxY2HbPMpCuB8kddpwEm6Emz4/cYsmwvRWwohDT1FctlKzcBD2op2D6/H90Wi2mr3VI Lpwrut+VYD1RLsRaQ5lAAdccXY4aiT7xg9l0n3b/YfDWG3BpkP3qGnHYwVQxnWBhxahz 1DCwGqAjZ71BhXyPiJY/pMZ9UtsF1zBeAmOCoUyXoo8OQjsbQoIki9Z+U+geqOyRs/ra +L5/qRuva1epfkhkJ05j0/8ee3vxZYUE56VEmHxJtJlR9FVsJo2w5lLvFGCtxGx+rZ36 6H+zkb6yMyAere215uFYUEg+4yhcpDllh8lSWpK9ijXP1n5M8zNbIe+Pos8xWJBIwpsI Bw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36e7x16f1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 09:46:48 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D5E9310002A; Thu, 4 Feb 2021 09:46:47 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C7FF622AE4F; Thu, 4 Feb 2021 09:46:47 +0100 (CET) Received: from localhost (10.75.127.49) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 4 Feb 2021 09:46:47 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v3 15/15] rpmsg: char: return an error if device already open Date: Thu, 4 Feb 2021 09:45:34 +0100 Message-ID: <20210204084534.10516-16-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> References: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.49] X-ClientProxiedBy: SFHDAG2NODE1.st.com (10.75.127.4) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-04_03:2021-02-04,2021-02-04 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The rpmsg_create_ept function is invoked when the device is opened. As only one endpoint must be created per device. It is not possible to open the same device twice. But there is nothing to prevent multi open. Return -EBUSY when device is already opened to have a generic error instead of relying on the back-end to potentially detect the error. Without this patch for instance the GLINK driver return -EBUSY while the virtio bus return -ENOSPC. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_char.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/rpmsg/rpmsg_char.c b/drivers/rpmsg/rpmsg_char.c index 0b0a6b7c0c9a..2eacddb83e29 100644 --- a/drivers/rpmsg/rpmsg_char.c +++ b/drivers/rpmsg/rpmsg_char.c @@ -116,6 +116,9 @@ static int rpmsg_eptdev_open(struct inode *inode, struct file *filp) struct device *dev = &eptdev->dev; u32 addr = eptdev->chinfo.src; + if (eptdev->ept) + return -EBUSY; + get_device(dev); /* -- 2.17.1