Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: wan: framer: Add version sysfs attribute for the Lantiq PEF2256 framer

Lantiq PEF2256 framer has some little differences in behaviour
depending on its version.

Add a sysfs attribute to allow user applications to know the
version.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Link: https://patch.msgid.link/77a27941d6924b1009df0162ed9f0fa07ed6e431.1758726302.git.christophe.leroy@csgroup.eu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe Leroy and committed by
Jakub Kicinski
0e41b0af 231889d9

+27 -5
+8
Documentation/ABI/testing/sysfs-driver-framer-pef2256
··· 1 + What: /sys/bus/platform/devices/xxx/version 2 + Date: Sep 2025 3 + Contact: netdev@vger.kernel.org 4 + Description: Reports the version of the PEF2256 framer 5 + 6 + Access: Read 7 + 8 + Valid values: Represented as string
+19 -5
drivers/net/wan/framer/pef2256/pef2256.c
··· 37 37 struct device *dev; 38 38 struct regmap *regmap; 39 39 enum pef2256_version version; 40 + const char *version_txt; 40 41 struct clk *mclk; 41 42 struct clk *sclkr; 42 43 struct clk *sclkx; ··· 114 113 return version; 115 114 } 116 115 EXPORT_SYMBOL_GPL(pef2256_get_version); 116 + 117 + static ssize_t version_show(struct device *dev, struct device_attribute *attr, 118 + char *buf) 119 + { 120 + struct pef2256 *pef2256 = dev_get_drvdata(dev); 121 + 122 + return sysfs_emit(buf, "%s\n", pef2256->version_txt); 123 + } 124 + 125 + static DEVICE_ATTR_RO(version); 117 126 118 127 enum pef2256_gcm_config_item { 119 128 PEF2256_GCM_CONFIG_1544000 = 0, ··· 708 697 unsigned long sclkr_rate, sclkx_rate; 709 698 struct framer_provider *framer_provider; 710 699 struct pef2256 *pef2256; 711 - const char *version_txt; 712 700 void __iomem *iomem; 713 701 int ret; 714 702 int irq; ··· 773 763 pef2256->version = pef2256_get_version(pef2256); 774 764 switch (pef2256->version) { 775 765 case PEF2256_VERSION_1_2: 776 - version_txt = "1.2"; 766 + pef2256->version_txt = "1.2"; 777 767 break; 778 768 case PEF2256_VERSION_2_1: 779 - version_txt = "2.1"; 769 + pef2256->version_txt = "2.1"; 780 770 break; 781 771 case PEF2256_VERSION_2_2: 782 - version_txt = "2.2"; 772 + pef2256->version_txt = "2.2"; 783 773 break; 784 774 default: 785 775 return -ENODEV; 786 776 } 787 - dev_info(pef2256->dev, "Version %s detected\n", version_txt); 777 + dev_info(pef2256->dev, "Version %s detected\n", pef2256->version_txt); 788 778 789 779 ret = pef2556_of_parse(pef2256, np); 790 780 if (ret) ··· 845 835 return ret; 846 836 } 847 837 838 + device_create_file(pef2256->dev, &dev_attr_version); 839 + 848 840 return 0; 849 841 } 850 842 ··· 861 849 pef2256_write8(pef2256, PEF2256_IMR3, 0xff); 862 850 pef2256_write8(pef2256, PEF2256_IMR4, 0xff); 863 851 pef2256_write8(pef2256, PEF2256_IMR5, 0xff); 852 + 853 + device_remove_file(pef2256->dev, &dev_attr_version); 864 854 } 865 855 866 856 static const struct of_device_id pef2256_id_table[] = {