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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Oct 15, 2021 at 5:26 PM Eugene Shalygin
<eugene.shalygin@xxxxxxxxx> wrote:

...

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

...

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

Definitely. We don't want homegrown copies of library APIs.

...

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

...

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

Read my comment again, please.

-- 
With Best Regards,
Andy Shevchenko



[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux