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,