mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
solid: workaround device properties inconsistencies
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
1420f2070f
commit
8ee64ca77c
2 changed files with 16 additions and 3 deletions
|
@ -19033,6 +19033,16 @@ static const struct pciDeviceTblData {
|
|||
};
|
||||
static const size_t pciDeviceTblSize = sizeof(pciDeviceTbl) / sizeof(pciDeviceTblData);
|
||||
|
||||
// some but not all device vendor/product properties (e.g. ID_VENDOR_ID and ID_MODEL_ID on network
|
||||
// devices on Linux) have "0x" prefix, get rid of that inconsistency
|
||||
static QByteArray normalizeID(const QByteArray &id)
|
||||
{
|
||||
if (id.startsWith("0x")) {
|
||||
return id.mid(2, id.size() - 2);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
static QString lookupPCIVendor(const char* const vendor)
|
||||
{
|
||||
for (size_t i = 0; i < pciVendorTblSize; i++) {
|
||||
|
|
|
@ -99,7 +99,8 @@ QString UDevDevice::vendor() const
|
|||
}
|
||||
|
||||
if (vendor.isEmpty()) {
|
||||
const QByteArray idvendorid(m_device.deviceProperty("ID_VENDOR_ID").toLatin1());
|
||||
QByteArray idvendorid(m_device.deviceProperty("ID_VENDOR_ID").toLatin1());
|
||||
idvendorid = normalizeID(idvendorid);
|
||||
if (!idvendorid.isEmpty()) {
|
||||
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
||||
if (idbus == QLatin1String("pci")) {
|
||||
|
@ -142,8 +143,10 @@ QString UDevDevice::product() const
|
|||
}
|
||||
|
||||
if (product.isEmpty()) {
|
||||
const QByteArray idvendorid(m_device.deviceProperty("ID_VENDOR_ID").toLatin1());
|
||||
const QByteArray idmodelid(m_device.deviceProperty("ID_MODEL_ID").toLatin1());
|
||||
QByteArray idvendorid(m_device.deviceProperty("ID_VENDOR_ID").toLatin1());
|
||||
idvendorid = normalizeID(idvendorid);
|
||||
QByteArray idmodelid(m_device.deviceProperty("ID_MODEL_ID").toLatin1());
|
||||
idmodelid = normalizeID(idmodelid);
|
||||
if (!idvendorid.isEmpty() && !idmodelid.isEmpty()) {
|
||||
const QString idbus(m_device.deviceProperty("ID_BUS"));
|
||||
if (idbus == QLatin1String("pci")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue