From e1a39a4460c17fa397020cd064744a908e2eac71 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Wed, 3 Feb 2021 21:54:23 +0000 Subject: [PATCH] platform/x86: ideapad-laptop: remove unnecessary NULL checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The checks that are removed test pointers which should not be NULL. If they are NULL, that indicates a bug in a different part of the kernel. Instead of silently bailing out, let it fail loudly. Signed-off-by: Barnabás Pőcze Link: https://lore.kernel.org/r/20210203215403.290792-3-pobrn@protonmail.com Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede --- drivers/platform/x86/ideapad-laptop.c | 78 ++++++++++++++--------------------- 1 file changed, 31 insertions(+), 47 deletions(-) diff --git a/drivers/platform/x86/ideapad-laptop.c b/drivers/platform/x86/ideapad-laptop.c index 18c71e2..415d362 100644 --- a/drivers/platform/x86/ideapad-laptop.c +++ b/drivers/platform/x86/ideapad-laptop.c @@ -264,9 +264,6 @@ static int debugfs_status_show(struct seq_file *s, void *data) struct ideapad_private *priv = s->private; unsigned long value; - if (!priv) - return -EINVAL; - if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL_MAX, &value)) seq_printf(s, "Backlight max:\t%lu\n", value); if (!read_ec_data(priv->adev->handle, VPCCMD_R_BL, &value)) @@ -311,39 +308,36 @@ static int debugfs_cfg_show(struct seq_file *s, void *data) { struct ideapad_private *priv = s->private; - if (!priv) { - seq_printf(s, "cfg: N/A\n"); - } else { - seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ", - priv->cfg); - if (test_bit(CFG_BT_BIT, &priv->cfg)) - seq_printf(s, "Bluetooth "); - if (test_bit(CFG_3G_BIT, &priv->cfg)) - seq_printf(s, "3G "); - if (test_bit(CFG_WIFI_BIT, &priv->cfg)) - seq_printf(s, "Wireless "); - if (test_bit(CFG_CAMERA_BIT, &priv->cfg)) - seq_printf(s, "Camera "); - seq_printf(s, "\nGraphic: "); - switch ((priv->cfg)&0x700) { - case 0x100: - seq_printf(s, "Intel"); - break; - case 0x200: - seq_printf(s, "ATI"); - break; - case 0x300: - seq_printf(s, "Nvidia"); - break; - case 0x400: - seq_printf(s, "Intel and ATI"); - break; - case 0x500: - seq_printf(s, "Intel and Nvidia"); - break; - } - seq_printf(s, "\n"); + seq_printf(s, "cfg: 0x%.8lX\n\nCapability: ", + priv->cfg); + if (test_bit(CFG_BT_BIT, &priv->cfg)) + seq_printf(s, "Bluetooth "); + if (test_bit(CFG_3G_BIT, &priv->cfg)) + seq_printf(s, "3G "); + if (test_bit(CFG_WIFI_BIT, &priv->cfg)) + seq_printf(s, "Wireless "); + if (test_bit(CFG_CAMERA_BIT, &priv->cfg)) + seq_printf(s, "Camera "); + seq_printf(s, "\nGraphic: "); + switch ((priv->cfg)&0x700) { + case 0x100: + seq_printf(s, "Intel"); + break; + case 0x200: + seq_printf(s, "ATI"); + break; + case 0x300: + seq_printf(s, "Nvidia"); + break; + case 0x400: + seq_printf(s, "Intel and ATI"); + break; + case 0x500: + seq_printf(s, "Intel and Nvidia"); + break; } + seq_printf(s, "\n"); + return 0; } DEFINE_SHOW_ATTRIBUTE(debugfs_cfg); @@ -1050,9 +1044,6 @@ static int ideapad_backlight_get_brightness(struct backlight_device *blightdev) struct ideapad_private *priv = bl_get_data(blightdev); unsigned long now; - if (!priv) - return -EINVAL; - if (read_ec_data(priv->adev->handle, VPCCMD_R_BL, &now)) return -EIO; return now; @@ -1062,9 +1053,6 @@ static int ideapad_backlight_update_status(struct backlight_device *blightdev) { struct ideapad_private *priv = bl_get_data(blightdev); - if (!priv) - return -EINVAL; - if (write_ec_cmd(priv->adev->handle, VPCCMD_W_BL, blightdev->props.brightness)) return -EIO; @@ -1374,13 +1362,9 @@ static int ideapad_acpi_remove(struct platform_device *pdev) } #ifdef CONFIG_PM_SLEEP -static int ideapad_acpi_resume(struct device *device) +static int ideapad_acpi_resume(struct device *dev) { - struct ideapad_private *priv; - - if (!device) - return -EINVAL; - priv = dev_get_drvdata(device); + struct ideapad_private *priv = dev_get_drvdata(dev); ideapad_sync_rfk_state(priv); ideapad_sync_touchpad_state(priv); -- 2.7.4