From patchwork Fri Jun 25 19:51:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45231C48BC2 for ; Fri, 25 Jun 2021 19:54:13 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0F98D6162E for ; Fri, 25 Jun 2021 19:54:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F98D6162E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QTkfpQoyecUdmAXgcQWx5sKzBBzr41tJ15ITWJYWzyg=; b=xYHYcbI1+C8HY/ tqXjOe/TcWEc8jzaZ+9NBKAEYLsOxTBQs7CsF2F+oraira77Qcop+sbJ6ypSsCzLOmKOfMx2SHHlX dJqcl3wxIM6OJUfpv4XYb2NYAOSHo9z1X5yx5CiBhEMyw3KuKP11AterQgSsM0b05yg2QiBks2WxT HhBCU3dNTuLpK8AZUKBvVFtHSYHP5taSdeXGWa11uO0/iWUwPukRfQ3ZxX8YtnqF4f1I2G1E4OTOD +OGYbjd/KeDYvnHZdAf3qe/Lv3ynf0fs7h2M2Wua55nwcoG4eOeVxgzmCci++M9k+SQQ3Jz3VaPo3 8wtZdhO1PnWI/bIuQcBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsJ-002iZF-04; Fri, 25 Jun 2021 19:52:27 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrs3-002iVc-GO for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=h3Hx4g23iCqTdbLSgslXxph/KRyl4q03Nb7dWJc/obU=; b=idN0Fwa0xJsQCKEaCsIRfEupznJ0pmzPXVXB03/I0G2qZks9TXe90bVJlUQRyxUNR1UewK vpSWGAKHYrOyIflrJizJS095CxRYXAdfr5sXf7OCWs8IeOJHpBCiEuuhCOWKmiCFE3Olj7 u3MJcflRG0Bt2VA5xeTOJF+oOdaLXBU= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-563-KfR2Q7t9O8KqjKcBQR_B0g-1; Fri, 25 Jun 2021 15:52:09 -0400 X-MC-Unique: KfR2Q7t9O8KqjKcBQR_B0g-1 Received: by mail-oi1-f197.google.com with SMTP id a29-20020a544e1d0000b02901eef9e4a58cso6544914oiy.3 for ; Fri, 25 Jun 2021 12:52:08 -0700 (PDT) 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=h3Hx4g23iCqTdbLSgslXxph/KRyl4q03Nb7dWJc/obU=; b=aBI5C0lKckR6Hh3cApzgEdH8aRsG8HGDF1181WAcsHX8G9Xa6CCcD+mzYiBh2cD2vy p2rAd0joKWZds3VqhPxgoAprH38z0r2njjHc9eRF0Hf61pQRbcW/CYP3/1vQGMMuqGZC 2FDJqTEYUw1Rv8j05GVrVH0k4FH27nFZH3pizMbKSpq0IoGWZRTHDGf00mcdqlJfW4ac C6Yk4ORqz19w4a8KgTZMwrYC+Uxw2WXvtGlr+rBDuI1eLs0RSIgvkFMYHbyT9h1LQPMB kBu6QFGQXN5BJAlK68Y5FPZCsUKtNMhCYASf0cD/9KACAmBXLjGSO/1GqJOlfVb8fX9m Zyhw== X-Gm-Message-State: AOAM533qoRU9bqXMdtMsbMtFqJxtMhDwA0V2KMJHg8BRNA6gR6wUYhkE MV7fssGTLO+AkUkt1txP4pgPXd3s8UebQZZf9SYsmihssjPHiwWsbjhzNx5OZ4nvULEgJSz2J5k 67GMAyvSo5RcS5xXhZz5LyzTv8gTGqFG51Zk= X-Received: by 2002:aca:360b:: with SMTP id d11mr9778916oia.108.1624650728369; Fri, 25 Jun 2021 12:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRkUHu9PZy3otLlcnM8UdeRlQ9ClzhhP/XcfbGlosU7eNjGFuxzVDIFpY6HanOFEkjF94u2A== X-Received: by 2002:aca:360b:: with SMTP id d11mr9778907oia.108.1624650728233; Fri, 25 Jun 2021 12:52:08 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id o25sm1535446ood.20.2021.06.25.12.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:07 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v4 2/7] fpga-mgr: make write_complete() op optional Date: Fri, 25 Jun 2021 12:51:43 -0700 Message-Id: <20210625195148.837230-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210625195148.837230-1-trix@redhat.com> References: <20210625195148.837230-1-trix@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210625_125211_683070_EB005DD9 X-CRM114-Status: GOOD ( 17.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a write_complete function if there is nothing. Move the op check to the existing wrapper. Default to success. Remove noop function. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 45 +++++++++++++++++++------------------- drivers/fpga/zynqmp-fpga.c | 7 ------ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c047de8a059b7..05a69ab3ecb9e 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,28 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +/* + * After all the FPGA image has been written, do the device specific steps to + * finish and set the FPGA into operating mode. + */ +static inline int fpga_mgr_write_complete(struct fpga_manager *mgr, + struct fpga_image_info *info) +{ + int ret = 0; + + mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; + if (mgr->mops->write_complete) + ret = mgr->mops->write_complete(mgr, info); + if (ret) { + dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); + mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; + return ret; + } + mgr->state = FPGA_MGR_STATE_OPERATING; + + return 0; +} + static inline int fpga_mgr_write_init(struct fpga_manager *mgr, struct fpga_image_info *info, const char *buf, size_t count) @@ -146,27 +168,6 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, return ret; } -/* - * After all the FPGA image has been written, do the device specific steps to - * finish and set the FPGA into operating mode. - */ -static int fpga_mgr_write_complete(struct fpga_manager *mgr, - struct fpga_image_info *info) -{ - int ret; - - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - ret = mgr->mops->write_complete(mgr, info); - if (ret) { - dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; - return ret; - } - mgr->state = FPGA_MGR_STATE_OPERATING; - - return 0; -} - /** * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list * @mgr: fpga manager @@ -577,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->write_complete || !mops->state || + if (!mops || !mops->state || (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index 125743c9797ff..9efbd70aa6864 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -66,12 +66,6 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, return ret; } -static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr, - struct fpga_image_info *info) -{ - return 0; -} - static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) { u32 status = 0; @@ -87,7 +81,6 @@ static const struct fpga_manager_ops zynqmp_fpga_ops = { .state = zynqmp_fpga_ops_state, .write_init = zynqmp_fpga_ops_write_init, .write = zynqmp_fpga_ops_write, - .write_complete = zynqmp_fpga_ops_write_complete, }; static int zynqmp_fpga_probe(struct platform_device *pdev)