From patchwork Fri Jun 25 19:51:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345827 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 2D5ECC2B9F4 for ; Fri, 25 Jun 2021 19:54:04 +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 034696162E for ; Fri, 25 Jun 2021 19:54:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 034696162E 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=F0Vkx0qCkk0XVE8M7y9mc341tgIYxh4QfgJoplbQfuQ=; b=QQK6bgbolbO4aC 81ykZUP1No1/yaHyNt9rnCr3KgCKaFrmkzLkCGfFdktLMHiP1EnrYhQRvwd2v4KaQMo4ORfpSqOac K2f5vXq6Y4Q1YGOdTENVfF69CBxnHktf9Q+g/ehVJ/3A4CaKV/fC29XMFtnkL1Etu4dpEJqqMtZ6x OOsTvPcTSqx2PcB8NDDHkYDel3gRNMUDm673CPy7xiLDcfVPT8POQLu1W0t2YMhGBbSOGigFEPe1Y XPQzBeHf060XXPNSnvq1B0rgyNrb4G5qsdMgLXYzDMZ1g/AoRTI+WU7ncfQJzGvR/iE5VBPJCw8VK KmwGpSRpAeHnlqHCpUGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrs9-002iWu-3A; Fri, 25 Jun 2021 19:52:17 +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 1lwrs2-002iVZ-U9 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=1624650729; 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=8DrGKCk1PyABrk56DLPAvdbVVOLwe1RJgwvPdYUZWO0=; b=P6+hKMMezOM2q58Suy6bzLZJ2JvR0ekyX9Nda6fUycyfLfMRfenIce8t3AKbN6MZWuzPyx RYiijMiztLKnsSW1mmWGa7ePSRvOVifA+zbGcj3U7XfQyoeViZfoYm+OVfpJ5hyvN600rH CFzIZbP5Cj2MIoviHirTxbGIGFREBBQ= Received: from mail-oi1-f198.google.com (mail-oi1-f198.google.com [209.85.167.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-107-O0GQCWCsOMmFMMLnEHUwqw-1; Fri, 25 Jun 2021 15:52:06 -0400 X-MC-Unique: O0GQCWCsOMmFMMLnEHUwqw-1 Received: by mail-oi1-f198.google.com with SMTP id r3-20020aca44030000b02902241b7398a8so6511001oia.19 for ; Fri, 25 Jun 2021 12:52:06 -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=8DrGKCk1PyABrk56DLPAvdbVVOLwe1RJgwvPdYUZWO0=; b=D+0/kNBUk1eyMxpNf5tZbHKRwS48VcGyFeHRMQfV42fnyt0/MKxCZUz6/BSuQT1y7v KEkea+d2R9oRdqkkT8ewcIVeS/AEf03vgvu37UEELIdoOCigfwveZUbV4AWQloJqpBBR J9CACEw8kG2rHqZw/gqPSP0IktH6TI7owHmCgt1ZcZjN5bKe9HcBBFLb7p8TIl5tiIeK v8ArRKBB0mL6O4DflOvirPHqGn0wfAFuird2wHaDpeHSTbi2yxFdhLJF6yu+P3l9W7XN dsx4TSw2b8H/VI/YExeQ2XK5vP5ty/vHQjC/SAD6353HHlxpP/hbTDkU+2oKRo6GvkgT ppXg== X-Gm-Message-State: AOAM531gKhZMlr5DEF2nN6l5pKe5wQH79poiJ/EBbSyIk7uQwEZcZabW BUxY03urAauL19mTMg1LYwS3fgAdjo/2ioBYwvcuOhxvrAuB3zYyULauesDQokkj5m5jtFQrOw+ FRiXqZ3MvnFTzj1R4GiVTf/uGkdhYy2A+Aho= X-Received: by 2002:aca:de07:: with SMTP id v7mr12660087oig.8.1624650725853; Fri, 25 Jun 2021 12:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwksAeBpoAvEUezEdyZ5NcQyipuc4+d8PdYoULnG6dzFZDi28TVoKaNvmx21VMJfDFVEgV/4A== X-Received: by 2002:aca:de07:: with SMTP id v7mr12660075oig.8.1624650725709; Fri, 25 Jun 2021 12:52:05 -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.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:05 -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 1/7] fpga-mgr: wrap the write_init() op Date: Fri, 25 Jun 2021 12:51:42 -0700 Message-Id: <20210625195148.837230-3-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_111321_0BAF7012 X-CRM114-Status: GOOD ( 13.11 ) 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_init() op if there is nothing for it do. So add a wrapper and move the op checking. Default to success. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index ecb4c3c795fa5..c047de8a059b7 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,15 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline int fpga_mgr_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + if (mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} + /** * fpga_image_info_alloc - Allocate an FPGA image info struct * @dev: owning device @@ -83,9 +92,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr, mgr->state = FPGA_MGR_STATE_WRITE_INIT; if (!mgr->mops->initial_header_size) - ret = mgr->mops->write_init(mgr, info, NULL, 0); + ret = fpga_mgr_write_init(mgr, info, NULL, 0); else - ret = mgr->mops->write_init( + ret = fpga_mgr_write_init( mgr, info, buf, min(mgr->mops->initial_header_size, count)); if (ret) { @@ -569,7 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, int id, ret; if (!mops || !mops->write_complete || !mops->state || - !mops->write_init || (!mops->write && !mops->write_sg) || + (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL; 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) From patchwork Fri Jun 25 19:51:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345831 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=ham 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 895C8C2B9F4 for ; Fri, 25 Jun 2021 19:54:30 +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 5403260FDB for ; Fri, 25 Jun 2021 19:54:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5403260FDB 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=IRZOTGIUq/TBEeiw5c1QQrOUSKIz/1KcszBgoQjBbZM=; b=kjQca4eCM3INKg I5wxmyduINVI+V3K3RodCa5RoLJy6plQxqb34k8WjRp7slVPpm2h0hPGMQUnlaZY1vq7fvHj7S11L /MnArztCXkpRY/zkTtfo/UtgYePFK4jEJzwtk/G8v3bvBVayHxtPCmLwBHhBjhrSDmQzT3OWpdwGn vEQgrb+qRmntnbo29WneEhNpCmB9vSPhvo/nYw4qFhxIPmrWEiMOL7U//8p57QfMKwOO+De+CP0kn iHYQCQCnIVDgppohb1AoY9oXRRS5ASkNGDlElhniFHomw6kUUa9xo5DzkqKJGdhh7yGweP9LBjYpD mVHm7450IG8XPAyMXsvA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsT-002ibS-74; Fri, 25 Jun 2021 19:52:37 +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 1lwrs5-002iWA-JV for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650732; 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=zmCqJFhviJpySBAFzJy5r5IMKlvduxQc5V68S9Vd+94=; b=cvY7S6BPqSoFyQBi7gEVp4bIpY59lktA8toNFI650tzlI0k7BfJuEROxGW9/tZm00FCe5D ERj8JnmhSibPtp5QMVhXGLj8O5wpILhl5slu+imMAnQRQUa/emYigT9/g6WGwIF39uu9/S RWDv8NEnvHv7I0/Ra6VFZTiT9+hi5XQ= Received: from mail-oi1-f199.google.com (mail-oi1-f199.google.com [209.85.167.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-121-VfSU4LLZNvKHm9paLnqlNg-1; Fri, 25 Jun 2021 15:52:11 -0400 X-MC-Unique: VfSU4LLZNvKHm9paLnqlNg-1 Received: by mail-oi1-f199.google.com with SMTP id b12-20020a056808010cb029021dde407eb3so6536504oie.13 for ; Fri, 25 Jun 2021 12:52:11 -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=zmCqJFhviJpySBAFzJy5r5IMKlvduxQc5V68S9Vd+94=; b=EgS8IPZ0GpTYucBkY12L6kIgJ2t71eG/ikk62jKClswWIzprcSX9NN15MPuf6rKfIO 9eXOL2F8YnkmqmNbbIDhDGN/XaHo0xN5CK+qJ4KXvXOSmCieChN9WI8zQmjNVM4BzrKx n6hwyJsCeCTB+30/Z9nv/ZROWgU68PQ52Qw1YA3nEyR3p9WUanmLBC8ub/nvQm4CP9T6 Rle7LRGa+VOfVTCRYLvdn+j05CrGf4mpOSuk51+JeoWtNFeV8cnTIpLvThuClfk680c8 6IZyYBlULuWAk6zN0+5vKiDhghqEODNM8svK1ag71Y1uzjxQX36J7iwvr/QsLR7JRsbR KJIg== X-Gm-Message-State: AOAM533qb3FePzhNMHLD2Ecv9IkWgN0CLw3glhUFMQIZI2jvcrYiC298 +Oq9Db5IeRpuGMaid+5qoP1GFo4tdqO4jupPDs+4NnCYP8rgeBJs0CdG4HIIRaPrqPQ3fU1xYaW ewQrsvZEGqMStIXLpydUX5UOuCUdTUI5lWjY= X-Received: by 2002:a9d:6f10:: with SMTP id n16mr11442604otq.165.1624650730698; Fri, 25 Jun 2021 12:52:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyrgSs3HSrKX/eB4qtz68tFE9zA+wja/zPnCCLulswoCm4r95WfyEGRwhxQDpXEZZe+Gx01A== X-Received: by 2002:a9d:6f10:: with SMTP id n16mr11442598otq.165.1624650730534; Fri, 25 Jun 2021 12:52:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:10 -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 3/7] fpga-mgr: wrap the write() op Date: Fri, 25 Jun 2021 12:51:44 -0700 Message-Id: <20210625195148.837230-5-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_125213_774585_51FBF4EB X-CRM114-Status: GOOD ( 14.67 ) 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 function. Move the op check to the wrapper. Default to -EOPNOTSUP so its users will fail gracefully. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 05a69ab3ecb9e..8d5536d748081 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,13 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +{ + if (mgr->mops->write) + return mgr->mops->write(mgr, buf, count); + return -EOPNOTSUPP; +} + /* * After all the FPGA image has been written, do the device specific steps to * finish and set the FPGA into operating mode. @@ -204,7 +211,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG); while (sg_miter_next(&miter)) { - ret = mgr->mops->write(mgr, miter.addr, miter.length); + ret = fpga_mgr_write(mgr, miter.addr, miter.length); if (ret) break; } @@ -234,7 +241,7 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, * Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; - ret = mgr->mops->write(mgr, buf, count); + ret = fpga_mgr_write(mgr, buf, count); if (ret) { dev_err(&mgr->dev, "Error while writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_ERR; @@ -578,9 +585,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state || - (!mops->write && !mops->write_sg) || - (mops->write && mops->write_sg)) { + if (!mops || !mops->state) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL; } From patchwork Fri Jun 25 19:51:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345833 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=ham 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 442BFC2B9F4 for ; Fri, 25 Jun 2021 19:54:48 +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 0B90961949 for ; Fri, 25 Jun 2021 19:54:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0B90961949 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=9Il1VMlWzU9Q/gIe/Z4PlCkSHMYL1hu4Jvhp0a2Q7uI=; b=D73usDrR4QMK+f ZI+FmC1s1cvT4HC6IlW1RisXl2gPSOMXQh7PfsEf4+0hzy+mg1K7+RU9cSjWp/ikePMEsZDCzVK5L BiqOFo3O6DaIcogQ+zoKl6URttqD/DjDaSxUXm6U08+N8wg3dSYkE0JE8xfOxEnpT3m9UBxLRUYw0 uyh4VqbheECcyFscpRIcekq++jsplB3wNUN4pzBEY22asQvyCkDyw06FPXeZnuSESPqI9UdIcRlbT +qZgJvB1rlTHfZhe8i2QLiSjoeZRpC3Jqc+bBX+ZxjsuhR475xIwyWfCweEl8ElUWAOKgZZmliNs+ GW97cSPZuA3YDc4qNQEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsf-002ieH-MU; Fri, 25 Jun 2021 19:52:50 +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 1lwrsA-002iX0-27 for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650737; 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=nd5/Ncm9trzPQHKxxw2QIB0gwtpNADHT5q5Ylf5cTos=; b=czUdyFGinJaITyQqh8w2L/I8mjqGfFmMTT5p9GVrAuVWNAVWJ7bAr/BNzv55ngFrUi3Kt7 ysNP6N4e5+96tiOxtJMysLH9z4oKfAAY+h4xBoODUF9+CvvgPeYtehHZE28Q9rvNkC2cNb qhrbl9APjV+xT1LiWPXqrZMo70ADWy4= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-151-0h1K0j6EOcauFLAhVkxjCA-1; Fri, 25 Jun 2021 15:52:13 -0400 X-MC-Unique: 0h1K0j6EOcauFLAhVkxjCA-1 Received: by mail-ot1-f69.google.com with SMTP id v29-20020a056830091db029045efea1ec9bso6551432ott.21 for ; Fri, 25 Jun 2021 12:52:13 -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=nd5/Ncm9trzPQHKxxw2QIB0gwtpNADHT5q5Ylf5cTos=; b=G5w+U0hkW85m8woBBycYTwyzZcT3SeYdtmucG4p9My2dG7Wq5HWskxmvcCn0jjY9ZH nF5lTanKRxIID67yktnyaiH0jm3GkaqlmtufTqFmYiK/AvB6vZu8AVLIxjV1rNfuHwlU 3EWdfGfnfSzpXDzmkNEQQ7V+/36d1kM47CmEHg+ZKz0mWzSXFykXgyZxlibDo0Dh++D7 gQjlGfniQJnXhQ5ATP80HGnh3q2l7BgbXM/HCD62z/wMHTMuAXFRzmYcq7NE7yYYzVYf vL05YqvYJok7NHOvSP9levUg+RCYGc0c/d8Vli3oB8rfd72gYyRagtF8ffCI5FUNJcF0 ZKWA== X-Gm-Message-State: AOAM531xZ6oZY3GlrL6A4mFHET0R/0lANV1N8vVBufrmwnDdcB5KHC4b 8YGgorez6a792fQPKKOGGkbmhuzhO/+AtLU/2pmQ1s3dE/h0JjOALDb6sfnyITrUrnvyfaU6zej AjRdit1a7+pffMeDy0NHICysE7lHixrYKYX4= X-Received: by 2002:a9d:6219:: with SMTP id g25mr11096326otj.262.1624650732933; Fri, 25 Jun 2021 12:52:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOFoWkEHJLZJiCZogum6sza4B5EXPuEPCfHnSXmakawUVjrxJB8y25xvgEdsfFXS38d1e+fQ== X-Received: by 2002:a9d:6219:: with SMTP id g25mr11096313otj.262.1624650732804; Fri, 25 Jun 2021 12:52:12 -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.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:12 -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 4/7] fpga-mgr: wrap the status() op Date: Fri, 25 Jun 2021 12:51:45 -0700 Message-Id: <20210625195148.837230-6-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_125218_246662_7826E9AA X-CRM114-Status: GOOD ( 12.56 ) 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 is not required to provide a status() op. Add a wrapper consistent with the other op wrappers. Move the op check to the wrapper. Default to 0, no errors to report. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 8d5536d748081..43518b6eed21e 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,13 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline u64 fpga_mgr_status(struct fpga_manager *mgr) +{ + if (mgr->mops->status) + return mgr->mops->status(mgr); + return 0; +} + static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) { if (mgr->mops->write) @@ -434,10 +441,7 @@ static ssize_t status_show(struct device *dev, u64 status; int len = 0; - if (!mgr->mops->status) - return -ENOENT; - - status = mgr->mops->status(mgr); + status = fpga_mgr_status(mgr); if (status & FPGA_MGR_STATUS_OPERATION_ERR) len += sprintf(buf + len, "reconfig operation error\n"); From patchwork Fri Jun 25 19:51:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345835 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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 EBB81C48BC2 for ; Fri, 25 Jun 2021 19:54:59 +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 B6E5361949 for ; Fri, 25 Jun 2021 19:54:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6E5361949 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=2OMgmI+86lGFO65ujh4vhqLYvI+SesezRGArnmxTRX0=; b=Ci1EoFxBMLMeg+ MlGmC+wGGrSi46jYVy26wt2P9+yHQj3PfdCIQA77kFbYKAeG4RLTAicVtkv/y+CpmQNx6C+BVGbhG +TarKHU5+e7MpkL3yN6loXaL8hbPSoXoJln395zduRnfrKrkf2BysB8FR/9eKcjX9nf0FyPiKUjMS hxsgyveU2IJbXMwIzxNVScpOOyWuil8U2oGefPrSsMUiPbl/VRMTVPifX152QWk0qtm0t7W3nYZPx IfVDfM9JTORX0aWOdaqptyJJjlGvDH12rtVuC/MSjfKHgclVyo5GDzoSAoqDAlCrxuyiVQQ9kVAsA YLfWWYths7HsEN/V3cag==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsw-002iiz-2E; Fri, 25 Jun 2021 19:53:06 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsA-002iX2-9T for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650737; 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=+BoEiwZWmcnwYp+vuFKo9FHmPBN3oC7TpcdPOM8LN0s=; b=YFZshsnVpqYqibrHaKaPN3cdQ4lvbfW77BxESUiB6e8vZBUIWfesW1qhfg/97VVTGN1maM 3Hz834K6ybZiawqdKFz0DVSQaiQjr2i5gssOKZ9Cj+AU4yLkFAjzvBIa/WZT/ZMNNqBNhJ wN+tGZUwST1nXiUn2d9ZNyRk6fdBW9I= 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-586-I2DjvqLYNv6t4jmg_XZlRA-1; Fri, 25 Jun 2021 15:52:16 -0400 X-MC-Unique: I2DjvqLYNv6t4jmg_XZlRA-1 Received: by mail-oi1-f197.google.com with SMTP id z18-20020a0568080652b029022413cd7d4dso6534259oih.11 for ; Fri, 25 Jun 2021 12:52:15 -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=+BoEiwZWmcnwYp+vuFKo9FHmPBN3oC7TpcdPOM8LN0s=; b=otx5OY3b5rhs1bWInLJoCNulcskhPKGTIvs0JVCewX0mzrcqLxkDxB13fFYWARL/wt UDP4FOB3fkhEZHsszK8AVV6rFEc6G6PoyRL/EG3RN5tXgTn+QmIF9p119fV9jW9MkeOo dm1SzWNvSJgY4YHwLfsVIo9y17ikkhNpz3dM1aifFLx7H4yk2tVS0no70eEbdhNZtOc8 XsOs5L57T3uCBRrSds8yT8hJyU8GYWbvui9dematL5dV5jy6QzVOiD0CyEgHXIIBvhPk +y8GHasGLUyEHHNoHp8zp0fGUdD5RJHDcvLxI/I5Ssc/zumvuePXCnB3qa0hnLacpiHI bAVA== X-Gm-Message-State: AOAM532uFdJAe5Ts9kL904M+Y45IZlI94bzmzOYynwcAlx/B1OSLuqtM B5BcGDVYWndRM27qRzKgN8yphl0nMMg5uVuzSxzqU/OZPMHp6HTBoJEe0c3gcMZR3dHqAigGP0Q 42/oBJfhfM35Yq8bXgAPHbiEMvF+OtwRkOio= X-Received: by 2002:a4a:e2d5:: with SMTP id l21mr3723006oot.8.1624650735212; Fri, 25 Jun 2021 12:52:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkkI3SZznlD6Uem8J6dDkJCRpJZ9IID/gLUHaZnjy+WJWItpPPMuJ7BvNbnRc9MgSQ3n+HUw== X-Received: by 2002:a4a:e2d5:: with SMTP id l21mr3722997oot.8.1624650735048; Fri, 25 Jun 2021 12:52:15 -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.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:14 -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 5/7] fpga-mgr: wrap the state() op Date: Fri, 25 Jun 2021 12:51:46 -0700 Message-Id: <20210625195148.837230-7-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_125218_453209_6EF87EEC X-CRM114-Status: GOOD ( 14.16 ) 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 state() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Default to FPGA_MGR_STATE_UNKNOWN, what noop state() ops use. Remove unneeded noop state() ops Signed-off-by: Tom Rix --- drivers/fpga/dfl-fme-mgr.c | 6 ------ drivers/fpga/fpga-mgr.c | 11 +++++++++-- drivers/fpga/stratix10-soc.c | 6 ------ drivers/fpga/ts73xx-fpga.c | 6 ------ 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index d5861d13b3069..313420405d5e8 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -252,11 +252,6 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr, return 0; } -static enum fpga_mgr_states fme_mgr_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static u64 fme_mgr_status(struct fpga_manager *mgr) { struct fme_mgr_priv *priv = mgr->priv; @@ -268,7 +263,6 @@ static const struct fpga_manager_ops fme_mgr_ops = { .write_init = fme_mgr_write_init, .write = fme_mgr_write, .write_complete = fme_mgr_write_complete, - .state = fme_mgr_state, .status = fme_mgr_status, }; diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 43518b6eed21e..b3380ad341d22 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,13 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops->state) + return mgr->mops->state(mgr); + return FPGA_MGR_STATE_UNKNOWN; +} + static inline u64 fpga_mgr_status(struct fpga_manager *mgr) { if (mgr->mops->status) @@ -589,7 +596,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state) { + if (!mops) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL; } @@ -707,7 +714,7 @@ int fpga_mgr_register(struct fpga_manager *mgr) * from device. FPGA may be in reset mode or may have been programmed * by bootloader or EEPROM. */ - mgr->state = mgr->mops->state(mgr); + mgr->state = fpga_mgr_state(mgr); ret = device_add(&mgr->dev); if (ret) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index a2cea500f7cc6..047fd7f237069 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -388,13 +388,7 @@ static int s10_ops_write_complete(struct fpga_manager *mgr, return ret; } -static enum fpga_mgr_states s10_ops_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static const struct fpga_manager_ops s10_ops = { - .state = s10_ops_state, .write_init = s10_ops_write_init, .write = s10_ops_write, .write_complete = s10_ops_write_complete, diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c index 101f016c6ed8c..167abb0b08d40 100644 --- a/drivers/fpga/ts73xx-fpga.c +++ b/drivers/fpga/ts73xx-fpga.c @@ -32,11 +32,6 @@ struct ts73xx_fpga_priv { struct device *dev; }; -static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static int ts73xx_fpga_write_init(struct fpga_manager *mgr, struct fpga_image_info *info, const char *buf, size_t count) @@ -98,7 +93,6 @@ static int ts73xx_fpga_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops ts73xx_fpga_ops = { - .state = ts73xx_fpga_state, .write_init = ts73xx_fpga_write_init, .write = ts73xx_fpga_write, .write_complete = ts73xx_fpga_write_complete, From patchwork Fri Jun 25 19:51:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345837 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 61897C2B9F4 for ; Fri, 25 Jun 2021 19:55:20 +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 34B6C61445 for ; Fri, 25 Jun 2021 19:55:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34B6C61445 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=1eBdnRqagISyZLQnr0sbuTmfD2oNANITj/vEpLkqNbE=; b=gmP9rkPABRQ48X 9gy4wOVS4Bs/bpgk0bbE5VJfOKo84CF83J9aIZ6hZVMa4Unwxp3jZLXvfleQoAGf8G/wSV3qLE7J/ 75JkP7sp0wuqZ1oeUMNr9Hr1ASnr7KU+WYC49iL/X0L7Wmbxd79v2SGwdhgYUP6v6WuyoPEWCpNbL 79L9WHyhIRIRJ+FpOvxgjrDEnbttn++X4mR0+OrCfnNWrhLlGTfmI88vomWg4w+WysWZUHDAqPgY6 1+WBos+QACadccera68bQ0gNHtqYKu66YcJfaS3Y2kd4aMUjE0By4UxfCpi5cD6PloM0pO4eZFcXR iymoeeg4fLR7BXeEkA5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrtC-002iov-Pd; Fri, 25 Jun 2021 19:53:23 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsE-002iXz-TV for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650742; 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=LjAdCEfiqEm9c0Ynsebg4BWNbSDpcr72TwU3P0oRZpc=; b=A/UepZYKvirfToFz8Zmv6ZS9proH4NIh3q4cN9VOxe8Z1aStzjmUh7fvOxB3SJeLsOHJV/ eS2EAWUUww4pQwwkU5NzU3qhVeqU3DOA6VJPVFqK4OX+3DINM3iozI2OV1GfVMyZoSCMso sdhsXGTN4hKbnUZA0yTgS+HJpC9+V+0= 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-202-BoVgkR0ANfKKCeKpdBNo-Q-1; Fri, 25 Jun 2021 15:52:18 -0400 X-MC-Unique: BoVgkR0ANfKKCeKpdBNo-Q-1 Received: by mail-oi1-f197.google.com with SMTP id w125-20020acac6830000b029021ecc100d7bso6557193oif.6 for ; Fri, 25 Jun 2021 12:52:17 -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=LjAdCEfiqEm9c0Ynsebg4BWNbSDpcr72TwU3P0oRZpc=; b=mj01OXOwxd0JtG1cncC8/dX3HzOuR900l3YxrogKRBtOc02ZwAlUYhc4jQRpFvucWx yQuduRwxGytD89jRcFaCiXJ8KdzAe9TUasQUwLH8MnUsb6kLcBk+KE8gT7IRNniD4NfL 72sAnWksLZ4CoDH66C1FpOeOaYuVATUqYgBRq9OBHM7H4BQMbF1CsZpkryToJfLd+myX /Ee9jNaSBO5kNmeP/6F8wXXIfRgw7j/zTHDTvi39U9TFuihuGd0LCCalEt1yAyKCLI/L Zvb6kBT/xWcVyTUUzZZq0WhwfuQlLBa2iFl04Hax4rv7RbIjRuL+qEiFdg3l3yNDBaAX 9EtQ== X-Gm-Message-State: AOAM532zf8gw+UGT3Nl6WcJ4EoV3FeoDLrSNCMfw8r9Bq4gNsvVycqhM 2fomFIEx7pi4M0fWk3c1QTb/CuLJTkX7kDMKkPR5bSkiSOEjf865jY2fGMH7Brtzaf+PJE1z0oO NZbVsNKzWkKsnhO7X2SpReST9f2FZsZOpomw= X-Received: by 2002:aca:e107:: with SMTP id y7mr12990070oig.11.1624650737409; Fri, 25 Jun 2021 12:52:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwF1c4CKnAxDSoTM1uv3ouUh/l8z5JnAQLTGazp+4FQ/B0la7C6C13aQqkvGpjE5+63AdBssw== X-Received: by 2002:aca:e107:: with SMTP id y7mr12990063oig.11.1624650737263; Fri, 25 Jun 2021 12:52:17 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:17 -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 6/7] fpga-mgr: wrap the fpga_remove() op Date: Fri, 25 Jun 2021 12:51:47 -0700 Message-Id: <20210625195148.837230-8-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_125223_082084_D29916F6 X-CRM114-Status: GOOD ( 11.95 ) 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 is not required to provide a fpga_remove() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b3380ad341d22..077c0f9edbe4c 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,12 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr) +{ + if (mgr->mops->fpga_remove) + mgr->mops->fpga_remove(mgr); +} + static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) { if (mgr->mops->state) @@ -745,8 +751,7 @@ void fpga_mgr_unregister(struct fpga_manager *mgr) * If the low level driver provides a method for putting fpga into * a desired state upon unregister, do it. */ - if (mgr->mops->fpga_remove) - mgr->mops->fpga_remove(mgr); + fpga_mgr_fpga_remove(mgr); device_unregister(&mgr->dev); } From patchwork Fri Jun 25 19:51:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345839 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=-17.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 1CD39C49EAB for ; Fri, 25 Jun 2021 19:55:28 +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 DF75461445 for ; Fri, 25 Jun 2021 19:55:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF75461445 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=wQK8YVNQwtooPQT6Wr49qW79aNdRwz/Y2jUHMzHHEKw=; b=vZhVM42QojW4pZ UlboAwp2uJqzp+29msDhu20gcTcB+ZGzoBLkWRzE1YlhYTRrGQ3pJJ4vhPFxdIfYVwdaUiuN/pX9J UKP0XU+r9jY61+iV5mV7W1+47Hwl6fyBcNOHq6YsbCanj09TeQc76gZpAp66NRnTYfcnFflmYGLkY Qw82fSa6sOassFcub3NrSOrS25L64GLj7pBp+fpsgiVwt8T4QBbhQOWHXTY0q/bOvlWvTJzZ4bXM4 xCXtHVeQ3HRIhRsyeOCvJJPelxzCXM0kg367LVFTmr+WqMPzrlDqU2VFnkzYwrdWvzXufv7AI749O NN8xSLKG74QeGZd+zdpQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrtS-002ivU-8s; Fri, 25 Jun 2021 19:53:38 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrsE-002iXy-Rj for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650741; 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=4aYp4hJz/EjjMi3xPniOC0g0VH/UB+PZgaBhiQVtvD8=; b=cVnK/KsA4xcDxWV1tLBEnX4BFD1/ZWhl8kr76HBQ/UZ2VSMtBnMXXv36lFZwaavnOQHYyX 2BPHadeooAXmUmRPSJ2s/7i5zt088D5SRaMjgi7IDNybmLoyF11LTTFHR3tnSQrzkwU/Xv 45aYAsQx8o3Xh2Ebi1jokRC+ymCkoHc= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-458-cL-FZV5HMdqPIieBdrcA1g-1; Fri, 25 Jun 2021 15:52:20 -0400 X-MC-Unique: cL-FZV5HMdqPIieBdrcA1g-1 Received: by mail-ot1-f69.google.com with SMTP id e14-20020a0568301f2eb0290405cba3beedso6560056oth.13 for ; Fri, 25 Jun 2021 12:52:20 -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=4aYp4hJz/EjjMi3xPniOC0g0VH/UB+PZgaBhiQVtvD8=; b=lKCTurAutU58aK/S52eGDvwGnQz6mgl6lfvyP8fjwor6Q98uCFIt+a6pB/oZNJaO8i fd2oZz/0kZ9gtOSQ7aywec/48sJ0IjebtIlr3+wCSCjd3GtJHcFSRxJFK6oge2+oLied VbRh00R6sIN3TY9gb12vY5HGEC1a6ksn+Z/TmrgJz1EmfPud8uZ1IfL+7Yayuxpjvc+8 5RPYaDD98sw4u+AUUSDx4YoIpBvM4mm6h8KwdSfFZG7u+SMPqsdh/UfhX6X6R2EM5JdL unw1Sd+nOZ2Glxr6TENBESDds4ZVikIQRuCHHAn5D74mK0KU3QJKiooSHZBtalA9APdV yJmQ== X-Gm-Message-State: AOAM5302aBZ6CIwEimkNGHu61cFwFERfGMlpjV9gLWbKYDn6FMKMSCkr IskkB1/4FvV3nSei1AwqEMvdjvEY9bCZZowyGzRIf6em4jwS3ihHCiW7qcOZJAMbIB47hFCZSdc NHEPLI0CmdEI6bxUUD/dWaRvTAWsKTr5bMAs= X-Received: by 2002:a05:6808:bc1:: with SMTP id o1mr12878397oik.176.1624650739896; Fri, 25 Jun 2021 12:52:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypIr38r6Xwat7SHOutFdWdtMBZB5yIHYyEpbFVr7YNiZOiaRsU1APN36mLAM8st0Os4NeZUA== X-Received: by 2002:a05:6808:bc1:: with SMTP id o1mr12878390oik.176.1624650739792; Fri, 25 Jun 2021 12:52:19 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:19 -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 7/7] fpga-mgr: wrap the write_sg() op Date: Fri, 25 Jun 2021 12:51:48 -0700 Message-Id: <20210625195148.837230-9-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_125223_017525_29203EBA X-CRM114-Status: GOOD ( 13.14 ) 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_sg function. Move the op check to the wrapper. Default to -EOPNOTSUP so its users will fail gracefully. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 077c0f9edbe4c..aa30889e23208 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -83,6 +83,14 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr, return 0; } +static inline int fpga_mgr_write_sg(struct fpga_manager *mgr, + struct sg_table *sgt) +{ + if (mgr->mops->write_sg) + return mgr->mops->write_sg(mgr, sgt); + return -EOPNOTSUPP; +} + /** * fpga_image_info_alloc - Allocate an FPGA image info struct * @dev: owning device @@ -225,7 +233,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, /* Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; if (mgr->mops->write_sg) { - ret = mgr->mops->write_sg(mgr, sgt); + ret = fpga_mgr_write_sg(mgr, sgt); } else { struct sg_mapping_iter miter;