Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp613520pxf; Wed, 10 Mar 2021 13:13:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwRa/RR7lrW5l/COLFpEmtEwPtAAk95I+Gw9FgpREVD46V8D+VIZ3iolZStUiCtB4QsMQU4 X-Received: by 2002:a17:906:7d7:: with SMTP id m23mr353658ejc.205.1615410780485; Wed, 10 Mar 2021 13:13:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615410780; cv=none; d=google.com; s=arc-20160816; b=U3uUzMFdANMDQ1nV2SUZLkwDfFiMpixsKIqFLjq1NlIMYTeGU1tK15tkvesCTVyeWC KE/GVF9bbR6hEtqpftUCrTV4F6317NHn4v6gpjbSST2tHbbP3wyv6c4DLgSez7shXicZ yan7Or0DvRupluNjjmXWxoN89vQgAsFshSmLtexWb3Vf4nb0MtU2zqqiQXpfLW9+txRR V0+Im8ttVQR70y22lJ/EIEyAjshn3hAme9DFw6OEpkqLffPswBHAQb2qipOatHMgWKUk /3GY22Xp2ZTSmfaKiIdmvDiiXLtsEQwU8cq4AATmBAqyOIlgQQR4fFEZYMxCuHvdplIX DQnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BGL2ihK/psb3Syg4v822MS7bSYXQTTBjUBjeuGJcCyw=; b=QyByOKf6YnagEaXo3zQMKaBGYoA0y3qov8bMEyTOW2IfivQORhMniXzBlVehWpOHZR OcLxghoshUCjTuj/lcng/QgMiIe14jMLxhSXo45E7iuiVlCrogfU3sMLVrz60HMnnqao a8g1n8RxJCKiFnWV8gQBiyyufnSP5jNu/rMjVi43hSSQ+eLx02rLTAks4+EUnIcX4vYA Tj/OSfKwIS7CW6bfiGY4HoWFj5CetoF+9wOtPzPJaA4kNbejDUkq+K4u3B+8tleDwy4A daBOkY3L3Dl53TtXjt3DH+SRP7UeHbvPIvdLnWL5EfNrzRSCMwR7UOLRIjyi1maUaaKg kDmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Vb8k+1a9; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si356124edh.58.2021.03.10.13.12.37; Wed, 10 Mar 2021 13:13:00 -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=@linaro.org header.s=google header.b=Vb8k+1a9; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233782AbhCJVLQ (ORCPT + 99 others); Wed, 10 Mar 2021 16:11:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232327AbhCJVKw (ORCPT ); Wed, 10 Mar 2021 16:10:52 -0500 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B15DC061756 for ; Wed, 10 Mar 2021 13:10:52 -0800 (PST) Received: by mail-pj1-x102e.google.com with SMTP id q2-20020a17090a2e02b02900bee668844dso7936418pjd.3 for ; Wed, 10 Mar 2021 13:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BGL2ihK/psb3Syg4v822MS7bSYXQTTBjUBjeuGJcCyw=; b=Vb8k+1a9Xet0PbxpzdS19v+gh8mkgVMJGpJouQqrohu8j1rhefkJMCeyCKgo2iAkFp HGtHWaFWm000lW+mCa+MG4FwdJvucPutY370SC6gpN5cDSeZ4PGfIhRSv0PpPo/CecOM dpnQJ4+oMn6bUgrZLsRTijPoCS7bRaSvp6+tzEk1I8MgpFjSclrntDPW8UAUObZ1iVIs Z4PmsEh91nNNkPhUkri+RmFgRwJCXsFAA8K04ysQWMmd9i5j+VGYvvpELsPmxBI6oTli Hp9VoCooO8UraqRnoXzAi1NHDtmpUhFPhBOtF5mMLslvj2lmjzR64+xtR8Aatbkutl2w 9gMQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=BGL2ihK/psb3Syg4v822MS7bSYXQTTBjUBjeuGJcCyw=; b=htuOYLjCct8I6bvfsowIzKc5cnPfyQf8SOipF7yn2+UKciIDc84IXt2yK5CZ9YU7kB lKZrm6u454eMc4Dr3ON4bO9rQCNdhquyaHS3AP23nlxq6VYWBmVrx2H7AxmGUH2C2bwz dEp6s/PYsfZ0Ox7Z48DcUmQR0+k8hg1BDYAI7Fp+zgF86lkjFg6N++iBaC9v8CsJ8cmg ebbwjQWoaBfDcEwmdRxSVeVmakeB5At4h7JUXsQV1UScyNeKAYVUQqnchYvgNcMjbpwn EauR1jIy+WJANzplnXMWwSAqkkMV9yr95czin7BxUBplJypAvbHnzyBi/xlp+ecfYxsE GFpQ== X-Gm-Message-State: AOAM530iXizbOtnoybCwcwF9F/ja0pccYKGlecWpnSoHA0im5CPuMoQo 5DOFQ6B0DwsbgseGL8DJPVN+mg== X-Received: by 2002:a17:90a:3902:: with SMTP id y2mr5532955pjb.202.1615410651845; Wed, 10 Mar 2021 13:10:51 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id j21sm371508pfc.114.2021.03.10.13.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 13:10:51 -0800 (PST) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org Cc: arnaud.pouliquen@st.com, mcoquelin.stm32@gmail.com, alexandre.torgue@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v7 17/17] remoteproc: Refactor function rproc_cdev_release() Date: Wed, 10 Mar 2021 14:10:25 -0700 Message-Id: <20210310211025.1084636-18-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310211025.1084636-1-mathieu.poirier@linaro.org> References: <20210310211025.1084636-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactor function rproc_cdev_release() to take into account the current state of the remote processor when choosing the state to transition to. Signed-off-by: Mathieu Poirier --- New for V7: Keep the behavior of the shutdown operation in rproc_del() intact. --- drivers/remoteproc/remoteproc_cdev.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_cdev.c b/drivers/remoteproc/remoteproc_cdev.c index 2db494816d5f..0b8a84c04f76 100644 --- a/drivers/remoteproc/remoteproc_cdev.c +++ b/drivers/remoteproc/remoteproc_cdev.c @@ -86,11 +86,17 @@ static long rproc_device_ioctl(struct file *filp, unsigned int ioctl, unsigned l static int rproc_cdev_release(struct inode *inode, struct file *filp) { struct rproc *rproc = container_of(inode->i_cdev, struct rproc, cdev); + int ret = 0; + + if (!rproc->cdev_put_on_release) + return 0; - if (rproc->cdev_put_on_release && rproc->state == RPROC_RUNNING) + if (rproc->state == RPROC_RUNNING) rproc_shutdown(rproc); + else if (rproc->state == RPROC_ATTACHED) + ret = rproc_detach(rproc); - return 0; + return ret; } static const struct file_operations rproc_fops = { -- 2.25.1