Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1390390pxf; Fri, 12 Mar 2021 08:27:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1m2G1VkvHiXdNANRqXxa9GQCMQBmw6oa421pQUfXVG3h4wm39qa87R4qNQkKqBeuFoIXP X-Received: by 2002:a17:906:3105:: with SMTP id 5mr9466426ejx.168.1615566434529; Fri, 12 Mar 2021 08:27:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615566434; cv=none; d=google.com; s=arc-20160816; b=pnt0oH9z6HWMT2ppfU6/bKATLJnrbO5AbS4zBeq5yFQCXPZdZUjSz1vuw9cmOMqErx krl7BiDNcKXYu8rHkwQgCHKft2cMHIT5koyPTqo5LsAqb1VKN0noscsjWR1Ki33WzIMn t6orv2ikT6jC9/W0ECad0wFK2h/XemBrk7KxJz/vX7kGsINlC2EGYkEJPOKD9dc5WNuI a5OtTHHudxtNXh2CvKX35Rw7WLb1BKKitDvl0nrdNh+CBOKA/9DjmWLgTf9E9vgtFWoh PxQk7Uc9wJ9d98qXXC1Jdvz3FhR/ZTCIG3yhfRDH8C8+vrivgGnCmYC/m9ZraWAk/FPt kKCA== 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=iXhTHlq228l+0iB04Y1r45kd4DhCxMw3571PP4zILAA=; b=UeCzRu8j5zy2EyCnyLekJn9nDJj4l7V6y+DNaU9YqXaQhvZHyFKc4hpqQZWl+i5/rK 8T2cJC4VRJl0RNhUgD/YTQRUcQTZqIQecfbA/vhAdGvcVYhmmX/talVMUov40pAwBMsq /hhOpzXOpXxHS8SOfV/C8cjK5/7GEOLHPYZumgYkctVjG0wqZ2W28T982dUPLmwKie6V jdRs4T1j4o3e+yqUOn4s4Tw8+4t+9kIj/Y0MpdsjYu1MfJNwVJOH/6Qs9dbvT8ha35te 5a8ArQIrG651hJfzCuz4wdAEm54/vjqSKR9OsKbCFSV3zLYGPDuEAdzgyOocwBNLsCIh sD4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VEmmh5X9; 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 rp14si4497450ejb.435.2021.03.12.08.26.51; Fri, 12 Mar 2021 08:27:14 -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=VEmmh5X9; 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 S233020AbhCLQZz (ORCPT + 99 others); Fri, 12 Mar 2021 11:25:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbhCLQZP (ORCPT ); Fri, 12 Mar 2021 11:25:15 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 596CCC061761 for ; Fri, 12 Mar 2021 08:25:15 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id w8so5383858pjf.4 for ; Fri, 12 Mar 2021 08:25:15 -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=iXhTHlq228l+0iB04Y1r45kd4DhCxMw3571PP4zILAA=; b=VEmmh5X9fa7g3DiKuaT8KWl1POaMjOAm+T7VEA/s9HtE3LAT5keAH5jFQKyhSL/xMS 9uJBXewfM5+b2Q2pTgzWrVmV+u5Zklkra+XF6ZoMjwzwl3nDrYS25Sca4ZwK34BjwuaT fKdOhGmGki2L5vZnbr5jVEN6XKD47xT2oYXdqvo0L1b8XCgR1uYJZdPlUcn/aXTAgURg I89r80V6WlTTOdGZi7HbkMFBU4jDHk1ojvazPOfgEmHUj9IT73xhKzFO6Wf7Ptw2JyoU U0VILhPzwdvcAg87OIl0CFSYeewaobSPcU6c2uZ3UFeD0/cPDtw51Z4qZKVRZebEgqPA pFWg== 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=iXhTHlq228l+0iB04Y1r45kd4DhCxMw3571PP4zILAA=; b=IwB2+E1a3wrBY3zKDfmBPWtK3ryedi2R7L/zbjaw4I7K8lVAi8XI2CCDhUn8DCQEaS hPZ2jEuFdDXq80bGhwJTgHKcjJ94ud+/Kv9mqxo0ekgYvMdnP7/5pL1ZOzgYlz8sR6cq 4fsvnaINjWW+Hr3acvA5U5vpYQ+huOEVFA//dWdywaqZlnwvlC3e7jxzi6cKIFCqPvQD pXtVicHYwj2X+CtUVOiLGowdjBD5w24FArGviEEPuoPI6n6C/L7hsqRbMUanMwUN1I+A HKCm6UfNKInyNbs6OhAhK7fupkwAirxuV1e3vL/ZbbccHTOQOrnaYmoPagy5aE/a7fJ7 LyCw== X-Gm-Message-State: AOAM532gXO8dzd+dBo++DYaI507CVOqPJr+tL4nhTqGfHZ6rswmbLdfB 8DFjVoJPwMlgeuz4707erlQtlA== X-Received: by 2002:a17:90a:a618:: with SMTP id c24mr15091131pjq.108.1615566314572; Fri, 12 Mar 2021 08:25:14 -0800 (PST) Received: from xps15.cg.shawcable.net (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id e8sm5899599pgb.35.2021.03.12.08.25.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Mar 2021 08:25:14 -0800 (PST) From: Mathieu Poirier To: bjorn.andersson@linaro.org, ohad@wizery.com 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 v8 17/17] remoteproc: Refactor function rproc_cdev_release() Date: Fri, 12 Mar 2021 09:24:53 -0700 Message-Id: <20210312162453.1234145-18-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210312162453.1234145-1-mathieu.poirier@linaro.org> References: <20210312162453.1234145-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 --- 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