integ/base/pf-bb-config/debian/patches/0001-Reject-device-configuration-if-not-enabled.patch
Andre Kantek 503ea50cc5 Debian: Add missing patches in pf-bb-config
During the port from CentOS to Debian there were missing patches for
this application. This change also updates the patches to be used
on the current pf-bb-config version (22.07).

Test Plan:
[PASS] execute the application during FEC accelerator cards config

Closes-Bug: 1997878

Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
Change-Id: I384aa358150e7306692f408d1ae16ef94d2566b8
2022-11-24 15:01:13 -03:00

51 lines
1.5 KiB
Diff

From a12967eba299f63f3abe5a906765d5beb16db81c Mon Sep 17 00:00:00 2001
From: Andre Kantek <andrefernandozanella.kantek@windriver.com>
Date: Wed, 23 Nov 2022 08:27:52 -0300
Subject: [PATCH] Reject device configuration if not enabled
Check if device is enabled in the return logic of get_device_id()
Signed-off-by: Andre Kantek <andrefernandozanella.kantek@windriver.com>
---
config_app.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/config_app.c b/config_app.c
index 6acd8f1..4f72764 100644
--- a/config_app.c
+++ b/config_app.c
@@ -85,6 +85,7 @@ static bool
get_device_id(hw_device *device, const char *location)
{
unsigned long vendor_id = -1, device_id = -1;
+ unsigned int device_enabled = 0;
struct dirent *dirent;
DIR *dir;
char pci_path[PATH_MAX];
@@ -112,6 +113,12 @@ get_device_id(hw_device *device, const char *location)
if (snprintf_ret < 0)
LOG(ERR, "Failed to format PCI path");
+ /* Is device enabled? */
+ if (strncmp(dirent->d_name, "enable",
+ strlen(dirent->d_name)) == 0 &&
+ dirent->d_type == DT_REG)
+ device_enabled = get_file_val(file_path);
+
/* Get Device ID */
if (strncmp(dirent->d_name, DEVICE_FILE,
strlen(dirent->d_name)) == 0 &&
@@ -127,7 +134,8 @@ get_device_id(hw_device *device, const char *location)
closedir(dir);
/* Check if device is found */
- return (vendor_id == device->vendor_id &&
+ return (device_enabled &&
+ vendor_id == device->vendor_id &&
device_id == device->device_id);
}
--
2.17.1