Date: Tue, 25 Sep 2018 16:10:26 +0300 From: Yuri Pankov <yuripv@yuripv.net> To: freebsd-hackers@freebsd.org Subject: allow specifying literal values in MODULE_PNP_INFO(9) Message-ID: <2926f43a-4709-3335-07a4-03248e13675a@yuripv.net>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. --------------F77BAD18663E3FDB44654300 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, Looking at adding the MODULE_PNP_INFO() entry to iwm(4), I came up with the patch in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=231625 adding redundant and useless vendor field to iwm_devices. While it works, it's unfortunate, and I have started looking into possible solutions and the result is a small patch for kldxref(8) allowing specifying literal values in descriptor_string like the following: MODULE_PNP_INFO("U16=8086:vendor;U16:device;P:#", pci, iwm_pci_driver, iwm_devices, sizeof(iwm_devices[0]), nitems(iwm_devices)); ...so that we always have vendor 0x8086 and only consume the device field. If it makes at least some sense, I'll put it for review. --------------F77BAD18663E3FDB44654300 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="kldxref-literal.diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="kldxref-literal.diff" ZGlmZiAtLWdpdCBhL3Vzci5zYmluL2tsZHhyZWYva2xkeHJlZi5jIGIvdXNyLnNiaW4va2xk eHJlZi9rbGR4cmVmLmMKaW5kZXggZjBkNjk5MzY5ZGJkLi5lNDk0ZThhOWYwMzkgMTAwNjQ0 Ci0tLSBhL3Vzci5zYmluL2tsZHhyZWYva2xkeHJlZi5jCisrKyBiL3Vzci5zYmluL2tsZHhy ZWYva2xkeHJlZi5jCkBAIC0xNjgsNyArMTY4LDcgQEAgcG5wX2Vpc2Fmb3JtYXQodWludDMy X3QgaWQpCiAKIHN0cnVjdCBwbnBfZWx0CiB7Ci0JaW50CXBlX2tpbmQ7CS8qIFdoYXQga2lu ZCBvZiBlbnRyeSAqLworCWludAkJcGVfa2luZDsJLyogV2hhdCBraW5kIG9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ZmZmZm KQogCQkJCQkJCQl2YWx1ZSA9IC0xOwogCQkJCQkJCWVsc2UK --------------F77BAD18663E3FDB44654300--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2926f43a-4709-3335-07a4-03248e13675a>