Skip to content
/ linux Public

Commit e05d6b6

Browse files
vadimp-nvidiajwrdegoede
authored andcommitted
platform/x86: mlx-platform: Make activation of some drivers conditional
Current assumption in driver that any system is capable of LED, hotplug or watchdog support. It could be not true for some new coming systems. Add validation for LED, hotplug, watchdog configuration and skip activation of relevant drivers if not configured. Signed-off-by: Vadim Pasternak <vadimp@nvidia.com> Reviewed-by: Oleksandr Shamray <oleksandrs@nvidia.com> Link: https://lore.kernel.org/r/20220711084559.62447-2-vadimp@nvidia.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
1 parent b644c95 commit e05d6b6

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

drivers/platform/x86/mlx-platform.c

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,16 +4853,18 @@ static int __init mlxplat_init(void)
48534853
}
48544854

48554855
/* Add hotplug driver */
4856-
mlxplat_hotplug->regmap = priv->regmap;
4857-
priv->pdev_hotplug = platform_device_register_resndata(
4858-
&mlxplat_dev->dev, "mlxreg-hotplug",
4859-
PLATFORM_DEVID_NONE,
4860-
mlxplat_mlxcpld_resources,
4861-
ARRAY_SIZE(mlxplat_mlxcpld_resources),
4862-
mlxplat_hotplug, sizeof(*mlxplat_hotplug));
4863-
if (IS_ERR(priv->pdev_hotplug)) {
4864-
err = PTR_ERR(priv->pdev_hotplug);
4865-
goto fail_platform_mux_register;
4856+
if (mlxplat_hotplug) {
4857+
mlxplat_hotplug->regmap = priv->regmap;
4858+
priv->pdev_hotplug =
4859+
platform_device_register_resndata(&mlxplat_dev->dev,
4860+
"mlxreg-hotplug", PLATFORM_DEVID_NONE,
4861+
mlxplat_mlxcpld_resources,
4862+
ARRAY_SIZE(mlxplat_mlxcpld_resources),
4863+
mlxplat_hotplug, sizeof(*mlxplat_hotplug));
4864+
if (IS_ERR(priv->pdev_hotplug)) {
4865+
err = PTR_ERR(priv->pdev_hotplug);
4866+
goto fail_platform_mux_register;
4867+
}
48664868
}
48674869

48684870
/* Set default registers. */
@@ -4875,24 +4877,26 @@ static int __init mlxplat_init(void)
48754877
}
48764878

48774879
/* Add LED driver. */
4878-
mlxplat_led->regmap = priv->regmap;
4879-
priv->pdev_led = platform_device_register_resndata(
4880-
&mlxplat_dev->dev, "leds-mlxreg",
4881-
PLATFORM_DEVID_NONE, NULL, 0,
4882-
mlxplat_led, sizeof(*mlxplat_led));
4883-
if (IS_ERR(priv->pdev_led)) {
4884-
err = PTR_ERR(priv->pdev_led);
4885-
goto fail_platform_hotplug_register;
4880+
if (mlxplat_led) {
4881+
mlxplat_led->regmap = priv->regmap;
4882+
priv->pdev_led =
4883+
platform_device_register_resndata(&mlxplat_dev->dev, "leds-mlxreg",
4884+
PLATFORM_DEVID_NONE, NULL, 0, mlxplat_led,
4885+
sizeof(*mlxplat_led));
4886+
if (IS_ERR(priv->pdev_led)) {
4887+
err = PTR_ERR(priv->pdev_led);
4888+
goto fail_platform_hotplug_register;
4889+
}
48864890
}
48874891

48884892
/* Add registers io access driver. */
48894893
if (mlxplat_regs_io) {
48904894
mlxplat_regs_io->regmap = priv->regmap;
4891-
priv->pdev_io_regs = platform_device_register_resndata(
4892-
&mlxplat_dev->dev, "mlxreg-io",
4893-
PLATFORM_DEVID_NONE, NULL, 0,
4894-
mlxplat_regs_io,
4895-
sizeof(*mlxplat_regs_io));
4895+
priv->pdev_io_regs = platform_device_register_resndata(&mlxplat_dev->dev,
4896+
"mlxreg-io",
4897+
PLATFORM_DEVID_NONE, NULL,
4898+
0, mlxplat_regs_io,
4899+
sizeof(*mlxplat_regs_io));
48964900
if (IS_ERR(priv->pdev_io_regs)) {
48974901
err = PTR_ERR(priv->pdev_io_regs);
48984902
goto fail_platform_led_register;
@@ -4949,9 +4953,11 @@ static int __init mlxplat_init(void)
49494953
if (mlxplat_regs_io)
49504954
platform_device_unregister(priv->pdev_io_regs);
49514955
fail_platform_led_register:
4952-
platform_device_unregister(priv->pdev_led);
4956+
if (mlxplat_led)
4957+
platform_device_unregister(priv->pdev_led);
49534958
fail_platform_hotplug_register:
4954-
platform_device_unregister(priv->pdev_hotplug);
4959+
if (mlxplat_hotplug)
4960+
platform_device_unregister(priv->pdev_hotplug);
49554961
fail_platform_mux_register:
49564962
while (--i >= 0)
49574963
platform_device_unregister(priv->pdev_mux[i]);
@@ -4974,8 +4980,10 @@ static void __exit mlxplat_exit(void)
49744980
platform_device_unregister(priv->pdev_fan);
49754981
if (priv->pdev_io_regs)
49764982
platform_device_unregister(priv->pdev_io_regs);
4977-
platform_device_unregister(priv->pdev_led);
4978-
platform_device_unregister(priv->pdev_hotplug);
4983+
if (priv->pdev_led)
4984+
platform_device_unregister(priv->pdev_led);
4985+
if (priv->pdev_hotplug)
4986+
platform_device_unregister(priv->pdev_hotplug);
49794987

49804988
for (i = mlxplat_mux_num - 1; i >= 0 ; i--)
49814989
platform_device_unregister(priv->pdev_mux[i]);

0 commit comments

Comments
 (0)