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;