diff mbox

[v6,2/3] platform/mellanox: mlxreg-hotplug: allow driver for ARM architecture

Message ID 1513603204-13536-3-git-send-email-vadimp@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Darren Hart
Headers show

Commit Message

Vadim Pasternak Dec. 18, 2017, 1:20 p.m. UTC
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.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
v5->v6:
v4->v5:
 Comments pointed out by Andy:
 - remove unnessecary logic in Kconfig;
 - remove !COMPILE_TEST in mlxreg-hotplug;
---
 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(-)

Comments

kernel test robot Dec. 20, 2017, 9:11 a.m. UTC | #1
Hi Vadim,

I love your patch! Yet something to improve:

[auto build test ERROR on platform-drivers-x86/for-next]
[also build test ERROR on v4.15-rc4 next-20171220]
[cannot apply to linus/master]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Vadim-Pasternak/drivers-platform-replace-module-x86-mlxcpld-hotplug-with-mellanox-mlxreg-hotplug/20171220-163359
base:   git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git for-next
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

Note: the linux-review/Vadim-Pasternak/drivers-platform-replace-module-x86-mlxcpld-hotplug-with-mellanox-mlxreg-hotplug/20171220-163359 HEAD 7e98e72a743e69069c34f3bbd3b9289740e30de0 builds fine.
      It only hurts bisectibility.

All errors (new ones prefixed by >>):

   drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_attr_show':
>> drivers/platform/mellanox/mlxreg-hotplug.c:224:17: error: implicit declaration of function 'inb' [-Werror=implicit-function-declaration]
      reg_val = !!!(inb(priv->plat->psu_reg_offset) & BIT(index));
                    ^~~
   drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_work_helper':
>> drivers/platform/mellanox/mlxreg-hotplug.c:305:2: error: implicit declaration of function 'outb' [-Werror=implicit-function-declaration]
     outb(0, offset + MLXREG_HOTPLUG_MASK_OFF);
     ^~~~
   cc1: some warnings being treated as errors

vim +/inb +224 drivers/platform/mellanox/mlxreg-hotplug.c

