From patchwork Tue Jun 8 19:55: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: 12308037 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 999ACC4743D for ; Tue, 8 Jun 2021 19:55:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83C8D613AC for ; Tue, 8 Jun 2021 19:55:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234583AbhFHT5K (ORCPT ); Tue, 8 Jun 2021 15:57:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52200 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234553AbhFHT5J (ORCPT ); Tue, 8 Jun 2021 15:57:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182115; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FcdIlm0NN5VNBYEPRLo+XaYQu2TJXZBESFHXWMw15dI=; b=E23t18+q7gPHJhXQiHciAGnJkppP5iNF+Vlau+XPuwHTpIeRe2Q8lkx7Vif57LlnP6Miqw CA7+RFnAA8n1urozoaLo9IlnKhBhxSCY66vlR94JJ6XAZu1ClkJiuMl9AWYQ5Qp+t/Iftr hr2v5gOYwdyiZHr3QTe6c7B0ONUhv44= 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-139-AAAibtaOPgmvVjSnwkRcmw-1; Tue, 08 Jun 2021 15:55:14 -0400 X-MC-Unique: AAAibtaOPgmvVjSnwkRcmw-1 Received: by mail-oo1-f69.google.com with SMTP id r4-20020a4ab5040000b02902446eb55473so13937331ooo.20 for ; Tue, 08 Jun 2021 12:55:14 -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=FcdIlm0NN5VNBYEPRLo+XaYQu2TJXZBESFHXWMw15dI=; b=poxP8micgXD1nlH+o0QySG7E5dxhFME6+SIu8jcVEU2VQgrKGRn4D/SgzRKD9ypO8+ 6iQaAFzXsMgzH5raufuSExEHOja3XVyPDiER8SGN3BwhujhhcpU+X0l12cCauEedMGwk AFFyXORgG0ZJrVYGotv/aAF3uIRvKr4+ivhM3ftNJZh0XQ5haPSyQPsi/vGqZsQ8rRpA sqyChAl+sChmYk0oyPmx3cNtBaa5m4+Cy6VpyLNGShwxRQANIQkgjfClLWiB6a0BJwcP BAadZGVRSCMCKja8vf9ewipvvWm4xVf32kFES/EbfJWpZJKUlw5AwxxwTn4wDgXW5KJO PD9Q== X-Gm-Message-State: AOAM533hYivpIxGHqbX6VTraOBwCXrbecX3nl/kY5WA2epbIxHAxslig 9tNtt4SZuipKNSxDD+fpDKHxmLyz2A0edBvWiEITuBsvRYbxcaOSHd69BdIr+JkAaOat8Rjunlr 676SuawVpdNgAP29P8idgKw== X-Received: by 2002:a05:6830:1196:: with SMTP id u22mr19013062otq.247.1623182113731; Tue, 08 Jun 2021 12:55:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqo6DxfNK6I+lWN5sfQvkwGiAiPoqkDUE8a+xJp4NKMQdM32CuK6iZZVO/5IicjbQM4Pau3A== X-Received: by 2002:a05:6830:1196:: with SMTP id u22mr19013055otq.247.1623182113585; Tue, 08 Jun 2021 12:55:13 -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 s17sm3024046oog.31.2021.06.08.12.55.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:13 -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 v2 1/7] fpga-mgr: wrap the write_init() op Date: Tue, 8 Jun 2021 12:55:00 -0700 Message-Id: <20210608195506.3022550-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 b85bc47c91a9a..24547e36a56d8 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 Tue Jun 8 19:55: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: 12308039 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 DEE8EC47082 for ; Tue, 8 Jun 2021 19:55:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C8CBA613AD for ; Tue, 8 Jun 2021 19:55:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234620AbhFHT5M (ORCPT ); Tue, 8 Jun 2021 15:57:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49147 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234576AbhFHT5K (ORCPT ); Tue, 8 Jun 2021 15:57:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182117; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ik8JGUYI3/+hbO9x+DDmD96jPOqQ4zVk4ycCcPjNv+o=; b=Btq/NxzDSIAyqk9nZj/5MjApxy8iWKQ6x+S39fl+fn4aC8if9siIva49SNM3Fw+yw0Pox+ tRGquARHP43Yr3YwUX7PVbpkbVp5jVpvQQ42hX013roj9gpIYG5RVNZtQ+tZrGZ/69597S rTGErVGqd42bjPfDbL4XDzsCw/4nLgw= 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-447-Wn3FvEk7OO2Rarf98-l-RQ-1; Tue, 08 Jun 2021 15:55:15 -0400 X-MC-Unique: Wn3FvEk7OO2Rarf98-l-RQ-1 Received: by mail-ot1-f72.google.com with SMTP id q20-20020a9d7c940000b02903f5a4101f8eso1848137otn.17 for ; Tue, 08 Jun 2021 12:55:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ik8JGUYI3/+hbO9x+DDmD96jPOqQ4zVk4ycCcPjNv+o=; b=Oq9BSg4ml7x5+1N1YTwjuxyuPq8yXM4q2cLhh1KEIzQdjk2ZVmTU2xRmKnAU6PJbau XtLUpOoSxK+q6nOVLrFM/qGcMs7xSw8RegNWUC2Gtbe+NR8oBXz1boMuD7BHgA3h/rmn AqUdDGnlfmicLzGDHpPX9exbHMUD3x61BC1mgbvdlrDfiJ8Dx37QbWPF/vzX5Amh0fof GOUscAAXoFwbVgB6CjB2G1qTbsDooF3WZKjRY0tz6xfXzyVln0PmerNQBBDeCLaX81AT 0P9YxThxNiEo7ahr7eKRe4jgE7xl2TClbay+nasEtTlNZcXRLXvIXE12/dQwO+61alCT JO3w== X-Gm-Message-State: AOAM533DDNh4E+rGPNNAGYX1HdxKigA32dnt+Vx2UYO46NeTbS9qoTp3 o1Fs20KG8aRxiV84jM2YIT81k2AYXM//ctRmf9C/w1C+1AXYssOS+haOB7AHMo9a09ZFirypKE6 Cd9nt1CwBml+NS47yEDVUkg== X-Received: by 2002:aca:1a05:: with SMTP id a5mr3820092oia.26.1623182115007; Tue, 08 Jun 2021 12:55:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4gcno8v2BQWArONVSZdl6j/JvTWxDq9sZDI7o76liP0AeU55RDfKdp5C+vsmCglW/+gol4w== X-Received: by 2002:aca:1a05:: with SMTP id a5mr3820083oia.26.1623182114836; Tue, 08 Jun 2021 12:55:14 -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 s17sm3024046oog.31.2021.06.08.12.55.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:14 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v2 2/7] fpga-mgr: make write_complete() op optional Date: Tue, 8 Jun 2021 12:55:01 -0700 Message-Id: <20210608195506.3022550-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 24547e36a56d8..dadad24015020 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 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 Tue Jun 8 19:55: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: 12308041 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 6DC8DC47082 for ; Tue, 8 Jun 2021 19:55:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56513613AD for ; Tue, 8 Jun 2021 19:55:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234757AbhFHT5V (ORCPT ); Tue, 8 Jun 2021 15:57:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:20437 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234618AbhFHT5M (ORCPT ); Tue, 8 Jun 2021 15:57:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182118; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F+ieZpNx5CLGtvApXLWeUj3JhBAH5I6pceFuxGmJ04c=; b=C7H1GEO/fLNlOc0yN0sP1v3rU6t65UQNq3bLCtvq8U2ibTWxSI0kZlFWkKDrGy8RqnzLXz LJSjoZ+OpbWfnd6FbS09W8YjrEa5Aed1596Ixscdty/k2IeZUJK4qjC5kGyEQXuvQLSaoT 3wjsJOOYKxnFhYSRLLxggJrSiAFr2dA= 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-500-FEI6dFUcNeCEZb5dDySklg-1; Tue, 08 Jun 2021 15:55:17 -0400 X-MC-Unique: FEI6dFUcNeCEZb5dDySklg-1 Received: by mail-oi1-f198.google.com with SMTP id l1-20020a5441010000b02901ecd2ee1861so8844610oic.13 for ; Tue, 08 Jun 2021 12:55:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=F+ieZpNx5CLGtvApXLWeUj3JhBAH5I6pceFuxGmJ04c=; b=tVof5N/W2SqfhJ3fWGknB45AYoVXJ98oVl5NfBRz8XHcIsETz+CdZiOyvnhqUHkKeZ aZAhb/WfwZDD74g4DgP3iSHhc70oPrB1WGeccFiCimxeZzwkF7w3py7vLqlKAz5ghVwm /StmOPOXxOUpiYvw5bNsoRgwY4hNFsp57FiIU21c22CyvP8nImuexoOI4nif0ENTNS0U QkRB3kLTLaQzt4FGimzUwG06JrzbXDLhCiZCejD//cVfrJmzXtfGqwARcTQqJVYAsYhG GKVhv7WrektP0Rvto+NUrdMXRygT/TWw6LgKDJhyo369BPXKrZnl75CD6i1mOj+8YCEC xxEQ== X-Gm-Message-State: AOAM5318vXmS0JRWjWzTx2/Fwz8xMBP4pWXY5kNOXbUb93kkWlhkHDFW mGaJNh4W+dpXTxfmyuV1o7JE03NfIpw1yq5wVrRjiFK4f7fYzTTKwyMnmzUSb4UFJjhPB/+0cVt zmWK/igy19HlYFkg6kcimfw== X-Received: by 2002:a9d:6d01:: with SMTP id o1mr3273298otp.285.1623182116398; Tue, 08 Jun 2021 12:55:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzSar9h1GULVkRSGLcpyrS0rYxMTcGF2lkZPgA01LIMglsS8alL7LOIgUpvolCuPMbXVdeVw== X-Received: by 2002:a9d:6d01:: with SMTP id o1mr3273286otp.285.1623182116240; Tue, 08 Jun 2021 12:55:16 -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 s17sm3024046oog.31.2021.06.08.12.55.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:15 -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 v2 3/7] fpga-mgr: wrap the write() op Date: Tue, 8 Jun 2021 12:55:02 -0700 Message-Id: <20210608195506.3022550-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 dadad24015020..c484b4309b2f4 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 Tue Jun 8 19:55:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12308043 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 76E7CC47082 for ; Tue, 8 Jun 2021 19:55:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5E744613B9 for ; Tue, 8 Jun 2021 19:55:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234565AbhFHT5Y (ORCPT ); Tue, 8 Jun 2021 15:57:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:43059 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234633AbhFHT5N (ORCPT ); Tue, 8 Jun 2021 15:57:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=htxg7QFhlugIkUjEBRB6MmryeZkakMXu7uhWLDq62MQ=; b=fIySp3vH0eSj3hCLDeYg3V5APorNcyGv7OPMKijN9YBj/ZCjr+19w62vtiDi/yxEYJhirb RQyqmJxVyeBSm1mFJsEymmbXEzKAMs5ZtzrnDw9l5WVPKkGGli/x6ltdal2gNa5NREBMmF NXwIOMaQHB/fqLuvDeGegDGoH9LF8dE= 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-59-2K4t_HB0NKqa8p0dRG58ow-1; Tue, 08 Jun 2021 15:55:18 -0400 X-MC-Unique: 2K4t_HB0NKqa8p0dRG58ow-1 Received: by mail-oi1-f198.google.com with SMTP id w12-20020aca490c0000b02901f1fdc1435aso6303676oia.14 for ; Tue, 08 Jun 2021 12:55:18 -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=htxg7QFhlugIkUjEBRB6MmryeZkakMXu7uhWLDq62MQ=; b=bkhjDOCbuy3o0dwFs/8XOpQd9zVnwboxwjXXU47pYPVUDRObak/WXcchmS/4jgWhWS HzKJm0vKPW3U5kWbh/981JR74wQn8r6EbvSUZZLsKFZNDNSzyW3QqZuSfsRjt3cb++wz 5WLVU8v/E0QGJnwNYb8dxPZRAannDdsrX1ldUUIFm1CB16HJ0IjP+mCdC8cAYxiPT4J+ CHpoTyEMRNsQPJKjx3vvCQ1sQxPYthmmPewQKVKHNTi/8nMXlU7672rIZmRNq0xqBQ08 /wM4anh0QStYiY+25yvQKsiJUV9M1qhaJ3z7mmCaHVbRwj+NbVP3xjLjtSiA4ThL52mX 8qcw== X-Gm-Message-State: AOAM533kfyq34nZNYIiYyJqkoXd1RCqcYtmV+cQMQxPaR10cSZhR8mMh lsQ3HRfFzsSTTCpcLUcE4PO0q3RVRFvAInImzgRi8VoC3lS/aets6D00RYISMsXAdD63o0FrTjd sKwRnLijggLlwj2wWOag3uA== X-Received: by 2002:aca:4703:: with SMTP id u3mr3955503oia.37.1623182117640; Tue, 08 Jun 2021 12:55:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkQnduqFmHXGXncV3/7jvv7BP7nZordQ4ddUIl4lAERn1K6+6xmEGbcvd4LPsWckV0CQEsPA== X-Received: by 2002:aca:4703:: with SMTP id u3mr3955495oia.37.1623182117532; Tue, 08 Jun 2021 12:55:17 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id s17sm3024046oog.31.2021.06.08.12.55.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:17 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v2 4/7] fpga-mgr: wrap the status() op Date: Tue, 8 Jun 2021 12:55:03 -0700 Message-Id: <20210608195506.3022550-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 c484b4309b2f4..cc531f0537acf 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 Tue Jun 8 19:55: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: 12308045 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 9C3F4C48BCD for ; Tue, 8 Jun 2021 19:55:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 83289613AE for ; Tue, 8 Jun 2021 19:55:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234833AbhFHT51 (ORCPT ); Tue, 8 Jun 2021 15:57:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46981 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234639AbhFHT5O (ORCPT ); Tue, 8 Jun 2021 15:57:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182121; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KD9jjN3L1AODL3xYyQk4Owi0Be8ipyYlfv9872RELmE=; b=HH3OzAGnutskXHKksYrZISwUecFJNhUKAoGqQLHJzgjBa7wfC1fLeYv5hlhfrYyoFWOsUP /tVERhO2r7dg3iUcHJcyjkt82lw1dIbuDw3I9CCUgvLtORuITtUvja3c+/YlVnMmn5dDfZ hIu2j6ADq9Stc5e+zi+k1TeaZMso2fI= 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-416-7ObKQvy4MmSVcW3J0zoLFQ-1; Tue, 08 Jun 2021 15:55:19 -0400 X-MC-Unique: 7ObKQvy4MmSVcW3J0zoLFQ-1 Received: by mail-oi1-f198.google.com with SMTP id j1-20020aca65410000b02901f1d632e208so8034832oiw.16 for ; Tue, 08 Jun 2021 12:55:19 -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=KD9jjN3L1AODL3xYyQk4Owi0Be8ipyYlfv9872RELmE=; b=iOihMUAGGfNiUVaIXlNb4kmSOcW2XXBBxp9OHVEe1CG7Bixe8VeL/0iYPg+qkDrTI/ bqjdXArBNGo5bTI44PftNiHZ6IsmDWQQOLUkDkhpFQWadzHX2DhotYR+YHkcYnaZTOeP r7ontIoltpFhckK8+dqrSCCg42h2rGOZs+gMH0/jmmes7lW4eGwf0K7DpYL5FqhuBW/B Wh+GRRrpPPpWXQ6lRqFlmz7+0PifrQMDdLGOxDsP0nNwEYXoJpVQKXxyyEctpdwCPgV9 g1JWEl6I1z6Pvn1piR1CtIHa259Uh84qh7UGc1nWUtPFN7A3oN0UtIo/8ERprbrjDORu 9oOA== X-Gm-Message-State: AOAM533H5OkDLmaObxCqYs2AsAqNcC2SEss947J2D8Lc7iFHchghIQxY DZpHM8vd/oZjFw5L2peT19BsC5vkTFJ8y3k3PO+I0vkRuCQIdHwPIvO+SqwL7kUjRkFGwF2N0EU fzzDOY3utAoCfTt7PuzgoLg== X-Received: by 2002:a05:6830:1155:: with SMTP id x21mr19421575otq.303.1623182118955; Tue, 08 Jun 2021 12:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykl5o+u9RLuM4h3jotxgiDysFbOa6laysW8rYMHSawSoGYmKyN8um5Gh7iRgeUty8a9wXpEA== X-Received: by 2002:a05:6830:1155:: with SMTP id x21mr19421563otq.303.1623182118802; Tue, 08 Jun 2021 12:55:18 -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 s17sm3024046oog.31.2021.06.08.12.55.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:18 -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 v2 5/7] fpga-mgr: wrap the state() op Date: Tue, 8 Jun 2021 12:55:04 -0700 Message-Id: <20210608195506.3022550-7-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 cc531f0537acf..d06752be9c6ef 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 657a70c5fc996..5219fa1b555af 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 Tue Jun 8 19:55: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: 12308049 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 B1036C4743D for ; Tue, 8 Jun 2021 19:55:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C63661375 for ; Tue, 8 Jun 2021 19:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234915AbhFHT5d (ORCPT ); Tue, 8 Jun 2021 15:57:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:28887 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234719AbhFHT5S (ORCPT ); Tue, 8 Jun 2021 15:57:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ub84QQXk/80gOx9jVYvQgeu9ZbjU0KtFBnV/GBkRc70=; b=V3ThtLMcL6fuXSRwKkZ56m/m60A9yhH+fPvD6I51FZY1Iq9YzlxCPySnskiUDyNDBPD1Rs d5EUKR+WpFgM4QeK0XlTyNeCd+gKjR9CEUv4fGHICBocI8DS6FRKVKVaE0HO4yPqezgUZI xK0eypU2jIXjRGaxtKJ9U/EG9qwLF/Y= Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-nleR9qMRPB6Iehy7fu7wBg-1; Tue, 08 Jun 2021 15:55:21 -0400 X-MC-Unique: nleR9qMRPB6Iehy7fu7wBg-1 Received: by mail-oi1-f200.google.com with SMTP id p5-20020acabf050000b02901eed1481b82so8830730oif.20 for ; Tue, 08 Jun 2021 12:55:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ub84QQXk/80gOx9jVYvQgeu9ZbjU0KtFBnV/GBkRc70=; b=LHgh/FPH0hdmKMcv9dmRUXk2P+M22xlS9oKB9XCVMo9OE1/uFrGJB42AEpdvAQ7N8d Awm6qn4zyGOFBSr1cSqWPkjKC47LxD9FoLk1alUV4npCNSYE3JNDKrn6qBNffF+akEsp 0k+k4+Sd/Ul9rdn9IQBtIGlu14G/XaMT0ViJ9lp9Iu4dO2J4hIETT3jiMsFnH8Ts4UDa x1G38vSRY/ckyJ1kIoDKjPp+FLwaL6zqoCzQ0P48ZhLiFphnHLd7JalLf1ftsU52R9l/ 8fKnLfRKnEw7sCawmANwoXPtVN6hyOTyVZE4UlBEErml+zXza04f7mF3KWo436E1fqo6 6Aqg== X-Gm-Message-State: AOAM530sa0x6M9gAAJK0AJzOx6ePvcNI+nSDa5LTB8K/bowaqgYyufop CfLctfPcowhL8j8hr35YARuQAzunl/2gHz2fcroG+61LoV03ErNr44PYPG8klNZDJVO/B7OTaLj eyhTLWHVd4YWmI0j2H4aONg== X-Received: by 2002:a9d:2904:: with SMTP id d4mr19095276otb.238.1623182120325; Tue, 08 Jun 2021 12:55:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmGhb5zky/LBefjfpgPpDFor2hP6i0wi5WpKPdZompoRWYG/9Z6TmmFlW3LXeN5nlet8+wrw== X-Received: by 2002:a9d:2904:: with SMTP id d4mr19095265otb.238.1623182120144; Tue, 08 Jun 2021 12:55:20 -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 s17sm3024046oog.31.2021.06.08.12.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:19 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH v2 6/7] fpga-mgr: wrap the fpga_remove() op Date: Tue, 8 Jun 2021 12:55:05 -0700 Message-Id: <20210608195506.3022550-8-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 d06752be9c6ef..84808c7ca4406 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 Tue Jun 8 19:55: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: 12308047 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=-18.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 1039FC48BCD for ; Tue, 8 Jun 2021 19:55:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F37E7613BD for ; Tue, 8 Jun 2021 19:55:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234849AbhFHT52 (ORCPT ); Tue, 8 Jun 2021 15:57:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54969 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234697AbhFHT5R (ORCPT ); Tue, 8 Jun 2021 15:57:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623182123; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PX4XZRO4KpflUQEEgbL1ALBIADgPV7/V/iBUfhH7FVc=; b=Pv4Xt7SroJnz32APMAGIyGl89ObyPui3/nLVxm6uvDBWfoRh4FIkE0/F8NLVnMxAmab0hK mmfTEwfHKEgwhfJsis0s343efv1RU2MVJebqFiX7N6ws1ZK8EK6lb2WGzpftLLe68+Whof paMaV4IS0+qzFSJRZhyBEyiQOeVgDV8= 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-191-CPY-3tdfMLGlfFHnUuQyUA-1; Tue, 08 Jun 2021 15:55:22 -0400 X-MC-Unique: CPY-3tdfMLGlfFHnUuQyUA-1 Received: by mail-oo1-f69.google.com with SMTP id o21-20020a4ae5950000b0290211a73e7f50so13946694oov.12 for ; Tue, 08 Jun 2021 12:55:22 -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=PX4XZRO4KpflUQEEgbL1ALBIADgPV7/V/iBUfhH7FVc=; b=gR40HI4FZJSfXJwJGWjHc+62atvyLDsYREE+1ljDufGVOlkCIfw/+Wf4BKD/DKph7s chE9X8tQjZmXElVuYX/jdugy2Lh4c+W+u6pI/sc6S4z47+BoNODcVySqWRfsksB1+Nlm L3bQvJYgGvcAt41f2G7O6ZswF4+e86IXrmOYzh0iPGesC9udXJ5XaMy9fI7nyyRvldzE UvIEY6bLyjUQVJrHI9d35ZrPCSem4o+ZdeuVAjouL0R4xfn+XGdwMXK+CfIsIpZB08Au h44Gia2hxDx/iuVY86Kw2vWNE5SgEc0586R0WnM5LbHaYbjq3Zet/wYh0PCAK0zrenEk ox0A== X-Gm-Message-State: AOAM532qrOq+IMhIXzUn2xe/Q1/bf2F3pROoRTfproRRethYiSKYbrpb GPydCBrxkk2EhFlF5RqY7mfvwUh7OLq+4SAZYKi1BkaLvJF8RLMY/Ydt6JY8GWdDRBVR1RJNG51 nR7BNYZOoI0qoMPcZWPEYig== X-Received: by 2002:aca:af90:: with SMTP id y138mr3986011oie.92.1623182121634; Tue, 08 Jun 2021 12:55:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0UWwhNSy55xmGBEwarxMH51IQL5Vz8zCfespiQs2F3hecQ7wjI2E6o8F7F63GFd/GyJsx9g== X-Received: by 2002:aca:af90:: with SMTP id y138mr3986000oie.92.1623182121452; Tue, 08 Jun 2021 12:55:21 -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 s17sm3024046oog.31.2021.06.08.12.55.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jun 2021 12:55:21 -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 v2 7/7] fpga-mgr: collect wrappers and change to inline Date: Tue, 8 Jun 2021 12:55:06 -0700 Message-Id: <20210608195506.3022550-9-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210608195506.3022550-1-trix@redhat.com> References: <20210608195506.3022550-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.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 84808c7ca4406..198a44a620583 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