Thread (12 messages) 12 messages, 5 authors, 2021-10-18

Re: [PATCH v7 1/2] hwmon: (asus_wmi_ec_sensors) Support B550 Asus WMI.

From: Andy Shevchenko <hidden>
Date: 2021-10-15 14:38:05
Also in: linux-hwmon, lkml, platform-driver-x86

On Fri, Oct 15, 2021 at 5:26 PM Eugene Shalygin
[off-list ref] wrote:

...
quoted
quoted
+#define        ASUSWMI_METHODID_BREC   0x42524543
...above has definitely an ASCII combination in hex format, care to
decode it in the comment?
This is a constant from the WMI dispatch function, the number is a
four-letter ASCII-encoded method name, here BREC, which is already
noted in the define identifier. Is it needed to repeat that?
Method name and signature might be different, I tend to ask to add a
comment, simple /* BREC */ at the end of line would suffice.

...
quoted
quoted
+       utf16s_to_utf8s((wchar_t *)data, len * 2,  UTF16_LITTLE_ENDIAN, buffer, len * 2);
quoted
+       for (i = 0; i < len; i++, pos += 2)
+               out[i] = (hex_to_bin(pos[0]) << 4) + hex_to_bin(pos[1]);
NIH hex2bin().
Does it make sense to call hex2bin() with size = 1?
Definitely. We don't want homegrown copies of library APIs.

...
quoted
quoted
+       for (i = 0; i < len; i++) {
+               byte = registers[i] >> 8;
+               *pos = hex_asc_hi(byte);
+               pos++;
+               *pos = hex_asc_lo(byte);
+               pos++;
+               byte = registers[i];
+               *pos = hex_asc_hi(byte);
+               pos++;
+               *pos = hex_asc_lo(byte);
+               pos++;
+       }
NIH bin2hex()
bin2hex() can't output UTF-16LE characters, can it? It would need an
intermediate buffer and a call to convert ASCII (UTF-8) to UTF-16.
I didn't get it. If there is a strong endianess expected the parameter
should be __le16 or __be16, moreover it seems it missed the const
qualifier. Any preparatory stuff should be done in the
asus_wmi_ec_make_block_read_query() which prepares the input buffer,
doesn't it?

So, replace homegwon library APIs.

...
quoted
quoted
+       obj = output.pointer;
+       if (!obj || obj->type != ACPI_TYPE_BUFFER) {
quoted
+               acpi_os_free(obj);
What's the point of calling acpi_os_free(obj) when you already know it's NULL?
The case when obj->type != ACPI_TYPE_BUFFER
Read my comment again, please.

-- 
With Best Regards,
Andy Shevchenko
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help