From patchwork Fri Oct 6 22:46:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 149451 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:403:3b70:6f57 with SMTP id x8csp635621vqo; Fri, 6 Oct 2023 15:47:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFwjD+v96JQlf05tl6+sUr4lC6nEnCiG+CYzm2/bCCd5bVKhZNozQlCejOYBlEJP73hER3K X-Received: by 2002:a17:902:820c:b0:1c3:aee0:7d27 with SMTP id x12-20020a170902820c00b001c3aee07d27mr8961338pln.24.1696632428465; Fri, 06 Oct 2023 15:47:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696632428; cv=none; d=google.com; s=arc-20160816; b=euVbf0rzeAzIJC0jTSQD6pTPzklgCZztYPfJ755lLmwmU78wm/eS9cT0Ds5zyrIUUU 6Uh6XcitxcIz3vqiaJP6n+c1m7Nscdrwfoh7dYyrvbAIPpqZtMkbdTyP93Wm69tia8nm zxA6PADIb10Yr4vGpdwFVznPlMKBoRFcs8MEUiRdophX+dG4KgT/wQnPtUJcEeycL9W2 wopR+CrcjVIG3Licly0URuveAmDYpkimGtE3U9jMcBJTWyJXube7pqzLqFtLOrPfEBny G7tieeFRf8OyZUIghKF9/2mIIILZl2EUnPaWfkGi/g2zYVHJpjzwNN8ZBCb97Mi2kYik Q+ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=b0K10GEohoYBdPvXOwy/9rEzc7kbevAQHUzW069RE6g=; fh=UYsGdSj8yotudbKFKDx+d34rey+dX7UcfECvLLbtlXc=; b=L3IhI2wtMQHejIOxzDTgwh8RvrqjkCa8RrOfXRTortsRLjX7z5EYLjR4aRqN1TnKLf 1u0uxacZi59aRS7r9/YV0hAQUv0bENnegM++wVBSYvPy7xqxrlAsU+HLaAUp5DQjrLZi DnI9TC/WdjXJWCfT4y9mBzN1c9IN1KSyfzNPslGpoNEkaqWI1g7uozWepUim7bLutwm9 GndeeuantjGKZ+/rM/mrKrktFEPl+1tJTxQIScIH+48Tc9WI1blN7ZBefZCj00QB/DcN uQ6+BsgNIVi0Ap9Ej0+tnNk+5UZ2CPbjBHvKtpK3p3/8BWegO8jdKdTEuccr3447g0GD xWKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ip2tsOOt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id o6-20020a170902d4c600b001c5c370d4d3si4888419plg.534.2023.10.06.15.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 15:47:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Ip2tsOOt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 1477D836650E; Fri, 6 Oct 2023 15:47:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233843AbjJFWqe (ORCPT + 18 others); Fri, 6 Oct 2023 18:46:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233805AbjJFWqd (ORCPT ); Fri, 6 Oct 2023 18:46:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A65A2; Fri, 6 Oct 2023 15:46:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14360C433C7; Fri, 6 Oct 2023 22:46:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696632391; bh=ISXp2gYet5qklONCtk802z18uyrzOQLPrR+IectAYzM=; h=From:To:Cc:Subject:Date:From; b=Ip2tsOOtD1XFeJ7HcnZp4uXZtSnukFsIyWAsYCrBAyJ7Gd98G6L2uARSKSDosHjsr o45U27aHqeQo3BoMq8wn/G1CVA+UFIdZMP0eXCq/X8LObyss/f0ivMJpRbD7c9s90M opjh2LE8FFS4PPeU8/aMS6dHdk0XKSlmDVnjJ1Is+7nHIa7jsuOmJNXCMm0Pm1qPRn WcIn3jpwOMTufPOJvJ0h4ihPHG+mlFgXNi7RLSc6zYRdLoUcywZcE6CVPAj5N5GrB+ 51oaySw4Dfd2cHCps7uMcdCbI+4B+KgXqedpJVMpy5obEWq6oazJ9RH8ukl5UtylNm fmnm9Lrpn6OzA== Received: (nullmailer pid 444993 invoked by uid 1000); Fri, 06 Oct 2023 22:46:30 -0000 From: Rob Herring To: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix Cc: linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fpga: altera-ps-spi: Use spi_get_device_match_data() Date: Fri, 6 Oct 2023 17:46:24 -0500 Message-Id: <20231006224624.444857-1-robh@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 06 Oct 2023 15:47:05 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779048044972900550 X-GMAIL-MSGID: 1779048044972900550 Use preferred spi_get_device_match_data() instead of of_match_device() and spi_get_device_id() to get the driver match data. With this, adjust the includes to explicitly include the correct headers. Signed-off-by: Rob Herring Acked-by: Xu Yilun --- drivers/fpga/altera-ps-spi.c | 44 ++++-------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/drivers/fpga/altera-ps-spi.c b/drivers/fpga/altera-ps-spi.c index 5e1e009dba89..6be7410e4f09 100644 --- a/drivers/fpga/altera-ps-spi.c +++ b/drivers/fpga/altera-ps-spi.c @@ -18,8 +18,7 @@ #include #include #include -#include -#include +#include #include #include @@ -72,12 +71,6 @@ static struct altera_ps_data a10_data = { .t_st2ck_us = 10, /* min(t_ST2CK) */ }; -/* Array index is enum altera_ps_devtype */ -static const struct altera_ps_data *altera_ps_data_map[] = { - &c5_data, - &a10_data, -}; - static const struct of_device_id of_ef_match[] = { { .compatible = "altr,fpga-passive-serial", .data = &c5_data }, { .compatible = "altr,fpga-arria10-passive-serial", .data = &a10_data }, @@ -237,43 +230,16 @@ static const struct fpga_manager_ops altera_ps_ops = { .write_complete = altera_ps_write_complete, }; -static const struct altera_ps_data *id_to_data(const struct spi_device_id *id) -{ - kernel_ulong_t devtype = id->driver_data; - const struct altera_ps_data *data; - - /* someone added a altera_ps_devtype without adding to the map array */ - if (devtype >= ARRAY_SIZE(altera_ps_data_map)) - return NULL; - - data = altera_ps_data_map[devtype]; - if (!data || data->devtype != devtype) - return NULL; - - return data; -} - static int altera_ps_probe(struct spi_device *spi) { struct altera_ps_conf *conf; - const struct of_device_id *of_id; struct fpga_manager *mgr; conf = devm_kzalloc(&spi->dev, sizeof(*conf), GFP_KERNEL); if (!conf) return -ENOMEM; - if (spi->dev.of_node) { - of_id = of_match_device(of_ef_match, &spi->dev); - if (!of_id) - return -ENODEV; - conf->data = of_id->data; - } else { - conf->data = id_to_data(spi_get_device_id(spi)); - if (!conf->data) - return -ENODEV; - } - + conf->data = spi_get_device_match_data(spi); conf->spi = spi; conf->config = devm_gpiod_get(&spi->dev, "nconfig", GPIOD_OUT_LOW); if (IS_ERR(conf->config)) { @@ -308,9 +274,9 @@ static int altera_ps_probe(struct spi_device *spi) } static const struct spi_device_id altera_ps_spi_ids[] = { - { "cyclone-ps-spi", CYCLONE5 }, - { "fpga-passive-serial", CYCLONE5 }, - { "fpga-arria10-passive-serial", ARRIA10 }, + { "cyclone-ps-spi", (uintptr_t)&c5_data }, + { "fpga-passive-serial", (uintptr_t)&c5_data }, + { "fpga-arria10-passive-serial", (uintptr_t)&a10_data }, {} }; MODULE_DEVICE_TABLE(spi, altera_ps_spi_ids);