Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp677792rdb; Fri, 6 Oct 2023 15:46:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFgu8n5aa1cZ5pHPeVlxBg0Gt9fiobvd5v8coQRTLDgWdNCqHttrhnDjzNC0OuV9+/BKfkM X-Received: by 2002:a17:902:ed01:b0:1c6:335b:1d75 with SMTP id b1-20020a170902ed0100b001c6335b1d75mr8618442pld.69.1696632413574; Fri, 06 Oct 2023 15:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696632413; cv=none; d=google.com; s=arc-20160816; b=Pgx0zWeH9A2iwcjwOzZhltMxwS/Kv5aKT6CS43Nw41wb0qPeCY53lv3bhBuwecj7fb 0TbwIRccSr/D2pa+yV2NRSpvF/0CR3umtTfcGo7V0FqgZpW35keTKx5hwbWkxxYrNKiI GalRBfkREjQkG2OtELs2z/8FlGfSnfaf86sy2lju1S0u/Ch/DL1dBce263l2+2J1zITJ QpuEkfPCEmKgTumVQg3hEppb1IzQgywYpPA6vLnlTkdRskC03mnk3g8LH+23jOkC6u4A 8R0OrqN6SuZVeETCEeLtRO7WkQbehCAK2kpATkAUay9EIPYWlg3SclBX/i73lo+J1gj5 Wodw== 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 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id kp8-20020a170903280800b001c73f364120si4361909plb.407.2023.10.06.15.46.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 15:46:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; 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 23.128.96.35 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 065C58365274; Fri, 6 Oct 2023 15:46:51 -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 S233838AbjJFWqe (ORCPT + 99 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 Content-Transfer-Encoding: 8bit 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:46:51 -0700 (PDT) X-Spam-Level: ** 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 --- 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); -- 2.40.1