Commit afbd3c12aca5a29f1627c0c68e6bc77f32459935
Committed by
Linus Torvalds
1 parent
c3e2567384
Exists in
master
and in
4 other branches
viafb: switch to seq_file
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de> Cc: Scott Fang <ScottFang@viatech.com.cn> Cc: Joseph Chan <JosephChan@via.com.tw> Cc: Harald Welte <laforge@gnumonks.org> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 110 additions and 69 deletions Side-by-side Diff
drivers/video/via/viafbdev.c
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | */ |
21 | 21 | |
22 | 22 | #include <linux/module.h> |
23 | +#include <linux/seq_file.h> | |
23 | 24 | #define _MASTER_FILE |
24 | 25 | |
25 | 26 | #include "global.h" |
26 | 27 | |
... | ... | @@ -1485,10 +1486,8 @@ |
1485 | 1486 | * DVP1Driving, DFPHigh, DFPLow CR96, SR2A[5], SR1B[1], SR2A[4], SR1E[2], |
1486 | 1487 | * CR9B, SR65, CR97, CR99 |
1487 | 1488 | */ |
1488 | -static int viafb_dvp0_proc_read(char *buf, char **start, off_t offset, | |
1489 | -int count, int *eof, void *data) | |
1489 | +static int viafb_dvp0_proc_show(struct seq_file *m, void *v) | |
1490 | 1490 | { |
1491 | - int len = 0; | |
1492 | 1491 | u8 dvp0_data_dri = 0, dvp0_clk_dri = 0, dvp0 = 0; |
1493 | 1492 | dvp0_data_dri = |
1494 | 1493 | (viafb_read_reg(VIASR, SR2A) & BIT5) >> 4 | |
1495 | 1494 | |
1496 | 1495 | |
... | ... | @@ -1497,14 +1496,18 @@ |
1497 | 1496 | (viafb_read_reg(VIASR, SR2A) & BIT4) >> 3 | |
1498 | 1497 | (viafb_read_reg(VIASR, SR1E) & BIT2) >> 2; |
1499 | 1498 | dvp0 = viafb_read_reg(VIACR, CR96) & 0x0f; |
1500 | - len += | |
1501 | - sprintf(buf + len, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri); | |
1502 | - *eof = 1; /*Inform kernel end of data */ | |
1503 | - return len; | |
1499 | + seq_printf(m, "%x %x %x\n", dvp0, dvp0_data_dri, dvp0_clk_dri); | |
1500 | + return 0; | |
1504 | 1501 | } |
1505 | -static int viafb_dvp0_proc_write(struct file *file, | |
1506 | - const char __user *buffer, unsigned long count, void *data) | |
1502 | + | |
1503 | +static int viafb_dvp0_proc_open(struct inode *inode, struct file *file) | |
1507 | 1504 | { |
1505 | + return single_open(file, viafb_dvp0_proc_show, NULL); | |
1506 | +} | |
1507 | + | |
1508 | +static ssize_t viafb_dvp0_proc_write(struct file *file, | |
1509 | + const char __user *buffer, size_t count, loff_t *pos) | |
1510 | +{ | |
1508 | 1511 | char buf[20], *value, *pbuf; |
1509 | 1512 | u8 reg_val = 0; |
1510 | 1513 | unsigned long length, i; |
1511 | 1514 | |
1512 | 1515 | |
1513 | 1516 | |
1514 | 1517 | |
... | ... | @@ -1547,22 +1550,34 @@ |
1547 | 1550 | } |
1548 | 1551 | return count; |
1549 | 1552 | } |
1550 | -static int viafb_dvp1_proc_read(char *buf, char **start, off_t offset, | |
1551 | - int count, int *eof, void *data) | |
1553 | + | |
1554 | +static const struct file_operations viafb_dvp0_proc_fops = { | |
1555 | + .owner = THIS_MODULE, | |
1556 | + .open = viafb_dvp0_proc_open, | |
1557 | + .read = seq_read, | |
1558 | + .llseek = seq_lseek, | |
1559 | + .release = single_release, | |
1560 | + .write = viafb_dvp0_proc_write, | |
1561 | +}; | |
1562 | + | |
1563 | +static int viafb_dvp1_proc_show(struct seq_file *m, void *v) | |
1552 | 1564 | { |
1553 | - int len = 0; | |
1554 | 1565 | u8 dvp1 = 0, dvp1_data_dri = 0, dvp1_clk_dri = 0; |
1555 | 1566 | dvp1 = viafb_read_reg(VIACR, CR9B) & 0x0f; |
1556 | 1567 | dvp1_data_dri = (viafb_read_reg(VIASR, SR65) & 0x0c) >> 2; |
1557 | 1568 | dvp1_clk_dri = viafb_read_reg(VIASR, SR65) & 0x03; |
1558 | - len += | |
1559 | - sprintf(buf + len, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri); | |
1560 | - *eof = 1; /*Inform kernel end of data */ | |
1561 | - return len; | |
1569 | + seq_printf(m, "%x %x %x\n", dvp1, dvp1_data_dri, dvp1_clk_dri); | |
1570 | + return 0; | |
1562 | 1571 | } |
1563 | -static int viafb_dvp1_proc_write(struct file *file, | |
1564 | - const char __user *buffer, unsigned long count, void *data) | |
1572 | + | |
1573 | +static int viafb_dvp1_proc_open(struct inode *inode, struct file *file) | |
1565 | 1574 | { |
1575 | + return single_open(file, viafb_dvp1_proc_show, NULL); | |
1576 | +} | |
1577 | + | |
1578 | +static ssize_t viafb_dvp1_proc_write(struct file *file, | |
1579 | + const char __user *buffer, size_t count, loff_t *pos) | |
1580 | +{ | |
1566 | 1581 | char buf[20], *value, *pbuf; |
1567 | 1582 | u8 reg_val = 0; |
1568 | 1583 | unsigned long length, i; |
1569 | 1584 | |
1570 | 1585 | |
1571 | 1586 | |
1572 | 1587 | |
... | ... | @@ -1600,19 +1615,31 @@ |
1600 | 1615 | return count; |
1601 | 1616 | } |
1602 | 1617 | |
1603 | -static int viafb_dfph_proc_read(char *buf, char **start, off_t offset, | |
1604 | - int count, int *eof, void *data) | |
1618 | +static const struct file_operations viafb_dvp1_proc_fops = { | |
1619 | + .owner = THIS_MODULE, | |
1620 | + .open = viafb_dvp1_proc_open, | |
1621 | + .read = seq_read, | |
1622 | + .llseek = seq_lseek, | |
1623 | + .release = single_release, | |
1624 | + .write = viafb_dvp1_proc_write, | |
1625 | +}; | |
1626 | + | |
1627 | +static int viafb_dfph_proc_show(struct seq_file *m, void *v) | |
1605 | 1628 | { |
1606 | - int len = 0; | |
1607 | 1629 | u8 dfp_high = 0; |
1608 | 1630 | dfp_high = viafb_read_reg(VIACR, CR97) & 0x0f; |
1609 | - len += sprintf(buf + len, "%x\n", dfp_high); | |
1610 | - *eof = 1; /*Inform kernel end of data */ | |
1611 | - return len; | |
1631 | + seq_printf(m, "%x\n", dfp_high); | |
1632 | + return 0; | |
1612 | 1633 | } |
1613 | -static int viafb_dfph_proc_write(struct file *file, | |
1614 | - const char __user *buffer, unsigned long count, void *data) | |
1634 | + | |
1635 | +static int viafb_dfph_proc_open(struct inode *inode, struct file *file) | |
1615 | 1636 | { |
1637 | + return single_open(file, viafb_dfph_proc_show, NULL); | |
1638 | +} | |
1639 | + | |
1640 | +static ssize_t viafb_dfph_proc_write(struct file *file, | |
1641 | + const char __user *buffer, size_t count, loff_t *pos) | |
1642 | +{ | |
1616 | 1643 | char buf[20]; |
1617 | 1644 | u8 reg_val = 0; |
1618 | 1645 | unsigned long length; |
1619 | 1646 | |
1620 | 1647 | |
1621 | 1648 | |
1622 | 1649 | |
... | ... | @@ -1626,19 +1653,32 @@ |
1626 | 1653 | viafb_write_reg_mask(CR97, VIACR, reg_val, 0x0f); |
1627 | 1654 | return count; |
1628 | 1655 | } |
1629 | -static int viafb_dfpl_proc_read(char *buf, char **start, off_t offset, | |
1630 | - int count, int *eof, void *data) | |
1656 | + | |
1657 | +static const struct file_operations viafb_dfph_proc_fops = { | |
1658 | + .owner = THIS_MODULE, | |
1659 | + .open = viafb_dfph_proc_open, | |
1660 | + .read = seq_read, | |
1661 | + .llseek = seq_lseek, | |
1662 | + .release = single_release, | |
1663 | + .write = viafb_dfph_proc_write, | |
1664 | +}; | |
1665 | + | |
1666 | +static int viafb_dfpl_proc_show(struct seq_file *m, void *v) | |
1631 | 1667 | { |
1632 | - int len = 0; | |
1633 | 1668 | u8 dfp_low = 0; |
1634 | 1669 | dfp_low = viafb_read_reg(VIACR, CR99) & 0x0f; |
1635 | - len += sprintf(buf + len, "%x\n", dfp_low); | |
1636 | - *eof = 1; /*Inform kernel end of data */ | |
1637 | - return len; | |
1670 | + seq_printf(m, "%x\n", dfp_low); | |
1671 | + return 0; | |
1638 | 1672 | } |
1639 | -static int viafb_dfpl_proc_write(struct file *file, | |
1640 | - const char __user *buffer, unsigned long count, void *data) | |
1673 | + | |
1674 | +static int viafb_dfpl_proc_open(struct inode *inode, struct file *file) | |
1641 | 1675 | { |
1676 | + return single_open(file, viafb_dfpl_proc_show, NULL); | |
1677 | +} | |
1678 | + | |
1679 | +static ssize_t viafb_dfpl_proc_write(struct file *file, | |
1680 | + const char __user *buffer, size_t count, loff_t *pos) | |
1681 | +{ | |
1642 | 1682 | char buf[20]; |
1643 | 1683 | u8 reg_val = 0; |
1644 | 1684 | unsigned long length; |
1645 | 1685 | |
... | ... | @@ -1652,10 +1692,18 @@ |
1652 | 1692 | viafb_write_reg_mask(CR99, VIACR, reg_val, 0x0f); |
1653 | 1693 | return count; |
1654 | 1694 | } |
1655 | -static int viafb_vt1636_proc_read(char *buf, char **start, | |
1656 | - off_t offset, int count, int *eof, void *data) | |
1695 | + | |
1696 | +static const struct file_operations viafb_dfpl_proc_fops = { | |
1697 | + .owner = THIS_MODULE, | |
1698 | + .open = viafb_dfpl_proc_open, | |
1699 | + .read = seq_read, | |
1700 | + .llseek = seq_lseek, | |
1701 | + .release = single_release, | |
1702 | + .write = viafb_dfpl_proc_write, | |
1703 | +}; | |
1704 | + | |
1705 | +static int viafb_vt1636_proc_show(struct seq_file *m, void *v) | |
1657 | 1706 | { |
1658 | - int len = 0; | |
1659 | 1707 | u8 vt1636_08 = 0, vt1636_09 = 0; |
1660 | 1708 | switch (viaparinfo->chip_info->lvds_chip_info.lvds_chip_name) { |
1661 | 1709 | case VT1636_LVDS: |
... | ... | @@ -1665,7 +1713,7 @@ |
1665 | 1713 | vt1636_09 = |
1666 | 1714 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info, |
1667 | 1715 | &viaparinfo->chip_info->lvds_chip_info, 0x09) & 0x1f; |
1668 | - len += sprintf(buf + len, "%x %x\n", vt1636_08, vt1636_09); | |
1716 | + seq_printf(m, "%x %x\n", vt1636_08, vt1636_09); | |
1669 | 1717 | break; |
1670 | 1718 | default: |
1671 | 1719 | break; |
1672 | 1720 | |
1673 | 1721 | |
1674 | 1722 | |
... | ... | @@ -1678,17 +1726,22 @@ |
1678 | 1726 | vt1636_09 = |
1679 | 1727 | viafb_gpio_i2c_read_lvds(viaparinfo->lvds_setting_info2, |
1680 | 1728 | &viaparinfo->chip_info->lvds_chip_info2, 0x09) & 0x1f; |
1681 | - len += sprintf(buf + len, " %x %x\n", vt1636_08, vt1636_09); | |
1729 | + seq_printf(m, " %x %x\n", vt1636_08, vt1636_09); | |
1682 | 1730 | break; |
1683 | 1731 | default: |
1684 | 1732 | break; |
1685 | 1733 | } |
1686 | - *eof = 1; /*Inform kernel end of data */ | |
1687 | - return len; | |
1734 | + return 0; | |
1688 | 1735 | } |
1689 | -static int viafb_vt1636_proc_write(struct file *file, | |
1690 | - const char __user *buffer, unsigned long count, void *data) | |
1736 | + | |
1737 | +static int viafb_vt1636_proc_open(struct inode *inode, struct file *file) | |
1691 | 1738 | { |
1739 | + return single_open(file, viafb_vt1636_proc_show, NULL); | |
1740 | +} | |
1741 | + | |
1742 | +static ssize_t viafb_vt1636_proc_write(struct file *file, | |
1743 | + const char __user *buffer, size_t count, loff_t *pos) | |
1744 | +{ | |
1692 | 1745 | char buf[30], *value, *pbuf; |
1693 | 1746 | struct IODATA reg_val; |
1694 | 1747 | unsigned long length, i; |
1695 | 1748 | |
1696 | 1749 | |
1697 | 1750 | |
... | ... | @@ -1776,39 +1829,27 @@ |
1776 | 1829 | return count; |
1777 | 1830 | } |
1778 | 1831 | |
1832 | +static const struct file_operations viafb_vt1636_proc_fops = { | |
1833 | + .owner = THIS_MODULE, | |
1834 | + .open = viafb_vt1636_proc_open, | |
1835 | + .read = seq_read, | |
1836 | + .llseek = seq_lseek, | |
1837 | + .release = single_release, | |
1838 | + .write = viafb_vt1636_proc_write, | |
1839 | +}; | |
1840 | + | |
1779 | 1841 | static void viafb_init_proc(struct proc_dir_entry **viafb_entry) |
1780 | 1842 | { |
1781 | - struct proc_dir_entry *entry; | |
1782 | 1843 | *viafb_entry = proc_mkdir("viafb", NULL); |
1783 | 1844 | if (viafb_entry) { |
1784 | - entry = create_proc_entry("dvp0", 0, *viafb_entry); | |
1785 | - if (entry) { | |
1786 | - entry->read_proc = viafb_dvp0_proc_read; | |
1787 | - entry->write_proc = viafb_dvp0_proc_write; | |
1788 | - } | |
1789 | - entry = create_proc_entry("dvp1", 0, *viafb_entry); | |
1790 | - if (entry) { | |
1791 | - entry->read_proc = viafb_dvp1_proc_read; | |
1792 | - entry->write_proc = viafb_dvp1_proc_write; | |
1793 | - } | |
1794 | - entry = create_proc_entry("dfph", 0, *viafb_entry); | |
1795 | - if (entry) { | |
1796 | - entry->read_proc = viafb_dfph_proc_read; | |
1797 | - entry->write_proc = viafb_dfph_proc_write; | |
1798 | - } | |
1799 | - entry = create_proc_entry("dfpl", 0, *viafb_entry); | |
1800 | - if (entry) { | |
1801 | - entry->read_proc = viafb_dfpl_proc_read; | |
1802 | - entry->write_proc = viafb_dfpl_proc_write; | |
1803 | - } | |
1845 | + proc_create("dvp0", 0, *viafb_entry, &viafb_dvp0_proc_fops); | |
1846 | + proc_create("dvp1", 0, *viafb_entry, &viafb_dvp1_proc_fops); | |
1847 | + proc_create("dfph", 0, *viafb_entry, &viafb_dfph_proc_fops); | |
1848 | + proc_create("dfpl", 0, *viafb_entry, &viafb_dfpl_proc_fops); | |
1804 | 1849 | if (VT1636_LVDS == viaparinfo->chip_info->lvds_chip_info. |
1805 | 1850 | lvds_chip_name || VT1636_LVDS == |
1806 | 1851 | viaparinfo->chip_info->lvds_chip_info2.lvds_chip_name) { |
1807 | - entry = create_proc_entry("vt1636", 0, *viafb_entry); | |
1808 | - if (entry) { | |
1809 | - entry->read_proc = viafb_vt1636_proc_read; | |
1810 | - entry->write_proc = viafb_vt1636_proc_write; | |
1811 | - } | |
1852 | + proc_create("vt1636", 0, *viafb_entry, &viafb_vt1636_proc_fops); | |
1812 | 1853 | } |
1813 | 1854 | |
1814 | 1855 | } |