drivers/platform: replace module x86/mlxcpld-hotplug with mellanox/mlxreg-hotplug
Subsystems (2)
v4 cover drivers/platform: replace module x86/mlxcpld-hotplug with mellanox/mlxreg-hotplug
The patchset:
- replaces modules include/linux/platform_data/mlxcpld-hotplug.h and drivers/platform/x86/mlxcpld-hotplug.c with the modules include/linux/platform_data/mlxreg.h and drivers/platform/mellanox/mlxreg-hotplug.c;
relevant Makefile and Kconfig are updated;
- modifies Mellanox hotplug driver for making it architecture independent. Drivers has been tested for x86 and ARM based systems.
- introduces regmap interface for mlxreg-hotplug driver to allow hotplug event functionality over programmable devices logic, when these devices can be attached to different interfaces types, like I2C, LPC, SPI; driver drivers/platform/x86/mlx-platform.c is updated according to new interface.
Vadim Pasternak (3):
platform/x86: move Mellanox hardware platform hotplug driver to
platform/mellanox
platform/mellanox: mlxreg-hotplug: allow driver for ARM architecture platform/mellanox: mlxreg-hotplug: modify to use regmap intreface
MAINTAINERS | 15 +- drivers/platform/Kconfig | 2 + drivers/platform/Makefile | 1 + drivers/platform/mellanox/Kconfig | 25 + drivers/platform/mellanox/Makefile | 1 + drivers/platform/mellanox/mlxreg-hotplug.c | 699 ++++++++++++++++++++++++++ drivers/platform/x86/Kconfig | 9 - drivers/platform/x86/Makefile | 1 - drivers/platform/x86/mlx-platform.c | 239 +++++++-- drivers/platform/x86/mlxcpld-hotplug.c | 515 ------------------- include/linux/platform_data/mlxcpld-hotplug.h | 99 ---- include/linux/platform_data/mlxreg.h | 138 +++++ 12 files changed, 1060 insertions(+), 684 deletions(-) create mode 100644 drivers/platform/mellanox/Kconfig create mode 100644 drivers/platform/mellanox/Makefile create mode 100644 drivers/platform/mellanox/mlxreg-hotplug.c delete mode 100644 drivers/platform/x86/mlxcpld-hotplug.c delete mode 100644 include/linux/platform_data/mlxcpld-hotplug.h create mode 100644 include/linux/platform_data/mlxreg.h
Signature · 1 line
2.1.4
PATCH v4 1/3 platform/x86: move Mellanox hardware platform hotplug driver to platform/mellanox
It moves drivers/platform/x86/mlxcpld-hotplug.c to drivers/platform/mellanox/mlxreg-hotplug.c and include/linux/platform_data/mlxcpld-hotplug.h to include/linux/platform_data/mlxreg.h for making hotplug driver usable for the different machine architectures.
---v3->v4:
Comments pointed out by Darren:
- Refactor the patches to provide the changes in patchset in incremental order;
- Modify MAINTAINERS records;
- Use git-mv for the replaced files;
Commnets pointed out by Colin:
- Make structures mlxplat_dev and mlxplat_hotplug static;
---
MAINTAINERS | 15 +-
drivers/platform/Kconfig | 2 +
drivers/platform/Makefile | 1 +
drivers/platform/mellanox/Kconfig | 24 +++
drivers/platform/mellanox/Makefile | 1 +
.../mlxreg-hotplug.c} | 223 ++++++++++-----------
drivers/platform/x86/Kconfig | 9 -
drivers/platform/x86/Makefile | 1 -
drivers/platform/x86/mlx-platform.c | 20 +-
.../platform_data/{mlxcpld-hotplug.h => mlxreg.h} | 25 ++-
10 files changed, 169 insertions(+), 152 deletions(-)
create mode 100644 drivers/platform/mellanox/Kconfig
create mode 100644 drivers/platform/mellanox/Makefile
rename drivers/platform/{x86/mlxcpld-hotplug.c => mellanox/mlxreg-hotplug.c} (65%)
rename include/linux/platform_data/{mlxcpld-hotplug.h => mlxreg.h} (84%)MAINTAINERS +8 -7
@@ -8723,6 +8723,14 @@ W: http://www.mellanox.com Q: http://patchwork.ozlabs.org/project/netdev/list/ F: drivers/net/ethernet/mellanox/mlxsw/ +MELLANOX HARDWARE PLATFORM SUPPORT +M: Andy Shevchenko <[email protected]> +M: Darren Hart <[email protected]> +M: Vadim Pasternak <[email protected]> +L: [email protected] +S: Supported +F: drivers/platform/mellanox/ + MELLANOX FIRMWARE FLASH LIBRARY (mlxfw) M: Yotam Gigi <[email protected]> L: [email protected]
@@ -8731,13 +8739,6 @@ W: http://www.mellanox.com Q: http://patchwork.ozlabs.org/project/netdev/list/ F: drivers/net/ethernet/mellanox/mlxfw/ -MELLANOX MLX CPLD HOTPLUG DRIVER -M: Vadim Pasternak <[email protected]> -L: [email protected] -S: Supported -F: drivers/platform/x86/mlxcpld-hotplug.c -F: include/linux/platform_data/mlxcpld-hotplug.h - MELLANOX MLX4 core VPI driver M: Tariq Toukan <[email protected]> L: [email protected]
drivers/platform/Kconfig +2 -0
@@ -8,3 +8,5 @@ endif source "drivers/platform/goldfish/Kconfig" source "drivers/platform/chrome/Kconfig" + +source "drivers/platform/mellanox/Kconfig"
drivers/platform/Makefile +1 -0
@@ -3,6 +3,7 @@ # obj-$(CONFIG_X86) += x86/ +obj-$(CONFIG_MELLANOX_PLATFORM) += mellanox/ obj-$(CONFIG_MIPS) += mips/ obj-$(CONFIG_OLPC) += olpc/ obj-$(CONFIG_GOLDFISH) += goldfish/
drivers/platform/mellanox/Kconfig new file +24 -0
@@ -0,0 +1,24 @@ +# +# Platform support for Mellanox hardware +# + +menuconfig MELLANOX_PLATFORM + bool "Platform support for Mellanox hardware" + depends on X86 || COMPILE_TEST + ---help--- + Say Y here to get to see options for platform support for + Mellanox systems. This option alone does not add any kernel code. + + If you say N, all options in this submenu will be skipped and disabled. + +if MELLANOX_PLATFORM + +config MLXREG_HOTPLUG + tristate "Mellanox platform hotplug driver support" + depends on HWMON + depends on I2C + ---help--- + This driver handles hot-plug events for the power suppliers, power + cables and fans on the wide range Mellanox IB and Ethernet systems. + +endif # MELLANOX_PLATFORM
drivers/platform/mellanox/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_MLXREG_HOTPLUG) += mlxreg-hotplug.o
drivers/platform/mellanox/mlxreg-hotplug.c renamed from drivers/platform/x86/mlxcpld-hotplug.c +111 -112
486 lines not on this page · raw message
drivers/platform/x86/Kconfig +0 -9
@@ -1122,15 +1122,6 @@ config MLX_PLATFORM If you have a Mellanox system, say Y or M here. -config MLX_CPLD_PLATFORM - tristate "Mellanox platform hotplug driver support" - default n - select HWMON - select I2C - ---help--- - This driver handles hot-plug events for the power suppliers, power - cables and fans on the wide range Mellanox IB and Ethernet systems. - config INTEL_TURBO_MAX_3 bool "Intel Turbo Boost Max Technology 3.0 enumeration driver" depends on X86_64 && SCHED_MC_PRIO
drivers/platform/x86/Makefile +0 -1
@@ -82,5 +82,4 @@ obj-$(CONFIG_INTEL_TELEMETRY) += intel_telemetry_core.o \ obj-$(CONFIG_INTEL_PMC_CORE) += intel_pmc_core.o obj-$(CONFIG_PMC_ATOM) += pmc_atom.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o -obj-$(CONFIG_MLX_CPLD_PLATFORM) += mlxcpld-hotplug.o obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
drivers/platform/x86/mlx-platform.c +10 -10
@@ -38,7 +38,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/platform_data/i2c-mux-reg.h> -#include <linux/platform_data/mlxcpld-hotplug.h> +#include <linux/platform_data/mlxreg.h> #define MLX_PLAT_DEVICE_NAME "mlxplat"
@@ -138,7 +138,7 @@ static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = { };/* Platform hotplug devices */ -static struct mlxcpld_hotplug_device mlxplat_mlxcpld_psu[] = { +static struct mlxreg_hotplug_device mlxplat_mlxcpld_psu[] = { { .brdinfo = {I2C_BOARD_INFO ("24c02" ,0x51 ) }, .bus =10 ,
@@ -149,7 +149,7 @@ static struct mlxcpld_hotplug_device mlxplat_mlxcpld_psu[] = { }, }; -static struct mlxcpld_hotplug_device mlxplat_mlxcpld_pwr[] = { +static struct mlxreg_hotplug_device mlxplat_mlxcpld_pwr[] = { { .brdinfo = {I2C_BOARD_INFO ("dps460" ,0x59 ) }, .bus =10 ,
@@ -160,7 +160,7 @@ static struct mlxcpld_hotplug_device mlxplat_mlxcpld_pwr[] = { }, }; -static struct mlxcpld_hotplug_device mlxplat_mlxcpld_fan[] = { +static struct mlxreg_hotplug_device mlxplat_mlxcpld_fan[] = { { .brdinfo = {I2C_BOARD_INFO ("24c32" ,0x50 ) }, .bus =11 ,
@@ -181,7 +181,7 @@ static struct mlxcpld_hotplug_device mlxplat_mlxcpld_fan[] = {/* Platform hotplug default data */ static -struct mlxcpld_hotplug_platform_data mlxplat_mlxcpld_default_data = { +struct mlxreg_hotplug_platform_data mlxplat_mlxcpld_default_data = { .top_aggr_offset =MLXPLAT_CPLD_LPC_REG_AGGR_ADRR , .top_aggr_mask =MLXPLAT_CPLD_AGGR_MASK_DEF , .top_aggr_psu_mask =MLXPLAT_CPLD_AGGR_PSU_MASK_DEF ,
@@ -203,7 +203,7 @@ struct mlxcpld_hotplug_platform_data mlxplat_mlxcpld_default_data = {/* Platform hotplug MSN21xx system family data */ static -struct mlxcpld_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { +struct mlxreg_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { .top_aggr_offset =MLXPLAT_CPLD_LPC_REG_AGGR_ADRR , .top_aggr_mask =MLXPLAT_CPLD_AGGR_MASK_MSN21XX , .top_aggr_pwr_mask =MLXPLAT_CPLD_AGGR_MASK_MSN21XX ,
@@ -213,11 +213,11 @@ struct mlxcpld_hotplug_platform_data mlxplat_mlxcpld_msn21xx_data = { };static struct resource mlxplat_mlxcpld_resources[] = { - [0 ] =DEFINE_RES_IRQ_NAMED (17 ,"mlxcpld-hotplug" ), + [0 ] =DEFINE_RES_IRQ_NAMED (17 ,"mlxreg-hotplug" ), }; -struct platform_device *mlxplat_dev; -struct mlxcpld_hotplug_platform_data *mlxplat_hotplug; +static struct platform_device *mlxplat_dev; +static struct mlxreg_hotplug_platform_data *mlxplat_hotplug;static int __init mlxplat_dmi_default_matched (const struct dmi_system_id *dmi) {
@@ -329,7 +329,7 @@ static int __init mlxplat_init(void) } priv->pdev_hotplug = platform_device_register_resndata( - &mlxplat_dev->dev, "mlxcpld-hotplug", + &mlxplat_dev->dev, "mlxreg-hotplug", PLATFORM_DEVID_NONE, mlxplat_mlxcpld_resources, ARRAY_SIZE(mlxplat_mlxcpld_resources),
include/linux/platform_data/mlxreg.h renamed from include/linux/platform_data/mlxcpld-hotplug.h +12 -13
@@ -1,7 +1,6 @@/* -* include/linux/platform_data/mlxcpld-hotplug.h -* Copyright (c) 2016 Mellanox Technologies. All rights reserved. -* Copyright (c) 2016 Vadim Pasternak <[email protected]> +* Copyright (c) 2017 Mellanox Technologies. All rights reserved. +* Copyright (c) 2017 Vadim Pasternak <[email protected]> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met:
@@ -32,11 +31,11 @@* POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H -#define __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H +#ifndef __LINUX_PLATFORM_DATA_MLXREG_H +#define __LINUX_PLATFORM_DATA_MLXREG_H/** -* struct mlxcpld_hotplug_device - I2C device data: +* struct mlxreg_hotplug_device - I2C device data: * @adapter: I2C device adapter; * @client: I2C device client; * @brdinfo: device board information;
@@ -45,7 +44,7 @@* Structure represents I2C hotplug device static data (board topology) and * dynamic data (related kernel objects handles). */ -struct mlxcpld_hotplug_device { +struct mlxreg_hotplug_device {struct i2c_adapter *adapter;struct i2c_client *client;struct i2c_board_info brdinfo;
@@ -53,7 +52,7 @@ struct mlxcpld_hotplug_device { };/** -* struct mlxcpld_hotplug_platform_data - device platform data: +* struct mlxreg_hotplug_platform_data - device platform data: * @top_aggr_offset: offset of top aggregation interrupt register; * @top_aggr_mask: top aggregation interrupt common mask; * @top_aggr_psu_mask: top aggregation interrupt PSU mask;
@@ -76,24 +75,24 @@ struct mlxcpld_hotplug_device {* like FAN, PSU, power cable insertion and removing. This data provides the * number of hot-pluggable devices and hardware description for event handling. */ -struct mlxcpld_hotplug_platform_data { +struct mlxreg_hotplug_platform_data {u16 top_aggr_offset;u8 top_aggr_mask;u8 top_aggr_psu_mask;u16 psu_reg_offset;u8 psu_mask;u8 psu_count; -struct mlxcpld_hotplug_device *psu; +struct mlxreg_hotplug_device *psu;u8 top_aggr_pwr_mask;u16 pwr_reg_offset;u8 pwr_mask;u8 pwr_count; -struct mlxcpld_hotplug_device *pwr; +struct mlxreg_hotplug_device *pwr;u8 top_aggr_fan_mask;u16 fan_reg_offset;u8 fan_mask;u8 fan_count; -struct mlxcpld_hotplug_device *fan; +struct mlxreg_hotplug_device *fan; }; -#endif /* __LINUX_PLATFORM_DATA_MLXCPLD_HOTPLUG_H */ +#endif /* __LINUX_PLATFORM_DATA_MLXREG_H */
Signature · 1 line
2.1.4
Re: [patch v4 1/3] platform/x86: move Mellanox hardware platform hotplug driver to platform/mellanox
Quoted 9 lines · Vadim Pasternak
It moves
drivers/platform/x86/mlxcpld-hotplug.ctodrivers/platform/mellanox/mlxreg-hotplug.candinclude/linux/platform_data/mlxcpld-hotplug.htoinclude/linux/platform_data/mlxreg.hfor making hotplug driver usable for the different machine architectures.Signed-off-by Vadim Pasternak <[email protected]>Acked-by Andy Shevchenko <[email protected]>
MAINTAINERS W: http://www.mellanox.com · line 8734
Quoted 9 lines
MAINTAINERS +8
-0+MELLANOX HARDWARE PLATFORM SUPPORT +M: Andy Shevchenko <[email protected]> +M: Darren Hart <[email protected]> +M: Vadim Pasternak <[email protected]> +L: [email protected] +S: Supported +F: drivers/platform/mellanox/ + MELLANOX FIRMWARE FLASH LIBRARY (mlxfw)
A ... F ... H ... Z
Linus even created a script for that.
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 2/3 platform/mellanox: mlxreg-hotplug: allow driver for ARM architecture
In reply to Vadim PasternakIt allows driver to run on x86 and ARM architecture based systems. And allows to specify hotplug device parameters through the device table tree files.
Also some unnecessary includes are removed.
--- drivers/platform/mellanox/Kconfig | 2 +- drivers/platform/mellanox/mlxreg-hotplug.c | 164 +++++++++++++++++++++-------- drivers/platform/x86/mlx-platform.c | 16 +-- include/linux/platform_data/mlxreg.h | 6 +- 4 files changed, 132 insertions(+), 56 deletions(-)
drivers/platform/mellanox/Kconfig +1 -1
@@ -4,7 +4,7 @@ menuconfig MELLANOX_PLATFORM bool "Platform support for Mellanox hardware" - depends on X86 || COMPILE_TEST + depends on (X86 && !OF_DYNAMIC) || ARM || COMPILE_TEST ---help--- Say Y here to get to see options for platform support for Mellanox systems. This option alone does not add any kernel code.
drivers/platform/mellanox/mlxreg-hotplug.c +119 -45
211 lines not on this page · raw message
drivers/platform/x86/mlx-platform.c +8 -8
@@ -141,41 +141,41 @@ static struct i2c_mux_reg_platform_data mlxplat_mux_data[] = {static struct mlxreg_hotplug_device mlxplat_mlxcpld_psu[] = { { .brdinfo = {I2C_BOARD_INFO ("24c02" ,0x51 ) }, - .bus =10 , + .nr =10 , }, { .brdinfo = {I2C_BOARD_INFO ("24c02" ,0x50 ) }, - .bus =10 , + .nr =10 , }, };static struct mlxreg_hotplug_device mlxplat_mlxcpld_pwr[] = { { .brdinfo = {I2C_BOARD_INFO ("dps460" ,0x59 ) }, - .bus =10 , + .nr =10 , }, { .brdinfo = {I2C_BOARD_INFO ("dps460" ,0x58 ) }, - .bus =10 , + .nr =10 , }, };static struct mlxreg_hotplug_device mlxplat_mlxcpld_fan[] = { { .brdinfo = {I2C_BOARD_INFO ("24c32" ,0x50 ) }, - .bus =11 , + .nr =11 , }, { .brdinfo = {I2C_BOARD_INFO ("24c32" ,0x50 ) }, - .bus =12 , + .nr =12 , }, { .brdinfo = {I2C_BOARD_INFO ("24c32" ,0x50 ) }, - .bus =13 , + .nr =13 , }, { .brdinfo = {I2C_BOARD_INFO ("24c32" ,0x50 ) }, - .bus =14 , + .nr =14 , }, };
include/linux/platform_data/mlxreg.h +4 -2
@@ -39,7 +39,8 @@* @adapter: I2C device adapter; * @client: I2C device client; * @brdinfo: device board information; -* @bus: I2C bus, where device is attached; +* @nr: I2C device adapter number, to which device is to be attached; +* @np - pointer to node platform associated with attribute; * * Structure represents I2C hotplug device static data (board topology) and * dynamic data (related kernel objects handles).
@@ -48,7 +49,8 @@ struct mlxreg_hotplug_device {struct i2c_adapter *adapter;struct i2c_client *client;struct i2c_board_info brdinfo; -u16 bus; +int nr; +struct device_node *np; };/**
Signature · 1 line
2.1.4
Re: [patch v4 2/3] platform/mellanox: mlxreg-hotplug: allow driver for ARM architecture
drivers/platform/mellanox/Kconfig line 7
Quoted 9 lines · Vadim Pasternak
It allows driver to run on x86 and ARM architecture based systems. And allows to specify hotplug device parameters through the device table tree files.
Also some unnecessary includes are removed.menuconfig
MELLANOX_PLATFORM
bool "Platform support for Mellanox hardware"drivers/platform/mellanox/Kconfig +1
-1- depends on X86 || COMPILE_TEST + depends on (X86 && !OF_DYNAMIC) || ARM || COMPILE_TEST
I'm not sure I now understand why you need a tricky dependency chain here...
Quoted 1 line
+#if
defined(CONFIG_OF_DYNAMIC)&& !defined(CONFIG_COMPILE_TEST)
...and what's wrong with COMPILE_TEST here.
Quoted 14 lines
drivers/platform/mellanox/mlxreg-hotplug.c +13
-0+static int mlxreg_hotplug_of_device_create (struct mlxreg_hotplug_device *data) +{ +return of_update_property (data->np, &mlxreg_hotplug_device_en); +} + +static void +mlxreg_hotplug_of_device_destroy (struct mlxreg_hotplug_device *data) +{ +of_update_property (data->np, &mlxreg_hotplug_device_dis); +of_node_clear_flag (data->np,OF_POPULATED ); +} +#else +#endif
Signature · 2 lines
With Best Regards, Andy Shevchenko
PATCH v4 3/3 platform/mellanox: mlxreg-hotplug: modify to use regmap intreface
In reply to Vadim PasternakIt includes:
- restructuring of mlxreg header file for unification of hotplug items definition;
- unification of hotplug items to allow any kind of item (power controller, fan eeprom, psu eeprom, asic health in common way);
- utilization of regmap interface to allow independency of underlying hardware. It allows to support hotplug event functionality over programmable devices logic, when these devices can be attached to different interfaces types, like I2C, LPC, SPI.
--- drivers/platform/mellanox/Kconfig | 1 + drivers/platform/mellanox/mlxreg-hotplug.c | 613 +++++++++++++++++------------ drivers/platform/x86/mlx-platform.c | 231 ++++++++--- include/linux/platform_data/mlxreg.h | 120 ++++-- 4 files changed, 624 insertions(+), 341 deletions(-)
drivers/platform/mellanox/Kconfig +1 -0
@@ -15,6 +15,7 @@ if MELLANOX_PLATFORM config MLXREG_HOTPLUG tristate "Mellanox platform hotplug driver support" + depends on REGMAP depends on HWMON depends on I2C ---help---
drivers/platform/mellanox/mlxreg-hotplug.c +362 -251
823 lines not on this page · raw message
drivers/platform/x86/mlx-platform.c +182 -49
293 lines not on this page · raw message
include/linux/platform_data/mlxreg.h +79 -41
145 lines not on this page · raw message
Signature · 1 line
2.1.4
Re: [patch v4 3/3] platform/mellanox: mlxreg-hotplug: modify to use regmap intreface
Quoted 13 lines · Vadim Pasternak
It includes:
- restructuring of mlxreg header file for unification of hotplug items definition;
- unification of hotplug items to allow any kind of item (power controller, fan eeprom, psu eeprom, asic health in common way);
- utilization of regmap interface to allow independency of underlying hardware. It allows to support hotplug event functionality over programmable devices logic, when these devices can be attached to different interfaces types, like I2C, LPC, SPI.Signed-off-by Vadim Pasternak <[email protected]>Acked-by Andy Shevchenko <[email protected]>
drivers/platform/mellanox/mlxreg-hotplug.c static ssize_t mlxreg_hotplug_attr_show(struct device *dev, · line 241
Quoted 6 lines
drivers/platform/mellanox/mlxreg-hotplug.c +2
-3-#define PRIV_ATTR (i) priv->mlxreg_hotplug_attr[i] -#define PRIV_DEV_ATTR (i) priv->mlxreg_hotplug_dev_attr[i] -static int mlxreg_hotplug_attr_init (struct mlxreg_hotplug_priv_data *priv) +static int +mlxreg_hotplug_attr_init (struct mlxreg_hotplug_priv_data *priv)
This is kinda noisy change.
Quoted 37 lines
{
drivers/platform/mellanox/mlxreg-hotplug.c +12
-23-for (i =0 ; i < num_attrs; i++) { -PRIV_ATTR (i) = &PRIV_DEV_ATTR (i).dev_attr.attr; - -if (i < priv->plat->psu_count) { -PRIV_ATTR (i)->name =devm_kasprintf (&priv->pdev->dev, -GFP_KERNEL ,"psu%u" , i +1 ); -PRIV_DEV_ATTR (i).nr =MLXREG_HOTPLUG_ATTR_TYPE_PSU ; - }else if (i < priv->plat->psu_count + priv->plat->pwr_count) { -PRIV_ATTR (i)->name =devm_kasprintf (&priv->pdev->dev, -GFP_KERNEL ,"pwr%u" , i % - priv->plat->pwr_count +1 ); -PRIV_DEV_ATTR (i).nr =MLXREG_HOTPLUG_ATTR_TYPE_PWR ; - }else { -PRIV_ATTR (i)->name =devm_kasprintf (&priv->pdev->dev, -GFP_KERNEL ,"fan%u" , i % - priv->plat->fan_count +1 ); -PRIV_DEV_ATTR (i).nr =MLXREG_HOTPLUG_ATTR_TYPE_FAN ; - } - -if (!PRIV_ATTR (i)->name) { -dev_err (&priv->pdev->dev,"Memory allocation failed for sysfs attribute %d.\n" , - i +1 ); -return -ENOMEM ; +for (i =0 ; i < pdata->counter; i++, item++) { + data = item->data; +for (j =0 ; j < item->count; j++, data++, id++) { + priv->mlxreg_hotplug_attr[id] = + &priv->mlxreg_hotplug_dev_attr[id].dev_attr.attr; + priv->mlxreg_hotplug_attr[id]->name = +devm_kasprintf (&priv->pdev->dev,GFP_KERNEL , + data->label); + +if (!priv->mlxreg_hotplug_attr[id]->name) { +dev_err (priv->dev,"Memory allocation failed for attr %d.\n" , + id);
drivers/platform/mellanox/mlxreg-hotplug.c static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
Quoted 10 lines
drivers/platform/mellanox/mlxreg-hotplug.c +9
-0+return -ENOMEM ; + } + + priv->mlxreg_hotplug_dev_attr[id].dev_attr.attr.mode = +0444 ; + priv->mlxreg_hotplug_dev_attr[id].dev_attr.show = + mlxreg_hotplug_attr_show; + priv->mlxreg_hotplug_dev_attr[id].nr = i; + priv->mlxreg_hotplug_dev_attr[id].index = j;
Why you drop macros usage here?
Quoted 10 lines
}(quoted diff) +0
-6- - PRIV_DEV_ATTR(i).dev_attr.attr.name = PRIV_ATTR(i)->name; - PRIV_DEV_ATTR(i).dev_attr.attr.mode = S_IRUGO; - PRIV_DEV_ATTR(i).dev_attr.show = mlxreg_hotplug_attr_show; - PRIV_DEV_ATTR(i).index = i; - sysfs_attr_init(&PRIV_DEV_ATTR(i).dev_attr.attr); #define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR 0x2000
Review
Quoted 10 lines
(quoted diff) +4
-4#define MLXPLAT_CPLD_LPC_REG_BASE_ADRR 0x2500 -#define MLXPLAT_CPLD_LPC_REG_AGGR_ADRR 0x253a -#define MLXPLAT_CPLD_LPC_REG_PSU_ADRR 0x2558 -#define MLXPLAT_CPLD_LPC_REG_PWR_ADRR 0x2564 -#define MLXPLAT_CPLD_LPC_REG_FAN_ADRR 0x2588 +#define MLXPLAT_CPLD_LPC_REG_AGGR_ADRR 0x3a +#define MLXPLAT_CPLD_LPC_REG_PSU_ADRR 0x58 +#define MLXPLAT_CPLD_LPC_REG_PWR_ADRR 0x64 +#define MLXPLAT_CPLD_LPC_REG_FAN_ADRR 0x88
These now by the fact *offsets*.
Signature · 2 lines
With Best Regards, Andy Shevchenko