hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/mtd/devices/docg3.c
....@@ -1,22 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Handles the M-Systems DiskOnChip G3 chip
34 *
45 * Copyright (C) 2011 Robert Jarzmik
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
- *
206 */
217
228 #include <linux/kernel.h>
....@@ -661,7 +647,7 @@
661647
662648 for (i = 0; i < DOC_ECC_BCH_SIZE; i++)
663649 ecc[i] = bitrev8(hwecc[i]);
664
- numerrs = decode_bch(docg3->cascade->bch, NULL,
650
+ numerrs = bch_decode(docg3->cascade->bch, NULL,
665651 DOC_ECC_BCH_COVERED_BYTES,
666652 NULL, ecc, NULL, errorpos);
667653 BUG_ON(numerrs == -EINVAL);
....@@ -1603,7 +1589,7 @@
16031589 /*
16041590 * Debug sysfs entries
16051591 */
1606
-static int dbg_flashctrl_show(struct seq_file *s, void *p)
1592
+static int flashcontrol_show(struct seq_file *s, void *p)
16071593 {
16081594 struct docg3 *docg3 = (struct docg3 *)s->private;
16091595
....@@ -1623,9 +1609,9 @@
16231609
16241610 return 0;
16251611 }
1626
-DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show);
1612
+DEFINE_SHOW_ATTRIBUTE(flashcontrol);
16271613
1628
-static int dbg_asicmode_show(struct seq_file *s, void *p)
1614
+static int asic_mode_show(struct seq_file *s, void *p)
16291615 {
16301616 struct docg3 *docg3 = (struct docg3 *)s->private;
16311617
....@@ -1660,9 +1646,9 @@
16601646 seq_puts(s, ")\n");
16611647 return 0;
16621648 }
1663
-DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show);
1649
+DEFINE_SHOW_ATTRIBUTE(asic_mode);
16641650
1665
-static int dbg_device_id_show(struct seq_file *s, void *p)
1651
+static int device_id_show(struct seq_file *s, void *p)
16661652 {
16671653 struct docg3 *docg3 = (struct docg3 *)s->private;
16681654 int id;
....@@ -1674,9 +1660,9 @@
16741660 seq_printf(s, "DeviceId = %d\n", id);
16751661 return 0;
16761662 }
1677
-DEBUGFS_RO_ATTR(device_id, dbg_device_id_show);
1663
+DEFINE_SHOW_ATTRIBUTE(device_id);
16781664
1679
-static int dbg_protection_show(struct seq_file *s, void *p)
1665
+static int protection_show(struct seq_file *s, void *p)
16801666 {
16811667 struct docg3 *docg3 = (struct docg3 *)s->private;
16821668 int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high;
....@@ -1726,7 +1712,7 @@
17261712 !!(dps1 & DOC_DPS_KEY_OK));
17271713 return 0;
17281714 }
1729
-DEBUGFS_RO_ATTR(protection, dbg_protection_show);
1715
+DEFINE_SHOW_ATTRIBUTE(protection);
17301716
17311717 static void __init doc_dbg_register(struct mtd_info *floor)
17321718 {
....@@ -1767,8 +1753,8 @@
17671753
17681754 switch (chip_id) {
17691755 case DOC_CHIPID_G3:
1770
- mtd->name = kasprintf(GFP_KERNEL, "docg3.%d",
1771
- docg3->device_id);
1756
+ mtd->name = devm_kasprintf(docg3->dev, GFP_KERNEL, "docg3.%d",
1757
+ docg3->device_id);
17721758 if (!mtd->name)
17731759 return -ENOMEM;
17741760 docg3->max_block = 2047;
....@@ -1872,7 +1858,7 @@
18721858 nomem2:
18731859 kfree(docg3);
18741860 nomem1:
1875
- return ERR_PTR(ret);
1861
+ return ret ? ERR_PTR(ret) : NULL;
18761862 }
18771863
18781864 /**
....@@ -1886,7 +1872,6 @@
18861872 mtd_device_unregister(mtd);
18871873 kfree(docg3->bbt);
18881874 kfree(docg3);
1889
- kfree(mtd->name);
18901875 kfree(mtd);
18911876 }
18921877
....@@ -1990,17 +1975,22 @@
19901975 dev_err(dev, "No I/O memory resource defined\n");
19911976 return ret;
19921977 }
1993
- base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
19941978
19951979 ret = -ENOMEM;
1980
+ base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
1981
+ if (!base) {
1982
+ dev_err(dev, "devm_ioremap dev failed\n");
1983
+ return ret;
1984
+ }
1985
+
19961986 cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade),
19971987 GFP_KERNEL);
19981988 if (!cascade)
19991989 return ret;
20001990 cascade->base = base;
20011991 mutex_init(&cascade->lock);
2002
- cascade->bch = init_bch(DOC_ECC_BCH_M, DOC_ECC_BCH_T,
2003
- DOC_ECC_BCH_PRIMPOLY);
1992
+ cascade->bch = bch_init(DOC_ECC_BCH_M, DOC_ECC_BCH_T,
1993
+ DOC_ECC_BCH_PRIMPOLY, false);
20041994 if (!cascade->bch)
20051995 return ret;
20061996
....@@ -2036,7 +2026,7 @@
20362026 ret = -ENODEV;
20372027 dev_info(dev, "No supported DiskOnChip found\n");
20382028 err_probe:
2039
- free_bch(cascade->bch);
2029
+ bch_free(cascade->bch);
20402030 for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++)
20412031 if (cascade->floors[floor])
20422032 doc_release_device(cascade->floors[floor]);
....@@ -2060,7 +2050,7 @@
20602050 if (cascade->floors[floor])
20612051 doc_release_device(cascade->floors[floor]);
20622052
2063
- free_bch(docg3->cascade->bch);
2053
+ bch_free(docg3->cascade->bch);
20642054 return 0;
20652055 }
20662056