From patchwork Mon Jun 7 17:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304163 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.0 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 1AC81C47082 for ; Mon, 7 Jun 2021 17:26:50 +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 E02726105A for ; Mon, 7 Jun 2021 17:26:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E02726105A 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=MCVi92SULpiV9e3wCTFqoMmEBQYgEyVIFxPbLww7Xqk=; b=yndtuTmF0O7BoR QJlLdzfQyP89E5yQR77P5Lo2ILdlkkpGlb5b7o4+Y12dNzUjA8RDNJ3ExhkIUCsCf/xEUFQSsfSkw tAiryp33Hae5MtWo//erZ1L4QiK0CUaJO7+077C6U3AHMnju6fOflUTG9AKTcOwWXdlanrojxqwNO e1QCVpKfi+XKtTMwma5WOoWsz8zc+XJa4VNNVDr4LVD1flKdVwckqtHxpUfUJFvkTaLSXRjZy+tc7 0hL9ZgQkgovxHuND+WGaIiHUtwIzXrA+JoBREKTYk5gW/H4Unfqh39TGnXZFsGdDOhoIrxfPZzahv BQnkXnzd5z0pasmxLJ3A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzY-004mER-K8; Mon, 07 Jun 2021 17:24:48 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzJ-004m96-5u for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086671; 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=9Kr/vWB+/nwKdeKs8KkDEzQieFV1Y1AcDYKa+Pf56V8=; b=b7xpPuSnbaatdYNPfRFr8WGK5390VSSwdJwoIfVVzYKPAbZW3UzLyK/z3LeKTSM75WqMez 2lXFafO6TbZXdnHpnN2PiBvwiDrD2PCY4neGf6bOQDGkBhFY3FkG3ZcN8w+cITK1QvpzHL aRbSlbfnWYYHCAChYlKwotm2F2cJaq4= 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-500-fzoATg3CMKqC2clU0kZURQ-1; Mon, 07 Jun 2021 13:24:30 -0400 X-MC-Unique: fzoATg3CMKqC2clU0kZURQ-1 Received: by mail-ot1-f69.google.com with SMTP id 59-20020a9d0dc10000b02902a57e382ca1so12029724ots.7 for ; Mon, 07 Jun 2021 10:24:30 -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=9Kr/vWB+/nwKdeKs8KkDEzQieFV1Y1AcDYKa+Pf56V8=; b=ltCYqam51AtN7dUgkc+COaAV7jOwsGlEmbxJdzKoi8NMDp5hDUrj95huGs+2qJ4tOJ qukj4iGgirSHPcGkIuG0ECFq9dZ9e+23ZVR9de7IyuMwEt+lTmpEYVizPXG2tDPIsdSl +Sk+KVPMPbG+CfSh54nCREV4c3OokGhi4V+4sceFLuX1IVCm/7z0R4t5cCYW2qBGPrS5 1wLWzl9fu13elYDqVJPwemkD1hedi+BnOSi5QYNl85VNbGr6drxfDWhmpP6OAqF2JGgS eoQuE0k4XgfnMoDC4XveqRCLEN/focCTinQa2xpV65A49Hd9MmUDBvb5XQnMjMMYDRrU PEvQ== X-Gm-Message-State: AOAM533r13vqHvlZhCukgaXHbeH1ibyvkB2xyAspe+5N29S2ZBHXCEmZ NQxsfiDm58TW7WuX+DWAM+FAxvPVVAGT7UhVzv5eo35eJve8cJ40IhHnboVws/aYkI1EmTcJEsc GpJ2QBl0VTA6mXjPoINnlzXixz1aM5MM7laA= X-Received: by 2002:a05:6830:208c:: with SMTP id y12mr14976940otq.129.1623086669451; Mon, 07 Jun 2021 10:24:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx+lDqZrglifUpJyQXQIS8VUnzoYQx644bk2oknGt1yXO+O7Fiz78iL3xYwnV4DBj9rU5fJQ== X-Received: by 2002:a05:6830:208c:: with SMTP id y12mr14976930otq.129.1623086669317; Mon, 07 Jun 2021 10:24:29 -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 15sm2409859oij.26.2021.06.07.10.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:29 -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 1/7] fpga: wrap the write_init() op Date: Mon, 7 Jun 2021 10:23:56 -0700 Message-Id: <20210607172402.2938697-2-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102433_323600_A9CC45F9 X-CRM114-Status: GOOD ( 15.40 ) 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 The board 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b85bc47c91a9..24547e36a56d 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -69,6 +69,14 @@ void fpga_image_info_free(struct fpga_image_info *info) } EXPORT_SYMBOL_GPL(fpga_image_info_free); +static int fpga_mgr_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} /* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is ready to @@ -83,9 +91,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 +577,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, 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(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; From patchwork Mon Jun 7 17:23:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304165 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.0 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 65E49C47094 for ; Mon, 7 Jun 2021 17:26: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 311D96105A for ; Mon, 7 Jun 2021 17:26:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 311D96105A 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=ZCVZYaSwPC0OWAqYO5FjOkRc9ESZ/sg1JKumW7lhxoU=; b=DohbxWgpjOT7oI v4LXFc0F2kPOtcjPE5GminHWQUAXoEyoXrox3JtryeXtCYDBOBJaw4u6Vmox4hPIwZ/sAIGy1YPnf o5Dl9j5H0u5gWpWfOwEfJHPZorUD2NNaMVb4yHDR01UCwBBceVsa5yd7ROL8z/AlKCHNiV1xKivVx 6hDLNb+46j2Nk/DbuSocAQbWnnjzsn1qEln7g10eCHgXisd+CtyxEiURNETrFy4T4xZ5aN/Era8ih TwyAkSrEsYIz90cFupDcR5XiaAlg6aohS3ru8NBCjYFQfm1Pwx6Y7kuQOQmaV8OWUD+A2SmbFZvFZ mQwbCuITSmMrg7b3S1uA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzl-004mH2-1d; Mon, 07 Jun 2021 17:25:01 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzJ-004m9I-CQ for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086672; 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=5POgGzXgN4h++cWuVkMb7E0DYWkWN/zT+5ctpxHYXH4=; b=SOLWVH20QTRSkTLKbeiTZ1yLXk3ysONQShtQjUS4B5qYpZBZGIVZ9GRcHlmM6zAYMEmaNz Mwi1p6i8sLPwX8xJhFZrK5D+aD81oOjiOEVRY/ef6xl8hkUY+gJ1fhLvcqBBxS+hOIaRFQ ZMCmm4OVUbtEj+BB7o23aC2g6YVj+wQ= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-LnrgRuQ2MaSqUOZXqn3_5w-1; Mon, 07 Jun 2021 13:24:31 -0400 X-MC-Unique: LnrgRuQ2MaSqUOZXqn3_5w-1 Received: by mail-oo1-f72.google.com with SMTP id l13-20020a4aa78d0000b0290245c8f11ac2so11481515oom.11 for ; Mon, 07 Jun 2021 10:24:31 -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=5POgGzXgN4h++cWuVkMb7E0DYWkWN/zT+5ctpxHYXH4=; b=m3JhNlcF8AYLzISDzd+qBz3eH4JfdVsbUnFmVH+UkDZnpdjT3La5nh4NHtIMd1vIbY ziQnPjQs8FOzBIdoJ8dN0gDfberxpHaT4p/nWCr38p4Kvpf0IGYr/m4vSBtt9rYItCo4 JnVFht6GVhKoETX6jhe7JoDDgNpWBDlrJ6DTh6np/LDtfV5hw31ne/8rxkR7cCBqkBt7 1LnZKJuo0xGej/b4K6rygZM30Ssqm6P5cOnlOLyDdjDMPe6coczY6vIAmXMu1vQQ2no7 a2FCJIk58ew7UzfN4X9VH90+m2tgmbk/w8kMInwtWq2bDjoRauTadCxbmNAjIiOTMMco fQBw== X-Gm-Message-State: AOAM532KyBQalvBAOHQvtQa2MpsFp8qu09AyOAqbs7tevG7ibfXrwsuP UrbsuGajN2QwMspeyiRsbRZrU+7FdYtAjL5GPhZpxKpAsjjzQAfnQUpHbNu3rtZ0GrzIOpfCDhy 2xYxh/L/TXFNvZ1QpuUyOIgfFO+XFZtggXMM= X-Received: by 2002:aca:4d3:: with SMTP id 202mr206172oie.9.1623086670702; Mon, 07 Jun 2021 10:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyErLrAs2nKUGQD+6vZuLJsm5Ds5EU5sJZCfJ1o9Ju4lJGFyG6X2XnaYzYSzpxZbczqt8XM1A== X-Received: by 2002:aca:4d3:: with SMTP id 202mr206164oie.9.1623086670568; Mon, 07 Jun 2021 10:24:30 -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 15sm2409859oij.26.2021.06.07.10.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:30 -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 2/7] fpga: make write_complete() op optional Date: Mon, 7 Jun 2021 10:23:57 -0700 Message-Id: <20210607172402.2938697-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102433_520793_7237DC81 X-CRM114-Status: GOOD ( 14.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 The board 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 | 7 ++++--- drivers/fpga/zynqmp-fpga.c | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 24547e36a56d..dadad2401502 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -152,10 +152,11 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, static int fpga_mgr_write_complete(struct fpga_manager *mgr, struct fpga_image_info *info) { - int ret; + int ret = 0; mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - ret = mgr->mops->write_complete(mgr, info); + if (mgr->mops && 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; @@ -576,7 +577,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, 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(dev, "Attempt to register without fpga_manager_ops\n"); diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index 125743c9797f..9efbd70aa686 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 Mon Jun 7 17:23:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304167 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.0 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 5DE61C47082 for ; Mon, 7 Jun 2021 17:27:14 +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 3036A6108D for ; Mon, 7 Jun 2021 17:27:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3036A6108D 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=kRKzftjKiT825TDHtyc6qQinxcZuzhoeDCYuN8kOT50=; b=L+B1XtVOFxgbSH 23Xmck3dtwtqUGxuqxAIxjzvC5EGiMe3ZK/b7Xvp2/7VDFWEOjO9GVaJtJGg7B0hKOjvibylN17Wy L6XZAKirFRJXUB2z3AYlLw6L6E1VYX3NHH4ZCYwRrN7rdUJdauRA4tbr1gbtKQJayy5U+RRNQDUlq QvfVOtMD1Zvh+Pr2wyyLsaTULfyykENU3fKabwVozblTElCNkXVw5RZutDsHrzNNJbwFo/XMnh1hB DLueThKZo2GP/K2zdB/lZyXMwbJeLhYmfsQcWGwLbyPegqFfEh0s/LuHgh7Bw/OSJaxDBJsKYFJeJ TNv9OY1RjpmfwwjPiePQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzy-004mJq-Ct; Mon, 07 Jun 2021 17:25:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzK-004mAB-DY for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086673; 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=SEbyFeW80QMIpdYKjW+aZzDgMZUI77VaMOflkO8h6rs=; b=jRLQYTyzxobljzGt04Zl/L8JCBhGPM03ngsihuIpWrNUx+T0bQ54uehArh8KJp5R1VvDx+ rDcPNsXtOhF2m8a5QXl8nO2ZmAFuHz+PxcR6Y2eCYL+xJuM2hNWjC7rZTUhQkpkqlPgocR 7R8RGsX6ArmP8gxwmXSk8N92ua+8xMc= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-68-mHhsOCbmNSer9oLCnHEbFw-1; Mon, 07 Jun 2021 13:24:32 -0400 X-MC-Unique: mHhsOCbmNSer9oLCnHEbFw-1 Received: by mail-oo1-f72.google.com with SMTP id o21-20020a4ae5950000b0290211a73e7f50so11465493oov.12 for ; Mon, 07 Jun 2021 10:24:32 -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=SEbyFeW80QMIpdYKjW+aZzDgMZUI77VaMOflkO8h6rs=; b=bq2UopldRg4NqCUhbOcygyVykWyScSDS/YMSQYgXmP4HF7SJ/dYCYap7lyYz1sJ7/i VK9n7PDe8PB98JHuxDF3F2HXl3L7VRSY7Ak3C7OccGqL6/OLrPIFC4ksQdXopbH3E5lj ysZT62aOjlpP6Tk5qTHWh0PduRz9rt9QDWPposMZ2x3PJHy+abtVxv3Tsp00ba5I2hKJ UGYoDd3ytbFgFKF9eb/HUrWyEaHQbxDAyHX1DIrgpWIz0r/tMhGJX5/VdN0RokPOttl/ c7MCi/YLSbnVLfudU+F+phYaVULZMy92pCjvIEhjitV+apRkVHZgxnAIHgM3Nff503Mj Ev7g== X-Gm-Message-State: AOAM532xLzEK64AH1tR+1U9Yi8WEi14De7UAFs0+ioPumEO9LVz7LXvc XJHjQsxtwtJ3Cf7jzTzlxSJJA27Ymz8daL3ccamjfE0iBnfplDR8CjUxonxoU4OzR+EW/k4UiO4 jVmoj94/P1XTNLHg1FKRr1kHGnk7lQutk+6Y= X-Received: by 2002:a4a:952b:: with SMTP id m40mr14054021ooi.69.1623086672035; Mon, 07 Jun 2021 10:24:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU4iBtCJ074OuzGQTVAEsS9VugipnW5FrZyj5UcXmgr+HN+HU4/UgZKKLwOvSNn74uqAKqVw== X-Received: by 2002:a4a:952b:: with SMTP id m40mr14054006ooi.69.1623086671810; Mon, 07 Jun 2021 10:24:31 -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 15sm2409859oij.26.2021.06.07.10.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:31 -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 3/7] fpga: wrap the write() op Date: Mon, 7 Jun 2021 10:23:58 -0700 Message-Id: <20210607172402.2938697-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102434_563060_62582795 X-CRM114-Status: GOOD ( 14.30 ) 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 The board 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 dadad2401502..c484b4309b2f 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -167,6 +167,13 @@ static int fpga_mgr_write_complete(struct fpga_manager *mgr, return 0; } +static int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write) + return mgr->mops->write(mgr, buf, count); + return -EOPNOTSUPP; +} + /** * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list * @mgr: fpga manager @@ -203,7 +210,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; } @@ -233,7 +240,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; @@ -577,9 +584,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, 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(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; } From patchwork Mon Jun 7 17:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304199 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.0 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 28508C47082 for ; Mon, 7 Jun 2021 17:27:29 +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 E59C36108C for ; Mon, 7 Jun 2021 17:27:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E59C36108C 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=im50gtx20W91eRohskaSUSuZxiQkKgsa+t0I2oYMYCY=; b=Q4VGAdQMZHlzt8 Jd7AJIhdrLBeRG9wz4ZcKb4A9iI/L6j8z+qfCrzRL3QVdPXFwRzVVplY2H5+K5e7v+clcwM59BoYD eFgMPv6o2Y8i8SL0h8ai2zF1iMSDulWMZAn5gU5Sq7+ykd49FgheYXtZWnD3T0+3zxvLsPkNgPpGc WdlbUQRvGGy8kNotEb8BQPLk8GXMrtVNFAnD3IG0hFxpRhPTuSi+ky+wYraByUNVui8e//gX99pIC bS0u2i3OkUIJIButEpMGJ1yxz/n9o8NMd9Y0fvnl0CzOL98eVYLPi46KKqFXYh1FjcNuRUtz8+jrM XwVoWzT5xb5O2PIIQs6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqJ0I-004mQH-26; Mon, 07 Jun 2021 17:25:34 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzL-004mAu-T2 for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086675; 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=sw7849LMLQbMNBNh72cG9DpmFetu7hYYk7CqmCZ+A8c=; b=IXYTaGR2y5o2laISOmCoQ179C/Mk4m0U+UN4UuC9D7hR9RDHv/mo+1p4ryP8vcacxeH67L Zt3hWsZfMXd5+Eqzi7jvq60IU70BePlKq3Iib18BIexDUogUyCuy0gjHYt6kU49Q+FbhJw 0QngK9b8MDQXlfX2h23O2ynVn4yLH6Y= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-diY4YoyPOdGMvTm3PTuTYA-1; Mon, 07 Jun 2021 13:24:33 -0400 X-MC-Unique: diY4YoyPOdGMvTm3PTuTYA-1 Received: by mail-ot1-f72.google.com with SMTP id k7-20020a9d4b870000b02902a5bfbbbd3bso11977292otf.18 for ; Mon, 07 Jun 2021 10:24:33 -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=sw7849LMLQbMNBNh72cG9DpmFetu7hYYk7CqmCZ+A8c=; b=tg5M204Tn42auroT2klPbSWDPswxFCfhoMU3n9jdQhvtuU0Wv35pu/pMU0AapgOGce rrYKge4QTxOC/2/HXODYkePC+VowYlzU+LexB3SX7k5hA0LDXM4cLTYTZDrPOLL/HLdN dPM9jQxuAYTdYmdxLfRIt2wwViK1zNDeBk42gT18IGk2y10P+heZRSA6BJLC3l3RW5he wdsI8A5T9gjv1aeuPsxhrA4W1Zrrzf6L1Ysp57NxiAgZLn95eljmPSrnv5Jpzu0DA9RW HYHdaEhBnVUuF5OEpc0/TM9h+PFY6/bB6wF+1j9+rRLY6HPXHNAQyJ576MrBEC/u3iKq 62QA== X-Gm-Message-State: AOAM533tg9DftwYIlkOlf3Uf+Bo/Viw72/OLWm1/JcprQu+/wCFnwrol kPJi7XVAUqoKzuLVhOIWFTezX+lwvaxtnZxM4TQ615Yoh10qNFFswoT4RFdmvlpPMJ/sKnHT/gF t4ukozZ20VZQr/cibEKAwAyUrB9I2X81PRLo= X-Received: by 2002:a9d:249:: with SMTP id 67mr14552436otb.356.1623086673292; Mon, 07 Jun 2021 10:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaxynMSyVdOH834Xr+aDUn5sjwj9lSK2uSYH4p7kRGsbU3UK3AsLkYepvXRVkAP7p0oedWLA== X-Received: by 2002:a9d:249:: with SMTP id 67mr14552418otb.356.1623086673160; Mon, 07 Jun 2021 10:24:33 -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 15sm2409859oij.26.2021.06.07.10.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:32 -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 4/7] fpga: wrap the status() op Date: Mon, 7 Jun 2021 10:23:59 -0700 Message-Id: <20210607172402.2938697-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102436_055677_D779CFCF X-CRM114-Status: GOOD ( 12.65 ) 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 The board 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c484b4309b2f..cc531f0537ac 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -426,6 +426,14 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } +static u64 fpga_mgr_status(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->status) + return mgr->mops->status(mgr); + + return 0; +} + static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -433,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 Mon Jun 7 17:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304203 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.0 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 57C66C47082 for ; Mon, 7 Jun 2021 17:28: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 2CB2561090 for ; Mon, 7 Jun 2021 17:28:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2CB2561090 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=d33H2vX3K/8MHTrl2btMlv28P4MZyMXlXK7l0taXjeQ=; b=clxToRPvSKRaiU cXh4iDOk5ixuUTbLPN1/5NUNn3b+46Ttf5pNTmpJ0jtPYL9Qe/j3kZ4sXi4PWQtd3eh8bmrW3BwNe vNQ4x0C+gH/J3haC/iu1fEjzkLanwmwkImb11SCuktd0v+DWB1ORAt88aXTCQIH2NbeBsUTHLXp6H KnTTwPqFRtFEqu9gRqHxrz9Buue/AyQ3DiYNCCSzWgDdqHVPV6/tZ5PNHd8vPGyCx1UL4IpD+6pKx 8373NJsIVXsnmSwBisC59SMj7XhE/ni8Xc0gk7+smwaMvOojcHK3UozHFABhMiGNjY2b8OAfKKoNt RzInqgz+wV8E+PM7dU6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqJ1H-004mo6-Dg; Mon, 07 Jun 2021 17:26:36 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzP-004mCG-GQ for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086678; 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=G5k+k/BkzK0E2Fb8ne6IfEyRpjN4V1PdloHP6kDhHkg=; b=X2Ihuzg1mXEJQ6Svla4JcBckm6WCjBHhAC6Cbh0H5Tr28mx5OcDNOTClF7zV/NGeN1T0Uf J9BMvwnbcIsOP/KoA0L0X/fKvP2gBaO4z9XYyWmO84zi5xtHmQI1nKJA2WaRaZc56nYhYi NCQ77+UPsg/DShzD0qS33Xr8xwG9n0g= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-434-Cr-Ks3UiNIm_iT98pZ2aEg-1; Mon, 07 Jun 2021 13:24:35 -0400 X-MC-Unique: Cr-Ks3UiNIm_iT98pZ2aEg-1 Received: by mail-ot1-f72.google.com with SMTP id z18-20020a0568301292b02902dc88381e4dso12043115otp.1 for ; Mon, 07 Jun 2021 10:24:35 -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=G5k+k/BkzK0E2Fb8ne6IfEyRpjN4V1PdloHP6kDhHkg=; b=fjy0rxt3D3qUcwrDVLzCmrk2jBv8DcZiXUdL58WSlrEjHXvKkEvv6i/xsSwUj0sIbH Nj7WGnb4tos0tPfbwR1gmjQVQGxzEE3HDNPJPLjvAGQ0RkAiGqOgmpIOGJibnRigG5HP wNlRTSZRY38Lx2uP7GYNZG9L0edvRVmCWosFt1Yq6P9HM4dkOG9ZIiOPRjz/B3W+PA5f JMiKa+87Ftr/th1Zl1MwnlAh1bnHiTxoK/7Kd03BNh6zBO1m0ShuTCznBCPo8QhXuyhH aQtbsR0RujEonbXUDWrF+SEbdYruPFiZ9nR1rUX2re9wBUYnORZ4OpvucvHJNqIWnNtE kCXw== X-Gm-Message-State: AOAM5336Fu9m5LNkCyirFReJaXNmi7MZJqpf06ETyUNjB77vQkLAm6wF 7pY5/zoM28PxCDRqBySCeE34alBbgQOobVquK7sYQLq8bYnBY5FsOV5WWZ1MZHobpMcyP12uYhR 21seETP/PGL2lM2nmkkKz/nH6v4AMD1T0uUw= X-Received: by 2002:a9d:29:: with SMTP id 38mr14916720ota.30.1623086674616; Mon, 07 Jun 2021 10:24:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdkpS0Guz//cpGeFC9kznpgrVRbhlD0K8fyi/LgsZtWiEH9dfWzy9fSlnLDe0GSy4E+y4ipQ== X-Received: by 2002:a9d:29:: with SMTP id 38mr14916708ota.30.1623086674460; Mon, 07 Jun 2021 10:24:34 -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 15sm2409859oij.26.2021.06.07.10.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:34 -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 5/7] fpga: wrap the state() op Date: Mon, 7 Jun 2021 10:24:00 -0700 Message-Id: <20210607172402.2938697-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102439_662800_555D97D4 X-CRM114-Status: GOOD ( 14.79 ) 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 The board 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() uses. 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 d5861d13b306..313420405d5e 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 cc531f0537ac..d06752be9c6e 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -589,7 +589,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state) { + if (!mops) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; } @@ -692,6 +692,13 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(devm_fpga_mgr_create); +static enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->state) + return mgr->mops->state(mgr); + return FPGA_MGR_STATE_UNKNOWN; +} + /** * fpga_mgr_register - register a FPGA manager * @mgr: fpga manager struct @@ -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 657a70c5fc99..5219fa1b555a 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 101f016c6ed8..167abb0b08d4 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 Mon Jun 7 17:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304201 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.0 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 DB097C47094 for ; Mon, 7 Jun 2021 17:27:56 +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 A6BF161090 for ; Mon, 7 Jun 2021 17:27:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6BF161090 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=8FXd9KdNQ1wML5c9l9YMOoFrmDa//cunzuFMLy9rC90=; b=T2Ev4QRQc3ng/x CMGEmsIA7kPwdGvZroJN9n2x1drb4mMLDUuiclqgNTizG10rsRN45hzBkyxcvevtpwuRkJVY7wqRM 9I7skXso/RKJyex08JmwPmkqmWhdmEv26rzjpdnvhreRg0nZl1SMC/teMOUZQG++oxWNraA/DipGR hVW0U02p5W9qWn9U+L/PinByshD7knb0tJgIf0m/AFiHe0p4CjGClbncywJYOHFxqDEUyk3WxMEQq hCtZYhkEbQWdNmoYCLGEvJ8I48Ju0Vyw45nLMdefaUOrqsNX7T3wq7vmJ9rlZTJ3q5DACtDkgEX5c veuhzSW0foGyTTXD1avQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqJ0d-004mZJ-Cw; Mon, 07 Jun 2021 17:25:55 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzO-004mBq-CR for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086677; 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=laSi6Idv6MJlRydvvlMqTdjYXdoIYW3EUNa0fNYB5JY=; b=KgAQ18yALYDPBowT4sAyDuvfXNqTkFTTKvsjUmIX3fi6fYcy9ytwUyz92QNN7ZuHbumV5l xsoZjzv4PFVG8iJ2naB/JNK2l4S5tFvX8A1TYeMWVpp8vSLhDULXl3qaPLL60FyJl0gCAH YUeezCElQyMalrw+WM1d8FBZainQRxk= 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-534--vzuHpUCPPap0pbzsvunMQ-1; Mon, 07 Jun 2021 13:24:36 -0400 X-MC-Unique: -vzuHpUCPPap0pbzsvunMQ-1 Received: by mail-oi1-f197.google.com with SMTP id 82-20020aca04550000b02901f40670cf75so1991519oie.19 for ; Mon, 07 Jun 2021 10:24:36 -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=laSi6Idv6MJlRydvvlMqTdjYXdoIYW3EUNa0fNYB5JY=; b=pP8lgkLmsoBnxTvSL3Eo5NvIS//E5cnm2E4mLefzAi/8oqKp1hU59Tkm3Hg9S4TIfp odkmRKLQL6PId4xFDEmEx7vFbdP0luXLHo2xRZucChx5nyy3VS/Ioq7hP7VLoWM/7A2c m7BqR0GndojzcB/ytPQXg+YjWuF9ZTWMxNIBYBbklq/tEVC7WH54CyfpCn7PsWokuHvq NQCiGbm4HORetIEUTCPGNitTI4f6pBhH5zl+bvgS2mW5ggH1qPg0+1RAugH16aa8S8ne M5ngzWhecNFTzjbOJugCi0lY6yfGRrI5J4XWAXNg8VctWwurT+oPzsX9JOkeqfQxxGXO KG/A== X-Gm-Message-State: AOAM530Od0JlDZ/3SFFcss/8RLgKrHTzXjvGlNTyQrYouzuDGNd6ARcC YTAFd2jt2O/eqehanK7pF8gjlpVjM9xOQzs+eg0Pvn/mLF2Ha7DZOmddSyk0y7al45haSBlm/Jg VLP2apfFpKBCIDhClTdgvOit17BeWtI5f8Lc= X-Received: by 2002:a9d:289:: with SMTP id 9mr14127915otl.10.1623086675884; Mon, 07 Jun 2021 10:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0Mxu9OWeXq29nlPkEMpqQQx4J506+qxFfVHTsHRyJukzcKWG9aLTPxri3PNB8lw79Q0A/dw== X-Received: by 2002:a9d:289:: with SMTP id 9mr14127899otl.10.1623086675698; Mon, 07 Jun 2021 10:24:35 -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 15sm2409859oij.26.2021.06.07.10.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:35 -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 6/7] fpga: wrap the fpga_remove() op Date: Mon, 7 Jun 2021 10:24:01 -0700 Message-Id: <20210607172402.2938697-7-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102438_535502_CDB4D087 X-CRM114-Status: GOOD ( 11.79 ) 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 The board 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 d06752be9c6e..84808c7ca440 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -731,6 +731,12 @@ int fpga_mgr_register(struct fpga_manager *mgr) } EXPORT_SYMBOL_GPL(fpga_mgr_register); +static void fpga_mgr_fpga_remove(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->fpga_remove) + mgr->mops->fpga_remove(mgr); +} + /** * fpga_mgr_unregister - unregister a FPGA manager * @mgr: fpga manager struct @@ -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 Mon Jun 7 17:24:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304205 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.0 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 4D47DC47094 for ; Mon, 7 Jun 2021 17:29:22 +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 14C6D61090 for ; Mon, 7 Jun 2021 17:29:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 14C6D61090 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=OelnNZFL65CjbqeaWh8lYLxlvBjG0JDEmnX97lJ8XrU=; b=yGeTxjQHbotZE6 K7nZyerccVSiFZsVJRBgse7eaiEQxpDEoDSvhfUP1VH5Yakx4K86AlQLlUzxn+4lqScqI2EfOzDge M/WbZIE4XrRNVs5MDtNY8ETmm7SJ7TFHDPAtdYG4A1BswSVFGc0RNswfwuMxZSmXlfctIFx64+NJC 3goWmuD1VjhtYVsTp6Vd5vS1yQwCCNAlkjqg44nMFkAD9rUbk9o0YP9WMUC3jMZ5/ViIk4mMiiyoK EGgMpgxgS/QUI9ODgA24XYKf8ISE9e8vrW6caQamwg+glclRPgYMg1IFI2QLYOmLB99s8H4bd+4Ed cp87cEHqf6hcv3kTFFBQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqJ26-004nCe-A9; Mon, 07 Jun 2021 17:27:28 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqIzP-004mCH-NK for linux-arm-kernel@lists.infradead.org; Mon, 07 Jun 2021 17:24:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086678; 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=tiUiVni7HRdj/fMNccMqDWFIL2bqdt7yewe5StEQKT4=; b=HJuvPJfGMgH+6sh+y2oJ+u6jzsNgRWI6cPsVxSXrkwoxxHKV1Czlo1EkgO5XRirl7Ss9L4 A7YBjXAG61LdFQyvxv9g3a8Vawz24BAkS9iBgP9HODKkLXNw4Tm4FtXczdsbIhotH7+FNq agZBfaP6yBZE/DQ4BS9fSJDzw7cqwJs= Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-m5URMxcnO0C38m-UyqM3vw-1; Mon, 07 Jun 2021 13:24:37 -0400 X-MC-Unique: m5URMxcnO0C38m-UyqM3vw-1 Received: by mail-ot1-f71.google.com with SMTP id w1-20020a0568304101b02902fc17224cf5so12035390ott.3 for ; Mon, 07 Jun 2021 10:24:37 -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=tiUiVni7HRdj/fMNccMqDWFIL2bqdt7yewe5StEQKT4=; b=CPHn1yQJsoS/ZWJRK4WndByWpoJlPTKniQRrgtdf0IM79xN/ao+4p3IP+Qv5kWlJ8Z cfdw1sj0AZsF8BzYmfwbqalJ+7wvseVLobZ8wM0U+W8dMMxYbox3Me9TffM5a65fq0nZ 2nxwc/7mOZkK21csHB6pw2D2ikRL3JYblDaKcG0H+/pl7p1tu1aqZBv0V1MMIFrIfuyr 6xPcTXrds7VW7gbS35BEdUOVgWTU6glbWWxl5RNz5ED5N3qtif3y2p5g8NnO8Iy4J+cp hKcx3kxqbK1N+khlwkAv28aCiIH3SI0oD6JhXpnf1Wb5GYvb7RihiKkx+rZaWJT1ycD0 ghbA== X-Gm-Message-State: AOAM532+29xYdMwQiuJreHHyQh6pRYeMGeLBiPvN/Jx2Oxj2nw2RBr46 oNzxwLf5Por5CLhtL+k0coiExxloUZfPkiQ4RJFwb4sb79Viq31Q1aw5nbvVCy4BH9qG88RHZcC P8NYh0uLeakNRoiHv0k4WVMorzlZkK/fzKjE= X-Received: by 2002:a05:6808:985:: with SMTP id a5mr156771oic.42.1623086677108; Mon, 07 Jun 2021 10:24:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX3CF8WfnS+aeD9xD/trkVT+VJIk8ws9Dd+CpNLkE8C8DuDcq2UDWOfKRoaNzbTM3tQfIkeg== X-Received: by 2002:a05:6808:985:: with SMTP id a5mr156764oic.42.1623086676962; Mon, 07 Jun 2021 10:24:36 -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 15sm2409859oij.26.2021.06.07.10.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:36 -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 7/7] fpga: collect wrappers and change to inline Date: Mon, 7 Jun 2021 10:24:02 -0700 Message-Id: <20210607172402.2938697-8-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-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-20210607_102439_932167_157E15B4 X-CRM114-Status: GOOD ( 17.91 ) 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 Anyone searching for the wrappers should find all of them together, so move the wrappers. Since they are all small functions, make them inline. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 117 ++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 84808c7ca440..198a44a62058 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,65 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +/* mops wrappers */ +static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops && 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 && mgr->mops->status) + return mgr->mops->status(mgr); + return 0; +} + +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 && mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} + +static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +{ + if (mgr->mops && 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. + */ +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 && 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 void fpga_mgr_fpga_remove(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->fpga_remove) + mgr->mops->fpga_remove(mgr); +} + /** * fpga_image_info_alloc - Allocate a FPGA image info struct * @dev: owning device @@ -69,14 +128,6 @@ void fpga_image_info_free(struct fpga_image_info *info) } EXPORT_SYMBOL_GPL(fpga_image_info_free); -static int fpga_mgr_write_init(struct fpga_manager *mgr, - struct fpga_image_info *info, - const char *buf, size_t count) -{ - if (mgr->mops && mgr->mops->write_init) - return mgr->mops->write_init(mgr, info, buf, count); - return 0; -} /* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is ready to @@ -145,35 +196,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 = 0; - - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - if (mgr->mops && 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 int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) -{ - if (mgr->mops && mgr->mops->write) - return mgr->mops->write(mgr, buf, count); - return -EOPNOTSUPP; -} - /** * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list * @mgr: fpga manager @@ -426,14 +448,6 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } -static u64 fpga_mgr_status(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->status) - return mgr->mops->status(mgr); - - return 0; -} - static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -692,13 +706,6 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(devm_fpga_mgr_create); -static enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->state) - return mgr->mops->state(mgr); - return FPGA_MGR_STATE_UNKNOWN; -} - /** * fpga_mgr_register - register a FPGA manager * @mgr: fpga manager struct @@ -731,12 +738,6 @@ int fpga_mgr_register(struct fpga_manager *mgr) } EXPORT_SYMBOL_GPL(fpga_mgr_register); -static void fpga_mgr_fpga_remove(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->fpga_remove) - mgr->mops->fpga_remove(mgr); -} - /** * fpga_mgr_unregister - unregister a FPGA manager * @mgr: fpga manager struct