86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  210  
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  211  static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  212  					struct device_attribute *attr,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  213  					char *buf)
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  214  {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  215  	struct platform_device *pdev = to_platform_device(dev);
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  216  	struct mlxreg_hotplug_priv_data *priv = platform_get_drvdata(pdev);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  217  	int index = to_sensor_dev_attr_2(attr)->index;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  218  	int nr = to_sensor_dev_attr_2(attr)->nr;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  219  	u8 reg_val = 0;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  220  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  221  	switch (nr) {
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  222  	case MLXREG_HOTPLUG_ATTR_TYPE_PSU:
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  223  		/* Bit = 0 : PSU is present. */
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20 @224  		reg_val = !!!(inb(priv->plat->psu_reg_offset) & BIT(index));
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  225  		break;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  226  
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  227  	case MLXREG_HOTPLUG_ATTR_TYPE_PWR:
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  228  		/* Bit = 1 : power cable is attached. */
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  229  		reg_val = !!(inb(priv->plat->pwr_reg_offset) & BIT(index %
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  230  						priv->plat->pwr_count));
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  231  		break;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  232  
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  233  	case MLXREG_HOTPLUG_ATTR_TYPE_FAN:
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  234  		/* Bit = 0 : FAN is present. */
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  235  		reg_val = !!!(inb(priv->plat->fan_reg_offset) & BIT(index %
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  236  						priv->plat->fan_count));
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  237  		break;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  238  	}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  239  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  240  	return sprintf(buf, "%u\n", reg_val);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  241  }
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  242  
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  243  #define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  244  #define PRIV_DEV_ATTR(i) priv->mlxreg_hotplug_dev_attr[i]
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  245  static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  246  {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  247  	int num_attrs = priv->plat->psu_count + priv->plat->pwr_count +
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  248  			priv->plat->fan_count;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  249  	int i;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  250  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  251  	priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs *
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  252  					 sizeof(struct attribute *),
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  253  					 GFP_KERNEL);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  254  	if (!priv->group.attrs)
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  255  		return -ENOMEM;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  256  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  257  	for (i = 0; i < num_attrs; i++) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  258  		PRIV_ATTR(i) = &PRIV_DEV_ATTR(i).dev_attr.attr;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  259  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  260  		if (i < priv->plat->psu_count) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  261  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  262  						GFP_KERNEL, "psu%u", i + 1);
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  263  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_PSU;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  264  		} else if (i < priv->plat->psu_count + priv->plat->pwr_count) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  265  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  266  						GFP_KERNEL, "pwr%u", i %
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  267  						priv->plat->pwr_count + 1);
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  268  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_PWR;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  269  		} else {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  270  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  271  						GFP_KERNEL, "fan%u", i %
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  272  						priv->plat->fan_count + 1);
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  273  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_FAN;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  274  		}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  275  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  276  		if (!PRIV_ATTR(i)->name) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  277  			dev_err(&priv->pdev->dev, "Memory allocation failed for sysfs attribute %d.\n",
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  278  				i + 1);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  279  			return -ENOMEM;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  280  		}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  281  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  282  		PRIV_DEV_ATTR(i).dev_attr.attr.name = PRIV_ATTR(i)->name;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  283  		PRIV_DEV_ATTR(i).dev_attr.attr.mode = S_IRUGO;
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  284  		PRIV_DEV_ATTR(i).dev_attr.show = mlxreg_hotplug_attr_show;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  285  		PRIV_DEV_ATTR(i).index = i;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  286  		sysfs_attr_init(&PRIV_DEV_ATTR(i).dev_attr.attr);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  287  	}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  288  
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  289  	priv->group.attrs = priv->mlxreg_hotplug_attr;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  290  	priv->groups[0] = &priv->group;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  291  	priv->groups[1] = NULL;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  292  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  293  	return 0;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  294  }
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  295  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  296  static inline void
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  297  mlxreg_hotplug_work_helper(struct device *dev,
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  298  			   struct mlxreg_hotplug_device *item, u8 is_inverse,
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  299  			   u16 offset, u8 mask, u8 *cache)
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  300  {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  301  	u8 val, asserted;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  302  	int bit;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  303  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  304  	/* Mask event. */
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18 @305  	outb(0, offset + MLXREG_HOTPLUG_MASK_OFF);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  306  	/* Read status. */
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  307  	val = inb(offset) & mask;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  308  	asserted = *cache ^ val;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  309  	*cache = val;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  310  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  311  	/*
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  312  	 * Validate if item related to received signal type is valid.
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  313  	 * It should never happen, excepted the situation when some
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  314  	 * piece of hardware is broken. In such situation just produce
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  315  	 * error message and return. Caller must continue to handle the
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  316  	 * signals from other devices if any.
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  317  	 */
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  318  	if (unlikely(!item)) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  319  		dev_err(dev, "False signal is received: register at offset 0x%02x, mask 0x%02x.\n",
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  320  			offset, mask);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  321  		return;
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  322  	}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  323  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  324  	for_each_set_bit(bit, (unsigned long *)&asserted, 8) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  325  		if (val & BIT(bit)) {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  326  			if (is_inverse)
86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  327  				mlxreg_hotplug_dev_disable(item + bit);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  328  			else
86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  329  				mlxreg_hotplug_dev_enable(item + bit);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  330  		} else {
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  331  			if (is_inverse)
86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  332  				mlxreg_hotplug_dev_enable(item + bit);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  333  			else
86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  334  				mlxreg_hotplug_dev_disable(item + bit);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  335  		}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  336  	}
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  337  
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  338  	/* Acknowledge event. */
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  339  	outb(0, offset + MLXREG_HOTPLUG_EVENT_OFF);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  340  	/* Unmask event. */
ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  341  	outb(mask, offset + MLXREG_HOTPLUG_MASK_OFF);
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  342  }
30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  343  

:::::: The code at line 224 was first introduced by commit
:::::: 304887041d953b6692c0d4a9f8fafb252d32e9a0 platform/x86: Introduce support for Mellanox hotplug driver

:::::: TO: Vadim Pasternak <vadimp@mellanox.com>
:::::: CC: Darren Hart <dvhart@linux.intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Darren Hart Jan. 3, 2018, 12:15 a.m. UTC | #2
On Wed, Dec 20, 2017 at 05:11:51PM +0800, kbuild test robot wrote:
> Hi Vadim,
> 

Hi Vadim,

This has been a long time in development, and has been tricky to get everyone
aligned for review. I'm prioritizing this series now and will commit to
reviewing in a timely manner. I assume you have seen the build error below -
will you prepare a v7 which addresses the build issue?

Regards,

> I love your patch! Yet something to improve:
> 
> [auto build test ERROR on platform-drivers-x86/for-next]
> [also build test ERROR on v4.15-rc4 next-20171220]
> [cannot apply to linus/master]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Vadim-Pasternak/drivers-platform-replace-module-x86-mlxcpld-hotplug-with-mellanox-mlxreg-hotplug/20171220-163359
> base:   git://git.infradead.org/users/dvhart/linux-platform-drivers-x86.git for-next
> config: sparc64-allyesconfig (attached as .config)
> compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
> reproduce:
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # save the attached .config to linux build tree
>         make.cross ARCH=sparc64 
> 
> Note: the linux-review/Vadim-Pasternak/drivers-platform-replace-module-x86-mlxcpld-hotplug-with-mellanox-mlxreg-hotplug/20171220-163359 HEAD 7e98e72a743e69069c34f3bbd3b9289740e30de0 builds fine.
>       It only hurts bisectibility.
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_attr_show':
> >> drivers/platform/mellanox/mlxreg-hotplug.c:224:17: error: implicit declaration of function 'inb' [-Werror=implicit-function-declaration]
>       reg_val = !!!(inb(priv->plat->psu_reg_offset) & BIT(index));
>                     ^~~
>    drivers/platform/mellanox/mlxreg-hotplug.c: In function 'mlxreg_hotplug_work_helper':
> >> drivers/platform/mellanox/mlxreg-hotplug.c:305:2: error: implicit declaration of function 'outb' [-Werror=implicit-function-declaration]
>      outb(0, offset + MLXREG_HOTPLUG_MASK_OFF);
>      ^~~~
>    cc1: some warnings being treated as errors
> 
> vim +/inb +224 drivers/platform/mellanox/mlxreg-hotplug.c
> 
> 86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  210  
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  211  static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  212  					struct device_attribute *attr,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  213  					char *buf)
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  214  {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  215  	struct platform_device *pdev = to_platform_device(dev);
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  216  	struct mlxreg_hotplug_priv_data *priv = platform_get_drvdata(pdev);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  217  	int index = to_sensor_dev_attr_2(attr)->index;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  218  	int nr = to_sensor_dev_attr_2(attr)->nr;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  219  	u8 reg_val = 0;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  220  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  221  	switch (nr) {
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  222  	case MLXREG_HOTPLUG_ATTR_TYPE_PSU:
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  223  		/* Bit = 0 : PSU is present. */
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20 @224  		reg_val = !!!(inb(priv->plat->psu_reg_offset) & BIT(index));
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  225  		break;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  226  
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  227  	case MLXREG_HOTPLUG_ATTR_TYPE_PWR:
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  228  		/* Bit = 1 : power cable is attached. */
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  229  		reg_val = !!(inb(priv->plat->pwr_reg_offset) & BIT(index %
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  230  						priv->plat->pwr_count));
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  231  		break;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  232  
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  233  	case MLXREG_HOTPLUG_ATTR_TYPE_FAN:
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  234  		/* Bit = 0 : FAN is present. */
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  235  		reg_val = !!!(inb(priv->plat->fan_reg_offset) & BIT(index %
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  236  						priv->plat->fan_count));
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  237  		break;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  238  	}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  239  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  240  	return sprintf(buf, "%u\n", reg_val);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  241  }
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  242  
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  243  #define PRIV_ATTR(i) priv->mlxreg_hotplug_attr[i]
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  244  #define PRIV_DEV_ATTR(i) priv->mlxreg_hotplug_dev_attr[i]
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  245  static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  246  {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  247  	int num_attrs = priv->plat->psu_count + priv->plat->pwr_count +
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  248  			priv->plat->fan_count;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  249  	int i;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  250  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  251  	priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs *
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  252  					 sizeof(struct attribute *),
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  253  					 GFP_KERNEL);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  254  	if (!priv->group.attrs)
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  255  		return -ENOMEM;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  256  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  257  	for (i = 0; i < num_attrs; i++) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  258  		PRIV_ATTR(i) = &PRIV_DEV_ATTR(i).dev_attr.attr;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  259  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  260  		if (i < priv->plat->psu_count) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  261  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  262  						GFP_KERNEL, "psu%u", i + 1);
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  263  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_PSU;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  264  		} else if (i < priv->plat->psu_count + priv->plat->pwr_count) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  265  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  266  						GFP_KERNEL, "pwr%u", i %
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  267  						priv->plat->pwr_count + 1);
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  268  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_PWR;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  269  		} else {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  270  			PRIV_ATTR(i)->name = devm_kasprintf(&priv->pdev->dev,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  271  						GFP_KERNEL, "fan%u", i %
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  272  						priv->plat->fan_count + 1);
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  273  			PRIV_DEV_ATTR(i).nr = MLXREG_HOTPLUG_ATTR_TYPE_FAN;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  274  		}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  275  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  276  		if (!PRIV_ATTR(i)->name) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  277  			dev_err(&priv->pdev->dev, "Memory allocation failed for sysfs attribute %d.\n",
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  278  				i + 1);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  279  			return -ENOMEM;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  280  		}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  281  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  282  		PRIV_DEV_ATTR(i).dev_attr.attr.name = PRIV_ATTR(i)->name;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  283  		PRIV_DEV_ATTR(i).dev_attr.attr.mode = S_IRUGO;
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  284  		PRIV_DEV_ATTR(i).dev_attr.show = mlxreg_hotplug_attr_show;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  285  		PRIV_DEV_ATTR(i).index = i;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  286  		sysfs_attr_init(&PRIV_DEV_ATTR(i).dev_attr.attr);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  287  	}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  288  
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  289  	priv->group.attrs = priv->mlxreg_hotplug_attr;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  290  	priv->groups[0] = &priv->group;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  291  	priv->groups[1] = NULL;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  292  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  293  	return 0;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  294  }
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  295  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  296  static inline void
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  297  mlxreg_hotplug_work_helper(struct device *dev,
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  298  			   struct mlxreg_hotplug_device *item, u8 is_inverse,
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  299  			   u16 offset, u8 mask, u8 *cache)
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  300  {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  301  	u8 val, asserted;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  302  	int bit;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  303  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  304  	/* Mask event. */
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18 @305  	outb(0, offset + MLXREG_HOTPLUG_MASK_OFF);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  306  	/* Read status. */
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  307  	val = inb(offset) & mask;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  308  	asserted = *cache ^ val;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  309  	*cache = val;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  310  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  311  	/*
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  312  	 * Validate if item related to received signal type is valid.
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  313  	 * It should never happen, excepted the situation when some
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  314  	 * piece of hardware is broken. In such situation just produce
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  315  	 * error message and return. Caller must continue to handle the
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  316  	 * signals from other devices if any.
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  317  	 */
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  318  	if (unlikely(!item)) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  319  		dev_err(dev, "False signal is received: register at offset 0x%02x, mask 0x%02x.\n",
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  320  			offset, mask);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  321  		return;
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  322  	}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  323  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  324  	for_each_set_bit(bit, (unsigned long *)&asserted, 8) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  325  		if (val & BIT(bit)) {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  326  			if (is_inverse)
> 86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  327  				mlxreg_hotplug_dev_disable(item + bit);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  328  			else
> 86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  329  				mlxreg_hotplug_dev_enable(item + bit);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  330  		} else {
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  331  			if (is_inverse)
> 86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  332  				mlxreg_hotplug_dev_enable(item + bit);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  333  			else
> 86a4f473 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  334  				mlxreg_hotplug_dev_disable(item + bit);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  335  		}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  336  	}
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  337  
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  338  	/* Acknowledge event. */
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  339  	outb(0, offset + MLXREG_HOTPLUG_EVENT_OFF);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  340  	/* Unmask event. */
> ebea1439 drivers/platform/mellanox/mlxreg-hotplug.c Vadim Pasternak 2017-12-18  341  	outb(mask, offset + MLXREG_HOTPLUG_MASK_OFF);
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  342  }
> 30488704 drivers/platform/x86/mlxcpld-hotplug.c     Vadim Pasternak 2016-10-20  343  
> 
> :::::: The code at line 224 was first introduced by commit
> :::::: 304887041d953b6692c0d4a9f8fafb252d32e9a0 platform/x86: Introduce support for Mellanox hotplug driver
> 
> :::::: TO: Vadim Pasternak <vadimp@mellanox.com>
> :::::: CC: Darren Hart <dvhart@linux.intel.com>
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

