]> err.no Git - linux-2.6/commitdiff
[PATCH] ppc64 iSeries: remove some more members of iSeries_Device_Node
authorStephen Rothwell <sfr@canb.auug.org.au>
Wed, 22 Jun 2005 00:15:48 +0000 (17:15 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 22 Jun 2005 01:46:30 +0000 (18:46 -0700)
The AgentId, PhbId, FrameId, CardLocation and Location members of
iSeries_Device_Node are stored early in the boot process just so that a
message about the device can be printed later in the boot process.  Remove
them and construct the message by doing the VPD parsing at the time the
message is printed.

Also remove a few unused defines in iSeries_VpdInfo.c.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
arch/ppc64/kernel/iSeries_VpdInfo.c
arch/ppc64/kernel/iSeries_pci.c
include/asm-ppc64/iSeries/iSeries_pci.h

index 9c89ce9a3d0be1db3842586fd27f0878a6527242..d11c732daf816a2a7bed18c58e0a20fa52439c0e 100644 (file)
@@ -44,7 +44,6 @@
 /*
  * Bus Vpd Tags
  */
-#define  VpdEndOfDataTag   0x78
 #define  VpdEndOfAreaTag   0x79
 #define  VpdIdStringTag    0x82
 #define  VpdVendorAreaTag  0x84
 /*
  * Mfg Area Tags
  */
-#define  VpdFruFlag       0x4647     // "FG"
 #define  VpdFruFrameId    0x4649     // "FI"
 #define  VpdSlotMapFormat 0x4D46     // "MF"
-#define  VpdAsmPartNumber 0x504E     // "PN"
-#define  VpdFruSerial     0x534E     // "SN"
 #define  VpdSlotMap       0x534D     // "SM"
 
 /*
@@ -82,49 +78,11 @@ struct SlotMapStruct {
 typedef struct SlotMapStruct SlotMap;
 #define SLOT_ENTRY_SIZE   16
 
-/*
- * Formats the device information.
- * - Pass in pci_dev* pointer to the device.
- * - Pass in buffer to place the data.  Danger here is the buffer must
- *   be as big as the client says it is.   Should be at least 128 bytes.
- * Return will the length of the string data put in the buffer.
- * Format:
- * PCI: Bus  0, Device 26, Vendor 0x12AE  Frame  1, Card  C10  Ethernet
- * controller
- */
-int iSeries_Device_Information(struct pci_dev *PciDev, char *buffer,
-               int BufferSize)
-{
-       struct iSeries_Device_Node *DevNode =
-               (struct iSeries_Device_Node *)PciDev->sysdata;
-       int len;
-
-       if (DevNode == NULL)
-               return sprintf(buffer,
-                               "PCI: iSeries_Device_Information DevNode is NULL");
-
-       if (BufferSize < 128)
-               return 0;
-
-       len = sprintf(buffer, "PCI: Bus%3d, Device%3d, Vendor %04X ",
-                       ISERIES_BUS(DevNode), PCI_SLOT(PciDev->devfn),
-                       PciDev->vendor);
-       len += sprintf(buffer + len, "Frame%3d, Card %4s  ",
-                       DevNode->FrameId, DevNode->CardLocation);
-       if (pci_class_name(PciDev->class >> 8) == 0)
-               len += sprintf(buffer + len, "0x%04X  ",
-                               (int)(PciDev->class >> 8));
-       else
-               len += sprintf(buffer + len, "%s",
-                               pci_class_name(PciDev->class >> 8));
-       return len;
-}
-
 /*
  * Parse the Slot Area
  */
-static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
-               struct iSeries_Device_Node *DevNode)
+static void __init iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
+               HvAgentId agent, u8 *PhbId, char card[4])
 {
        int SlotMapLen = MapLen;
        SlotMap *SlotMapPtr = MapPtr;
@@ -133,17 +91,16 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
         * Parse Slot label until we find the one requested
         */
        while (SlotMapLen > 0) {
-               if (SlotMapPtr->AgentId == DevNode->AgentId ) {
+               if (SlotMapPtr->AgentId == agent) {
                        /*
                         * If Phb wasn't found, grab the entry first one found.
                         */
-                       if (DevNode->PhbId == 0xff)
-                               DevNode->PhbId = SlotMapPtr->PhbId; 
+                       if (*PhbId == 0xff)
+                               *PhbId = SlotMapPtr->PhbId;
                        /* Found it, extract the data. */
-                       if (SlotMapPtr->PhbId == DevNode->PhbId ) {
-                               memcpy(&DevNode->CardLocation,
-                                               &SlotMapPtr->CardLocation, 3);
-                               DevNode->CardLocation[3]  = 0;
+                       if (SlotMapPtr->PhbId == *PhbId) {
+                               memcpy(card, &SlotMapPtr->CardLocation, 3);
+                               card[3]  = 0;
                                break;
                        }
                }
@@ -156,8 +113,9 @@ static void iSeries_Parse_SlotArea(SlotMap *MapPtr, int MapLen,
 /*
  * Parse the Mfg Area
  */
-static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
-               struct iSeries_Device_Node *DevNode)
+static void __init iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
+               HvAgentId agent, u8 *PhbId,
+               u8 *frame, char card[4])
 {
        MfgArea *MfgAreaPtr = (MfgArea *)AreaData;
        int MfgAreaLen = AreaLen;
@@ -168,7 +126,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
                int MfgTagLen = MfgAreaPtr->TagLength;
                /* Frame ID         (FI 4649020310 ) */
                if (MfgAreaPtr->Tag == VpdFruFrameId)           /* FI  */
-                       DevNode->FrameId = MfgAreaPtr->AreaData1;
+                       *frame = MfgAreaPtr->AreaData1;
                /* Slot Map Format  (MF 4D46020004 ) */
                else if (MfgAreaPtr->Tag == VpdSlotMapFormat)   /* MF  */
                        SlotMapFmt = (MfgAreaPtr->AreaData1 * 256)
@@ -183,7 +141,8 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
                        else
                                SlotMapPtr = (SlotMap *)((char *)MfgAreaPtr
                                                + MFG_ENTRY_SIZE);
-                       iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen, DevNode);
+                       iSeries_Parse_SlotArea(SlotMapPtr, MfgTagLen,
+                                       agent, PhbId, card);
                }
                /*
                 * Point to the next Mfg Area
@@ -199,7 +158,7 @@ static void iSeries_Parse_MfgArea(u8 *AreaData, int AreaLen,
  * Look for "BUS".. Data is not Null terminated.
  * PHBID of 0xFF indicates PHB was not found in VPD Data.
  */
-static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
+static int __init iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
 {
        u8 *PhbPtr = AreaPtr;
        int DataLen = AreaLength;
@@ -223,27 +182,30 @@ static int iSeries_Parse_PhbId(u8 *AreaPtr, int AreaLength)
 /*
  * Parse out the VPD Areas
  */
-static void iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
-               struct iSeries_Device_Node *DevNode)
+static void __init iSeries_Parse_Vpd(u8 *VpdData, int VpdDataLen,
+               HvAgentId agent, u8 *frame, char card[4])
 {
        u8 *TagPtr = VpdData;
        int DataLen = VpdDataLen - 3;
+       u8 PhbId;
 
        while ((*TagPtr != VpdEndOfAreaTag) && (DataLen > 0)) {
                int AreaLen = *(TagPtr + 1) + (*(TagPtr + 2) * 256);
                u8 *AreaData  = TagPtr + 3;
 
                if (*TagPtr == VpdIdStringTag)
-                       DevNode->PhbId = iSeries_Parse_PhbId(AreaData, AreaLen);
+                       PhbId = iSeries_Parse_PhbId(AreaData, AreaLen);
                else if (*TagPtr == VpdVendorAreaTag)
-                       iSeries_Parse_MfgArea(AreaData, AreaLen, DevNode);
+                       iSeries_Parse_MfgArea(AreaData, AreaLen,
+                                       agent, &PhbId, frame, card);
                /* Point to next Area. */
                TagPtr  = AreaData + AreaLen;
                DataLen -= AreaLen;
        }
 }
 
-void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode)
+static void __init iSeries_Get_Location_Code(u16 bus, HvAgentId agent,
+               u8 *frame, char card[4])
 {
        int BusVpdLen = 0;
        u8 *BusVpdPtr = kmalloc(BUS_VPDSIZE, GFP_KERNEL);
@@ -252,23 +214,58 @@ void iSeries_Get_Location_Code(struct iSeries_Device_Node *DevNode)
                printk("PCI: Bus VPD Buffer allocation failure.\n");
                return;
        }
-       BusVpdLen = HvCallPci_getBusVpd(ISERIES_BUS(DevNode),
-                                       ISERIES_HV_ADDR(BusVpdPtr),
+       BusVpdLen = HvCallPci_getBusVpd(bus, ISERIES_HV_ADDR(BusVpdPtr),
                                        BUS_VPDSIZE);
        if (BusVpdLen == 0) {
-               kfree(BusVpdPtr);
                printk("PCI: Bus VPD Buffer zero length.\n");
-               return;
+               goto out_free;
        }
        /* printk("PCI: BusVpdPtr: %p, %d\n",BusVpdPtr, BusVpdLen); */
        /* Make sure this is what I think it is */
        if (*BusVpdPtr != VpdIdStringTag) {     /* 0x82 */
                printk("PCI: Bus VPD Buffer missing starting tag.\n");
-               kfree(BusVpdPtr);
-               return;
+               goto out_free;
        }
-       iSeries_Parse_Vpd(BusVpdPtr,BusVpdLen, DevNode);
-       sprintf(DevNode->Location, "Frame%3d, Card %-4s", DevNode->FrameId,
-                       DevNode->CardLocation);
+       iSeries_Parse_Vpd(BusVpdPtr, BusVpdLen, agent, frame, card);
+out_free:
        kfree(BusVpdPtr);
 }
+
+/*
+ * Prints the device information.
+ * - Pass in pci_dev* pointer to the device.
+ * - Pass in the device count
+ *
+ * Format:
+ * PCI: Bus  0, Device 26, Vendor 0x12AE  Frame  1, Card  C10  Ethernet
+ * controller
+ */
+void __init iSeries_Device_Information(struct pci_dev *PciDev, int count)
+{
+       struct iSeries_Device_Node *DevNode = PciDev->sysdata;
+       u16 bus;
+       u8 frame;
+       char card[4];
+       HvSubBusNumber subbus;
+       HvAgentId agent;
+
+       if (DevNode == NULL) {
+               printk("%d. PCI: iSeries_Device_Information DevNode is NULL\n",
+                               count);
+               return;
+       }
+
+       bus = ISERIES_BUS(DevNode);
+       subbus = ISERIES_SUBBUS(DevNode);
+       agent = ISERIES_PCI_AGENTID(ISERIES_GET_DEVICE_FROM_SUBBUS(subbus),
+                       ISERIES_GET_FUNCTION_FROM_SUBBUS(subbus));
+       iSeries_Get_Location_Code(bus, agent, &frame, card);
+
+       printk("%d. PCI: Bus%3d, Device%3d, Vendor %04X Frame%3d, Card %4s  ",
+                       count, bus, PCI_SLOT(PciDev->devfn), PciDev->vendor,
+                       frame, card);
+       if (pci_class_name(PciDev->class >> 8) == 0)
+               printk("0x%04X\n", (int)(PciDev->class >> 8));
+       else
+               printk("%s\n", pci_class_name(PciDev->class >> 8));
+}
index 0a28b6ca65d0e22bdae2f31beb72702fa55ce390..356e4fd9a94fecc763e90a13bb79860ba2880f7b 100644 (file)
@@ -223,9 +223,7 @@ static struct iSeries_Device_Node *build_device_node(HvBusNumber Bus,
        node->DsaAddr.Dsa.busNumber = Bus;
        node->DsaAddr.Dsa.subBusNumber = SubBus;
        node->DsaAddr.Dsa.deviceId = 0x10;
-       node->AgentId = AgentId;
        node->DevFn = PCI_DEVFN(ISERIES_ENCODE_DEVICE(AgentId), Function);
-       iSeries_Get_Location_Code(node);
        return node;
 }
 
@@ -299,7 +297,6 @@ void __init iSeries_pci_final_fixup(void)
 {
        struct pci_dev *pdev = NULL;
        struct iSeries_Device_Node *node;
-       char Buffer[256];
        int DeviceCount = 0;
 
        PPCDBG(PPCDBG_BUSWALK, "iSeries_pcibios_fixup Entry.\n"); 
@@ -321,9 +318,7 @@ void __init iSeries_pci_final_fixup(void)
                                        "pdev 0x%p <==> DevNode 0x%p\n",
                                        pdev, node);
                        allocate_device_bars(pdev);
-                       iSeries_Device_Information(pdev, Buffer,
-                                       sizeof(Buffer));
-                       printk("%d. %s\n", DeviceCount, Buffer);
+                       iSeries_Device_Information(pdev, DeviceCount);
                        iommu_devnode_init_iSeries(node);
                } else
                        printk("PCI: Device Tree not found for 0x%016lX\n",
index ee0212f18b99ace972a29d0eb49be8ef0f1b7ddd..575f611f8b3391b04ec461adf70c65dbe207e812 100644 (file)
@@ -76,19 +76,13 @@ struct iSeries_Device_Node {
        union HvDsaMap  DsaAddr;        /* Direct Select Address */
                                        /* busNumber, subBusNumber, */
                                        /* deviceId, barNumber */
-       HvAgentId       AgentId;        /* Hypervisor DevFn */
        int             DevFn;          /* Linux devfn */
        int             Irq;            /* Assigned IRQ */
        int             Flags;          /* Possible flags(disable/bist)*/
        u8              LogicalSlot;    /* Hv Slot Index for Tces */
        struct iommu_table *iommu_table;/* Device TCE Table */
-       u8              PhbId;          /* Phb Card is on. */
-       u8              FrameId;        /* iSeries spcn Frame Id */
-       char            CardLocation[4];/* Char format of planar vpd */
-       char            Location[20];   /* Frame        1, Card C10 */
 };
 
-extern int     iSeries_Device_Information(struct pci_dev*, char*, int);
-extern void    iSeries_Get_Location_Code(struct iSeries_Device_Node*);
+extern void    iSeries_Device_Information(struct pci_dev*, int);
 
 #endif /* _ISERIES_64_PCI_H */