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: 12308067 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 2765AC47082 for ; Tue, 8 Jun 2021 19:58:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E8E1A6024A for ; Tue, 8 Jun 2021 19:58:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E8E1A6024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=a4hV4VROBEhPxk/N5mmLrGy/HWBVGAEDts2396VbtI0=; b=GXUq2i/tuS+2Ft RyIxiMcPbGqfRyeY7sQI0iU45rYahN/tMxaq/USMT97RkXLxakqQxXFWmEA2AMaLejoNgTH7txtP9 JDZ/c0XlXdULK/OEXEQ8I6Tl9bhlaBQycm4n+Ikm3WB8wRgaY034OcKz3GRFldf8EUSlUnwoj6uiY bb+7YGL0CRgamD57k7nV29qOQjAwbKsUnW3/p8kApHBTFoyBt748kMV8gKhnzMNfERHwhU3LMHJ62 y7YTjta7ZjxeyGMCdKWMfqUneQBqltTHV6D4lIWP4wHTr4iVcxtAqCq5QEXu6uZizqRHk+jCdTtSy YYjtPKQre08FuHiq1s7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhpK-00AJOh-25; Tue, 08 Jun 2021 19:55:54 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhok-00AIhV-Mh for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:20 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FcdIlm0NN5VNBYEPRLo+XaYQu2TJXZBESFHXWMw15dI=; b=URdPGHr0JOLV/AnJs+iDZked/7PM6Bxs9IwlXpuheITgK5CPY+QVAtNqH7KAKTjOs7KUH1 SvS0b3QtRIJm1se4GYi/gY5cbPeo6qXB2pAwvnfu38lo5ruymTIXDIkK+X0FVs9D3EDn3w Z+LIS0UVm3Z8QxpCWHcy6eFrENpnH2g= 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-144-hrR4f0zNMT2Epp8a5v09rw-1; Tue, 08 Jun 2021 15:55:14 -0400 X-MC-Unique: hrR4f0zNMT2Epp8a5v09rw-1 Received: by mail-oi1-f200.google.com with SMTP id k11-20020a54440b0000b02901f3e6a011b4so4713211oiw.23 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=DC4a89qoBYtP4GgxKum4LGwfDpKB6OhSfGo4kDJTsCfSQoqBgGPfYFz7DIcRloSsbt h+OWpW5Xz/6wzu+5IsN3toBsQDtU7rpn6ver6GwlPPZcxA3Ta1PxrSi0hiuoNe2X32KR SlvPHRNXP2e3FBZGBwPSJlcaOBAGvRXEOspPXk+rMmEjZeIIWdFTRW0Vb6TqwZOXzlwW 8748/QyuE/vJnT5C8t4tjqNUXw5xoZk+Po61KsFMmnwzPUz93mkKxi7BF3EFIeGLdifh 6qXc3o8ANeLj7MELH69eDjh8nctygIUHad5c/uqCXgETu1soOtAbWN6xXQ0bQslrLGAL extw== X-Gm-Message-State: AOAM530rIuqEOpkSYsaiPt00BJa/ME4omdv6Gx3SIUWTkQDNXD29K2qB Ct/usQJHlI+/itjvlTlZwD0c8uolDNQitDP4qMRZ+K1s+gXJlCgDtIZPj9kG4T0f8AteyAX9uU0 fR3wMpxxEXM2vay+cccAXwJEPHChKQorstRs= X-Received: by 2002:a05:6830:1196:: with SMTP id u22mr19013067otq.247.1623182113793; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125518_872382_119EF092 X-CRM114-Status: GOOD ( 14.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a write_init() op if there is nothing for it do. So add a wrapper and move the op checking. Default to success. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308065 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 3D5BCC47082 for ; Tue, 8 Jun 2021 19:58:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 130A56024A for ; Tue, 8 Jun 2021 19:58:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 130A56024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bwrbkhBqjlIXbNXfRvx8/4rQfrUSIMDwi5ZydB5Ur+Y=; b=JLNFkDEkityp5V oTFabXEwui9lXjn8L1MROTMpJ78h2a9RxWJb8O5ag4NzKR1bl1xfZZ3qb1mFXUH7j5/TUiS5nYS4x fjLAchmQQTOSdbiqsMRk5IDL5Jvf/ctcld+3mMWLCU0FViAepTSOPUoL3g7cCBU72LvA3WBUec3GL e0Kzsz15ain/evHFUW+r6lASSF05ZgWsKVNLXaujbnwKVTXO4EFvoLqDJJDTg8EEsUNb0IJsUBlSw ih45zXdaX6xGgib7JBYG2YJPNcQn6LaJbPq4TytxcpI93sEyopJ7LnrCmpTyuSB5oSXE8OP1uBAsI YPfXkVWEAtdA1RlFestw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhpq-00AK6Q-QA; Tue, 08 Jun 2021 19:56:27 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhom-00AIiM-0p for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:21 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ik8JGUYI3/+hbO9x+DDmD96jPOqQ4zVk4ycCcPjNv+o=; b=GTCkQ0CEbe6tNUS+r8exj5ZTbYCPS9h69WuXdoTCd3QVYhxqhsqpNhg9HbAhZjLYyOXD7Z qBbDLpbyzT8F5kFV5LE8up8bpaFpuseaYdDua3CYqr0Z7ApR/GD9wY/BZ609EaB+/19w4d U3nfQY+JYdzDhFyrztxXKAmil2KfHRY= 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-200-HVY2EN5kNBWB6yglVgFn9g-1; Tue, 08 Jun 2021 15:55:15 -0400 X-MC-Unique: HVY2EN5kNBWB6yglVgFn9g-1 Received: by mail-ot1-f72.google.com with SMTP id 88-20020a9d06e10000b029030513a66c79so14700647otx.0 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=XafGrXpGWTgUB2ibTmEJBM0kemug18skdxqHi/4YuzDvUqgdJLX5c86zZw4Iob8tTs bWi6Qp8t57/Ud0HYYOsGYnmKED/mQbAVqLRR82ytQX6GmoCgdDTCLU5N2DDNnkgZoj7v 8gJ+sl1Y+nfaimOvg/Jyixu2iZvuGp4ZPnunt0GbfSiGCeZLcGsYI0XftCqzIhOMeAxO GgGGvjpsvKY12EkzyjH579DJnrQwZ/aGMcxF+2/UqClGmOFDTpwiLbcAoIecKKslOx2r LJJ0Y+55MvDLWxBKngsCgHJHmhFC+Pxgemq+y2dzh/LYTPB8JwAdeiMz/i0dR/eiRyxE 6gfQ== X-Gm-Message-State: AOAM53095dg4cqx4CNcMe78nbJo6f9G//kp00uFDWFfY968jq2lf4+fJ 3NAi0bGWvQNoh8Fnl79Hnam8XUBZj9ySBLKnUjgjiXEAUOuoAJRHhWZCeohpQ5emVlI6l2PJnFN twS8e7Z4zqya0iHY4AaShTn7Taz/BydjeJic= X-Received: by 2002:aca:1a05:: with SMTP id a5mr3820095oia.26.1623182115009; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125520_248637_3A79F6A3 X-CRM114-Status: GOOD ( 14.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a write_complete function if there is nothing. Move the op check to the existing wrapper. Default to success. Remove noop function. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 7 ++++--- drivers/fpga/zynqmp-fpga.c | 7 ------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308063 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 9FEA4C4743F for ; Tue, 8 Jun 2021 19:58:10 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 686046024A for ; Tue, 8 Jun 2021 19:58:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 686046024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zkn83wFmoCJSyph5ejHYFbfDFyZQfizLAHEA1GD0Hfo=; b=uiVe/YQol016gZ +yBE8FzcXcKZCN5crxHL2LLMOBDY3DoSDhaKhjti/A6dDYsBMXi4UgqqCxzDDh8LK9+EAmYOe31mv p4hvVsTkASchGupVVnMvznwSU20jQ1AH8d8SuX1kj6NxbYgwVkhyXKprYWtu10KtaOslaxvpKmR2E niXAeLJ8YpGFHbCOow4GOfOs8g6M1MckAlGOCEei7PBiwfBQ+xyCzEG6njn3H5Vv1XyNcxHpQCRgf 73y9r4YfnN7L6FDIudgo1zQI9xCnKGK1fpbZETiHUNme+fN62BiN53W3P9//H9Cn/pWlc/CN0zVA/ e/CdgZufAo0P2fElSfJg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhpZ-00AJkU-8k; Tue, 08 Jun 2021 19:56:09 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhol-00AIhw-IM for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:21 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F+ieZpNx5CLGtvApXLWeUj3JhBAH5I6pceFuxGmJ04c=; b=aW1Ju9fn9klY+i12pZ3mYxo8xqV7vDjMFK+RkTLr6VC3swvbAVen2K16Z7dtD/1b6bu7nG ojy15X9wtaKbYjcT5xxJbgII8Gq5WrFb2FVMvVVw8rIp1dqKeSq8uKMjrFqqXQgeNJ6HkE +pGGzfKKpZSWISMitKmbUNr3WcCtrQg= 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-403-iq1BRAZyMJWWqt-7Tq0kWg-1; Tue, 08 Jun 2021 15:55:17 -0400 X-MC-Unique: iq1BRAZyMJWWqt-7Tq0kWg-1 Received: by mail-oi1-f200.google.com with SMTP id l136-20020acaed8e0000b02901f3ebfedbf2so4454660oih.11 for ; Tue, 08 Jun 2021 12:55:16 -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=Ob5rD5fUkMIqfFH2wbRfld02Ga6vadlwQrd2aiI0DKe47Znqnze6I6Ts/e7w+oWaYi T6SSKtFOqAkFG3sL3lZb069fs18ae1OtOVC3yA67ntViQvMwRNcXT7cj5XnfyPFUtd55 Iy1rNQ5BFxayEYUHImCO9LwWn+Sj5+4K9mqLi6vwRzvWdvRsk2vMXyMto/h3wLRkqPFT OXoeFktjPOgiwiTvG7vBN/O1Zmc+X9EQQiwIS2Gl3iV5i7Dic/CUrNFCIiEhT3x5mIvn XkqtApDIbqX1C6rF4D+D3vm9kQeK+8U1ICJrGZ9nptmt010w6xi4KKg0r4sk8myzo0Pc VUYg== X-Gm-Message-State: AOAM532LXZki9BqWU1SY0AQaU+4NJ9RCma/S90qleMfQwM/t/f1qK/ay rzgFqCiuP2BnvNcIso5WAMDs8nPvJ5fB6Mrtx0zd3zLWZCpsgPAp6prKbJYV3E5aEfLe3LeIYY5 pQHeOzhpGpyto6qbJlGhb+jK7S7mti5/HeKk= X-Received: by 2002:a9d:6d01:: with SMTP id o1mr3273295otp.285.1623182116397; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125519_736406_7D146A4D X-CRM114-Status: GOOD ( 13.78 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a write function. Move the op check to the wrapper. Default to -EOPNOTSUP so its users will fail gracefully. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308069 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 2BCA6C47082 for ; Tue, 8 Jun 2021 19:59:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E5B536024A for ; Tue, 8 Jun 2021 19:59:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E5B536024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RJBeZSXGxpUL0c0tJUmMbi/tZCjlEEnJKusKI0g60z8=; b=k6hheyPPgnJZYI Trbej3jvBVO9mhVUYLhVvm0l+0xODVNfbs8gxPkCDELyHGL92rFB3nFokzNYnc2BEgwzCORetxr+m XFL795Hve2YyTlVuiC7ecNPnRfxmZMleaY1aR++o74iYHgH1m9c7CCc6AHzA0YJselBBpn7TAx4n2 NcA09C0hOhVc+PO+tcw+oINNomqDdb9mRg6VyDpGB92Qt6jwi0mqcqF1D+jWLRnH+B7GiDbWsVDul KH5wSnP5n+NY88Ps5Vg+VlCkQS9Z0b13IrlQl4eKzWs7ZVRm9ligYAtneitw/ygruZAsPCJvbY/et V5P2IweFSIFMWCjMK5vA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhqL-00AKTj-AN; Tue, 08 Jun 2021 19:56:57 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhom-00AIin-Hj for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:23 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=htxg7QFhlugIkUjEBRB6MmryeZkakMXu7uhWLDq62MQ=; b=e5vVPMZQOjd9/476FXYGPR+h5gHpqseZg6paLoxBC2pZ/dftCiNK2dGsHOWQZ/XXYq6mlf WpjE8+a30srWmPhvifMYFpe2n7P8wkafjaTZtvkjgS9S571hGcTjJJQibc5VzTEZtDaI5V YFnjttPpI+8rebH+dlURNyMrcdIWFNw= 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-506-r34K9cMMOfGrusT4BIU7PA-1; Tue, 08 Jun 2021 15:55:18 -0400 X-MC-Unique: r34K9cMMOfGrusT4BIU7PA-1 Received: by mail-oo1-f71.google.com with SMTP id o21-20020a4ae5950000b0290211a73e7f50so13946597oov.12 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=Df7ptTJ70tHvgfBaUikhKWhO5SyxzkkTo3pEBy+eNLne+hKAmr02jXQXq3gVto1uUo I8/7SCA+jiH4wEYkhRxOcl/qIG5CbDeoXIz/aqPWYbFsnCN50GI3HrYkf0SdZxiEsaqI i9qAhQGXsA3ffjLDH9vHXhrY7WuTjFFRwZB1dVkvRoSp+7mLa2PRilje01NaYqKBegEq MkLNARk3GJFrmpnwBBcVG+F//tze633pdz1dFGjlPoPvc1YfiA/WZj/j8h/4mtJzdFMW u+2cZ9e5ElYgMmzpfp6ajwCoWkCQYFvQPU6qQ7K5hHKTp1GhAIpx//rxBhk+5L80H16j Lbwg== X-Gm-Message-State: AOAM530pvPy0pRpVaCQ7P62pVmZYZU7hHixL2m16dTPdyIXnM1CqfEDK OtXDKJLosVi+/9531wQZ0KctA8L5uHwDc3gmbpnPh5xLeR0zuddJwcVfTIYOoX2HIE1PBhltiGJ LuTqS54z4tYr+FDhTJRTMHf8HWwSk926u81w= X-Received: by 2002:aca:4703:: with SMTP id u3mr3955501oia.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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125520_722206_687E5699 X-CRM114-Status: GOOD ( 12.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager is not required to provide a status() op. Add a wrapper consistent with the other op wrappers. Move the op check to the wrapper. Default to 0, no errors to report. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308071 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 B7A03C47082 for ; Tue, 8 Jun 2021 20:00:14 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 82C836024A for ; Tue, 8 Jun 2021 20:00:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82C836024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1Rmp6UANmWRyNXh5ZByxA+zSXxApPSXx9ikU4Q13zbA=; b=QmvIWDTRch7PJ2 HbrAQyZBCBJG5wp9clKuzUhHtziELP0ihbRGs1cmdaDHjbHTqZG6g8y+jpggH6BMc41sogHHM4J39 U0dFXc6hUBnmCuktpAeD4XvjVt8MR0HDV1LmeY3F7XXTgqmWQgGoULnAKaTloNTOSO10UexO7Hfjc 4Au6jYnw+CXXbbV3ZKPpwx4E15ddgIOpgeeXiph1XwQyIbckURmXGHb7Eyx/dO8xdAzU6+rPQ29vZ M0PGFiR+cw1qI/cuLmAPpiI7YLd3Up+mOh3Cf/74B7VIUN6ibrX43BOxFpV82UQsfAg7jhJiq/1ZZ AgIeEtt1wYSzOMKxjN0Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhrK-00AKtH-F3; Tue, 08 Jun 2021 19:58:00 +0000 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhoo-00AIjw-4y for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:24 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KD9jjN3L1AODL3xYyQk4Owi0Be8ipyYlfv9872RELmE=; b=EUVRdcwqY1nBJtgZYZGP5ybubJ2ktbGp7ZModTBRKSU/1Av7VIjnv/Haj1XmuU2WsUmNbf n1ex+Iwx28HMN5/pV4wxskrzrvB1Kjn6IQsFALIlYaAmmhEukru4OYdTLA/AFUQojMXkbE prrwls0ftBHpERSqAft9X4zRPDYIs2M= 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-275-VGrlCXUUMFeZ2u6w8KgHgQ-1; Tue, 08 Jun 2021 15:55:19 -0400 X-MC-Unique: VGrlCXUUMFeZ2u6w8KgHgQ-1 Received: by mail-oi1-f200.google.com with SMTP id r5-20020a5448850000b02901f4271c7d03so3077360oic.4 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=aYyqBv1pKW/flJrwxMTXQ2O7DRXWHmF9LYKrVB5EP1MnmdS+LYujDMsdfKGViDQQlY 0hw+QxqQW4KP04a2prHgMa2OM2AdvadqHQEuWweXstUNSld8JCxe9O88GMDdcNgv2oGc tbgQpZCQ8GO6AvOaeWp2cmeIe2awrZgF16/DBGRbhAAGXEHUKPrFdXkWfL8un+1P4qr2 K+SDQUWVZ3HVaTXylZApgM1/6yiCqFS4O0uzxEA+jLXfAhCMiULRzP7Mo3/We1cqAG55 GdBGLlkuuHblq1OXFqjfFOZAZ+pgNghBvhpJ1+/pIhKCWlh/Jx3AIbl3KK18jfZ8HShI RrPA== X-Gm-Message-State: AOAM5304PJxFDPE9DJ0f9dwF2xrtiCIzF3Qc05wAKJKL92EaT0VaENcX UvxDb3DOfbH9ipppFRK0PZ83IWopP4fx0WOvGebf/xhiQNwXwwRDd0V0dcWjtthHPaGvguiqONy Ih8rFOHvnKd+RcTuXM/mXC9q9nmiwfwEHX/Q= X-Received: by 2002:a05:6830:1155:: with SMTP id x21mr19421576otq.303.1623182118956; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125522_357521_AE0ED30E X-CRM114-Status: GOOD ( 14.29 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager should not be required to provide a state() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Default to FPGA_MGR_STATE_UNKNOWN, what noop state() ops use. Remove unneeded noop state() ops Signed-off-by: Tom Rix --- drivers/fpga/dfl-fme-mgr.c | 6 ------ drivers/fpga/fpga-mgr.c | 11 +++++++++-- drivers/fpga/stratix10-soc.c | 6 ------ drivers/fpga/ts73xx-fpga.c | 6 ------ 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/fpga/dfl-fme-mgr.c b/drivers/fpga/dfl-fme-mgr.c index d5861d13b3069..313420405d5e8 100644 --- a/drivers/fpga/dfl-fme-mgr.c +++ b/drivers/fpga/dfl-fme-mgr.c @@ -252,11 +252,6 @@ static int fme_mgr_write_complete(struct fpga_manager *mgr, return 0; } -static enum fpga_mgr_states fme_mgr_state(struct fpga_manager *mgr) -{ - return FPGA_MGR_STATE_UNKNOWN; -} - static u64 fme_mgr_status(struct fpga_manager *mgr) { struct fme_mgr_priv *priv = mgr->priv; @@ -268,7 +263,6 @@ static const struct fpga_manager_ops fme_mgr_ops = { .write_init = fme_mgr_write_init, .write = fme_mgr_write, .write_complete = fme_mgr_write_complete, - .state = fme_mgr_state, .status = fme_mgr_status, }; diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308073 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 C8DCDC47082 for ; Tue, 8 Jun 2021 20:01:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9A4D96024A for ; Tue, 8 Jun 2021 20:01:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A4D96024A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SbPGE0i6l9Qel625wx0eJ+oyg68DGe0Ao4u6n171s8k=; b=dykeCQs3iD+J9s zpkG9qLj3n2rCbnsdQev1sqwZfpb3mYYW4RoKyiV+z5HHuc0Cru15muGPtXBY4osms9+CvwF03hal kQYyqAI+ghCaN4oqvz3rIJL+CfC05Fekb2kVAhY422+u2gZp3j1dm2RXroi23tXbxBVwhf3LmzzJH TxSIItLWU+zYEbGolz6OmSYAws69R6kl5M/IDG1sqdQdR8rDNaL1h6SGBdF3oZ4BU/aaBkBZosN98 YE3F85q84STkYAHjN7I7k3EPud2J2xFXxsvCKFsPom8qXAzbvknhfLWJtg2KE+EyfiTf43cFvf8UD kudK+8Q1lMXnyVDHsyUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhsY-00ALQq-8r; Tue, 08 Jun 2021 19:59:14 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhoq-00AIl2-1y for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:26 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ub84QQXk/80gOx9jVYvQgeu9ZbjU0KtFBnV/GBkRc70=; b=SdR4QMf/4fc1OS2NkouV3IVdxgRE5x/hyIB4Zp2yFzI/IDRB4YcQ8WgBgd69fSEuxFkR86 aTexhU1Mi5/FfF+UYcao5t7e5HcnexdUbU2WY6dAZHX5E0xRNVSYfXGAPWvl4Muxrq0GHK A9zHvmPXomu8YBH/q5ELTwEgb/tMY3c= 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-384-aaFwETXnPnaDbXsBEAFlLw-1; Tue, 08 Jun 2021 15:55:21 -0400 X-MC-Unique: aaFwETXnPnaDbXsBEAFlLw-1 Received: by mail-oi1-f198.google.com with SMTP id 82-20020aca04550000b02901f40670cf75so3417483oie.19 for ; Tue, 08 Jun 2021 12:55:21 -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=taNlOiLo1WT1SMhbrr5s0Q6ek7o1ccz1RtWtg5dk9beoj6TWrlL9znAOBnw7z2z4Ts GcuLnW8U+AGUEn3sRUE01cUYvnexDdAXn1YWl7RaZnQ5UOPu3sYMFU9luTzn+xnmGg/t aTQV+FKa9eIuIGPHDtX98oKBfAfD7yAwVPqtE9KjPSs+/em8hxMR3yT2tmZy6IwA9EfN xoTJHBT6j4Xrzd7ah58FWLbp9cJIIC5jpZtne6mSuaCvp3jW7c0af/QNb6kl1Yp5jxT3 8wqnjD/Xo++D0ONov44jcP+/luobWzk8izHJh4xJu9ShYB1+vk5zGUmWNczUoz5HX9R/ bZjw== X-Gm-Message-State: AOAM533zc3gvKyDrXsMUIoihOkRQ78uV40/99cX8vlejXUA6sJYbxFyP 5xMwLoL2ojv3n3ijPTn4bKqKU+uYmyghudnJd4/LCWlZNWrhtLZl4fnm/YgN1pCYjvoJ8pvHzm8 R9oQhh9KNWnCi61UZeYeh/fhNFDLdT4Xz4Bo= X-Received: by 2002:a9d:2904:: with SMTP id d4mr19095279otb.238.1623182120327; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125524_222647_2526B82C X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix An FPGA manager is not required to provide a fpga_remove() op. Add a wrapper consistent with the other op wrappers. Move op check to wrapper. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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: 12308075 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=-16.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 DF6CAC47082 for ; Tue, 8 Jun 2021 20:01:35 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7B0F61008 for ; Tue, 8 Jun 2021 20:01:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7B0F61008 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VjMu6MttTh2XGU78mY6G85XMYJCF7/9a1Vo8z8NQFB8=; b=TAJO7YCdkqaqGX yCtJiCeWEsHp11aM/1Pf3CFE4T1dQV1u08GNishPKwxeENtfJf8sZfmsEBAYryJSx/v79jcTJQOPR uMikhlLo7qPUYBPsp0Hw3nvYCfspBY382Oou+yBeDzB+oDHhuwRpK4Uhs5T3lRoYHttdX/bURnaoK GHemh8BTW43UONzztJs+jt0F0eubA29lpuOAa39yfPCWLRlBWiTjsPyItowy8m40LHmNi5/7wxR62 oNKV8YqBWkE67+w5mY7yJLnD6fN2G5cRVkCt16AMCAKucxuVTDFShHfPI2OKdYOj4cj4wnPjCtGF1 4jL3XRyrfRi8aJkEF4lQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqht7-00ALer-1V; Tue, 08 Jun 2021 19:59:49 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lqhoq-00AIlQ-HR for linux-arm-kernel@lists.infradead.org; Tue, 08 Jun 2021 19:55:27 +0000 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-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PX4XZRO4KpflUQEEgbL1ALBIADgPV7/V/iBUfhH7FVc=; b=AEMqM0GKwsSGSdisYYSvJ31WiXPnQz53Pst4usfePvVs72r60vjBFlI89Q6C1pyyn7uqm+ ZYKhUxn/x/cCGWACL1/VE4XTYxtn7fjL0t81nq0UFHWhjIxyHuKQd36WTdlHSMEMFd2Cch QoiOC/zDibMay0eX0Mu3cy98UQ2wLqc= 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-28--6RJ3N83MdC6wdJUmYp5ug-1; Tue, 08 Jun 2021 15:55:22 -0400 X-MC-Unique: -6RJ3N83MdC6wdJUmYp5ug-1 Received: by mail-oo1-f71.google.com with SMTP id m22-20020a0568200356b0290248e4270f00so11256399ooe.14 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=IGTNXqvSsg0o6g0E0mWtTohjlLB5H3btIwMKTAzygBSzNPq2Ef8mT16cFc6BUjk9gD 6SWHrqCklrUJqu6vJ3xkK/WXZ+u6edx3B4IbsroKwkPqdpstBEsKO44C1xJR+rlvXCxH PKRTeC/JfAhYnK5a/10qaQ0Xg72Twx22DX/fP+QikRUVOj5Uy78xlyBUSYrp8YtwXQ+Y B7Ei+EYLq2HghOQGKbct479HCG+WoaOZMZjdcskWASeLtB34bXqU6ooJk/1hiFkAPBBw tJuMB5hSloRDB5suk+5m3nnGPEUcHk9jCtrlfa3SMzVkT/eRUNgQaj3OZZnLG353ddWL DVPw== X-Gm-Message-State: AOAM533y+J3OfTkxn134UT7E2Gzoumkf6XPBD0b/1T7m6Yjb37rEjpg0 gJTMmtqOODdjngw4Bk62dZfofnqhjTSkFlPq1i1KOZdUk0wRDmw5kXEexawKquFrpMh4kYFQOCC fys+59RMbE3cvttuaLpjG5RiyJAbhaZg8GGI= X-Received: by 2002:aca:af90:: with SMTP id y138mr3986007oie.92.1623182121633; 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 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=trix@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210608_125524_742893_B66BA98F X-CRM114-Status: GOOD ( 18.11 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Tom Rix Anyone searching for the wrappers should find all of them together, so move the wrappers. Since they are all small functions, make them inline. Signed-off-by: Tom Rix --- drivers/fpga/fpga-mgr.c | 117 ++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 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