Path: blob/master/arch/powerpc/platforms/pseries/eeh_sysfs.c
10818 views
/*1* Sysfs entries for PCI Error Recovery for PAPR-compliant platform.2* Copyright IBM Corporation 20073* Copyright Linas Vepstas <[email protected]> 20074*5* All rights reserved.6*7* This program is free software; you can redistribute it and/or modify8* it under the terms of the GNU General Public License as published by9* the Free Software Foundation; either version 2 of the License, or (at10* your option) any later version.11*12* This program is distributed in the hope that it will be useful, but13* WITHOUT ANY WARRANTY; without even the implied warranty of14* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or15* NON INFRINGEMENT. See the GNU General Public License for more16* details.17*18* You should have received a copy of the GNU General Public License19* along with this program; if not, write to the Free Software20* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.21*22* Send comments and feedback to Linas Vepstas <[email protected]>23*/24#include <linux/pci.h>25#include <asm/ppc-pci.h>26#include <asm/pci-bridge.h>2728/**29* EEH_SHOW_ATTR -- create sysfs entry for eeh statistic30* @_name: name of file in sysfs directory31* @_memb: name of member in struct pci_dn to access32* @_format: printf format for display33*34* All of the attributes look very similar, so just35* auto-gen a cut-n-paste routine to display them.36*/37#define EEH_SHOW_ATTR(_name,_memb,_format) \38static ssize_t eeh_show_##_name(struct device *dev, \39struct device_attribute *attr, char *buf) \40{ \41struct pci_dev *pdev = to_pci_dev(dev); \42struct device_node *dn = pci_device_to_OF_node(pdev); \43struct pci_dn *pdn; \44\45if (!dn || PCI_DN(dn) == NULL) \46return 0; \47\48pdn = PCI_DN(dn); \49return sprintf(buf, _format "\n", pdn->_memb); \50} \51static DEVICE_ATTR(_name, S_IRUGO, eeh_show_##_name, NULL);525354EEH_SHOW_ATTR(eeh_mode, eeh_mode, "0x%x");55EEH_SHOW_ATTR(eeh_config_addr, eeh_config_addr, "0x%x");56EEH_SHOW_ATTR(eeh_pe_config_addr, eeh_pe_config_addr, "0x%x");57EEH_SHOW_ATTR(eeh_check_count, eeh_check_count, "%d");58EEH_SHOW_ATTR(eeh_freeze_count, eeh_freeze_count, "%d");59EEH_SHOW_ATTR(eeh_false_positives, eeh_false_positives, "%d");6061void eeh_sysfs_add_device(struct pci_dev *pdev)62{63int rc=0;6465rc += device_create_file(&pdev->dev, &dev_attr_eeh_mode);66rc += device_create_file(&pdev->dev, &dev_attr_eeh_config_addr);67rc += device_create_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);68rc += device_create_file(&pdev->dev, &dev_attr_eeh_check_count);69rc += device_create_file(&pdev->dev, &dev_attr_eeh_false_positives);70rc += device_create_file(&pdev->dev, &dev_attr_eeh_freeze_count);7172if (rc)73printk(KERN_WARNING "EEH: Unable to create sysfs entries\n");74}7576void eeh_sysfs_remove_device(struct pci_dev *pdev)77{78device_remove_file(&pdev->dev, &dev_attr_eeh_mode);79device_remove_file(&pdev->dev, &dev_attr_eeh_config_addr);80device_remove_file(&pdev->dev, &dev_attr_eeh_pe_config_addr);81device_remove_file(&pdev->dev, &dev_attr_eeh_check_count);82device_remove_file(&pdev->dev, &dev_attr_eeh_false_positives);83device_remove_file(&pdev->dev, &dev_attr_eeh_freeze_count);84}85868788