]> git.karo-electronics.de Git - linux-beck.git/commitdiff
EDAC: octeon: Use static attribute groups for sysfs entries
authorTakashi Iwai <tiwai@suse.de>
Wed, 4 Feb 2015 10:48:57 +0000 (11:48 +0100)
committerBorislav Petkov <bp@suse.de>
Mon, 23 Feb 2015 12:12:05 +0000 (13:12 +0100)
... instead of manual device_create_file() and device_remove_file()
calls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: http://lkml.kernel.org/r/1423046938-18111-8-git-send-email-tiwai@suse.de
Signed-off-by: Borislav Petkov <bp@suse.de>
drivers/edac/octeon_edac-lmc.c

index 4bd10f94f0683a3c14e44f0fb8e5f41bb92ab83e..bb19e0732681ce6a4af6c2e980c0c4bb382889f9 100644 (file)
@@ -209,35 +209,18 @@ static DEVICE_ATTR(row, S_IRUGO | S_IWUSR,
 static DEVICE_ATTR(col, S_IRUGO | S_IWUSR,
                   octeon_mc_inject_col_show, octeon_mc_inject_col_store);
 
+static struct attribute *octeon_dev_attrs[] = {
+       &dev_attr_inject.attr,
+       &dev_attr_error_type.attr,
+       &dev_attr_dimm.attr,
+       &dev_attr_rank.attr,
+       &dev_attr_bank.attr,
+       &dev_attr_row.attr,
+       &dev_attr_col.attr,
+       NULL
+};
 
-static int octeon_set_mc_sysfs_attributes(struct mem_ctl_info *mci)
-{
-       int rc;
-
-       rc = device_create_file(&mci->dev, &dev_attr_inject);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_error_type);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_dimm);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_rank);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_bank);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_row);
-       if (rc < 0)
-               return rc;
-       rc = device_create_file(&mci->dev, &dev_attr_col);
-       if (rc < 0)
-               return rc;
-
-       return 0;
-}
+ATTRIBUTE_GROUPS(octeon_dev);
 
 static int octeon_lmc_edac_probe(struct platform_device *pdev)
 {
@@ -271,18 +254,12 @@ static int octeon_lmc_edac_probe(struct platform_device *pdev)
                mci->ctl_name = "octeon-lmc-err";
                mci->edac_check = octeon_lmc_edac_poll;
 
-               if (edac_mc_add_mc(mci)) {
+               if (edac_mc_add_mc_with_groups(mci, octeon_dev_groups)) {
                        dev_err(&pdev->dev, "edac_mc_add_mc() failed\n");
                        edac_mc_free(mci);
                        return -ENXIO;
                }
 
-               if (octeon_set_mc_sysfs_attributes(mci)) {
-                       dev_err(&pdev->dev, "octeon_set_mc_sysfs_attributes() failed\n");
-                       return -ENXIO;
-               }
-
-
                cfg0.u64 = cvmx_read_csr(CVMX_LMCX_MEM_CFG0(mc));
                cfg0.s.intr_ded_ena = 0;        /* We poll */
                cfg0.s.intr_sec_ena = 0;
@@ -309,18 +286,12 @@ static int octeon_lmc_edac_probe(struct platform_device *pdev)
                mci->ctl_name = "co_lmc_err";
                mci->edac_check = octeon_lmc_edac_poll_o2;
 
-               if (edac_mc_add_mc(mci)) {
+               if (edac_mc_add_mc_with_groups(mci, octeon_dev_groups)) {
                        dev_err(&pdev->dev, "edac_mc_add_mc() failed\n");
                        edac_mc_free(mci);
                        return -ENXIO;
                }
 
-               if (octeon_set_mc_sysfs_attributes(mci)) {
-                       dev_err(&pdev->dev, "octeon_set_mc_sysfs_attributes() failed\n");
-                       return -ENXIO;
-               }
-
-
                en.u64 = cvmx_read_csr(CVMX_LMCX_MEM_CFG0(mc));
                en.s.intr_ded_ena = 0;  /* We poll */
                en.s.intr_sec_ena = 0;