diff --git a/drivers/platform/mellanox/Kconfig b/drivers/platform/mellanox/Kconfig
index d735292..0267e1d 100644
--- a/drivers/platform/mellanox/Kconfig
+++ b/drivers/platform/mellanox/Kconfig
@@ -5,7 +5,7 @@ 
 
 menuconfig MELLANOX_PLATFORM
 	bool "Platform support for Mellanox hardware"
-	depends on X86 || COMPILE_TEST
+	depends on X86 || 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.
diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index 2866c76..53228b2 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -37,12 +37,9 @@ 
 #include <linux/hwmon-sysfs.h>
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
-#include <linux/io.h>
 #include <linux/module.h>
 #include <linux/platform_data/mlxreg.h>
 #include <linux/platform_device.h>
-#include <linux/spinlock.h>
-#include <linux/wait.h>
 #include <linux/workqueue.h>
 
 /* Offset of event and mask registers from status register */
@@ -50,6 +47,10 @@ 
 #define MLXREG_HOTPLUG_MASK_OFF	2
 #define MLXREG_HOTPLUG_AGGR_MASK_OFF	1
 
+#define MLXREG_HOTPLUG_PROP_OKAY	"okay"
+#define MLXREG_HOTPLUG_PROP_DISABLED	"disabled"
+#define MLXREG_HOTPLUG_PROP_STATUS	"status"
+
 #define MLXREG_HOTPLUG_ATTRS_NUM	8
 
 /**
@@ -99,6 +100,114 @@  struct mlxreg_hotplug_priv_data {
 	u8 fan_cache;
 };
 
+#if defined(CONFIG_OF_DYNAMIC)
+/**
+ * struct mlxreg_hotplug_device_en - Open Firmware property for enabling device
+ *
+ * @name - property name;
+ * @value - property value string;
+ * @length - length of proprty value string;
+ *
+ * The structure is used for the devices, which require some dynamic
+ * selection operation allowing access to them.
+ */
+static struct property mlxreg_hotplug_device_en = {
+	.name = MLXREG_HOTPLUG_PROP_STATUS,
+	.value = MLXREG_HOTPLUG_PROP_OKAY,
+	.length = sizeof(MLXREG_HOTPLUG_PROP_OKAY),
+};
+
+/**
+ * struct mlxreg_hotplug_device_dis - Open Firmware property for disabling
+ * device
+ *
+ * @name - property name;
+ * @value - property value string;
+ * @length - length of proprty value string;
+ *
+ * The structure is used for the devices, which require some dynamic
+ * selection operation disallowing access to them.
+ */
+static struct property mlxreg_hotplug_device_dis = {
+	.name = MLXREG_HOTPLUG_PROP_STATUS,
+	.value = MLXREG_HOTPLUG_PROP_DISABLED,
+	.length = sizeof(MLXREG_HOTPLUG_PROP_DISABLED),
+};
+
+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
+static int mlxreg_hotplug_of_device_create(struct mlxreg_hotplug_device *data)
+{
+	return 0;
+}
+
+static void
+mlxreg_hotplug_of_device_destroy(struct mlxreg_hotplug_device *data)
+{
+}
+#endif
+
+static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_device *data)
+{
+	data->adapter = i2c_get_adapter(data->nr);
+	if (!data->adapter)
+		return -EFAULT;
+
+	data->client = i2c_new_device(data->adapter, &data->brdinfo);
+	if (!data->client) {
+		i2c_put_adapter(data->adapter);
+		data->adapter = NULL;
+		return -EFAULT;
+	}
+
+	return 0;
+}
+
+static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *data)
+{
+	if (data->client) {
+		i2c_unregister_device(data->client);
+		data->client = NULL;
+	}
+
+	if (data->adapter) {
+		i2c_put_adapter(data->adapter);
+		data->adapter = NULL;
+	}
+}
+
+static int mlxreg_hotplug_dev_enable(struct mlxreg_hotplug_device *data)
+{
+	int err;
+
+	/* Enable and create device. */
+	if (data->np)
+		err = mlxreg_hotplug_of_device_create(data);
+	else
+		err = mlxreg_hotplug_device_create(data);
+
+	return err;
+}
+
+static void mlxreg_hotplug_dev_disable(struct mlxreg_hotplug_device *data)
+{
+	/* Disable and unregister platform device. */
+	if (data->np)
+		mlxreg_hotplug_of_device_destroy(data);
+	else
+		mlxreg_hotplug_device_destroy(data);
+}
+
 static ssize_t mlxreg_hotplug_attr_show(struct device *dev,
 					struct device_attribute *attr,
 					char *buf)
