From patchwork Wed Jun 23 18:24:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340309 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 B43C6C48BC2 for ; Wed, 23 Jun 2021 18:27: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 82BC7610F7 for ; Wed, 23 Jun 2021 18:27:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82BC7610F7 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=3GKbemxSOQC1Y3Yk5uLQqXeC1ceC9Ms+F+hWvDhHhAo=; b=e3pzmxY0Dmx4Bo WiB+BPeDULwH9e6/02O6g4dFeaK1CBCGz5gBZN9vbJzteHm6QfcNKn5GPYFC1bw9zqk5S/2t5q+Ic kmjcXk7zQXAuSKuEb6nH/EaYPwJDtyEgh8NyuKJFfLDfFRtN8zQbA6r1A+QxJCGuHKIuv3tpTNJ2F mGtB+3VZocVmMrWdHz+W8tASE16hJTkipi9/PbwLC9SKUI7b2IrrNfJnCRBr3lo5kAsfYFGqvZ4lt fJCV76fX0VmM8a0UNUcMB5CHLR9EJAKVESmYKQj0Q3cjSzGLJ3L0EL6/O4WDnrOZbMPQDfqjyo69p vQcas/1NNqyxN62oa6VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7YD-00BcBb-Rr; Wed, 23 Jun 2021 18:24:38 +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 1lw7Y5-00Bc9o-BT for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472668; 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=Htp54BK0JGPxX8hRg4+dCEnU8CurZfr6H6uRpE1E1JA=; b=g7sSqpuLZmm90Xjm+OHcjhjcVgDlvM9RlGlTak8l1vlKjAbwawWX+rSHg6NwuYUFCZsnUp kiXA4Z29R3wwzLae+tvlY1OGIydyHPMwUEJWG6V8YnnVT4dAd7ckPHgMRJ5r6ShJNzSbDl 7/T9TxCYQQir5yU6jyr1ZPNdChVFcsY= 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-239-A1Z1kB8aP_-30yOiURSLKw-1; Wed, 23 Jun 2021 14:24:26 -0400 X-MC-Unique: A1Z1kB8aP_-30yOiURSLKw-1 Received: by mail-oi1-f199.google.com with SMTP id a29-20020a544e1d0000b02901eef9e4a58cso2257042oiy.3 for ; Wed, 23 Jun 2021 11:24:26 -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=Htp54BK0JGPxX8hRg4+dCEnU8CurZfr6H6uRpE1E1JA=; b=L9yvhK5OZ+jhCw8ZqE2W2cXtOMTSV2ugEuw/IUEzMNozK7l2B43L9cjdG/9Onpa+n8 /sXxzuxRVYV1GRqd+ApyKVhuL4hSiy4mcWAjc3OgCyjLCrbdBhXPujpXb/iv/xot6Q3d quHaMHZyHepVjgxjE+rZwm2wM++pFC8zmtAj19Uw0yIHwlCl60lkWeQcD9yvhKiNAce7 s4RvUQPeb/3N7jYwjUvxY+oytBFYotG2Z81XtINGmziq30LCyHzFNBO63yFrizP9Si1l ZYat/LOV+Abt7WqWyl7n3C2AfmZsLKACgu/obNz7IPRg1CzaQqGE6mbkamKst+5HDLy2 5w8A== X-Gm-Message-State: AOAM531AF3M7wVbYGM+CERKlMlB4hvjT9Jp0FsVTa0p+qBcBwgIU00Zm zjp9mNtaoey0dUhuK96FlwxF3cRmZ6Ez0OpjBPM4rplMd6IZrJnzLBZVBBr8haN8xMVhRub7Ow2 0n6Q0l9Ep6PdvKmhsnqgfD4hqp6cVr7ooLAQ= X-Received: by 2002:a9d:4006:: with SMTP id m6mr1091547ote.130.1624472666218; Wed, 23 Jun 2021 11:24:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxF6Hb/fcM8IvALNCl6D5hK6kIQQYZrMClGzUljQpEiNs53aD0YD3Vsj5TzZ9p5+6KcUhipMQ== X-Received: by 2002:a9d:4006:: with SMTP id m6mr1091530ote.130.1624472666056; Wed, 23 Jun 2021 11:24:26 -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 l24sm105186oii.45.2021.06.23.11.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:25 -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 v3 1/7] fpga-mgr: wrap the write_init() op Date: Wed, 23 Jun 2021 11:24:04 -0700 Message-Id: <20210623182410.3787784-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112429_528954_4093D734 X-CRM114-Status: GOOD ( 14.85 ) 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 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index ecb4c3c795fa5..87bbb940c9504 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 *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 Wed Jun 23 18:24:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340311 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 8CC9DC4743C for ; Wed, 23 Jun 2021 18: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 58B2661164 for ; Wed, 23 Jun 2021 18:27:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58B2661164 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=e73Dp11z6NlJaL+U4kmzAP9CB3hTYkiktK7BVwz7EK0=; b=gYLIfBCDEuos6p gsHtLj614PQzle8i2t40TJnYz9gXx7AjMlUFkPihDuR135R84VLFQKyuCGw+CWBS8h1Hm2rRqW6i1 dNCfJ8wf8rnl2N92uB+8/7g/a38aoKOKzFLFZ8z2H1BDPhfRqBbbPfGDXKeSIGZrGF5Oyyoo9lkVr iVQyUGsgu2g1d7zIy0R3yzpqOKXf8GJF3bEIkhlFatB8nP9YBtyi/zlgWn4shIAckk/z5TYtIfLy/ 4ftEkK5hxtf/QfCPJ/Nv5W/8jD7yDs2TL64A68zlxoP333h9904dmni0p0PwrhF/Hz5DcggJEerAt uqfUpIbYfy9roZobXlGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7YR-00BcG8-91; Wed, 23 Jun 2021 18:24:51 +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 1lw7Y9-00BcAf-VJ for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472673; 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=5PxTldx17CDNKsCv+3pIoboW0CCoBJIoZzyWzxD7ju4=; b=ZFBhXVkNpgRjogI68Z7NDje52Aet8+ALYf+8RARgT6xwu3TIb+eYfHvvlkhmAOIgSwZkhU sQH9t/4kVTtwaCIlM2SkRYKqLgtHJMCjRh+ThE3yjXbot0+q7PWhJK6ybhiBqMRTPepELe 8Cupejh1GNnZz4CvP1+XZlYQA3780Zc= 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-122-D0R4Pxm1NXOQjF3UXq_mVA-1; Wed, 23 Jun 2021 14:24:29 -0400 X-MC-Unique: D0R4Pxm1NXOQjF3UXq_mVA-1 Received: by mail-ot1-f72.google.com with SMTP id 59-20020a9d0dc10000b02902a57e382ca1so1818925ots.7 for ; Wed, 23 Jun 2021 11:24:29 -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=5PxTldx17CDNKsCv+3pIoboW0CCoBJIoZzyWzxD7ju4=; b=nijJbB0+EBBJG9dGSOnHLFYZlT9ErmH1v8Fl2oIXACJ71gMhNqrAnwTRncc8GwNegc c92pMIqmG2ANaTJBc7zcS8KOemkK8TQWAhSD6RIVh3/JalZt6QBmVn8DP8/n4j0Vhzyj 4qoWfUmVyIaaWYCs9s9sabCm6DibwFDsiG/nZODgn2WYQSrOgSsyc3kJ1ljhCSqlR0xq 6GUUzP+FXVzvobhW14CyVVWkU+JDC+eetpfoKCcDpgB2KP5RtKEUF5dT2Ss+4d9W9Dfd WLkN9sAgHXzIXz/pzPr4lwrurzuTZqo+OguwVUwEt3O7aKh+IvIVdj2VMjoOj7gWjk/M IKwg== X-Gm-Message-State: AOAM531zbHma4ZQAGf/GZIanzrSQ+HvXoufu2EZZwwgq+0ZzqSlIX9xu dHwZInQkTYwGwwroldhSdjFuVQVb0T08qwPpD9wRE6N8DqzJdXDtvuof53npUma3Az82S3ZxLmv OSBewBQ7tJkrgfvRk4aK/Naz6BkDLYn5eIYU= X-Received: by 2002:a9d:6508:: with SMTP id i8mr1032026otl.368.1624472668642; Wed, 23 Jun 2021 11:24:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCRjF7FYY/2Pj0Mk+PNxI071W5obXDGwdzCI4+olhtl6o/gohgN6WImevV4bHQSOtf0rG6uA== X-Received: by 2002:a9d:6508:: with SMTP id i8mr1032007otl.368.1624472668467; Wed, 23 Jun 2021 11:24:28 -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 l24sm105186oii.45.2021.06.23.11.24.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:28 -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 v3 2/7] fpga-mgr: make write_complete() op optional Date: Wed, 23 Jun 2021 11:24:05 -0700 Message-Id: <20210623182410.3787784-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112434_149987_5229A8B6 X-CRM114-Status: GOOD ( 14.63 ) 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 | 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 87bbb940c9504..1c2cce1320367 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 *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 Wed Jun 23 18:24:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340313 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 D204DC4743C for ; Wed, 23 Jun 2021 18:27: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 9C34561164 for ; Wed, 23 Jun 2021 18:27:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9C34561164 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=gDeuQzdiNFl9Z43Q2ZdYDpocdBBOurFwqep+KvF4kIs=; b=BwGX8JCB0s6ZTe 7H4Dg8/3TZBxATbMpPpAUkQmTm5keiQf9bULPj84w7uQyCQXsSGyN1ziTSpitcv97SvjVEZMTI8ay UuknJ3oIHaxu98TZlf4w0zMp3VajjRd2OttOKRWOFAOaB6njG/ooUfvnFJArlo5EsdOxzE257FRVl yJ3kYTyvXGlK5r8R8i76zpirk5A4MFOmUmIQe/AccdKdiGDTtDJXTWaWvn5pV0WkkkDh/ZRZCqDdM CYOzjdnnmsavBAf4/pG9POUh5TLzvUm7n+2ojTp75R11Fbaz5zPtS+0hpRgvgLYLHjQ5Zc1BFKhJM hnW21cnSwiTV6tNrpyEA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7Yg-00BcKq-Eo; Wed, 23 Jun 2021 18:25:06 +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 1lw7YA-00BcAg-7i for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472673; 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=fEQMbiKZrppCytQ0u2udkzjR7r7bZTZL+PVWVEdpAcU=; b=iYITvT/Kduil0zwAG+k6jVrIHhVE61Pu6L5dOCOH6KzLwCfWLo+lcd4+lsRCs6q5dgw48L Ncvd1t+5dnSsN7k59SXdu5PR5Ok8TxNKTICqV/fU8xPswSGUZD/jEkjKE0GTZvur7IDcJj wDQnbF80+Y9Q70fRhWdB3exPjbGT6h0= 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-525-E_CS6tmZNbOhYqlBE9c6jA-1; Wed, 23 Jun 2021 14:24:31 -0400 X-MC-Unique: E_CS6tmZNbOhYqlBE9c6jA-1 Received: by mail-oi1-f197.google.com with SMTP id f84-20020aca38570000b02901f424a672b7so2223900oia.18 for ; Wed, 23 Jun 2021 11: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=fEQMbiKZrppCytQ0u2udkzjR7r7bZTZL+PVWVEdpAcU=; b=qW2+KauSbVXvdTc8TvYPGzdSyfEy/2aw83TUp/yaLGvUkFei/Yk2E9UHwi7InLLhmR /WMtokMnCPVQSOd/2W3yuccwN3GPSi4p2Wi/f5T5VUhcYO+ATHePxba5sAD9lCkyiLlq O7WAPgbv4rC42pgAdFvaZSpD6vbnbs82R1arr+/gUtJ5qZuRYarJR987XcLG57UGUfs4 bWub4PH7kx071DraXh4mCz9CSDFBLE4XG93myro6igdPFVfEeCxiwv663Vd8mhUnJvkp bBZHCNF76gqILSI/ypq924FYZsIgAMjhNzCz1CJYS59oH/2FZyn3yFWWGbg+gav+VJ12 rirg== X-Gm-Message-State: AOAM531tQRE13cFkmhUGiQhdL5e7sSW1GiKcK3knxDOWS+Kc88qQOQOP 0K7D6YcBb6/TlPg8d5anfTQ9YzTECUb0UAvem+EOUKKorLnJCSLQik0Bz4ogTLVFqw1gI1z3aWp +QvmV0GkwvVHkaKm/WJph5rm18heT0KokxQo= X-Received: by 2002:a05:6830:18c3:: with SMTP id v3mr1088680ote.41.1624472671164; Wed, 23 Jun 2021 11:24:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzofWL0s+9K9OfNcc82SlTa5xfyHlsy/iefBW//+vvA1JA43DNnvVFDylzr6dXYxVOuD53ow== X-Received: by 2002:a05:6830:18c3:: with SMTP id v3mr1088673ote.41.1624472671014; Wed, 23 Jun 2021 11: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 l24sm105186oii.45.2021.06.23.11.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11: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 v3 3/7] fpga-mgr: wrap the write() op Date: Wed, 23 Jun 2021 11:24:06 -0700 Message-Id: <20210623182410.3787784-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112434_416257_15002C29 X-CRM114-Status: GOOD ( 13.86 ) 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 1c2cce1320367..8f97e16e36f7e 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 *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 Wed Jun 23 18:24:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340333 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 2C18FC4743C for ; Wed, 23 Jun 2021 18:27:35 +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 F0EA161166 for ; Wed, 23 Jun 2021 18:27:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0EA161166 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=OmQKAeQN0stTkQPTlxCBzknOAe9cakRzsD75glGqPks=; b=mGYS70YvupL70q 1JJWoGSmEqezN/MUxJJxTw6dpEQgGy2c7/WsHUVjVYw9i015G1TU2lIUWomX/2xSbtKSsHoMNW5Rm FsiFe/oCqAoPuXq/0A35wf2bnh2QIgprtYaQR2An/ksnaNuCBGPd/Hgc2Vk/wGijuYluGMA+7Y4PD T+s+AKXF2fX1mvGLV8JlQbfFBOhUIi8+aeevK2JLl0MktxrXd/Gbck5NGNjeT/CTznFs9D9zWfC2U /kOQqf2xtV3RvU/uZR8Pkl5lUh2C1ICYZwsZGQ1uiU+5QN4nxP0IK+mWOS+uOOiQR/bGg0Leq4s78 GyiFLeFEyp0SvRP26ahQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7Yx-00BcPh-9Z; Wed, 23 Jun 2021 18:25: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 1lw7YD-00BcBi-NY for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:39 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472676; 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=zt+reJW9iH4L44dg7M6KqKyx61iwDVr84RgiCAGE6Po=; b=ajEOy87Y4ZcUD/03EEokPo51QuKwrwnkMxQUUMw9OzxzWj6FAZVIfuhSECNHk4n4Eh8zgl QorAYBT/xX8IOAwfOhMjdxWA8rPBaXXJ1RzEI8651vPnGz0HCAjj0CRRkCUK+RpBf3yeIM mfRQz3hJiNKe6tKuJpVR1iOTeLUGXqM= 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-34-Fct-K1D7PEKzgqxMOprYRw-1; Wed, 23 Jun 2021 14:24:34 -0400 X-MC-Unique: Fct-K1D7PEKzgqxMOprYRw-1 Received: by mail-ot1-f72.google.com with SMTP id e28-20020a9d491c0000b02903daf90867beso1799093otf.11 for ; Wed, 23 Jun 2021 11:24:34 -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=zt+reJW9iH4L44dg7M6KqKyx61iwDVr84RgiCAGE6Po=; b=d6pZwCJkmOovaT/nHmZ7y7rovb/Z0E6hsM/nyTQI8kWjNkED7rcS11vGasUGP8bzdd WuAeNPUhguJRxVynCid8drHa/DwfOfQGQJB/YuqxDVuLOjRJH/30bDzwwBHOgDiO6Jtn XzawlOK5h+V22rUkrFApqL85tFM4Cy03++dRaVry3G+y1AlJudAQK+GnRxBR7hMO8s1w ehJGxGbZvv+UCOcz3fSYuA1zuvDFImrJaGD6fygYkv+K8If8M1skPPnjPvF/E08MDiQH QH3NCuk/r/H3KfuO4KusvsRQ+zzlsnHvcF86Yg5zYKzftH4J4AflVD5Gmd/IjymkUqW3 rMLw== X-Gm-Message-State: AOAM530ot8IgLVYmw4W4KQ8gk/6NxYqrJYEryD/Ew/hPUNMC/hh58QGJ cBf2h9lbNIRHMoZ83cU6ehft31jSs66Kxxcc5T4G1imM7MyJD3ZpdwXHrGYbeo78O/SQe9EDbXf vmIr3kOD/7c8PU1O2wm+HfF/3AkY4H8jSPDU= X-Received: by 2002:a4a:db42:: with SMTP id 2mr924976oot.47.1624472673542; Wed, 23 Jun 2021 11:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyz4UFSl246oaEQqLiNgeEp6ZLXg4v/5NOgNJIyJ0IuAfGDYUCGLmn5W16/1naj3Oifo/u2IQ== X-Received: by 2002:a4a:db42:: with SMTP id 2mr924957oot.47.1624472673390; Wed, 23 Jun 2021 11: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 l24sm105186oii.45.2021.06.23.11.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:33 -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 v3 4/7] fpga-mgr: wrap the status() op Date: Wed, 23 Jun 2021 11:24:07 -0700 Message-Id: <20210623182410.3787784-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112437_889186_97C49CE8 X-CRM114-Status: GOOD ( 12.27 ) 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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 8f97e16e36f7e..6bfc4482abbf4 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 Wed Jun 23 18:24:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340337 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 0E5B1C4743C for ; Wed, 23 Jun 2021 18:28: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 CC75F61166 for ; Wed, 23 Jun 2021 18:28:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC75F61166 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=btM17R8eOtwKw1VILsSaEeO7G6IOaIAcB6ReY5GrS/c=; b=Dp7PCXWfYvAvm7 KCW0XThvVrIiiXiM6srMjtq/dRf50+A7zE1aWghe0lUNBy/LWSkILq3G1WZASo9zdiaNfeArMojg+ Rv/mu+bSMLA/EvhrHTRW4HADluIoU86veLbiLk501CWg1H/UePShnapd8bcMjY7VoCfT3Z8eDeK/9 5pjCValnnTcnl6VYtKvbn5QW4Q0WjGG77OrvS5jnySnpM71/ReNO6/lPxtzK677HihmjG9pzLKXIy Zi6l/PeFmLL1J0VDVo5T74Cob4LzHT2wSbkKHKU+4khlQYNOE0BjF2dQkxbFZgIm4x+/L0Ox4lcAm SfMsRvT9OACe8lB9m/ug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7ZZ-00Bcdo-5x; Wed, 23 Jun 2021 18:26:01 +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 1lw7YL-00BcDq-3M for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472684; 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=nnushO3xnTHoZzlU30ytNGeGLULTAlS7H2DDhaf9BHk=; b=GA466QT2rO4gklgiYe9LkWtEKv/fsLEswFLsj5qLUC0xGZ9M0gOBpIIvTFgBsdZxeW5uD7 6xJCichfSbL7dUIAdDHe5NqX330hRiyzoV6wrZoaKu+Sr137qGdkooAtLYEkHyFHbronCL rupW8+ocedpTB3zPGn0fOOhvsD9wZjQ= 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-189-b8ImFeWIMNuP-ZBgBOItDg-1; Wed, 23 Jun 2021 14:24:37 -0400 X-MC-Unique: b8ImFeWIMNuP-ZBgBOItDg-1 Received: by mail-oi1-f198.google.com with SMTP id y137-20020aca4b8f0000b02901f1fb748c74so2204704oia.21 for ; Wed, 23 Jun 2021 11: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=nnushO3xnTHoZzlU30ytNGeGLULTAlS7H2DDhaf9BHk=; b=MCdI6Upx4vDn0RCMFhx8dt7Ji0HRoTuL6am1nWQW7WTS+eon9zquhze833Sd+zlq6Q ujjQy1yFBchC3xYc/tpAKIssSENHudx0sHvQZgwDEjhQoolV41XqQULZJduy490UR7T+ 1eiuOm65D4TMvwiUFFP0zpGam+Kecuy9Qe+AEZZIiA2pYma4HKWFYqZbXwoDvLHlqcUC Hdl5QNGX33Qc1ouazi7fmGwNhhMi5wHda/6C5AMUhIAIyVsrOQiuqd4wY/PRmSFzNpk3 0XggHsNMjGb61otH/6diUNqfVXsQs84zJLebiZW4fnChvFZbZOmvwAii38ITmrFuDlYJ 6VhQ== X-Gm-Message-State: AOAM531MbN4AbT+ZAe6/k3hAe7aiKiZ+rZJeQ04MTl4o5LKk3moxMmpd Pn/sv66RGCodhlORIEBQZ0CwE1lnZ2MdLE2/g0ED+6L/aM7hXjyXBlTwZKK8pAGvsKxDTlm4FCd BkjtxBnWjr+Ay7v92Pj7XYy3yMiyirZpMRUE= X-Received: by 2002:a9d:4a8a:: with SMTP id i10mr1085012otf.282.1624472676161; Wed, 23 Jun 2021 11:24:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRwK3CQevF5ggD6yIeDOdZ80qiz0j6vxnsGn0oIWl17p/tCiW1qUTO4zyKA8PqRdv8zMXuLg== X-Received: by 2002:a9d:4a8a:: with SMTP id i10mr1084998otf.282.1624472676003; Wed, 23 Jun 2021 11: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 l24sm105186oii.45.2021.06.23.11.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11: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 v3 5/7] fpga-mgr: wrap the state() op Date: Wed, 23 Jun 2021 11:24:08 -0700 Message-Id: <20210623182410.3787784-7-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112445_312647_2418DE09 X-CRM114-Status: GOOD ( 14.46 ) 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 6bfc4482abbf4..7d50ce26bf00c 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 *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; } @@ -692,6 +692,13 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *parent, const char *nam } 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 an 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 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 Wed Jun 23 18:24:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340335 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 305DCC4743C for ; Wed, 23 Jun 2021 18:27:43 +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 F0FE461164 for ; Wed, 23 Jun 2021 18:27:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F0FE461164 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=LUJsmcRQ+kDIOO1wqnmz3XYH0kVkQ82Q3fxs4egme08=; b=DV8eBZxlvJGEfV aRNygtWz8pSZ6AEysA//CLkV7SWG8cvMGHSi5Sh5OZ/tx3rgo9BDuxK24Mzw46t8oBsTglw4wy41N GDHoCy9A6Ik6aECP15UgWsAutCmRLZBZekES4PS9iL0DZRBiudbu7vVEQeCyf8NC0qQqg6+7X/Eoe VXEWEOf0uquBjEoyNaUE9ZyhmtE2s52MiyTHyet8CaoMB4z6mQ++W9qwvN0/OeBpuTk8LomvKCqJi /TFz8mIiprlAo7jmv2mFU7Hy56KhI3XbNcaOM0zL7U6gazSoHgIafwEpe2ix7K6MMs428nKuqkjeG +STpagzqnpZQcfM+NYhQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7ZF-00BcV0-4t; Wed, 23 Jun 2021 18:25:41 +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 1lw7YK-00BcDY-Hn for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472683; 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=rfUUvCPY/yCW3nF5S1XXaaySwkjQfz2Hdett2DoZIxY=; b=JSuIApkuBe6rcbe8IaOJwfA3RAxpj2Kob3bLx1tYwCKN5IWvs2tQsyGHy04x1o30r+mx1O vRVWAbFXQufyL8JckrH0cll+nPqtOVWRtFHUbWQuY9c64iDAsFov28SI5Ub7L0wnb29rfH VM6oxwyxH7zCBphcShaHNBC0u4fGDvM= Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-178-vBz512P0MSuc1vToScnoQw-1; Wed, 23 Jun 2021 14:24:40 -0400 X-MC-Unique: vBz512P0MSuc1vToScnoQw-1 Received: by mail-oo1-f69.google.com with SMTP id 3-20020a4a03030000b029024950bdb69dso2240027ooi.3 for ; Wed, 23 Jun 2021 11:24:39 -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=rfUUvCPY/yCW3nF5S1XXaaySwkjQfz2Hdett2DoZIxY=; b=IqnIVe2VYQ2zwZQO9HQwa5yU018F056SE+Miazel2AcWTNMNG5TY0otLSAa6VSBXy/ XWr3YlfznR1qAtl1c6XNnhOudDntSJ58m0j2e34ycD97ZuIU4QM8mczBNl5L79nt3Djn ohNjabDphT8/e4kAqzbnba8I0oTy7sSocoxQdnho8bSQacYDCJbmtFyiSI4UgNFLXi6N XNQhmhDDrs4TPH2EkKM1JlHSSBguNfijrhJeVb6qdPSwX2qh57IwrZ5yhLfFhBVKd8cP pvW+NSf0Fc04CLaPeT18MooZcDhr2NU2TWsxLsBQb8266e3l9qQAV//ZEnK0I8pK7bCv /OgA== X-Gm-Message-State: AOAM531geq5vhBeUVgumIRMQUICL8i8NFFJ5TRC2iLKyz7Of0/QA+g5k fNOtOlgLsJICU+8I0iBfDbQIFMJN9wRiEJPPNqmlPCyqfF7mzB3F9cn41Q4zII2LyIvIMqGoQhx E5STl2UUU2dmNGK+LQL53ZCWzQlCiWWZdljc= X-Received: by 2002:a05:6830:33ea:: with SMTP id i10mr1095413otu.342.1624472678446; Wed, 23 Jun 2021 11:24:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR7yevscaTjSXDf/VKL6RCgn8jGzo+VVZs7d7rmrj54N3eCdj0y/Xdcw5y6jjNgsqzE+WPlw== X-Received: by 2002:a05:6830:33ea:: with SMTP id i10mr1095404otu.342.1624472678312; Wed, 23 Jun 2021 11:24:38 -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 l24sm105186oii.45.2021.06.23.11.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:37 -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 v3 6/7] fpga-mgr: wrap the fpga_remove() op Date: Wed, 23 Jun 2021 11:24:09 -0700 Message-Id: <20210623182410.3787784-8-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112444_722742_7BD8DD8F X-CRM114-Status: GOOD ( 11.43 ) 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 7d50ce26bf00c..1a2b8d8be7674 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 an 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 Wed Jun 23 18:24:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12340339 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 1ED00C4743C for ; Wed, 23 Jun 2021 18:28:35 +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 DE7BE61164 for ; Wed, 23 Jun 2021 18:28:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE7BE61164 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=fskgIMfTXyXXJgMjc/A47FVzjCRUtmzBKj2NzkY3S58=; b=yIS/e58/PQ+qwP IN0FVHsG10PSfhi6+cPVppz4Yl+CFidwUkn/WGyBxAehU3E560zfNSYx4LU6l4Bi6AQgMZt1FP8pA DFX5G23HMnD8Bq001RmaliqSTMTM1YFCmrmnAlCOq+RSc96erz1CREH8H5PKtNHtaf0mmNt+TGdm/ gf029neZJaKStYBrftWxig/0mNfaMjhIWbGLfva2ZnUrqUbCSjgixXki1ry1uMXF4KAT7h3FMFG5T jsf4AYf86opSBhayOypqJBbS6jnLD2WbjAR8kCGUuIJPxCx+XO4q98qnN1zimbLNHzs84rQ4n2pZM jpYN9Pe9MHRHAeY4o12g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lw7aF-00Bcwh-0Y; Wed, 23 Jun 2021 18:26:43 +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 1lw7YL-00BcDu-FW for linux-arm-kernel@lists.infradead.org; Wed, 23 Jun 2021 18:24:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472684; 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=tvDjxT4JNnOa6YI54+xpsPvfGpnD/xGsyt4kT9ZCqb0=; b=hNk2Owwrc/+yvLPNXw8Ql17AzXZUU3JHQBvLwNskqo7hO2BcLLpyaSPBfxKpNGbBIdlEH3 birc1mRwMfrKnnf4ZFNagbmOCTVoYAEZ0Hp9ltHIy+MQE25Lnj/jqq5KlpX3wInTCNeRWy Ybm4RirLGwaKL0rI573ZOAVIzkKh9/c= 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-383-gmmBHh2EMUyxK8SKb94VSg-1; Wed, 23 Jun 2021 14:24:42 -0400 X-MC-Unique: gmmBHh2EMUyxK8SKb94VSg-1 Received: by mail-ot1-f69.google.com with SMTP id a60-20020a9d26420000b0290448d2be15e6so1787210otb.23 for ; Wed, 23 Jun 2021 11:24:42 -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=tvDjxT4JNnOa6YI54+xpsPvfGpnD/xGsyt4kT9ZCqb0=; b=tRiUySH0GKxNvzSDy7z1I9pnVDzKAvXcg4NtDfD0Ocu21tqHKu5sksTkYC8ptbp9TG Bl7jF1yxoanyMo8jWSRPo043BlIMg1F1L1DWmUf3PSxbA5BZweclClPbYoHSRhkidbLB FVKfLR+fnJl37Bome9AZG/kr9Vssnj7DaJtfcbcc5ZcsSCYEb/2fVaxRAZbnZham5+2i isoMRRozgzlIFWFF/eVzFKddVE3D/qSCbAPu2RVtIC9kkl6btVkS6syOhwWkbL1mRAqt KAwflJ3S4EQiQnA46KqkqjCWumUEK0eSb1hAwbKri8ESKfNQ2BeAa1lVRa7yBk33aSGE nZdg== X-Gm-Message-State: AOAM531zmfVs82KMR78xlcy/gEAGSaeH7F2uN/b269qtjud9DUSP3Gq9 arr6cv7WMipOjSRxpm74I+bEv2SMMu2nsLVnI6Oi3LxC8WLxyhiRsVOG4tOeXr55jbIGAyC3RBf XE++wtL83POWnXC6lMQIgV8id4n6zHVTYxZE= X-Received: by 2002:a05:6830:1658:: with SMTP id h24mr1117201otr.149.1624472682140; Wed, 23 Jun 2021 11:24:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGxW/gR8wVzOIBVQ5Zi3UaRp0R838f9fy7n6jF4t2ZrwynunQMj2JjoRpRgrK/gAnIOAC4JA== X-Received: by 2002:a05:6830:1658:: with SMTP id h24mr1117185otr.149.1624472681977; Wed, 23 Jun 2021 11:24:41 -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 l24sm105186oii.45.2021.06.23.11.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:41 -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 v3 7/7] fpga-mgr: collect wrappers and change to inline Date: Wed, 23 Jun 2021 11:24:10 -0700 Message-Id: <20210623182410.3787784-9-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210623182410.3787784-1-trix@redhat.com> References: <20210623182410.3787784-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-20210623_112445_710682_6EFFA53A X-CRM114-Status: GOOD ( 18.09 ) 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 1a2b8d8be7674..000fa89fda99d 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 an 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 *parent, const char *nam } 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 an 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 an FPGA manager * @mgr: fpga manager struct