aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/mlxreg-fan.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/hwmon/mlxreg-fan.c')
-rw-r--r--drivers/hwmon/mlxreg-fan.c31
1 files changed, 10 insertions, 21 deletions
diff --git a/drivers/hwmon/mlxreg-fan.c b/drivers/hwmon/mlxreg-fan.c
index f816d2ae1e58..ed8d59d4eecb 100644
--- a/drivers/hwmon/mlxreg-fan.c
+++ b/drivers/hwmon/mlxreg-fan.c
@@ -465,42 +465,42 @@ static int mlxreg_fan_config(struct mlxreg_fan *fan,
465static int mlxreg_fan_probe(struct platform_device *pdev) 465static int mlxreg_fan_probe(struct platform_device *pdev)
466{ 466{
467 struct mlxreg_core_platform_data *pdata; 467 struct mlxreg_core_platform_data *pdata;
468 struct device *dev = &pdev->dev;
468 struct mlxreg_fan *fan; 469 struct mlxreg_fan *fan;
469 struct device *hwm; 470 struct device *hwm;
470 int err; 471 int err;
471 472
472 pdata = dev_get_platdata(&pdev->dev); 473 pdata = dev_get_platdata(dev);
473 if (!pdata) { 474 if (!pdata) {
474 dev_err(&pdev->dev, "Failed to get platform data.\n"); 475 dev_err(dev, "Failed to get platform data.\n");
475 return -EINVAL; 476 return -EINVAL;
476 } 477 }
477 478
478 fan = devm_kzalloc(&pdev->dev, sizeof(*fan), GFP_KERNEL); 479 fan = devm_kzalloc(dev, sizeof(*fan), GFP_KERNEL);
479 if (!fan) 480 if (!fan)
480 return -ENOMEM; 481 return -ENOMEM;
481 482
482 fan->dev = &pdev->dev; 483 fan->dev = dev;
483 fan->regmap = pdata->regmap; 484 fan->regmap = pdata->regmap;
484 platform_set_drvdata(pdev, fan);
485 485
486 err = mlxreg_fan_config(fan, pdata); 486 err = mlxreg_fan_config(fan, pdata);
487 if (err) 487 if (err)
488 return err; 488 return err;
489 489
490 hwm = devm_hwmon_device_register_with_info(&pdev->dev, "mlxreg_fan", 490 hwm = devm_hwmon_device_register_with_info(dev, "mlxreg_fan",
491 fan, 491 fan,
492 &mlxreg_fan_hwmon_chip_info, 492 &mlxreg_fan_hwmon_chip_info,
493 NULL); 493 NULL);
494 if (IS_ERR(hwm)) { 494 if (IS_ERR(hwm)) {
495 dev_err(&pdev->dev, "Failed to register hwmon device\n"); 495 dev_err(dev, "Failed to register hwmon device\n");
496 return PTR_ERR(hwm); 496 return PTR_ERR(hwm);
497 } 497 }
498 498
499 if (IS_REACHABLE(CONFIG_THERMAL)) { 499 if (IS_REACHABLE(CONFIG_THERMAL)) {
500 fan->cdev = thermal_cooling_device_register("mlxreg_fan", fan, 500 fan->cdev = devm_thermal_of_cooling_device_register(dev,
501 &mlxreg_fan_cooling_ops); 501 NULL, "mlxreg_fan", fan, &mlxreg_fan_cooling_ops);
502 if (IS_ERR(fan->cdev)) { 502 if (IS_ERR(fan->cdev)) {
503 dev_err(&pdev->dev, "Failed to register cooling device\n"); 503 dev_err(dev, "Failed to register cooling device\n");
504 return PTR_ERR(fan->cdev); 504 return PTR_ERR(fan->cdev);
505 } 505 }
506 } 506 }
@@ -508,22 +508,11 @@ static int mlxreg_fan_probe(struct platform_device *pdev)
508 return 0; 508 return 0;
509} 509}
510 510
511static int mlxreg_fan_remove(struct platform_device *pdev)
512{
513 struct mlxreg_fan *fan = platform_get_drvdata(pdev);
514
515 if (IS_REACHABLE(CONFIG_THERMAL))
516 thermal_cooling_device_unregister(fan->cdev);
517
518 return 0;
519}
520
521static struct platform_driver mlxreg_fan_driver = { 511static struct platform_driver mlxreg_fan_driver = {
522 .driver = { 512 .driver = {
523 .name = "mlxreg-fan", 513 .name = "mlxreg-fan",
524 }, 514 },
525 .probe = mlxreg_fan_probe, 515 .probe = mlxreg_fan_probe,
526 .remove = mlxreg_fan_remove,
527}; 516};
528 517
529module_platform_driver(mlxreg_fan_driver); 518module_platform_driver(mlxreg_fan_driver);