ptp_ocp.c (ee6439aaad3245851bbbcbf6c7534c9a29407ab2) | ptp_ocp.c (c1fd463d571a155bf43e04fd23d02aef364c5b0b) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright (c) 2020 Facebook */ 3 4#include <linux/bits.h> 5#include <linux/err.h> 6#include <linux/kernel.h> 7#include <linux/module.h> 8#include <linux/debugfs.h> --- 1516 unchanged lines hidden (view full) --- 1525 struct ptp_ocp *bp = devlink_priv(devlink); 1526 const struct ptp_ocp_firmware_header *hdr; 1527 size_t offset, length; 1528 u16 crc; 1529 1530 hdr = (const struct ptp_ocp_firmware_header *)fw->data; 1531 if (memcmp(hdr->magic, OCP_FIRMWARE_MAGIC_HEADER, 4)) { 1532 devlink_flash_update_status_notify(devlink, | 1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright (c) 2020 Facebook */ 3 4#include <linux/bits.h> 5#include <linux/err.h> 6#include <linux/kernel.h> 7#include <linux/module.h> 8#include <linux/debugfs.h> --- 1516 unchanged lines hidden (view full) --- 1525 struct ptp_ocp *bp = devlink_priv(devlink); 1526 const struct ptp_ocp_firmware_header *hdr; 1527 size_t offset, length; 1528 u16 crc; 1529 1530 hdr = (const struct ptp_ocp_firmware_header *)fw->data; 1531 if (memcmp(hdr->magic, OCP_FIRMWARE_MAGIC_HEADER, 4)) { 1532 devlink_flash_update_status_notify(devlink, |
1533 "No firmware header found, flashing raw image", | 1533 "No firmware header found, cancel firmware upgrade", |
1534 NULL, 0, 0); | 1534 NULL, 0, 0); |
1535 offset = 0; 1536 length = fw->size; 1537 goto out; | 1535 return -EINVAL; |
1538 } 1539 1540 if (be16_to_cpu(hdr->pci_vendor_id) != bp->pdev->vendor || 1541 be16_to_cpu(hdr->pci_device_id) != bp->pdev->device) { 1542 devlink_flash_update_status_notify(devlink, 1543 "Firmware image compatibility check failed", 1544 NULL, 0, 0); 1545 return -EINVAL; --- 11 unchanged lines hidden (view full) --- 1557 crc = crc16(0xffff, &fw->data[offset], length); 1558 if (be16_to_cpu(hdr->crc) != crc) { 1559 devlink_flash_update_status_notify(devlink, 1560 "Firmware image CRC check failed", 1561 NULL, 0, 0); 1562 return -EINVAL; 1563 } 1564 | 1536 } 1537 1538 if (be16_to_cpu(hdr->pci_vendor_id) != bp->pdev->vendor || 1539 be16_to_cpu(hdr->pci_device_id) != bp->pdev->device) { 1540 devlink_flash_update_status_notify(devlink, 1541 "Firmware image compatibility check failed", 1542 NULL, 0, 0); 1543 return -EINVAL; --- 11 unchanged lines hidden (view full) --- 1555 crc = crc16(0xffff, &fw->data[offset], length); 1556 if (be16_to_cpu(hdr->crc) != crc) { 1557 devlink_flash_update_status_notify(devlink, 1558 "Firmware image CRC check failed", 1559 NULL, 0, 0); 1560 return -EINVAL; 1561 } 1562 |
1565out: | |
1566 *data = &fw->data[offset]; 1567 *size = length; 1568 1569 return 0; 1570} 1571 1572static int 1573ptp_ocp_devlink_flash(struct devlink *devlink, struct device *dev, --- 2782 unchanged lines hidden --- | 1563 *data = &fw->data[offset]; 1564 *size = length; 1565 1566 return 0; 1567} 1568 1569static int 1570ptp_ocp_devlink_flash(struct devlink *devlink, struct device *dev, --- 2782 unchanged lines hidden --- |