Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/mellanox: mlxreg-hotplug: Add hotplug hwmon uevent notification

Notify user when hotplug device signal is received in order to allow user
to handle such case, if it wishes to take some action on this matter.

Signed-off-by: Vadim Pasternak <vadimp@mellanox.com>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>

authored by

Vadim Pasternak and committed by
Darren Hart (VMware)
9272d2d1 66342d1c

+17 -9
+17 -9
drivers/platform/mellanox/mlxreg-hotplug.c
··· 102 102 { 103 103 struct mlxreg_core_hotplug_platform_data *pdata; 104 104 105 + /* Notify user by sending hwmon uevent. */ 106 + kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); 107 + 105 108 /* 106 109 * Return if adapter number is negative. It could be in case hotplug 107 110 * event is not associated with hotplug device. ··· 136 133 return 0; 137 134 } 138 135 139 - static void mlxreg_hotplug_device_destroy(struct mlxreg_core_data *data) 136 + static void 137 + mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv, 138 + struct mlxreg_core_data *data) 140 139 { 140 + /* Notify user by sending hwmon uevent. */ 141 + kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE); 142 + 141 143 if (data->hpdev.client) { 142 144 i2c_unregister_device(data->hpdev.client); 143 145 data->hpdev.client = NULL; ··· 285 277 data = item->data + bit; 286 278 if (regval & BIT(bit)) { 287 279 if (item->inversed) 288 - mlxreg_hotplug_device_destroy(data); 280 + mlxreg_hotplug_device_destroy(priv, data); 289 281 else 290 282 mlxreg_hotplug_device_create(priv, data); 291 283 } else { 292 284 if (item->inversed) 293 285 mlxreg_hotplug_device_create(priv, data); 294 286 else 295 - mlxreg_hotplug_device_destroy(data); 287 + mlxreg_hotplug_device_destroy(priv, data); 296 288 } 297 289 } 298 290 ··· 359 351 * in steady state. Disconnect associated 360 352 * device, if it has been connected. 361 353 */ 362 - mlxreg_hotplug_device_destroy(data); 354 + mlxreg_hotplug_device_destroy(priv, data); 363 355 data->attached = false; 364 356 data->health_cntr = 0; 365 357 } ··· 577 569 /* Remove all the attached devices in group. */ 578 570 count = item->count; 579 571 for (j = 0; j < count; j++, data++) 580 - mlxreg_hotplug_device_destroy(data); 572 + mlxreg_hotplug_device_destroy(priv, data); 581 573 } 582 574 } 583 575 ··· 642 634 disable_irq(priv->irq); 643 635 spin_lock_init(&priv->lock); 644 636 INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler); 645 - /* Perform initial interrupts setup. */ 646 - mlxreg_hotplug_set_irq(priv); 647 - 648 - priv->after_probe = true; 649 637 dev_set_drvdata(&pdev->dev, priv); 650 638 651 639 err = mlxreg_hotplug_attr_init(priv); ··· 658 654 PTR_ERR(priv->hwmon)); 659 655 return PTR_ERR(priv->hwmon); 660 656 } 657 + 658 + /* Perform initial interrupts setup. */ 659 + mlxreg_hotplug_set_irq(priv); 660 + priv->after_probe = true; 661 661 662 662 return 0; 663 663 }