Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp833141rdb; Sat, 7 Oct 2023 00:44:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHe8f7BgaBZ+EUMY9f4IX4bcnqCc5cwYwKl4LcNO/Sx2qcwZ7LnIjgsfKqK9KeUVDOBL9L7 X-Received: by 2002:a17:902:cec6:b0:1c8:7d41:5b8c with SMTP id d6-20020a170902cec600b001c87d415b8cmr10110243plg.32.1696664685641; Sat, 07 Oct 2023 00:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696664685; cv=none; d=google.com; s=arc-20160816; b=qTqI3JFf93Pih0Eb9mv5EoLUs8gy11hlh/IiueKAe2FZVvm4VMjrkgiCBwD3Aq748O q8xai16yakxXa0jCKAkfhgratWdS3J5OxsYT7PPXVKJVLbRoZNzuhZoBRR50f44rSskf Tu/L2Pgy+/f596rKvGDBy48qRMbjFD56rDCdkK3OHyJfy2LHPbN+BTxoC2Mjhf160fWA U3Qzd72qGHTOISTJHAJmkEwoYJ9xU1iXSgao2yZzBcUfOwwxTHSLy0piHg+44KZV0gtt lLyXswLDFdeXi5jc5KzQkTeFzf7inMFUbHieuNMlZi0/cj431BE6TWDYfrDB5pkKph7W BS0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=kUpQN/kSMPE9Sd6/6b8rEFTQXsRtOlX89ceBFUSyivc=; fh=SSrIty8EiRFi/DZsy5nydz9NyRWvGtFUnvIqpC6PPL4=; b=wCqZjFyNc2of4hqwQgNStlQzhXVG6VMxsR1r/Mlq/YUnuL9bpodPJqwWgo+dFCLOkx TyLroX9LtcFPcATiaoJO/6sqinHzzVVYv4/qcxbrj6JqDKhVWgTIBfZp8KIr/2zNvcXx M4GilDeKCLqHqZZXsMdNzJjTWCsdiX2cyDAVOINnqtpCSMpZkmkIR8GCI81RDLBJw3CL AMWDVF7npRpO9bPsM4WqgpQwrb8yaljbIHwN4YISdrgeoeg3++X/yXOrt4/7L8Q8dvXN xdSyFfSrK6xCq2vf7IBz3mgaHz9Ok8ziqSrowG0sin08M9PmBPsi/hT8u4p9kBJu4ODD Gf9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IFRTYhnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id kx8-20020a170902f94800b001c61bd7cee0si5214222plb.211.2023.10.07.00.44.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Oct 2023 00:44:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IFRTYhnQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 7AD798095F5E; Sat, 7 Oct 2023 00:44:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343702AbjJGHog (ORCPT + 99 others); Sat, 7 Oct 2023 03:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343715AbjJGHoe (ORCPT ); Sat, 7 Oct 2023 03:44:34 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75AAFBF; Sat, 7 Oct 2023 00:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696664673; x=1728200673; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=sRng9T4/el7qzEq59uhXR9KsL4yghIT/iUgkp07WwMA=; b=IFRTYhnQWdq5vUq1WLYzIO/BG98iDrFQ9X/wbIy8bnyrQCVtn8zu7UqW LxY4UTJsuRLPQNtl0Wr1MmjFixnpphr7jzsCBlivWnsbsu4nuLKcF9JIt BlMXyL5X3PsWwTIlGsvloVJOJgu9W8M4NIAqur+K1LifOL56TttGufyH9 JOKpPIvx2Skrfw87lY4ZkQsfYcPofy1N8NNTtAIzkcKS8kH+QZgUx9A7P 4edhXNShGzAOj7VwU8b3k31DciFJJ0hE5kJBKcPsQ72AFzmexl57pyLMO cJNysxboI6N9IJx81FYu4jvgk7bEgvEa42R4vDiTpPz1iwk2PfiDKRS28 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="386742001" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="386742001" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Oct 2023 00:44:33 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="702316267" X-IronPort-AV: E=Sophos;i="6.03,205,1694761200"; d="scan'208";a="702316267" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga003.jf.intel.com with ESMTP; 07 Oct 2023 00:44:30 -0700 Date: Sat, 7 Oct 2023 15:43:41 +0800 From: Xu Yilun To: Rob Herring Cc: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] fpga: altera-ps-spi: Use spi_get_device_match_data() Message-ID: References: <20231006224624.444857-1-robh@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231006224624.444857-1-robh@kernel.org> X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 morse.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 (morse.vger.email [0.0.0.0]); Sat, 07 Oct 2023 00:44:43 -0700 (PDT) X-Spam-Level: ** On Fri, Oct 06, 2023 at 05:46:24PM -0500, Rob Herring wrote: > 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 Applied. > --- > 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 >