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: 12340317 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=-19.1 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 17613C4743C for ; Wed, 23 Jun 2021 18:24:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB328610F7 for ; Wed, 23 Jun 2021 18:24:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbhFWS0q (ORCPT ); Wed, 23 Jun 2021 14:26:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33914 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229523AbhFWS0q (ORCPT ); Wed, 23 Jun 2021 14:26:46 -0400 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Htp54BK0JGPxX8hRg4+dCEnU8CurZfr6H6uRpE1E1JA=; b=a9h9CEsznQ5V09qJkZYnvR3LnaW9uTQNlBEFuxPbZluEcj3+LPORwCm9xhCDzcVHdnxLkU pjPmNPhzqb0jSqvjskhz9bzjfRGyEVDEuLNu+FPkthEXY37UoNOmjP8pCrwJQHkIm1GxcT weUInZeF7MlnalknkyfyyRaaO81BfYs= 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-229-gTAIAo4kMrC6D2dRjA7OgA-1; Wed, 23 Jun 2021 14:24:26 -0400 X-MC-Unique: gTAIAo4kMrC6D2dRjA7OgA-1 Received: by mail-oi1-f197.google.com with SMTP id b185-20020acab2c20000b02901f6dd5f89fbso2244256oif.10 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=BUqQgmZZlcMNew/t681lgACP6aCY77jtz+Pu7abDuLdtw8x0RhghrssmOprCgmM1Hb G2b+C9eEP7OzG+YaV60Kk9DHBLE8Zni40hINb31YCnUek0JK5Ts9JK/9LNtIoynuY++O hju/NdCXM/sG1T6s7yKu0s+0TqP3nPSWRXR5k3vvUB3bhVRVh06TI4EaKg2yJjDQJAlt Iz/+fk7pi/wwb3fkYVHd8w91zR8RdzXB1aInudGgXZkGlc2cfegw8LgB7WKVG4Z46gab rQRSzcgPwDB/j/zlDYabmvkgUk2Fe5464T4QXpYhvvQDAuQS+XV2v9hLBoKoQU+T1/20 OwFg== X-Gm-Message-State: AOAM533905PHu02qwBdabxsUUixrtFqK9RZmpHHPVULEv5Bg9ksKEKD/ Ek6PcZOJ95rfbtKBl4lF5+emFB1POAecNvAuiu5/a3QDS+DLNMPifbmAeagbW+P05bAM7NsuVuH cpd+ywWL1STt1MdIiA0lFYQ== X-Received: by 2002:a9d:4006:: with SMTP id m6mr1091544ote.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 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 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: 12340319 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=-19.1 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 8534FC4743C for ; Wed, 23 Jun 2021 18:24:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DF67610F7 for ; Wed, 23 Jun 2021 18:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbhFWS0t (ORCPT ); Wed, 23 Jun 2021 14:26:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47954 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbhFWS0t (ORCPT ); Wed, 23 Jun 2021 14:26:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472670; 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=5PxTldx17CDNKsCv+3pIoboW0CCoBJIoZzyWzxD7ju4=; b=fLT8U6ZvCxrbi/jB4snTIsHAouKXowlB5mPWejH6a2fgGP4t0MPKh25IMeZZR/SnCIMtVW utk4YFe49xhxJLrNBXcb9ZbDtpAtnlilbSsBD4GbO+Cb0GxnUFZVzIGfKOvXOlzy/4wsly oZkG3jGbJu2gXQQUOntX5r6iIpBR840= 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-549-Zy60hyh8P6uHryOotgAv8w-1; Wed, 23 Jun 2021 14:24:29 -0400 X-MC-Unique: Zy60hyh8P6uHryOotgAv8w-1 Received: by mail-ot1-f69.google.com with SMTP id e14-20020a0568301f2eb0290405cba3beedso1812627oth.13 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=n49nJhSZTSshIyF0K2iGMiipj+WghXCxg6WXTKPXE3lZCy7FcCK3wJVukZP6qndHoH /DzBn0dK0dls4TIrMb3pzRj6n6oXLOA4O19jYainwNH8jNX0qZ82XeIfA3YkJoVjvGkI lblocL7+Lrg/XkxRkzdRMAoiv1qcFgkonQHpibjDX1gogCQOPmxQJ57rgBQFcdou4Y9i zID2zQUQQCVzF9iqxNcigqtzx6ncY5TIHEiEfQcBtGuwr+ixgpPAaJ+o1iPV0x3ASCZi QW0B6wVWdqVh8UlefVRr5lhrXYvj344ZEsneYQRyrbZhJjpOc7iHNZr7+YTcnmNQ4INZ SmiQ== X-Gm-Message-State: AOAM5306zK5G3pafpK5zCrvIi41lUQG2gHFJxe3C+o5hFNPiDq5q1bVa EXN3j7H7dXB9U8FWasCu3k2qNge5rJ1LXS/3cSy9yWyz76WNX2PDB/DzMAlMqn0TeB0+f2AANOY vpV2vAtiDuJAHshqYq5JDpg== X-Received: by 2002:a9d:6508:: with SMTP id i8mr1032023otl.368.1624472668640; 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 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 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: 12340321 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=-19.1 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 7B310C48BE5 for ; Wed, 23 Jun 2021 18:24:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5252461185 for ; Wed, 23 Jun 2021 18:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229945AbhFWS07 (ORCPT ); Wed, 23 Jun 2021 14:26:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32588 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbhFWS0v (ORCPT ); Wed, 23 Jun 2021 14:26:51 -0400 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fEQMbiKZrppCytQ0u2udkzjR7r7bZTZL+PVWVEdpAcU=; b=I9pnL2hTjT33xvtEC/Hf39uzCNJvbEnYww4XyZE6liCRQ+95Jg86K2npyvSvA/G5O2eCjx ph9BLE4r5Lfl+GpTIEkknCIjF0N3glgNOXpdGt4leL2o+ra8vlHEJa6KcJyRDOTuMMQpDO sSWbE6aRf/PG385IRfSlOwluJRkweZc= 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-201-TA0VtefJNtW_Gif_1pFBWQ-1; Wed, 23 Jun 2021 14:24:31 -0400 X-MC-Unique: TA0VtefJNtW_Gif_1pFBWQ-1 Received: by mail-oi1-f197.google.com with SMTP id j20-20020aca17140000b02901f3ef48ce7dso2226080oii.12 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=TExaVgJDTehNHza7+AJNBpZKibRrEyVJVtXkWNZmsk7fyISDmsN79/nVEiQIDYe55U HA6bcM+GV0/jzi/7mfGarE9mLWTZ3PswcT8AFjHzUYuuU6tJ6C124pQWriDtiGfj1VJ/ WmPfnZnfrDYb2qahhocCBqHMKPokCxGdWefyGEvswLoeklUsTkg9iE6xfzu07H3LJIqm Bwl0G8YE//Ff/y+2ePYoeDmlEUhKphdQ35M936rdH3JMAWKruKQbzSqBGwt0AvGkLjTd OCjLPwAdegRWx+0lF+MXHAT6t2fq0y7Y04RNfxZciT+m3s91D2SUg2GNygn6UblzMo8w 9dIw== X-Gm-Message-State: AOAM533kT0RtfUuckSh3AOaQTOtdbqtFb44uSwC5iKa3s4F7dNppI7vC ozDPYfKqLGuQ9O6Gw0uSBgSPunAkWXPjKxcxGc/1tYSvaIwAEWV+KcfjFz9Yf5AJNq9vuqTQFHs /unpkJyITZ3Hzr40Bx9y7IA== X-Received: by 2002:a05:6830:18c3:: with SMTP id v3mr1088681ote.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 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 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: 12340323 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=-19.1 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=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 6736FC48BC2 for ; Wed, 23 Jun 2021 18:24:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 525B2611AC for ; Wed, 23 Jun 2021 18:24:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229999AbhFWS1G (ORCPT ); Wed, 23 Jun 2021 14:27:06 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52897 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229926AbhFWS0x (ORCPT ); Wed, 23 Jun 2021 14:26:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472675; 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=zt+reJW9iH4L44dg7M6KqKyx61iwDVr84RgiCAGE6Po=; b=OLaxUuAp7bXlKX9dAfhlmhBzOTKYzy2n39e+Yw96WWfU6rp1sOVFvMuSU2tdhuBHWFXJ7F uB7o85VL4UdwLkej/lEFirqZ3CK0hXyiApMsKlqSL6N5f+6bmvrZiYNmx7/zQ349pnYjko qXbZuhkajXe4K8pNGysax0I5+Q2ZBak= 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-357-Z5GtW3k1NeaH6jBpkniVQg-1; Wed, 23 Jun 2021 14:24:34 -0400 X-MC-Unique: Z5GtW3k1NeaH6jBpkniVQg-1 Received: by mail-oi1-f198.google.com with SMTP id l123-20020acad4810000b02901f1fb44dca7so2226791oig.15 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=YTNEqJWnXH2FuJ8Js3ISlIGsQtHj8pIEl/C1OMXF2v3OzR2etlB48fY4UphZkI9rs8 5I6e2b2+FPKbd/IgN+NJJ6zc6zQwjIZnmsASdEEpLdIlr4hZ/K/YtvuJ5YNtpUn7HwD+ pOAQJwcbwX4DzCcqHE7KvKMvJFDi6QmVYMVvEshirDvZhldIoXVHogAwDL8IectRP04f gE3pyjUEKrz6F3etWOpFGabqBP/UhjH4y2wfkFeEjSKEx2KGwZemKbTh62QA+UBUJeVE 5JzJ0XgtDSHIZmTMWDE85ZhMViMBpwch53nuJpv8PodKG7+U1ueIyvPh5jhAtCfiEorM oaXw== X-Gm-Message-State: AOAM530yuKmgvOvpH9ixOkuKOaRxsjmEwFI9V2SDXCkeaEm4/QUOlC5l GjHBBX9zFBVCG5khSl973Jt9q1dcCtqGwmLPlmZDA03cHvo8sIo7NxiJWFzfo8WzDJtUErSkOJB SV2X/WKGSQPNMQCqw4D0shQ== X-Received: by 2002:a4a:db42:: with SMTP id 2mr924970oot.47.1624472673541; 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 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 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: 12340325 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=-19.1 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 B557CC4743C for ; Wed, 23 Jun 2021 18:24:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C379610F7 for ; Wed, 23 Jun 2021 18:24:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230015AbhFWS1K (ORCPT ); Wed, 23 Jun 2021 14:27:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33070 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbhFWS05 (ORCPT ); Wed, 23 Jun 2021 14:26:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472679; 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=nnushO3xnTHoZzlU30ytNGeGLULTAlS7H2DDhaf9BHk=; b=Hb+LLHJImoK2EsHZb3NFUpOJsgUGAef1oAcRkrhTMB38Cfwc85mTnIrfvUNSAYCISp7ILo Ix+/t5weEHCzzQ+RNpnnJc4jp7GoLSL4vlTYR7sGH1MfXLiVzyFxR/BJoGN8EvpdEevth+ jM/6/c8BMq7hkSGDojzgg2kmC3HA+pY= Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-526-IkY7WrVKPA2v5Nb06FiqBw-1; Wed, 23 Jun 2021 14:24:37 -0400 X-MC-Unique: IkY7WrVKPA2v5Nb06FiqBw-1 Received: by mail-oo1-f71.google.com with SMTP id e25-20020a4ab9990000b029024aa2670b1cso2183201oop.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=MH/AGqKu9fmeGUIr5cpU4JKdHC66EsPpV6Dn/j/AxnAyv1ebJGc3b6r2fwSYdbxFF9 FfN2w/oaRfGv5wh/eg34K6+71oHOrsNUCJFeu9Dz34jqQn1qG0nqEYzK7PdizLM1Ly0A CRnXn/uXxpgiE6z/6sj4m8wCJXQVieYvJpQ/ZdgQxp08106ykmkILr/POM0/A/HgcWsG C2MiW9ofnrwwvzOGB3254/R+/gLm7SwgUyUaikn5m/TJylY1bR4B2jAiBBFLtzsGmr4y 4g/wd29ng9hJGVViXkWdsWJ9M5azYCAih/3vSNKZ5j4LdLj4NUfMyYsb4wOWQmkt9NS4 kgQw== X-Gm-Message-State: AOAM532FO/VNJvCSd6JjtE6IXpzcZhzP+/toXKWFkaTGs89wyJwDBlu7 PDqfi/APZkiA8X8zikMv6Rhs2jA+h79RmQ2Wjc30g50VP3F4+asVp2I8f/PSJUyBL18kFSK2/no kraKGh4feRuY9XryzLi6Nag== X-Received: by 2002:a9d:4a8a:: with SMTP id i10mr1085013otf.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 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 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: 12340327 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=-19.1 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 7F282C48BC2 for ; Wed, 23 Jun 2021 18:24:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68BCB61164 for ; Wed, 23 Jun 2021 18:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhFWS1L (ORCPT ); Wed, 23 Jun 2021 14:27:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26980 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbhFWS07 (ORCPT ); Wed, 23 Jun 2021 14:26:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472680; 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=rfUUvCPY/yCW3nF5S1XXaaySwkjQfz2Hdett2DoZIxY=; b=HOFejhBbOnZy+/+rNaIrdqiTgWi42ooUIMP+RWMzaV+rhEoZ91GZMc5EPfcSVgucOrOII8 G9KPS2RFQQlsPUdwmxLnpVrwNhSs3d571TkyhP1JD3UW+fPC2QtPCyUJdSWX6ExDCz4OwV Wl6TOcaSJHo3ndh7KY84D9f3T+HUO8Q= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-564-sbG9gL93MPScyndbqmWp8Q-1; Wed, 23 Jun 2021 14:24:39 -0400 X-MC-Unique: sbG9gL93MPScyndbqmWp8Q-1 Received: by mail-ot1-f70.google.com with SMTP id w5-20020a0568304105b0290456b49b7526so1807772ott.16 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=STAT4msxq16SsOZ64/7FoktExpJavjt+97/SWoXtUG+ZeBFbeYKkqETcrZKTlmCVAX a/2y/mZzc+rBTqoRuTjDB189uGxx9ERA8qXSWrU0FqZ/ZTdvn7rhAhs9+DYZH5vmRjAw Myc0ZLjtduzD+7XS33rFpVNcMCYEmSTEIr0aVcAOyAtGpOKBbY/unH3BBM5Tld5RCw1w 2D0Bwdbq1McznygFkFcchPTnLE/K9tGGMTXA2ABk6RbFD3QRw1n4SB6D/TkIphVlg71S 9nI9zMxeu+IyP1d/lIv4bLWWGDsE7FPx/Cfcp/oS/JHa/NkJWhJpIMNV+yMHqx/QJB0A 0h2Q== X-Gm-Message-State: AOAM531yRjO4wrTfafQ3bgZZFX0LxXg3wGqKggbn2UpCwpUxz1qXXZ1I jLAc3SFOYxrhPLJ5DhJb39QKyDJI1ArRiKoVqtifWcLfV+8IkBU0t76na9cm6v9FqHMxzkGTzgr la/z0DnMlNai5adurgbPFNw== X-Received: by 2002:a05:6830:33ea:: with SMTP id i10mr1095416otu.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 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 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: 12340329 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=-19.1 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 036ACC4743C for ; Wed, 23 Jun 2021 18:24:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0C8561166 for ; Wed, 23 Jun 2021 18:24:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229959AbhFWS1M (ORCPT ); Wed, 23 Jun 2021 14:27:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:23857 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229996AbhFWS1G (ORCPT ); Wed, 23 Jun 2021 14:27:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624472688; 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=tvDjxT4JNnOa6YI54+xpsPvfGpnD/xGsyt4kT9ZCqb0=; b=cmf+rQXzlwc7GDgyosDVyxv9b4pP8Pq4Olkwl3iCUdHHq86N4mnWgd8lKvNPi73QJADaW6 GTXEO0u+3HS9sfaitWuo0G60q2kyBmdNqtxldUsJZmF6w4y0gScnQuiZ3h5b8HasSLMFb9 vgrN6TCdNjx2ahXAnqFeMxO3hq6mxB4= 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-555-eSu_kXb3PPuZeIPDLeKlAg-1; Wed, 23 Jun 2021 14:24:42 -0400 X-MC-Unique: eSu_kXb3PPuZeIPDLeKlAg-1 Received: by mail-ot1-f69.google.com with SMTP id y59-20020a9d22c10000b0290451891192f0so1827034ota.1 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=ORJkTuTMMLHda0bshXIawaG8h1PyqccKl/GxREmOGzSfHTtmr2fPnHTBNuSMjfTGbh 66V1MWkbvZg4pq/MZDEjblFpX5pfkkTsynln2Ak42V0Esu/BB6C+fNLCEBNOPLOdxyfV mKJYcoe7fs022OwkKsQqfnDCoG4HvvcFoA+oO/4jc7tORrYvahnHBEb9+g94iyYmY+SF 50OZkpdPb2N3DSri6o0IH2tHqv9Ut6TtvpXG2anNykL6GPZUHf/jAW+u46P4S982z/g3 szd6OXoecwz7JgIMYCD15RNzrnpEufGjBfhm4Ge4DorO/7E5zHPIALUqGmozTxo0mXc9 4tUw== X-Gm-Message-State: AOAM530dRSNBs3QpRZnjMwJ0hgFNukAAA9+IAJvxTzyrKb9UlwLpPAuN sM6gcREyuh/Tv4SUtiTxPg5IHp6TjS7Jd8F9nIGq0H5krt/ls5OQlxcMNRhJaA6cyt4Qh4gaXxd 4b55ZMBn5TmJ1Ba5GuUY3QQ== X-Received: by 2002:a05:6830:1658:: with SMTP id h24mr1117199otr.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 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 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