mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 15:03:52 +08:00
PCI: hotplug: Drop superfluous NULL pointer checks in has_*_file()
The PCI hotplug core contains five has_*_file() functions to determine
whether a certain sysfs file shall be added (or removed) for a given
hotplug slot.
The functions perform NULL pointer checks for the hotplug_slot and its
hotplug_slot_ops. However the callers already perform these checks:
pci_hp_register()
__pci_hp_register()
__pci_hp_initialize()
pci_hp_deregister()
pci_hp_del()
The only way to actually trigger these checks is to call pci_hp_add()
without having called pci_hp_initialize().
Amend pci_hp_add() to catch that and drop the now superfluous NULL
pointer checks in has_*_file().
Drop the same superfluous checks from pci_hp_create_module_link(),
which is (only) called from pci_hp_add().
Link: https://lore.kernel.org/r/37d1928edf8c3201a8b10794f1db3142e16e02b9.1740501868.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
committed by
Bjorn Helgaas
parent
666550a806
commit
62460bcb5a
@@ -209,8 +209,6 @@ static bool has_power_file(struct pci_slot *pci_slot)
|
||||
{
|
||||
struct hotplug_slot *slot = pci_slot->hotplug;
|
||||
|
||||
if ((!slot) || (!slot->ops))
|
||||
return false;
|
||||
if ((slot->ops->enable_slot) ||
|
||||
(slot->ops->disable_slot) ||
|
||||
(slot->ops->get_power_status))
|
||||
@@ -222,8 +220,6 @@ static bool has_attention_file(struct pci_slot *pci_slot)
|
||||
{
|
||||
struct hotplug_slot *slot = pci_slot->hotplug;
|
||||
|
||||
if ((!slot) || (!slot->ops))
|
||||
return false;
|
||||
if ((slot->ops->set_attention_status) ||
|
||||
(slot->ops->get_attention_status))
|
||||
return true;
|
||||
@@ -234,8 +230,6 @@ static bool has_latch_file(struct pci_slot *pci_slot)
|
||||
{
|
||||
struct hotplug_slot *slot = pci_slot->hotplug;
|
||||
|
||||
if ((!slot) || (!slot->ops))
|
||||
return false;
|
||||
if (slot->ops->get_latch_status)
|
||||
return true;
|
||||
return false;
|
||||
@@ -245,8 +239,6 @@ static bool has_adapter_file(struct pci_slot *pci_slot)
|
||||
{
|
||||
struct hotplug_slot *slot = pci_slot->hotplug;
|
||||
|
||||
if ((!slot) || (!slot->ops))
|
||||
return false;
|
||||
if (slot->ops->get_adapter_status)
|
||||
return true;
|
||||
return false;
|
||||
@@ -256,8 +248,6 @@ static bool has_test_file(struct pci_slot *pci_slot)
|
||||
{
|
||||
struct hotplug_slot *slot = pci_slot->hotplug;
|
||||
|
||||
if ((!slot) || (!slot->ops))
|
||||
return false;
|
||||
if (slot->ops->hardware_test)
|
||||
return true;
|
||||
return false;
|
||||
@@ -439,9 +429,14 @@ EXPORT_SYMBOL_GPL(__pci_hp_initialize);
|
||||
*/
|
||||
int pci_hp_add(struct hotplug_slot *slot)
|
||||
{
|
||||
struct pci_slot *pci_slot = slot->pci_slot;
|
||||
struct pci_slot *pci_slot;
|
||||
int result;
|
||||
|
||||
if (WARN_ON(!slot))
|
||||
return -EINVAL;
|
||||
|
||||
pci_slot = slot->pci_slot;
|
||||
|
||||
result = fs_add_slot(pci_slot);
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
@@ -340,8 +340,6 @@ void pci_hp_create_module_link(struct pci_slot *pci_slot)
|
||||
struct kobject *kobj = NULL;
|
||||
int ret;
|
||||
|
||||
if (!slot || !slot->ops)
|
||||
return;
|
||||
kobj = kset_find_obj(module_kset, slot->mod_name);
|
||||
if (!kobj)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user