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

From: Eugene Shalygin
Date: Fri Oct 15 2021 - 10:26:14 EST


Hi, Andy,


> > +#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?

> > + utf16s_to_utf8s((wchar_t *)data, len * 2, UTF16_LITTLE_ENDIAN, buffer, len * 2);
>
> > + 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?

> > + 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.


> > + obj = output.pointer;
> > + if (!obj || obj->type != ACPI_TYPE_BUFFER) {
>
> > + 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

Regards,
Eugene