From patchwork Fri Jun 25 19:51:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Rix X-Patchwork-Id: 12345827 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=-17.1 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,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 2D5ECC2B9F4 for ; Fri, 25 Jun 2021 19:54:04 +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 034696162E for ; Fri, 25 Jun 2021 19:54:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 034696162E 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=F0Vkx0qCkk0XVE8M7y9mc341tgIYxh4QfgJoplbQfuQ=; b=QQK6bgbolbO4aC 81ykZUP1No1/yaHyNt9rnCr3KgCKaFrmkzLkCGfFdktLMHiP1EnrYhQRvwd2v4KaQMo4ORfpSqOac K2f5vXq6Y4Q1YGOdTENVfF69CBxnHktf9Q+g/ehVJ/3A4CaKV/fC29XMFtnkL1Etu4dpEJqqMtZ6x OOsTvPcTSqx2PcB8NDDHkYDel3gRNMUDm673CPy7xiLDcfVPT8POQLu1W0t2YMhGBbSOGigFEPe1Y XPQzBeHf060XXPNSnvq1B0rgyNrb4G5qsdMgLXYzDMZ1g/AoRTI+WU7ncfQJzGvR/iE5VBPJCw8VK KmwGpSRpAeHnlqHCpUGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lwrs9-002iWu-3A; Fri, 25 Jun 2021 19:52:17 +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 1lwrs2-002iVZ-U9 for linux-arm-kernel@lists.infradead.org; Fri, 25 Jun 2021 19:52:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624650729; 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=8DrGKCk1PyABrk56DLPAvdbVVOLwe1RJgwvPdYUZWO0=; b=P6+hKMMezOM2q58Suy6bzLZJ2JvR0ekyX9Nda6fUycyfLfMRfenIce8t3AKbN6MZWuzPyx RYiijMiztLKnsSW1mmWGa7ePSRvOVifA+zbGcj3U7XfQyoeViZfoYm+OVfpJ5hyvN600rH CFzIZbP5Cj2MIoviHirTxbGIGFREBBQ= 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-107-O0GQCWCsOMmFMMLnEHUwqw-1; Fri, 25 Jun 2021 15:52:06 -0400 X-MC-Unique: O0GQCWCsOMmFMMLnEHUwqw-1 Received: by mail-oi1-f198.google.com with SMTP id r3-20020aca44030000b02902241b7398a8so6511001oia.19 for ; Fri, 25 Jun 2021 12:52:06 -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=8DrGKCk1PyABrk56DLPAvdbVVOLwe1RJgwvPdYUZWO0=; b=D+0/kNBUk1eyMxpNf5tZbHKRwS48VcGyFeHRMQfV42fnyt0/MKxCZUz6/BSuQT1y7v KEkea+d2R9oRdqkkT8ewcIVeS/AEf03vgvu37UEELIdoOCigfwveZUbV4AWQloJqpBBR J9CACEw8kG2rHqZw/gqPSP0IktH6TI7owHmCgt1ZcZjN5bKe9HcBBFLb7p8TIl5tiIeK v8ArRKBB0mL6O4DflOvirPHqGn0wfAFuird2wHaDpeHSTbi2yxFdhLJF6yu+P3l9W7XN dsx4TSw2b8H/VI/YExeQ2XK5vP5ty/vHQjC/SAD6353HHlxpP/hbTDkU+2oKRo6GvkgT ppXg== X-Gm-Message-State: AOAM531gKhZMlr5DEF2nN6l5pKe5wQH79poiJ/EBbSyIk7uQwEZcZabW BUxY03urAauL19mTMg1LYwS3fgAdjo/2ioBYwvcuOhxvrAuB3zYyULauesDQokkj5m5jtFQrOw+ FRiXqZ3MvnFTzj1R4GiVTf/uGkdhYy2A+Aho= X-Received: by 2002:aca:de07:: with SMTP id v7mr12660087oig.8.1624650725853; Fri, 25 Jun 2021 12:52:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwksAeBpoAvEUezEdyZ5NcQyipuc4+d8PdYoULnG6dzFZDi28TVoKaNvmx21VMJfDFVEgV/4A== X-Received: by 2002:aca:de07:: with SMTP id v7mr12660075oig.8.1624650725709; Fri, 25 Jun 2021 12:52:05 -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 o25sm1535446ood.20.2021.06.25.12.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Jun 2021 12:52:05 -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 v4 1/7] fpga-mgr: wrap the write_init() op Date: Fri, 25 Jun 2021 12:51:42 -0700 Message-Id: <20210625195148.837230-3-trix@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210625195148.837230-1-trix@redhat.com> References: <20210625195148.837230-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-20210625_125211_111321_0BAF7012 X-CRM114-Status: GOOD ( 13.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 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 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index ecb4c3c795fa5..c047de8a059b7 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,15 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +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->write_init) + return mgr->mops->write_init(mgr, info, buf, count); + return 0; +} + /** * fpga_image_info_alloc - Allocate an FPGA image info struct * @dev: owning device @@ -83,9 +92,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 +578,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, int id, ret; if (!mops || !mops->write_complete || !mops->state || - !mops->write_init || (!mops->write && !mops->write_sg) || + (!mops->write && !mops->write_sg) || (mops->write && mops->write_sg)) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL;