Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1977795rwb; Fri, 11 Nov 2022 03:21:25 -0800 (PST) X-Google-Smtp-Source: AA0mqf7X+ZmiwFI2YRt4uGKa64UI+sF5IQ+wN9yOD6TnIKfpwnaM/OGs8NTlLrbfny81kdG61Jtt X-Received: by 2002:a05:6402:5a:b0:45a:1bfa:98bf with SMTP id f26-20020a056402005a00b0045a1bfa98bfmr1007889edu.413.1668165684992; Fri, 11 Nov 2022 03:21:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668165684; cv=none; d=google.com; s=arc-20160816; b=E26fDyOhrrVst5azL3f7f9y3AnlEeUpVz6crxJcMccHpXLSgUneABiMPIFqHjLVrDL raRZSBxaRxQqU4uX4JWGHE3HpasugzAtqtkYcrDqc/pje5vbUiiPPZGLOchxYqR6lCM7 w3We7GgTqcHRukH8h/XshtJC+boINfxy1IvrUinTQOToRG+bnIP5pfRAdN9C/C31m+Rl 4864AZuLrRKjRuVt0fbxVzJwqT6xiGA0OI9JiKAUeTTh/3XHuUDe1NvrSKXLnC2ApPmP HBp7ehL21LyfXPXP3nlSVcyTk0+KkcKXB86iJjjU2zBBGXCjXe0lwHtFM7yLY+TWcFMk wxLQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nLKpbp4KgrjA7gU8aVT5yjQ7b/nUhNaQxhI4bUIb7gE=; b=kw8dvMmmqnzh5jOi4RwA2U1YMwPYT5aUQ+MsmFjReXKUd1k2MphJaVXL7pOQp4RMvl 6Zv6yF+mAjQxi8nFTNzHkKkZ+vgmNeAagZM4eWdKQLdotbxcAL1GaAuZoMxQxta2TaYH 2D9vzQj48jnE9ZGEfov53pC/JvL/GSNJVx5HdTSzWmyExviuN0lL5/AB2WI8nqPtz+0z 1WX5DO2Le8nV19k3+Ya5E167OJ2QML3Yut2CPtzVFLnmzOqEUDehTi49E6SZpRvA3Nfy 7gYbN5YKS2frEsUCpgKYU2BHwCEKcj7dAg5SOZbe07d01OxRC3QIPNRRZ7C73seYDtEX PWCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lsshsQmD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b17-20020a170906661100b00783a5f78700si1498012ejp.226.2022.11.11.03.21.02; Fri, 11 Nov 2022 03:21:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lsshsQmD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233132AbiKKKX0 (ORCPT + 92 others); Fri, 11 Nov 2022 05:23:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233254AbiKKKWu (ORCPT ); Fri, 11 Nov 2022 05:22:50 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47CB677225; Fri, 11 Nov 2022 02:22:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668162142; x=1699698142; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=/D9EhNFlTttYvmVVnJZDdQIYkR+YCuvihpc0/HImI0w=; b=lsshsQmDPadnfHLgWCN/qy2LKl42QtVYGIkTHd8s1HFQwZPtpY+CO2jJ bkDL9D4xsTytprQX+7pJSpGC3YdApiCq9VHaMtt3WJXxyxRlT9khDXzM/ 7+PEXLZEqaeuNSjcy/z1STYbaA32Afxrx/58k055/w9/eO71mwVgV084h 90FYaVeVZ8WO7pxhdntqWO1ioty7NbUx4QPhoREg6Tj+GueFhfgBVKa1r ZQFpAEa5n60b7sxttMEkNL6rWNvRZPRwJiRRHoAPrDadui8VB12GVy6rf Y0gyw7xIIen3aTNr/NAIAIZOJ6z2ZWWyaaCPSN8DmdSkwtHjvpbPCFF6+ w==; X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="291976265" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="291976265" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Nov 2022 02:22:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10527"; a="670704207" X-IronPort-AV: E=Sophos;i="5.96,156,1665471600"; d="scan'208";a="670704207" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga001.jf.intel.com with ESMTP; 11 Nov 2022 02:22:15 -0800 Date: Fri, 11 Nov 2022 18:12:55 +0800 From: Xu Yilun To: Ilpo =?iso-8859-1?Q?J=E4rvinen?= Cc: linux-fpga@vger.kernel.org, Wu Hao , Tom Rix , Moritz Fischer , Lee Jones , Matthew Gerlach , Russ Weight , Tianfei zhang , Mark Brown , Greg KH , linux-kernel@vger.kernel.org Subject: Re: [PATCH 02/12] mfd: intel-m10-bmc: Create m10bmc_platform_info for type specific info Message-ID: References: <20221108144305.45424-1-ilpo.jarvinen@linux.intel.com> <20221108144305.45424-3-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221108144305.45424-3-ilpo.jarvinen@linux.intel.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-11-08 at 16:42:55 +0200, Ilpo J?rvinen wrote: > BMC type specific info is currently set by a switch/case block. The > size of this info is expected to grow as more dev types and features > are added which would have made the switch block bloaty. > > Store type specific info into struct and place them into .driver_data > instead because it makes things a bit cleaner. > > Reviewed-by: Russ Weight > Signed-off-by: Ilpo J?rvinen > --- > drivers/mfd/intel-m10-bmc.c | 50 +++++++++++++++++-------------- > include/linux/mfd/intel-m10-bmc.h | 14 +++++++++ > 2 files changed, 41 insertions(+), 23 deletions(-) > > diff --git a/drivers/mfd/intel-m10-bmc.c b/drivers/mfd/intel-m10-bmc.c > index ee167c5dcd29..762808906380 100644 > --- a/drivers/mfd/intel-m10-bmc.c > +++ b/drivers/mfd/intel-m10-bmc.c > @@ -156,15 +156,17 @@ static int check_m10bmc_version(struct intel_m10bmc *ddata) > static int intel_m10_bmc_spi_probe(struct spi_device *spi) > { > const struct spi_device_id *id = spi_get_device_id(spi); > + const struct intel_m10bmc_platform_info *info; > struct device *dev = &spi->dev; > - struct mfd_cell *cells; > struct intel_m10bmc *ddata; > - int ret, n_cell; > + int ret; > > ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); > if (!ddata) > return -ENOMEM; > > + info = (struct intel_m10bmc_platform_info *)id->driver_data; > + ddata->info = info; Where to use the ddata->info? > ddata->dev = dev; > > ddata->regmap = > @@ -183,24 +185,8 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi) > return ret; > } > > - switch (id->driver_data) { > - case M10_N3000: > - cells = m10bmc_pacn3000_subdevs; > - n_cell = ARRAY_SIZE(m10bmc_pacn3000_subdevs); > - break; > - case M10_D5005: > - cells = m10bmc_d5005_subdevs; > - n_cell = ARRAY_SIZE(m10bmc_d5005_subdevs); > - break; > - case M10_N5010: > - cells = m10bmc_n5010_subdevs; > - n_cell = ARRAY_SIZE(m10bmc_n5010_subdevs); > - break; > - default: > - return -ENODEV; > - } > - > - ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, cells, n_cell, > + ret = devm_mfd_add_devices(dev, PLATFORM_DEVID_AUTO, > + info->cells, info->n_cells, > NULL, 0, NULL); > if (ret) > dev_err(dev, "Failed to register sub-devices: %d\n", ret); > @@ -208,10 +194,28 @@ static int intel_m10_bmc_spi_probe(struct spi_device *spi) > return ret; > } > > +static const struct intel_m10bmc_platform_info m10bmc_m10_n3000 = { > + .type = M10_N3000, Is the type enum still useful? Found no usage. Thanks, Yilun > + .cells = m10bmc_pacn3000_subdevs, > + .n_cells = ARRAY_SIZE(m10bmc_pacn3000_subdevs), > +}; > + > +static const struct intel_m10bmc_platform_info m10bmc_m10_d5005 = { > + .type = M10_D5005, > + .cells = m10bmc_d5005_subdevs, > + .n_cells = ARRAY_SIZE(m10bmc_d5005_subdevs), > +}; > + > +static const struct intel_m10bmc_platform_info m10bmc_m10_n5010 = { > + .type = M10_N5010, > + .cells = m10bmc_n5010_subdevs, > + .n_cells = ARRAY_SIZE(m10bmc_n5010_subdevs), > +}; > + > static const struct spi_device_id m10bmc_spi_id[] = { > - { "m10-n3000", M10_N3000 }, > - { "m10-d5005", M10_D5005 }, > - { "m10-n5010", M10_N5010 }, > + { "m10-n3000", (kernel_ulong_t)&m10bmc_m10_n3000 }, > + { "m10-d5005", (kernel_ulong_t)&m10bmc_m10_d5005 }, > + { "m10-n5010", (kernel_ulong_t)&m10bmc_m10_n5010 }, > { } > }; > MODULE_DEVICE_TABLE(spi, m10bmc_spi_id); > diff --git a/include/linux/mfd/intel-m10-bmc.h b/include/linux/mfd/intel-m10-bmc.h > index d77383a8a410..e58115f514b9 100644 > --- a/include/linux/mfd/intel-m10-bmc.h > +++ b/include/linux/mfd/intel-m10-bmc.h > @@ -124,14 +124,28 @@ enum m10bmc_type { > /* Address of 4KB inverted bit vector containing staging area FLASH count */ > #define STAGING_FLASH_COUNT 0x17ffb000 > > +/** > + * struct intel_m10bmc_platform_info - Intel MAX 10 BMC platform specific information > + * @type: the type of MAX10 BMC > + * @cells: MFD cells > + * @n_cells: MFD cells ARRAY_SIZE() > + */ > +struct intel_m10bmc_platform_info { > + enum m10bmc_type type; > + struct mfd_cell *cells; > + int n_cells; > +}; > + > /** > * struct intel_m10bmc - Intel MAX 10 BMC parent driver data structure > * @dev: this device > * @regmap: the regmap used to access registers by m10bmc itself > + * @info: the platform information for MAX10 BMC > */ > struct intel_m10bmc { > struct device *dev; > struct regmap *regmap; > + const struct intel_m10bmc_platform_info *info; > }; > > /* > -- > 2.30.2 >