All the attribute show call-backs check whether pcard is NULL. However, pci_set_drvdata(pdev, pcard) is called before the sysfs files are created during probe, and pci_set_drvdata(pdev, NULL) is not called until after they are destroyed during remove; therefore, pcard will not be NULL, and we can drop the checks. Signed-off-by: Jeremy Sowden <jeremy@xxxxxxxxxx> --- drivers/staging/kpc2000/kpc2000/core.c | 27 -------------------------- 1 file changed, 27 deletions(-) diff --git a/drivers/staging/kpc2000/kpc2000/core.c b/drivers/staging/kpc2000/kpc2000/core.c index f5ad90b17959..3a4773183cab 100644 --- a/drivers/staging/kpc2000/kpc2000/core.c +++ b/drivers/staging/kpc2000/kpc2000/core.c @@ -30,9 +30,6 @@ static ssize_t ssid_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%016llx\n", pcard->ssid); } static DEVICE_ATTR_RO(ssid); @@ -42,9 +39,6 @@ static ssize_t ddna_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%016llx\n", pcard->ddna); } static DEVICE_ATTR_RO(ddna); @@ -54,9 +48,6 @@ static ssize_t card_id_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->card_id); } static DEVICE_ATTR_RO(card_id); @@ -66,9 +57,6 @@ static ssize_t hw_rev_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->hardware_revision); } static DEVICE_ATTR_RO(hw_rev); @@ -78,9 +66,6 @@ static ssize_t build_show(struct device *dev, struct device_attribute *attr, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_version); } static DEVICE_ATTR_RO(build); @@ -90,9 +75,6 @@ static ssize_t build_date_show(struct device *dev, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_datestamp); } static DEVICE_ATTR_RO(build_date); @@ -102,9 +84,6 @@ static ssize_t build_time_show(struct device *dev, { struct kp2000_device *pcard = dev_get_drvdata(dev); - if (!pcard) - return -ENXIO; - return sprintf(buf, "%08x\n", pcard->build_timestamp); } static DEVICE_ATTR_RO(build_time); @@ -115,9 +94,6 @@ static ssize_t cpld_reg_show(struct device *dev, struct device_attribute *attr, struct kp2000_device *pcard = dev_get_drvdata(dev); u64 val; - if (!pcard) - return -ENXIO; - val = readq(pcard->sysinfo_regs_base + REG_CPLD_CONFIG); return sprintf(buf, "%016llx\n", val); } @@ -131,9 +107,6 @@ static ssize_t cpld_reconfigure(struct device *dev, long wr_val; int rv; - if (!pcard) - return -ENXIO; - rv = kstrtol(buf, 0, &wr_val); if (rv < 0) return rv; -- 2.20.1 _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel