From patchwork Fri Jan 5 23:58:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 123579 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp1428977qgn; Fri, 5 Jan 2018 15:59:38 -0800 (PST) X-Google-Smtp-Source: ACJfBouTZzpaPIaPGJui3O4+TgXRVS6IQEBKEyZFJNJ7PLOfK+AHHd/hpWtP1Kp/PuBgzcBzTpvk X-Received: by 10.159.231.20 with SMTP id w20mr4666540plq.7.1515196777998; Fri, 05 Jan 2018 15:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515196777; cv=none; d=google.com; s=arc-20160816; b=ZghJ64cjBbCQcZs5lbt0O7/4gdS8serbVwvNTobdolb0yvQ2p7c4sS6RwxlGNehv23 Jdr9w7wbyZ83BdSGV+QPZL5qD7ITj8bDBM/loKlXWOMs3/RKx9U5vBN0e868xWXY/IlD fkcU1E2xSd+MDtzlNv+eNzt1ci6fXWJXfM79HV+8epKEK6hPv5uaJhU04AWlsxY3qnCG eQ70WghNq8664TNm+fqeUK8nkyv/+pyT9kTnX2ympAFhGb88Y6mP90aw5X2m4AR+6SXF qTJYeq5N0uaI4FxBH4J6mgn9+CKkOyjXltnkjSgSOu+S3rfUPL6adB5fn1vjB0IcX6dl ml6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=YgEEFdFpbM+Gj/rJHSwialRRy09cj3qjfKJwWLES30/XprBmfrDD+RRj+W/TORBvBu hRwLSab9ChknqHXIh8AVcbRvOJxlh61d59SFGcJ1vF3yB3S7UitkjExpeHycmHhr7swM 098es1eRINIaiVSMAieBLuNCoOSWCUrZzcMJb+QJxBEjTWykf9RDD3vIn1Sqw0/mgEmd iu4CHmeyacFHZczTZlyZwTmQBuY2kmt6CEblBpLIHgExWkDRLIBUs14X/VqcWEln3nxH 7Axzw94/yncvwTe6oN/3mzqU5at3wAozZjSb9f2DYtDwQuT1hCjKAFQOOQJ3edMa/B7b 7B5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bDId6vbr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q13si4147846pgc.706.2018.01.05.15.59.37; Fri, 05 Jan 2018 15:59:37 -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=@linaro.org header.s=google header.b=bDId6vbr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753490AbeAEX7g (ORCPT + 28 others); Fri, 5 Jan 2018 18:59:36 -0500 Received: from mail-pf0-f196.google.com ([209.85.192.196]:44113 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753355AbeAEX6O (ORCPT ); Fri, 5 Jan 2018 18:58:14 -0500 Received: by mail-pf0-f196.google.com with SMTP id m26so2804926pfj.11 for ; Fri, 05 Jan 2018 15:58:13 -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; bh=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=bDId6vbrfxkuWix8+tKzEv2+aWtjKFor3oVhqrax0oHpNxI6NA0qpVs32q975OCRFM mDtruzsW9oNquOP4S0Rkzf7qKqDtjFi3joyWupp2WjJwJMv3oBiSKZX9JoFy9ZI5x1uK YCs18/Myr3R8o0y5CK+WaBhTWxPlq4xpcz5Vo= 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; bh=iqTyD6hBhmrQc6ar/FJCMW8Pf/57ABnqf+HauxLQSiA=; b=H5Z5Hr3TpNC2lEO8J9N4iwEgaX8g9YKNuw6NPgh2EDxnXezmDkQjdO1jhBgTHT707l E31Zr4oNXO1k2NJsMcxPkB35Lvao8A3pYEXVdeiInVWflkm+415buJfSsOWCPSrcI4tO tea8mllfRPl82QQ4gSAZeqzF5iAS9acMBHIjw15SJz1z2kBUSAIHfvhElaXuqNQbygDm ROKM61V8kMeR4BisICj2fgzdzVfldiR/RVaRRN1sQhTUOJeBsJN5o0wHH+mYw3C6arPI Llhp7HAJ8knNKR1AT3fKGWT0uxTySSqkrO/XgBrx2Vh157Giw/Xv+Vs27dsXcRJSio42 c5tw== X-Gm-Message-State: AKGB3mK2B13A8M6eO4Ac6d8wW97TCo0rn+9CBXWJryohJAuAEeV9Id1c 0JiqapnKiLEKy2FQ2P7Y2ixHNQeNFJs= X-Received: by 10.99.126.89 with SMTP id o25mr2726385pgn.161.1515196693366; Fri, 05 Jan 2018 15:58:13 -0800 (PST) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id x4sm14473188pfk.51.2018.01.05.15.58.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2018 15:58:12 -0800 (PST) From: Bjorn Andersson To: Ohad Ben-Cohen , Bjorn Andersson Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Loic Pallardy Subject: [PATCH v2 3/8] remoteproc: Clone rproc_ops in rproc_alloc() Date: Fri, 5 Jan 2018 15:58:00 -0800 Message-Id: <20180105235805.9948-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180105235805.9948-1-bjorn.andersson@linaro.org> References: <20180105235805.9948-1-bjorn.andersson@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to allow rproc_alloc() to, in a future patch, update entries in the "ops" struct we need to make a local copy of it. Signed-off-by: Bjorn Andersson --- Changes since v1: - None drivers/remoteproc/remoteproc_core.c | 9 ++++++++- include/linux/remoteproc.h | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) -- 2.15.0 diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 208ccf709cad..dbf685dbafcf 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1342,6 +1342,7 @@ static void rproc_type_release(struct device *dev) ida_simple_remove(&rproc_dev_index, rproc->index); kfree(rproc->firmware); + kfree(rproc->ops); kfree(rproc); } @@ -1406,9 +1407,15 @@ struct rproc *rproc_alloc(struct device *dev, const char *name, return NULL; } + rproc->ops = kmemdup(ops, sizeof(*ops), GFP_KERNEL); + if (!rproc->ops) { + kfree(p); + kfree(rproc); + return NULL; + } + rproc->firmware = p; rproc->name = name; - rproc->ops = ops; rproc->priv = &rproc[1]; rproc->auto_boot = true; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 6fdc62e29d6f..cc4d30a790b3 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -419,7 +419,7 @@ struct rproc { const char *name; char *firmware; void *priv; - const struct rproc_ops *ops; + struct rproc_ops *ops; struct device dev; const struct rproc_fw_ops *fw_ops; atomic_t power;