aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Pasternak <vadimp@mellanox.com>2018-07-26 18:40:59 -0400
committerDarren Hart (VMware) <dvhart@infradead.org>2018-08-01 20:41:31 -0400
commit9272d2d1d3bf5b66242acaeffe442fcd6079624e (patch)
tree332ef9976bb37baf017bac97012e121b8161e759
parent66342d1c9c2460fe7d2d9c75f7e88f14d88318f2 (diff)
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>
-rw-r--r--drivers/platform/mellanox/mlxreg-hotplug.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c
index f363e0786ef4..b6d44550d98c 100644
--- a/drivers/platform/mellanox/mlxreg-hotplug.c
+++ b/drivers/platform/mellanox/mlxreg-hotplug.c
@@ -102,6 +102,9 @@ static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
102{ 102{
103 struct mlxreg_core_hotplug_platform_data *pdata; 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 * Return if adapter number is negative. It could be in case hotplug 109 * Return if adapter number is negative. It could be in case hotplug
107 * event is not associated with hotplug device. 110 * event is not associated with hotplug device.
@@ -133,8 +136,13 @@ static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
133 return 0; 136 return 0;
134} 137}
135 138
136static void mlxreg_hotplug_device_destroy(struct mlxreg_core_data *data) 139static void
140mlxreg_hotplug_device_destroy(struct mlxreg_hotplug_priv_data *priv,
141 struct mlxreg_core_data *data)
137{ 142{
143 /* Notify user by sending hwmon uevent. */
144 kobject_uevent(&priv->hwmon->kobj, KOBJ_CHANGE);
145
138 if (data->hpdev.client) { 146 if (data->hpdev.client) {
139 i2c_unregister_device(data->hpdev.client); 147 i2c_unregister_device(data->hpdev.client);
140 data->hpdev.client = NULL; 148 data->hpdev.client = NULL;
@@ -277,14 +285,14 @@ mlxreg_hotplug_work_helper(struct mlxreg_hotplug_priv_data *priv,
277 data = item->data + bit; 285 data = item->data + bit;
278 if (regval & BIT(bit)) { 286 if (regval & BIT(bit)) {
279 if (item->inversed) 287 if (item->inversed)
280 mlxreg_hotplug_device_destroy(data); 288 mlxreg_hotplug_device_destroy(priv, data);
281 else 289 else
282 mlxreg_hotplug_device_create(priv, data); 290 mlxreg_hotplug_device_create(priv, data);
283 } else { 291 } else {
284 if (item->inversed) 292 if (item->inversed)
285 mlxreg_hotplug_device_create(priv, data); 293 mlxreg_hotplug_device_create(priv, data);
286 else 294 else
287 mlxreg_hotplug_device_destroy(data); 295 mlxreg_hotplug_device_destroy(priv, data);
288 } 296 }
289 } 297 }
290 298
@@ -351,7 +359,7 @@ mlxreg_hotplug_health_work_helper(struct mlxreg_hotplug_priv_data *priv,
351 * in steady state. Disconnect associated 359 * in steady state. Disconnect associated
352 * device, if it has been connected. 360 * device, if it has been connected.
353 */ 361 */
354 mlxreg_hotplug_device_destroy(data); 362 mlxreg_hotplug_device_destroy(priv, data);
355 data->attached = false; 363 data->attached = false;
356 data->health_cntr = 0; 364 data->health_cntr = 0;
357 } 365 }
@@ -569,7 +577,7 @@ static void mlxreg_hotplug_unset_irq(struct mlxreg_hotplug_priv_data *priv)
569 /* Remove all the attached devices in group. */ 577 /* Remove all the attached devices in group. */
570 count = item->count; 578 count = item->count;
571 for (j = 0; j < count; j++, data++) 579 for (j = 0; j < count; j++, data++)
572 mlxreg_hotplug_device_destroy(data); 580 mlxreg_hotplug_device_destroy(priv, data);
573 } 581 }
574} 582}
575 583
@@ -634,10 +642,6 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev)
634 disable_irq(priv->irq); 642 disable_irq(priv->irq);
635 spin_lock_init(&priv->lock); 643 spin_lock_init(&priv->lock);
636 INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler); 644 INIT_DELAYED_WORK(&priv->dwork_irq, mlxreg_hotplug_work_handler);
637 /* Perform initial interrupts setup. */
638 mlxreg_hotplug_set_irq(priv);
639
640 priv->after_probe = true;
641 dev_set_drvdata(&pdev->dev, priv); 645 dev_set_drvdata(&pdev->dev, priv);
642 646
643 err = mlxreg_hotplug_attr_init(priv); 647 err = mlxreg_hotplug_attr_init(priv);
@@ -655,6 +659,10 @@ static int mlxreg_hotplug_probe(struct platform_device *pdev)
655 return PTR_ERR(priv->hwmon); 659 return PTR_ERR(priv->hwmon);
656 } 660 }
657 661
662 /* Perform initial interrupts setup. */
663 mlxreg_hotplug_set_irq(priv);
664 priv->after_probe = true;
665
658 return 0; 666 return 0;
659} 667}
660 668