...
+}
+
+int pci_read(uint32_t fhandle, uint64_t offset, uint8_t pcias, void
*buf,
+ uint8_t len)
+{
+ uint64_t req, data;
+ uint8_t status;
+ int rc;
+
+ req = ZPCI_CREATE_REQ(fhandle, pcias, len);
+ rc = pcilg(&data, req, offset, &status);
+
+ /* Error condition detected */
+ if (rc != 0) {
+ printf("PCI load failed with status condition %d, return
code %d\n",
+ status, rc);
+ return -1;
+ }
+
+ switch (len) {
+ case 1:
+ *(uint8_t *)buf = data;
+ break;
+ case 2:
+ *(uint16_t *)buf = data;
+ break;
+ case 4:
+ *(uint32_t *)buf = data;
+ break;
+ case 8:
+ *(uint64_t *)buf = data;
+ break;
+ default:
+ return -1;
+ }
+
+ return rc ? -1 : 0;
dito, you checked for rc != 0 already earlier in this function.
My bad. The previous version didn't check "rc != 0" but when I modified
the status/error message I forgot that it made the later check
redundant. I'll fix it.
Thanks,
Jared Rossi