Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2355900ybl; Thu, 9 Jan 2020 11:16:10 -0800 (PST) X-Google-Smtp-Source: APXvYqw+Q+jU2GOKOdIhRSDPnhH1mokRJlJcqSC46y1WlcIUFGqZXc/xUqlfSgEHIeAde5ed7+13 X-Received: by 2002:a9d:68d1:: with SMTP id i17mr9403837oto.367.1578597370621; Thu, 09 Jan 2020 11:16:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578597370; cv=none; d=google.com; s=arc-20160816; b=HkoAtFo86z2kxWpmk/cNl3JCILMH/IuTng+ejEB1/SpQWAyCmsVAVfAbjyQ3JUjK4F TlCMSAL4SmFJfC7WzVjz/T0mGCUtDUbeu0PmkbbLThYBS7KG5GGVSWl1v+8VxS7rVIAX F/ORx3MoKVbGByEIghtKoymMsb831JGJQQMXYEdSrPhgMdRi/P7w9tr78j8OA1/AQOyP RjiHta39KhsyXszKBO0n9O8lGecZPheiRJEPgvBrXrQ1DATbtjEZbJft5eqrvACJ087J AOlwHfBtoyTiyuai34N7IK13U0WavptmN/jnl9OyhF4UF9Q8jICJsCk9WOcYKq+004r4 s94Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kaoDmnIv7fq2bK3Pw8FgyMWXUExVVooadbufCm0vA28=; b=vnbIYhMNA5GLnrUPl77inWuUUhhcv/vJ4WI+Q80rWI2kkkvwI8tSIP2iC6qf9a+F68 TFhc9JLg2R1MHQ0SyYVs7mqNaTLfsP/Uta8E+DHxXhH63KWVaHAqo4eEWtHa/2Jsqh6X ShonZ+kWfDMK0ksNN2WLu/ChyLqofr9uCPPkqdnbGer1MaWAlmEb3FK6gUevlODv/ZXE yzh80HY8vSj0a75u/C8izzjwUYygXS+3ipha5MEB6PNRi2R4xuMHgb3QpirtOeYcka3L kf6vrjbqUlFYvyeM7C5AIUbrXL7Y8shOSDIXS/9pmiWiJeMWkgxT497RdkJpQNJk7gK6 9edg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lyJZFdTE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b145si4324760oii.67.2020.01.09.11.15.58; Thu, 09 Jan 2020 11:16:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=lyJZFdTE; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732294AbgAIPT7 (ORCPT + 99 others); Thu, 9 Jan 2020 10:19:59 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:45034 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727945AbgAIPT6 (ORCPT ); Thu, 9 Jan 2020 10:19:58 -0500 Received: by mail-pl1-f193.google.com with SMTP id az3so2678698plb.11; Thu, 09 Jan 2020 07:19:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kaoDmnIv7fq2bK3Pw8FgyMWXUExVVooadbufCm0vA28=; b=lyJZFdTEmsR9yvYDQNZzfGSP/2DugXvk4aOPsCFKrQT9EZ/FM87d4Iyefb8hCBmCYY BxBESnnvF2jCUGboub4ZrzhLzxkGFInZn0UxfZ/rL0ncnEVhSkeAswDKaZkYNi21b2rv G+v8QpvJrB14eRmtbcprQi0mr2IwaQ2GiG8MTj7dSBSukpdNHX5Wd0b7dwwKFfPJffsL 8CnBoNXjca8eQ88Mi++1dqJ3Fjh7q+UYjDTQRxxwpY+x3JbyMeq2VmeGEOJdN9QVCwo8 H0Ge/orqiM8/imsKOvVVKiOjz4/yL0moBTrorDHigUsxOnFAEBOJWZbCQOTcKS0AN4vW XzrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kaoDmnIv7fq2bK3Pw8FgyMWXUExVVooadbufCm0vA28=; b=IqYeraTib9ykZLx30PH+fMomL3rpK8e9Pi8Y9EE8gxtKofM38M8E1Hmlq5NA/mWPoS I8qliRgJvZ7BL7XD+ZAn+p/D0ROcAqKm35WB264HwhAbgsb7GSjDukgbDaXlZ8vlMTT4 xpuf0mk1NAjXQG++KOfz2LJuHdce/iDv8cZTjWa0vjlrUQo/pMhBAE6s/P7VPSnBFJFn IS4ResM/1E1/tkHIa5+dRoTbA1Bi5HSmUNMxPvbIrS7akvWWtss+GCGNnnWiL/I3ATZ0 /GPYKqD7+RW+hpB9DiiSG2n2NdjcO3fiP1vMY35SjH7BYv+i33wZunGNTKViBwMfAAcj 3uNA== X-Gm-Message-State: APjAAAWARmleGdKzyPBCq9OxiBGyvF/f38Wx+kZODtjQc3A0UwJ/ApgT Ce1bYA+P6dm5XAyWxPxFdLiQK5TpXcCR6VOhBVs= X-Received: by 2002:a17:90a:b10b:: with SMTP id z11mr6005030pjq.132.1578583197418; Thu, 09 Jan 2020 07:19:57 -0800 (PST) MIME-Version: 1.0 References: <20191231102917.24181-1-vadimp@mellanox.com> <20191231102917.24181-6-vadimp@mellanox.com> In-Reply-To: <20191231102917.24181-6-vadimp@mellanox.com> From: Andy Shevchenko Date: Thu, 9 Jan 2020 17:19:48 +0200 Message-ID: Subject: Re: [PATCH platform-next v1 5/9] platform/x86: mlx-platform: Set system mux configuration based on system type To: Vadim Pasternak Cc: Andy Shevchenko , Darren Hart , Platform Driver , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 31, 2019 at 12:29 PM Vadim Pasternak wrote: > > Separate assignment for systems mux configuration based on system type, > instead of setting the same configuration for the all. > The motivation is to allow introduction of new systems types with the > different mux topology. > > Signed-off-by: Vadim Pasternak > --- > drivers/platform/x86/mlx-platform.c | 46 ++++++++++++++++++++++++++----------- > 1 file changed, 33 insertions(+), 13 deletions(-) > > diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c > index 7e92dc52071f..0a41668b1587 100644 > --- a/drivers/platform/x86/mlx-platform.c > +++ b/drivers/platform/x86/mlx-platform.c > @@ -219,7 +219,7 @@ static const int mlxplat_default_channels[][MLXPLAT_CPLD_GRP_CHNL_NUM] = { > static const int mlxplat_msn21xx_channels[] = { 1, 2, 3, 4, 5, 6, 7, 8 }; > > /* Platform mux data */ > -static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = { > +static struct i2c_mux_reg_platform_data mlxplat_default_mux_data[] = { > { > .parent = 1, > .base_nr = MLXPLAT_CPLD_CH1, > @@ -239,6 +239,11 @@ static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = { > > }; > > +/* Platform mux configuration variables */ > +static int mlxplat_max_adap_num; > +static int mlxplat_mux_num; > +static struct i2c_mux_reg_platform_data *mlxplat_mux_data; > + > /* Platform hotplug devices */ > static struct i2c_board_info mlxplat_mlxcpld_psu[] = { > { > @@ -1905,7 +1910,10 @@ static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; > + mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); > + mlxplat_mux_data = mlxplat_default_mux_data; > + for (i = 0; i < mlxplat_mux_num; i++) { > mlxplat_mux_data[i].values = mlxplat_default_channels[i]; > mlxplat_mux_data[i].n_values = > ARRAY_SIZE(mlxplat_default_channels[i]); > @@ -1924,7 +1932,10 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; > + mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); > + mlxplat_mux_data = mlxplat_default_mux_data; > + for (i = 0; i < mlxplat_mux_num; i++) { > mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; > mlxplat_mux_data[i].n_values = > ARRAY_SIZE(mlxplat_msn21xx_channels); > @@ -1943,7 +1954,10 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; > + mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); > + mlxplat_mux_data = mlxplat_default_mux_data; > + for (i = 0; i < mlxplat_mux_num; i++) { > mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; > mlxplat_mux_data[i].n_values = > ARRAY_SIZE(mlxplat_msn21xx_channels); > @@ -1962,7 +1976,10 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; > + mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); > + mlxplat_mux_data = mlxplat_default_mux_data; > + for (i = 0; i < mlxplat_mux_num; i++) { > mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; > mlxplat_mux_data[i].n_values = > ARRAY_SIZE(mlxplat_msn21xx_channels); > @@ -1981,7 +1998,10 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) > { > int i; > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + mlxplat_max_adap_num = MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; > + mlxplat_mux_num = ARRAY_SIZE(mlxplat_default_mux_data); > + mlxplat_mux_data = mlxplat_default_mux_data; > + for (i = 0; i < mlxplat_mux_num; i++) { > mlxplat_mux_data[i].values = mlxplat_msn21xx_channels; > mlxplat_mux_data[i].n_values = > ARRAY_SIZE(mlxplat_msn21xx_channels); > @@ -1998,7 +2018,7 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi) > mlxplat_regmap_config = &mlxplat_mlxcpld_regmap_config_ng; > > return 1; > -} > +}; And this, how does it happen? > > static const struct dmi_system_id mlxplat_dmi_table[] __initconst = { > { > @@ -2127,7 +2147,7 @@ static int mlxplat_mlxcpld_verify_bus_topology(int *nr) > /* Scan adapters from expected id to verify it is free. */ > *nr = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; > for (i = MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR; i < > - MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM; i++) { > + mlxplat_max_adap_num; i++) { I'm wondering why 'i <; is left on previous line, or, otherwise, the limit is on next one. > search_adap = i2c_get_adapter(i); > if (search_adap) { > i2c_put_adapter(search_adap); > @@ -2141,12 +2161,12 @@ static int mlxplat_mlxcpld_verify_bus_topology(int *nr) > } > > /* Return with error if free id for adapter is not found. */ > - if (i == MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM) > + if (i == mlxplat_max_adap_num) > return -ENODEV; > > /* Shift adapter ids, since expected parent adapter is not free. */ > *nr = i; > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + for (i = 0; i < mlxplat_mux_num; i++) { > shift = *nr - mlxplat_mux_data[i].parent; > mlxplat_mux_data[i].parent = *nr; > mlxplat_mux_data[i].base_nr += shift; > @@ -2202,7 +2222,7 @@ static int __init mlxplat_init(void) > if (nr < 0) > goto fail_alloc; > > - nr = (nr == MLXPLAT_CPLD_MAX_PHYS_ADAPTER_NUM) ? -1 : nr; > + nr = (nr == mlxplat_max_adap_num) ? -1 : nr; > if (mlxplat_i2c) > mlxplat_i2c->regmap = priv->regmap; > priv->pdev_i2c = platform_device_register_resndata( > @@ -2215,7 +2235,7 @@ static int __init mlxplat_init(void) > goto fail_alloc; > } > > - for (i = 0; i < ARRAY_SIZE(mlxplat_mux_data); i++) { > + for (i = 0; i < mlxplat_mux_num; i++) { > priv->pdev_mux[i] = platform_device_register_resndata( > &priv->pdev_i2c->dev, > "i2c-mux-reg", i, NULL, > @@ -2349,7 +2369,7 @@ static void __exit mlxplat_exit(void) > platform_device_unregister(priv->pdev_led); > platform_device_unregister(priv->pdev_hotplug); > > - for (i = ARRAY_SIZE(mlxplat_mux_data) - 1; i >= 0 ; i--) > + for (i = mlxplat_mux_num - 1; i >= 0 ; i--) It is basically while (i--) > platform_device_unregister(priv->pdev_mux[i]); > > platform_device_unregister(priv->pdev_i2c); > -- > 2.11.0 > -- With Best Regards, Andy Shevchenko