From patchwork Mon Jun 7 17:23:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304173 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.0 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 6D6EEC47095 for ; Mon, 7 Jun 2021 17:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51E0A6105A for ; Mon, 7 Jun 2021 17:24:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230241AbhFGR0X (ORCPT ); Mon, 7 Jun 2021 13:26:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27576 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230314AbhFGR0X (ORCPT ); Mon, 7 Jun 2021 13:26:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9Kr/vWB+/nwKdeKs8KkDEzQieFV1Y1AcDYKa+Pf56V8=; b=CGNw61Kkyb/5CJN5iYASckM8W1SBY22+AGS/1qAwYc//O9H2oh0oJf2EbeJobBQ2GJhG7O cU4kpgFHQb3IyA8gU/CvOT1zfzN3PQM6FmAjySUxN9N/2C3zscMdsFvK0iML92H69eZZTA 96GmL2+3pFw8NbCvswGGTaZ2wQWvlX4= 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-500-H7-Z8zBdOb6JK_J8EnRZ2Q-1; Mon, 07 Jun 2021 13:24:30 -0400 X-MC-Unique: H7-Z8zBdOb6JK_J8EnRZ2Q-1 Received: by mail-ot1-f70.google.com with SMTP id 19-20020a9d04130000b02903cb28b38d0aso10586156otc.19 for ; Mon, 07 Jun 2021 10:24:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Kr/vWB+/nwKdeKs8KkDEzQieFV1Y1AcDYKa+Pf56V8=; b=BHFF+1+3RqSvGNxAue33LzU4fu28hpDrJeREyuKn3LqPmmNkyDw8019FBVqy/pK+WG ehCSrQt45CIbMcGZvjDX/wGIcLAvlPiBwSh3hJCZzZiIEObhvjJG0iBPlFWn4oDyjZjg ydCT09Dtwsynm2eYVWrYcbe6uYKrYeqZlC6jcMkMVji8/LVPFC252QTPoEC/cJ3bYVwP hJktkA6BOkq3cVvbt5wau81sP5kY844K1ATvknvw1o3g3N1+5a0khOQzxGmk3CS2f1v6 nEDkFBuwVvbdvYAOrvbTIhcW1k1kMJxlQRfAFQOXUQReT/q1rXV43Uh7TWtPo7tGTbw1 vdMw== X-Gm-Message-State: AOAM532d8YUmSOa7dvMdENGrcDOB7eSlFivV1lGfdY3+DuASlvDgYFJW ptLzSp2scENiI1ZXpvRsO+mp8Ek6pX4UPI2F5WmeRXe74ShJHvBCOYXbeZrymPEQt1YALWD4RwU CPKUVe46qmel6V/8MHWxTBA== X-Received: by 2002:a05:6830:208c:: with SMTP id y12mr14976939otq.129.1623086669451; Mon, 07 Jun 2021 10:24:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx+lDqZrglifUpJyQXQIS8VUnzoYQx644bk2oknGt1yXO+O7Fiz78iL3xYwnV4DBj9rU5fJQ== X-Received: by 2002:a05:6830:208c:: with SMTP id y12mr14976930otq.129.1623086669317; Mon, 07 Jun 2021 10:24:29 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:29 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 1/7] fpga: wrap the write_init() op Date: Mon, 7 Jun 2021 10:23:56 -0700 Message-Id: <20210607172402.2938697-2-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board should not be required to provide a write_init() op if there is nothing for it do. So add a wrapper and move the op checking. Default to success. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b85bc47c91a9..24547e36a56d 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -69,6 +69,14 @@ void fpga_image_info_free(struct fpga_image_info *info) } EXPORT_SYMBOL_GPL(fpga_image_info_free); +static int fpga_mgr_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} /* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is ready to @@ -83,9 +91,9 @@ static int fpga_mgr_write_init_buf(struct fpga_manager *mgr, mgr->state = FPGA_MGR_STATE_WRITE_INIT; if (!mgr->mops->initial_header_size) - ret = mgr->mops->write_init(mgr, info, NULL, 0); + ret = fpga_mgr_write_init(mgr, info, NULL, 0); else - ret = mgr->mops->write_init( + ret = fpga_mgr_write_init( mgr, info, buf, min(mgr->mops->initial_header_size, count)); if (ret) { @@ -569,7 +577,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, int id, ret; if (!mops || !mops->write_complete || !mops->state || - !mops->write_init || (!mops->write && !mops->write_sg) || + (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; From patchwork Mon Jun 7 17:23:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304175 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.0 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 4A335C4743F for ; Mon, 7 Jun 2021 17:24:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2ADF26105A for ; Mon, 7 Jun 2021 17:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230502AbhFGR0Y (ORCPT ); Mon, 7 Jun 2021 13:26:24 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33060 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230481AbhFGR0Y (ORCPT ); Mon, 7 Jun 2021 13:26:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5POgGzXgN4h++cWuVkMb7E0DYWkWN/zT+5ctpxHYXH4=; b=Lcq44TjP6keku/eoviIaP+15ps4FAqMR85BlLHFj0cc9UnxukFO1t5UpvThx7glL8SzaEI tiuuIaZaDtBuh/4ntBJnbPVNIbu5uQT9/KkSd0STSADV5i6UHEZmwnoTfHdNLDizdkxr+3 vbctgVv0Lad8ZNsbyhgQNP97VFEinD8= 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-291-DqDwYVUlNsWOuKdIOQdXZg-1; Mon, 07 Jun 2021 13:24:31 -0400 X-MC-Unique: DqDwYVUlNsWOuKdIOQdXZg-1 Received: by mail-oo1-f71.google.com with SMTP id v8-20020a0568200048b0290249f46c70eeso1084102oob.22 for ; Mon, 07 Jun 2021 10:24:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5POgGzXgN4h++cWuVkMb7E0DYWkWN/zT+5ctpxHYXH4=; b=lLyjPC/AAYhoFzo1BFPNuuH4TbhF8kxtD8YeaiQg3N3g8OvbCgHP5p5qmqBXP68os4 RO/aInOqP50/BkZiRMWyIHteUFJiTpoX7nSDKUNzQ6y4eQCk9vj61EHFcnt1+MX/qSkf PTwiRfG9QKzhIDzfW/8WeI5bTDETH1G+q92QDF3c9pEa1k9rPzY/IZlXbAgMy2KImj3y hYZ7IaEeuZrz73RzV5Fw9mqMgNdAwg0dRTgjKAYwMX8D/2pbVWLeUzaXTW/q2lfEDgg+ AMaPpliU4le3J2OYaqlbVHwqGgCGGmfgypP68NdHMyYOOW1XgmX9PuoVoz8T+GWH5t7n BoMw== X-Gm-Message-State: AOAM532CMqZnwNOiebw24WjN3ujgg0eLHtfxNwtOOFOJaxO5tHedWOrv U5x3G+978sb5KZBGPo8nlXC1JeeIEREacVlq+5gYSpbOeBROsIkw7FGUpUhxZ8qkmPnM92iNSKm lx6YDwWEdoyiGzsTFKcNNig== X-Received: by 2002:aca:4d3:: with SMTP id 202mr206173oie.9.1623086670702; Mon, 07 Jun 2021 10:24:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyErLrAs2nKUGQD+6vZuLJsm5Ds5EU5sJZCfJ1o9Ju4lJGFyG6X2XnaYzYSzpxZbczqt8XM1A== X-Received: by 2002:aca:4d3:: with SMTP id 202mr206164oie.9.1623086670568; Mon, 07 Jun 2021 10:24:30 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:30 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 2/7] fpga: make write_complete() op optional Date: Mon, 7 Jun 2021 10:23:57 -0700 Message-Id: <20210607172402.2938697-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board should not be required to provide a write_complete function if there is nothing. Move the op check to the existing wrapper. Default to success. Remove noop function. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 7 ++++--- drivers/fpga/zynqmp-fpga.c | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 24547e36a56d..dadad2401502 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -152,10 +152,11 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, static int fpga_mgr_write_complete(struct fpga_manager *mgr, struct fpga_image_info *info) { - int ret; + int ret = 0; mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - ret = mgr->mops->write_complete(mgr, info); + if (mgr->mops && mgr->mops->write_complete) + ret = mgr->mops->write_complete(mgr, info); if (ret) { dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; @@ -576,7 +577,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->write_complete || !mops->state || + if (!mops || !mops->state || (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index 125743c9797f..9efbd70aa686 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -66,12 +66,6 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, return ret; } -static int zynqmp_fpga_ops_write_complete(struct fpga_manager *mgr, - struct fpga_image_info *info) -{ - return 0; -} - static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) { u32 status = 0; @@ -87,7 +81,6 @@ static const struct fpga_manager_ops zynqmp_fpga_ops = { .state = zynqmp_fpga_ops_state, .write_init = zynqmp_fpga_ops_write_init, .write = zynqmp_fpga_ops_write, - .write_complete = zynqmp_fpga_ops_write_complete, }; static int zynqmp_fpga_probe(struct platform_device *pdev) From patchwork Mon Jun 7 17:23:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304177 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.0 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 D3EEBC47094 for ; Mon, 7 Jun 2021 17:24:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD86E610A2 for ; Mon, 7 Jun 2021 17:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbhFGR02 (ORCPT ); Mon, 7 Jun 2021 13:26:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54819 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230522AbhFGR0Z (ORCPT ); Mon, 7 Jun 2021 13:26:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086673; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SEbyFeW80QMIpdYKjW+aZzDgMZUI77VaMOflkO8h6rs=; b=GW1lMzHPTGO39PfVkZcUm/e5iTDwAj5AuVcrDayyhICPYKMTE6hMtHYXg6nVuojOF0A3i9 mtiOL5C4P5rInJTxsy/KJjgTYNQzkuRtkSUvLHSa2nldQzwf6vIP+JyfF/ZPL9NDrtVtiL vUDEmreSZPD4ndAn+Y2oxVNzQkcOXs8= 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-587-5qVw1Mn_O3SsO70dTuZ1pg-1; Mon, 07 Jun 2021 13:24:32 -0400 X-MC-Unique: 5qVw1Mn_O3SsO70dTuZ1pg-1 Received: by mail-oi1-f199.google.com with SMTP id l123-20020acad4810000b02901f1fb44dca7so4959676oig.15 for ; Mon, 07 Jun 2021 10:24:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SEbyFeW80QMIpdYKjW+aZzDgMZUI77VaMOflkO8h6rs=; b=rjsNW0B05AIZHNORJc0oSEcH4g1cpmqnjlKoHGIeyVDnBajUuZ2j58vlfI0+nCsZz8 fXlOA2nt3fWD5gjzFtVn0i6QFFPEhPLWnX5+2unskrLVAYxWr6mmlXuGU7KkZ0MC+F1j fQ+nicag0mqBQf0M29RXUV9uslUSfvsl+SKBGJkBiMHsTUfrazEKObjFw0DIe+XAnrFb NKpeJefMWck+i+AuiPrBRuebnkDXIePt8ZbGdMcVjnnMy8wRm+/Q2ljb+fzXYmfo4gF+ leZ253N1k0dVC+x98U8V9mEy+xJrfPFIbzk5r/jorA+h7LPXUikE6qKMnGIt8U/CyOf6 DKZw== X-Gm-Message-State: AOAM533zmQXwS3jyCmufXRMuNc4m1wo+qWqTJmr1hgVKpIog+ajLcqsx kghPihP/yLZ5jk1O6vrqU6Iepp6I9JfsC+j+YoYjCgRik4XvM7ivg16YPfKNOCwvePNM1S9mvaa h5FlZRI0kcSagx91AyS+rLw== X-Received: by 2002:a4a:952b:: with SMTP id m40mr14054024ooi.69.1623086672036; Mon, 07 Jun 2021 10:24:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzU4iBtCJ074OuzGQTVAEsS9VugipnW5FrZyj5UcXmgr+HN+HU4/UgZKKLwOvSNn74uqAKqVw== X-Received: by 2002:a4a:952b:: with SMTP id m40mr14054006ooi.69.1623086671810; Mon, 07 Jun 2021 10:24:31 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:31 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 3/7] fpga: wrap the write() op Date: Mon, 7 Jun 2021 10:23:58 -0700 Message-Id: <20210607172402.2938697-4-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board should not be required to provide a write function. Move the op check to the wrapper. Default to -EOPNOTSUP so its users will fail gracefully. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index dadad2401502..c484b4309b2f 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -167,6 +167,13 @@ static int fpga_mgr_write_complete(struct fpga_manager *mgr, return 0; } +static int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write) + return mgr->mops->write(mgr, buf, count); + return -EOPNOTSUPP; +} + /** * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list * @mgr: fpga manager @@ -203,7 +210,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG); while (sg_miter_next(&miter)) { - ret = mgr->mops->write(mgr, miter.addr, miter.length); + ret = fpga_mgr_write(mgr, miter.addr, miter.length); if (ret) break; } @@ -233,7 +240,7 @@ static int fpga_mgr_buf_load_mapped(struct fpga_manager *mgr, * Write the FPGA image to the FPGA. */ mgr->state = FPGA_MGR_STATE_WRITE; - ret = mgr->mops->write(mgr, buf, count); + ret = fpga_mgr_write(mgr, buf, count); if (ret) { dev_err(&mgr->dev, "Error while writing image data to FPGA\n"); mgr->state = FPGA_MGR_STATE_WRITE_ERR; @@ -577,9 +584,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state || - (!mops->write && !mops->write_sg) || - (mops->write && mops->write_sg)) { + if (!mops || !mops->state) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; } From patchwork Mon Jun 7 17:23:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304181 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.0 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 6A065C47082 for ; Mon, 7 Jun 2021 17:24:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 559F861073 for ; Mon, 7 Jun 2021 17:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231504AbhFGR0a (ORCPT ); Mon, 7 Jun 2021 13:26:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50657 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231347AbhFGR02 (ORCPT ); Mon, 7 Jun 2021 13:26:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086676; 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=sw7849LMLQbMNBNh72cG9DpmFetu7hYYk7CqmCZ+A8c=; b=WT5C8IG2zvNoAdRGRmgV9XTBr5vPBr9p1wP0Ff6XCIhKjhZoJQV7S8WZVQCr3/9KSPKXYf XlzqlUb4WVpqxRKXRBnEVUt9Act6ueIK4hWLnz+sjpz1Dq+drxHzl6y3520VKIfvbCZ2A4 O0Zv40ESkx1lozzxfTdKRobxUfOSYFk= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-160-pUG0U7nRMMSkgaIf1odxvw-1; Mon, 07 Jun 2021 13:24:33 -0400 X-MC-Unique: pUG0U7nRMMSkgaIf1odxvw-1 Received: by mail-ot1-f72.google.com with SMTP id w1-20020a0568304101b02902fc17224cf5so12035140ott.3 for ; Mon, 07 Jun 2021 10:24:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sw7849LMLQbMNBNh72cG9DpmFetu7hYYk7CqmCZ+A8c=; b=VNFlxUX5kszuJoQ3XN8KfGfk4fR/IYg+MDwNCCZawVrCBmyY5tznl/kPkjCFn5LQ/i NvTeYCbT+v5QPjgXSZfLdVmDqhjF71Jv6XzcGzLiqD859xy4p4YuM5r9uXO9x+rUlPV0 Tyn5bOpHUl62jqOJJvD6xbozhTormzOtYbtuaHfWOo4zu4EsieWVBq0B9HemqO4VfGuq refQXsA9KlsEdVP9D+qJnMrXR+9AMycdakFEOk7AppUog1af/kQ67RzpAywTV6YbBfjQ sgJ9Xaf+PNoDf4VkuQEzEEr8CCYB5opTKLa9BQV4sy7OkJSHuFKPqlPbbJi2b8Dq6axF dt0Q== X-Gm-Message-State: AOAM532FDSoGfRXKS/o2sPz7HsYkSDZt4bu2OWSonZIG1uGlCtsWfmkE iuUzaHO8AA7rg0t4WVrN1SBB/xKDGzM8WWDKh3jLJLt3SVNlLdAt+aUmWwyjhYWBltLEnUaHWDS 2xs2X0FuucbA3IYE+TzAMDQ== X-Received: by 2002:a9d:249:: with SMTP id 67mr14552434otb.356.1623086673292; Mon, 07 Jun 2021 10:24:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaxynMSyVdOH834Xr+aDUn5sjwj9lSK2uSYH4p7kRGsbU3UK3AsLkYepvXRVkAP7p0oedWLA== X-Received: by 2002:a9d:249:: with SMTP id 67mr14552418otb.356.1623086673160; Mon, 07 Jun 2021 10:24:33 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:32 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 4/7] fpga: wrap the status() op Date: Mon, 7 Jun 2021 10:23:59 -0700 Message-Id: <20210607172402.2938697-5-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board is not required to provide a status() op. Add a wrapper consistent with the other op wrappers. Move the op check to the wrapper. Default to 0, no errors to report. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c484b4309b2f..cc531f0537ac 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -426,6 +426,14 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } +static u64 fpga_mgr_status(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->status) + return mgr->mops->status(mgr); + + return 0; +} + static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -433,10 +441,7 @@ static ssize_t status_show(struct device *dev, u64 status; int len = 0; - if (!mgr->mops->status) - return -ENOENT; - - status = mgr->mops->status(mgr); + status = fpga_mgr_status(mgr); if (status & FPGA_MGR_STATUS_OPERATION_ERR) len += sprintf(buf + len, "reconfig operation error\n"); From patchwork Mon Jun 7 17:24:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304179 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.0 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 AF2B0C47095 for ; Mon, 7 Jun 2021 17:24:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 916FB610A2 for ; Mon, 7 Jun 2021 17:24:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231493AbhFGR03 (ORCPT ); Mon, 7 Jun 2021 13:26:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:34436 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbhFGR02 (ORCPT ); Mon, 7 Jun 2021 13:26:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086676; 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=G5k+k/BkzK0E2Fb8ne6IfEyRpjN4V1PdloHP6kDhHkg=; b=Fwx/+C/nkOgPIKyr9MjehFDGHSWV3mHMTjCKjrAKODwMf1Eq0CkyWeLyg525X9gmcQkSTk M4A5qwmoN7925pXdtJxwgraxrmyb23Fr2G1I5bQ2A1Pi0jZBHrHf/60ACEk22PA2+56mMl oGJzC1YAdLtg5koR9GRFHHb7Y3gLayo= 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-191-AKB6oE_ePPeRWzG1rBNPMQ-1; Mon, 07 Jun 2021 13:24:35 -0400 X-MC-Unique: AKB6oE_ePPeRWzG1rBNPMQ-1 Received: by mail-ot1-f70.google.com with SMTP id p4-20020a9d45440000b02903cf162bb628so9725452oti.17 for ; Mon, 07 Jun 2021 10:24:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G5k+k/BkzK0E2Fb8ne6IfEyRpjN4V1PdloHP6kDhHkg=; b=UPig/sgaj0J2fAvQ8PgFNi/vTa9jAnCdJXOmMg5YA37R0+WYUp/Vy370LgRNL9ykF6 7iJtHAVXEB690tJs03Pu9cenN5koMqsPkkQ7sSV55nTbLxh2VHC81DAQAvmb4P3mN+vC HZU171/zD+NCXTo3UHsryTN3UPrq9ftbrxMRCk1x3I1f8BfZic/CA/xzhF4VPHgOh2yc srSOqpD9qBvK3FiZ0l2v3gMp2RnJpMVATnCpdmZpGSyuB+PbTaHyDcK/Ls19J2NKTn/r B3VMysOjJQdgs/LAz4WGx827ukpTFgicTWphOKtT7vm6Pn8LtmgkIKuTWs2tQRzr1FvA J/2w== X-Gm-Message-State: AOAM533YTYF83LQdiK/ydlglYYANvGoGmoGCknqRD4wCN7AnYTc+8qPa KAS+ex6znHGE9kZr3iH7PG4CWd/2UtvXEqpZ7znFvJyTAdGwYLkqlkNg2tQKZ9nvBB3u2/oLybZ sfhg6Uo6fKAeCb2rcdLT37A== X-Received: by 2002:a9d:29:: with SMTP id 38mr14916717ota.30.1623086674615; Mon, 07 Jun 2021 10:24:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdkpS0Guz//cpGeFC9kznpgrVRbhlD0K8fyi/LgsZtWiEH9dfWzy9fSlnLDe0GSy4E+y4ipQ== X-Received: by 2002:a9d:29:: with SMTP id 38mr14916708ota.30.1623086674460; Mon, 07 Jun 2021 10:24:34 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:34 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 5/7] fpga: wrap the state() op Date: Mon, 7 Jun 2021 10:24:00 -0700 Message-Id: <20210607172402.2938697-6-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board should not be required to provide a state() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Default to FPGA_MGR_STATE_UNKNOWN, what noop state() uses. Remove unneeded noop state() ops Signed-off-by: Tom Rix --- drivers/fpga/dfl-fme-mgr.c | 6 ------ drivers/fpga/fpga-mgr.c | 11 +++++++++-- drivers/fpga/stratix10-soc.c | 6 ------ drivers/fpga/ts73xx-fpga.c | 6 ------ 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index d5861d13b306..313420405d5e 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -252,11 +252,6 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr, return 0; } -static enum fpga_mgr_states fme_mgr_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static u64 fme_mgr_status(struct fpga_manager *mgr) { struct fme_mgr_priv *priv = mgr->priv; @@ -268,7 +263,6 @@ static const struct fpga_manager_ops fme_mgr_ops = { .write_init = fme_mgr_write_init, .write = fme_mgr_write, .write_complete = fme_mgr_write_complete, - .state = fme_mgr_state, .status = fme_mgr_status, }; diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index cc531f0537ac..d06752be9c6e 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -589,7 +589,7 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state) { + if (!mops) { dev_err(dev, "Attempt to register without fpga_manager_ops\n"); return NULL; } @@ -692,6 +692,13 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(devm_fpga_mgr_create); +static enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->state) + return mgr->mops->state(mgr); + return FPGA_MGR_STATE_UNKNOWN; +} + /** * fpga_mgr_register - register a FPGA manager * @mgr: fpga manager struct @@ -707,7 +714,7 @@ int fpga_mgr_register(struct fpga_manager *mgr) * from device. FPGA may be in reset mode or may have been programmed * by bootloader or EEPROM. */ - mgr->state = mgr->mops->state(mgr); + mgr->state = fpga_mgr_state(mgr); ret = device_add(&mgr->dev); if (ret) diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c index 657a70c5fc99..5219fa1b555a 100644 --- a/drivers/fpga/stratix10-soc.c +++ b/drivers/fpga/stratix10-soc.c @@ -388,13 +388,7 @@ static int s10_ops_write_complete(struct fpga_manager *mgr, return ret; } -static enum fpga_mgr_states s10_ops_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static const struct fpga_manager_ops s10_ops = { - .state = s10_ops_state, .write_init = s10_ops_write_init, .write = s10_ops_write, .write_complete = s10_ops_write_complete, diff --git a/drivers/fpga/ts73xx-fpga.c b/drivers/fpga/ts73xx-fpga.c index 101f016c6ed8..167abb0b08d4 100644 --- a/drivers/fpga/ts73xx-fpga.c +++ b/drivers/fpga/ts73xx-fpga.c @@ -32,11 +32,6 @@ struct ts73xx_fpga_priv { struct device *dev; }; -static enum fpga_mgr_states ts73xx_fpga_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static int ts73xx_fpga_write_init(struct fpga_manager *mgr, struct fpga_image_info *info, const char *buf, size_t count) @@ -98,7 +93,6 @@ static int ts73xx_fpga_write_complete(struct fpga_manager *mgr, } static const struct fpga_manager_ops ts73xx_fpga_ops = { - .state = ts73xx_fpga_state, .write_init = ts73xx_fpga_write_init, .write = ts73xx_fpga_write, .write_complete = ts73xx_fpga_write_complete, From patchwork Mon Jun 7 17:24:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304183 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.0 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 D72B8C47094 for ; Mon, 7 Jun 2021 17:24:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF8E8610A8 for ; Mon, 7 Jun 2021 17:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231519AbhFGR0c (ORCPT ); Mon, 7 Jun 2021 13:26:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37148 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231480AbhFGR03 (ORCPT ); Mon, 7 Jun 2021 13:26:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086677; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=laSi6Idv6MJlRydvvlMqTdjYXdoIYW3EUNa0fNYB5JY=; b=OveqWjvpBEAseSyH2/RrB/h/706n0cfVit98UBk6v0xA3U+Zx5slvH3g2xk8h8jiXmW3Pr NLGA7dSDSgba4zlVVFfxzIPE+D7ZOXeYVK2chXZ3fEki+O9E3wKlXwhrc2h2uHQvGIb+NM qkvC+uxg2EEOvcrl5xPtI9iqprDkNoY= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-92HK_s9SN_qj6XXYXDCWIQ-1; Mon, 07 Jun 2021 13:24:36 -0400 X-MC-Unique: 92HK_s9SN_qj6XXYXDCWIQ-1 Received: by mail-oo1-f72.google.com with SMTP id 3-20020a4a03030000b029024950bdb69dso6435214ooi.3 for ; Mon, 07 Jun 2021 10:24:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=laSi6Idv6MJlRydvvlMqTdjYXdoIYW3EUNa0fNYB5JY=; b=Tl+AJiKqJRNwTZla5Yk9qzEcsLOY6QKaYZwTivIzV7YSlvg4RYAPgtDQtqgPLBT43e VXgsnXgQdwK8ujQQarzCij9dal5ypBIiR2YzavtsYLp5Dvowbc/CbxDaZ/BSwYRk8PXJ icerZUU5E+gmUntEHB37AV5Hs9ck07HawwWtRvyaMwXvOokpem7oIiGSfatyAzN7OEhk 0W1cGZGUc4VgOJNQ7GcsEqwHt+JV4qNstW21TGPgkoOMQ8YSozvJNIbM8u/r/xQ3vFlO VZ8VbDjRKz0qPHyHawdy1a59cHvS0xgSZLCt+Gsgq+A2htb7pZviUzmhFZZA9ch9Jaim zy1g== X-Gm-Message-State: AOAM531F/pBApHGV5jT/TKVoADv0PIji4F5tsmnyj2aRR7ZxzIgNgp/z 8pnLSZpT2hjMwZWEqV45I/fuh1IArClawUgxskiRmToCBPpkPIUroC4eouSbRqAHnox6wkDvhVM M8Q63sa3hBhKVeXnFtXoWiw== X-Received: by 2002:a9d:289:: with SMTP id 9mr14127917otl.10.1623086675885; Mon, 07 Jun 2021 10:24:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0Mxu9OWeXq29nlPkEMpqQQx4J506+qxFfVHTsHRyJukzcKWG9aLTPxri3PNB8lw79Q0A/dw== X-Received: by 2002:a9d:289:: with SMTP id 9mr14127899otl.10.1623086675698; Mon, 07 Jun 2021 10:24:35 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:35 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 6/7] fpga: wrap the fpga_remove() op Date: Mon, 7 Jun 2021 10:24:01 -0700 Message-Id: <20210607172402.2938697-7-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org From: Tom Rix The board is not required to provide a fpga_remove() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index d06752be9c6e..84808c7ca440 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -731,6 +731,12 @@ int fpga_mgr_register(struct fpga_manager *mgr) } EXPORT_SYMBOL_GPL(fpga_mgr_register); +static void fpga_mgr_fpga_remove(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->fpga_remove) + mgr->mops->fpga_remove(mgr); +} + /** * fpga_mgr_unregister - unregister a FPGA manager * @mgr: fpga manager struct @@ -745,8 +751,7 @@ void fpga_mgr_unregister(struct fpga_manager *mgr) * If the low level driver provides a method for putting fpga into * a desired state upon unregister, do it. */ - if (mgr->mops->fpga_remove) - mgr->mops->fpga_remove(mgr); + fpga_mgr_fpga_remove(mgr); device_unregister(&mgr->dev); } From patchwork Mon Jun 7 17:24:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12304185 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.0 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 5FC12C4743F for ; Mon, 7 Jun 2021 17:24:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44F9561090 for ; Mon, 7 Jun 2021 17:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231222AbhFGR0c (ORCPT ); Mon, 7 Jun 2021 13:26:32 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38608 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231419AbhFGR0a (ORCPT ); Mon, 7 Jun 2021 13:26:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623086678; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tiUiVni7HRdj/fMNccMqDWFIL2bqdt7yewe5StEQKT4=; b=HQQGv6mIytMd7BUnIy67/R/p6DsptBa1RwESHBsND7Qx28fcBo7BQBbv3m9LZSNp7D27zt uUtXWIPLHfuYupyGnAqbsKaZZJGy8NsAf3Izqo8GlYIrYBNoUIQ6TD9FDv9gga5i+gqy2k HOoa8/wMZv8I/m3vdjxWrpFGS2mPuTQ= Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-20-uIDnbsZgOaaYjd35k--VjQ-1; Mon, 07 Jun 2021 13:24:37 -0400 X-MC-Unique: uIDnbsZgOaaYjd35k--VjQ-1 Received: by mail-oo1-f72.google.com with SMTP id b9-20020a4a87890000b0290248cb841124so9400243ooi.4 for ; Mon, 07 Jun 2021 10:24:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tiUiVni7HRdj/fMNccMqDWFIL2bqdt7yewe5StEQKT4=; b=i6rRYVsNHRecJsVNCaem0lji9SgXFNgWJlHjvQ+ugkaKk4Y5I6lazP1HG+7U9pMJ5K megpvl3MSeUPc+YES50paieaqfaj0LHR5HmkI/8vllDZTwsB1YrSURTYfM1DKBB2vp1g /hDG5Ktz45qb2eNiaxpXMxoIPWEW4mYxprJ+rQlxHeyqh9XPKu7kEUYnGj9IQGyl0PqC 8CjpX88N7aKyFbxqGkoXKETmQ7UHxbR2EV9X9YS6KP6HvIIxJSXkPG/YQFo71Ax/D81X ui89ei2g/6ljtPSFj+CdLkiDwuaLRkFdDoPhpavh3M0M62WIljSvWfO79eGMob99SaVo baiQ== X-Gm-Message-State: AOAM5335dz5d2JTkWmttgEvz9Ui1P7WCjsFOiNCnsY+bB+NQwapIK1cF 76W+mRf95wiANc0MxdzYoQAP5RsWpq343etXZj2O2Iszy4+GFN8LFN004Jq9ZGVVLR2JG62udQj 5m41f8RU825ZGMUMeXJr7qA== X-Received: by 2002:a05:6808:985:: with SMTP id a5mr156775oic.42.1623086677110; Mon, 07 Jun 2021 10:24:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzX3CF8WfnS+aeD9xD/trkVT+VJIk8ws9Dd+CpNLkE8C8DuDcq2UDWOfKRoaNzbTM3tQfIkeg== X-Received: by 2002:a05:6808:985:: with SMTP id a5mr156764oic.42.1623086676962; Mon, 07 Jun 2021 10:24:36 -0700 (PDT) Received: from localhost.localdomain.com (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id 15sm2409859oij.26.2021.06.07.10.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:24:36 -0700 (PDT) From: trix@redhat.com To: hao.wu@intel.com, mdf@kernel.org, michal.simek@xilinx.com Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tom Rix Subject: [PATCH 7/7] fpga: collect wrappers and change to inline Date: Mon, 7 Jun 2021 10:24:02 -0700 Message-Id: <20210607172402.2938697-8-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210607172402.2938697-1-trix@redhat.com> References: <20210607172402.2938697-1-trix@redhat.com> MIME-Version: 1.0 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 84808c7ca440..198a44a62058 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,65 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +/* mops wrappers */ +static inline enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->state) + return mgr->mops->state(mgr); + return FPGA_MGR_STATE_UNKNOWN; +} + +static inline u64 fpga_mgr_status(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->status) + return mgr->mops->status(mgr); + return 0; +} + +static inline int fpga_mgr_write_init(struct fpga_manager *mgr, + struct fpga_image_info *info, + const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} + +static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) +{ + if (mgr->mops && mgr->mops->write) + return mgr->mops->write(mgr, buf, count); + return -EOPNOTSUPP; +} + +/* + * After all the FPGA image has been written, do the device specific steps to + * finish and set the FPGA into operating mode. + */ +static inline int fpga_mgr_write_complete(struct fpga_manager *mgr, + struct fpga_image_info *info) +{ + int ret = 0; + + mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; + if (mgr->mops && mgr->mops->write_complete) + ret = mgr->mops->write_complete(mgr, info); + if (ret) { + dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); + mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; + return ret; + } + mgr->state = FPGA_MGR_STATE_OPERATING; + + return 0; +} + +static inline void fpga_mgr_fpga_remove(struct fpga_manager *mgr) +{ + if (mgr->mops && mgr->mops->fpga_remove) + mgr->mops->fpga_remove(mgr); +} + /** * fpga_image_info_alloc - Allocate a FPGA image info struct * @dev: owning device @@ -69,14 +128,6 @@ void fpga_image_info_free(struct fpga_image_info *info) } EXPORT_SYMBOL_GPL(fpga_image_info_free); -static int fpga_mgr_write_init(struct fpga_manager *mgr, - struct fpga_image_info *info, - const char *buf, size_t count) -{ - if (mgr->mops && mgr->mops->write_init) - return mgr->mops->write_init(mgr, info, buf, count); - return 0; -} /* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is ready to @@ -145,35 +196,6 @@ static int fpga_mgr_write_init_sg(struct fpga_manager *mgr, return ret; } -/* - * After all the FPGA image has been written, do the device specific steps to - * finish and set the FPGA into operating mode. - */ -static int fpga_mgr_write_complete(struct fpga_manager *mgr, - struct fpga_image_info *info) -{ - int ret = 0; - - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; - if (mgr->mops && mgr->mops->write_complete) - ret = mgr->mops->write_complete(mgr, info); - if (ret) { - dev_err(&mgr->dev, "Error after writing image data to FPGA\n"); - mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; - return ret; - } - mgr->state = FPGA_MGR_STATE_OPERATING; - - return 0; -} - -static int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) -{ - if (mgr->mops && mgr->mops->write) - return mgr->mops->write(mgr, buf, count); - return -EOPNOTSUPP; -} - /** * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list * @mgr: fpga manager @@ -426,14 +448,6 @@ static ssize_t state_show(struct device *dev, return sprintf(buf, "%s\n", state_str[mgr->state]); } -static u64 fpga_mgr_status(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->status) - return mgr->mops->status(mgr); - - return 0; -} - static ssize_t status_show(struct device *dev, struct device_attribute *attr, char *buf) { @@ -692,13 +706,6 @@ struct fpga_manager *devm_fpga_mgr_create(struct device *dev, const char *name, } EXPORT_SYMBOL_GPL(devm_fpga_mgr_create); -static enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->state) - return mgr->mops->state(mgr); - return FPGA_MGR_STATE_UNKNOWN; -} - /** * fpga_mgr_register - register a FPGA manager * @mgr: fpga manager struct @@ -731,12 +738,6 @@ int fpga_mgr_register(struct fpga_manager *mgr) } EXPORT_SYMBOL_GPL(fpga_mgr_register); -static void fpga_mgr_fpga_remove(struct fpga_manager *mgr) -{ - if (mgr->mops && mgr->mops->fpga_remove) - mgr->mops->fpga_remove(mgr); -} - /** * fpga_mgr_unregister - unregister a FPGA manager * @mgr: fpga manager struct