| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Handles the M-Systems DiskOnChip G3 chip |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * 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 | | - * |
|---|
| 20 | 6 | */ |
|---|
| 21 | 7 | |
|---|
| 22 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 661 | 647 | |
|---|
| 662 | 648 | for (i = 0; i < DOC_ECC_BCH_SIZE; i++) |
|---|
| 663 | 649 | ecc[i] = bitrev8(hwecc[i]); |
|---|
| 664 | | - numerrs = decode_bch(docg3->cascade->bch, NULL, |
|---|
| 650 | + numerrs = bch_decode(docg3->cascade->bch, NULL, |
|---|
| 665 | 651 | DOC_ECC_BCH_COVERED_BYTES, |
|---|
| 666 | 652 | NULL, ecc, NULL, errorpos); |
|---|
| 667 | 653 | BUG_ON(numerrs == -EINVAL); |
|---|
| .. | .. |
|---|
| 1603 | 1589 | /* |
|---|
| 1604 | 1590 | * Debug sysfs entries |
|---|
| 1605 | 1591 | */ |
|---|
| 1606 | | -static int dbg_flashctrl_show(struct seq_file *s, void *p) |
|---|
| 1592 | +static int flashcontrol_show(struct seq_file *s, void *p) |
|---|
| 1607 | 1593 | { |
|---|
| 1608 | 1594 | struct docg3 *docg3 = (struct docg3 *)s->private; |
|---|
| 1609 | 1595 | |
|---|
| .. | .. |
|---|
| 1623 | 1609 | |
|---|
| 1624 | 1610 | return 0; |
|---|
| 1625 | 1611 | } |
|---|
| 1626 | | -DEBUGFS_RO_ATTR(flashcontrol, dbg_flashctrl_show); |
|---|
| 1612 | +DEFINE_SHOW_ATTRIBUTE(flashcontrol); |
|---|
| 1627 | 1613 | |
|---|
| 1628 | | -static int dbg_asicmode_show(struct seq_file *s, void *p) |
|---|
| 1614 | +static int asic_mode_show(struct seq_file *s, void *p) |
|---|
| 1629 | 1615 | { |
|---|
| 1630 | 1616 | struct docg3 *docg3 = (struct docg3 *)s->private; |
|---|
| 1631 | 1617 | |
|---|
| .. | .. |
|---|
| 1660 | 1646 | seq_puts(s, ")\n"); |
|---|
| 1661 | 1647 | return 0; |
|---|
| 1662 | 1648 | } |
|---|
| 1663 | | -DEBUGFS_RO_ATTR(asic_mode, dbg_asicmode_show); |
|---|
| 1649 | +DEFINE_SHOW_ATTRIBUTE(asic_mode); |
|---|
| 1664 | 1650 | |
|---|
| 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) |
|---|
| 1666 | 1652 | { |
|---|
| 1667 | 1653 | struct docg3 *docg3 = (struct docg3 *)s->private; |
|---|
| 1668 | 1654 | int id; |
|---|
| .. | .. |
|---|
| 1674 | 1660 | seq_printf(s, "DeviceId = %d\n", id); |
|---|
| 1675 | 1661 | return 0; |
|---|
| 1676 | 1662 | } |
|---|
| 1677 | | -DEBUGFS_RO_ATTR(device_id, dbg_device_id_show); |
|---|
| 1663 | +DEFINE_SHOW_ATTRIBUTE(device_id); |
|---|
| 1678 | 1664 | |
|---|
| 1679 | | -static int dbg_protection_show(struct seq_file *s, void *p) |
|---|
| 1665 | +static int protection_show(struct seq_file *s, void *p) |
|---|
| 1680 | 1666 | { |
|---|
| 1681 | 1667 | struct docg3 *docg3 = (struct docg3 *)s->private; |
|---|
| 1682 | 1668 | int protect, dps0, dps0_low, dps0_high, dps1, dps1_low, dps1_high; |
|---|
| .. | .. |
|---|
| 1726 | 1712 | !!(dps1 & DOC_DPS_KEY_OK)); |
|---|
| 1727 | 1713 | return 0; |
|---|
| 1728 | 1714 | } |
|---|
| 1729 | | -DEBUGFS_RO_ATTR(protection, dbg_protection_show); |
|---|
| 1715 | +DEFINE_SHOW_ATTRIBUTE(protection); |
|---|
| 1730 | 1716 | |
|---|
| 1731 | 1717 | static void __init doc_dbg_register(struct mtd_info *floor) |
|---|
| 1732 | 1718 | { |
|---|
| .. | .. |
|---|
| 1767 | 1753 | |
|---|
| 1768 | 1754 | switch (chip_id) { |
|---|
| 1769 | 1755 | 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); |
|---|
| 1772 | 1758 | if (!mtd->name) |
|---|
| 1773 | 1759 | return -ENOMEM; |
|---|
| 1774 | 1760 | docg3->max_block = 2047; |
|---|
| .. | .. |
|---|
| 1872 | 1858 | nomem2: |
|---|
| 1873 | 1859 | kfree(docg3); |
|---|
| 1874 | 1860 | nomem1: |
|---|
| 1875 | | - return ERR_PTR(ret); |
|---|
| 1861 | + return ret ? ERR_PTR(ret) : NULL; |
|---|
| 1876 | 1862 | } |
|---|
| 1877 | 1863 | |
|---|
| 1878 | 1864 | /** |
|---|
| .. | .. |
|---|
| 1886 | 1872 | mtd_device_unregister(mtd); |
|---|
| 1887 | 1873 | kfree(docg3->bbt); |
|---|
| 1888 | 1874 | kfree(docg3); |
|---|
| 1889 | | - kfree(mtd->name); |
|---|
| 1890 | 1875 | kfree(mtd); |
|---|
| 1891 | 1876 | } |
|---|
| 1892 | 1877 | |
|---|
| .. | .. |
|---|
| 1990 | 1975 | dev_err(dev, "No I/O memory resource defined\n"); |
|---|
| 1991 | 1976 | return ret; |
|---|
| 1992 | 1977 | } |
|---|
| 1993 | | - base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE); |
|---|
| 1994 | 1978 | |
|---|
| 1995 | 1979 | 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 | + |
|---|
| 1996 | 1986 | cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade), |
|---|
| 1997 | 1987 | GFP_KERNEL); |
|---|
| 1998 | 1988 | if (!cascade) |
|---|
| 1999 | 1989 | return ret; |
|---|
| 2000 | 1990 | cascade->base = base; |
|---|
| 2001 | 1991 | 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); |
|---|
| 2004 | 1994 | if (!cascade->bch) |
|---|
| 2005 | 1995 | return ret; |
|---|
| 2006 | 1996 | |
|---|
| .. | .. |
|---|
| 2036 | 2026 | ret = -ENODEV; |
|---|
| 2037 | 2027 | dev_info(dev, "No supported DiskOnChip found\n"); |
|---|
| 2038 | 2028 | err_probe: |
|---|
| 2039 | | - free_bch(cascade->bch); |
|---|
| 2029 | + bch_free(cascade->bch); |
|---|
| 2040 | 2030 | for (floor = 0; floor < DOC_MAX_NBFLOORS; floor++) |
|---|
| 2041 | 2031 | if (cascade->floors[floor]) |
|---|
| 2042 | 2032 | doc_release_device(cascade->floors[floor]); |
|---|
| .. | .. |
|---|
| 2060 | 2050 | if (cascade->floors[floor]) |
|---|
| 2061 | 2051 | doc_release_device(cascade->floors[floor]); |
|---|
| 2062 | 2052 | |
|---|
| 2063 | | - free_bch(docg3->cascade->bch); |
|---|
| 2053 | + bch_free(docg3->cascade->bch); |
|---|
| 2064 | 2054 | return 0; |
|---|
| 2065 | 2055 | } |
|---|
| 2066 | 2056 | |
|---|