@@ -184,41 +293,6 @@  static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
 	return 0;
 }
 
-static int mlxreg_hotplug_device_create(struct device *dev,
-					struct mlxreg_hotplug_device *item)
-{
-	item->adapter = i2c_get_adapter(item->bus);
-	if (!item->adapter) {
-		dev_err(dev, "Failed to get adapter for bus %d\n",
-			item->bus);
-		return -EFAULT;
-	}
-
-	item->client = i2c_new_device(item->adapter, &item->brdinfo);
-	if (!item->client) {
-		dev_err(dev, "Failed to create client %s at bus %d at addr 0x%02x\n",
-			item->brdinfo.type, item->bus, item->brdinfo.addr);
-		i2c_put_adapter(item->adapter);
-		item->adapter = NULL;
-		return -EFAULT;
-	}
-
-	return 0;
-}
-
-static void mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_device *item)
-{
-	if (item->client) {
-		i2c_unregister_device(item->client);
-		item->client = NULL;
-	}
-
-	if (item->adapter) {
-		i2c_put_adapter(item->adapter);
-		item->adapter = NULL;
-	}
-}
-
 static inline void
 mlxreg_hotplug_work_helper(struct device *dev,
 			   struct mlxreg_hotplug_device *item, u8 is_inverse,
@@ -250,14 +324,14 @@  mlxreg_hotplug_work_helper(struct device *dev,
 	for_each_set_bit(bit, (unsigned long *)&asserted, 8) {
 		if (val & BIT(bit)) {
 			if (is_inverse)
-				mlxreg_hotplug_device_destroy(item + bit);
+				mlxreg_hotplug_dev_disable(item + bit);
 			else
-				mlxreg_hotplug_device_create(dev, item + bit);
+				mlxreg_hotplug_dev_enable(item + bit);
 		} else {
 			if (is_inverse)
-				mlxreg_hotplug_device_create(dev, item + bit);
+				mlxreg_hotplug_dev_enable(item + bit);
 			else
-				mlxreg_hotplug_device_destroy(item + bit);
+				mlxreg_hotplug_dev_disable(item + bit);
 		}
 	}
 
@@ -408,13 +482,13 @@  static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv)
 
 	/* Remove all the attached devices. */
 	for (i = 0; i < priv->plat->psu_count; i++)
-		mlxreg_hotplug_device_destroy(priv->plat->psu + i);
+		mlxreg_hotplug_dev_disable(priv->plat->psu + i);
 
 	for (i = 0; i < priv->plat->pwr_count; i++)
-		mlxreg_hotplug_device_destroy(priv->plat->pwr + i);
+		mlxreg_hotplug_dev_disable(priv->plat->pwr + i);
 
 	for (i = 0; i < priv->plat->fan_count; i++)
-		mlxreg_hotplug_device_destroy(priv->plat->fan + i);
+		mlxreg_hotplug_dev_disable(priv->plat->fan + i);
 }
 
 static irqreturn_t mlxreg_hotplug_irq_handler(int irq, void *dev)
diff --git a/drivers/platform/x86/mlx-platform.c b/drivers/platform/x86/mlx-platform.c
index 0fbec1f..5601714 100644
--- a/drivers/platform/x86/mlx-platform.c
+++ b/drivers/platform/x86/mlx-platform.c
@@ -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,
 	},
 };
 
diff --git a/include/linux/platform_data/mlxreg.h b/include/linux/platform_data/mlxreg.h
index 8dcbb8e..5c98ad1 100644
--- a/include/linux/platform_data/mlxreg.h
+++ b/include/linux/platform_data/mlxreg.h
@@ -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;
 };
 
 /**