lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 3 Feb 2023 12:06:32 +0100
From:   Balsam CHIHI <bchihi@...libre.com>
To:     Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
Cc:     daniel.lezcano@...aro.org, angelogioacchino.delregno@...labora.com,
        rafael@...nel.org, amitk@...nel.org, rui.zhang@...el.com,
        matthias.bgg@...il.com, robh+dt@...nel.org,
        krzysztof.kozlowski+dt@...aro.org, rdunlap@...radead.org,
        ye.xingchen@....com.cn, p.zabel@...gutronix.de,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org,
        linux-mediatek@...ts.infradead.org, devicetree@...r.kernel.org,
        khilman@...libre.com, james.lo@...iatek.com,
        rex-bc.chen@...iatek.com
Subject: Re: [PATCH v12] thermal: drivers: mediatek: Add the Low Voltage
 Thermal Sensor driver

Hi Krzysztof,

On Wed, Feb 1, 2023 at 6:12 PM Krzysztof Kozlowski
<krzysztof.kozlowski@...aro.org> wrote:
>
> On 01/02/2023 17:46, Balsam CHIHI wrote:
> >>> +#ifdef CONFIG_MTK_LVTS_THERMAL_DEBUGFS
> >>> +
> >>> +static struct dentry *root;
> >>
> >> How do you handle two instances of driver?
> >
> > This root node is the topmost directory for debugfs called 'lvts', the
> > different driver instances are below this. It is a singleton.
>
> Indeed. What about removal? Aren't you remobing entire directory
> structure on first device removal?
>

For now, the driver only supports one instance.
I will find a way to handle this when the driver supports more instances.
Is this suggestion OK for you?

> (...)
>
> >>> +
> >>> +     of_property_for_each_string(np, "nvmem-cell-names", prop, cell_name) {
> >>> +             size_t len;
> >>> +             u8 *efuse;
> >>> +
> >>> +             cell = of_nvmem_cell_get(np, cell_name);
> >>> +             if (IS_ERR(cell)) {
> >>> +                     dev_dbg(dev, "Failed to get cell '%s'\n", cell_name);
> >>
> >> Is this an error? If so, why debug? dbg is not for errors.
> >
> > AFAIK using dev_dbg does not increase ELF size when DEBUG is disabled.
> > If this is not a good reason for you, then I will change it to dev_err.
>
> But also dev_dbg are not visible in error or warn level logs. If this is
> not an error, then indeed dev_dbg could be fine. But errors should be
> verbose.

OK,
I will replace all "dev_dbg" with "dev_err" in this function.

>
> >
> >>
> >>> +                     return PTR_ERR(cell);
> >>> +             }
> >>> +
> >>> +             efuse = nvmem_cell_read(cell, &len);
> >>> +
> >>> +             nvmem_cell_put(cell);
> >>> +
> >>> +             if (IS_ERR(efuse)) {
> >>> +                     dev_dbg(dev, "Failed to read cell '%s'\n", cell_name);
> >>> +                     return PTR_ERR(efuse);
> >>> +             }
> >>> +
> >>> +             lvts_td->calib = devm_krealloc(dev, lvts_td->calib,
> >>> +                                            lvts_td->calib_len + len, GFP_KERNEL);
> >>> +             if (!lvts_td->calib)
> >>> +                     return -ENOMEM;
> >>> +
> >>> +             memcpy(lvts_td->calib + lvts_td->calib_len, efuse, len);
> >>> +
> >>> +             lvts_td->calib_len += len;
> >>> +
> >>> +             kfree(efuse);
> >>> +     }
> >>> +
> >>> +     return 0;
> >>> +}
> >>> +
> >>> +static int __init lvts_golden_temp_init(struct device *dev, u32 *value)
> >>
> >> You did not test it, right? Build with section mismatch analysis...
> >
> > I'm not sure to fully understand this comment.
> > Would you explain, please?
>
> git grep -i "section mismatch" leads to lib/Kconfig.debug and
> DEBUG_SECTION_MISMATCH

__init is removed from all functions.

>
> (...)
>
> >>> +static struct lvts_ctrl_data mt8195_lvts_data_ctrl[] = {
> >>
> >> Why this cannot be const?
> >
> > I've got the following warning when I added "const"
> > drivers/thermal/mediatek/lvts_thermal.c:1286:27: warning:
> > initialization discards ‘const’ qualifier from pointer target type
> > [-Wdiscarded-qualifiers]
> >  1286 |         .lvts_ctrl      = mt8195_lvts_data_ctrl,
> >       |                           ^~~~~~~~~~~~~~~~~~~~~~~~~
>
> As with every const... Do you need lvts_ctrl to be non-const? If yes,
> then how do you handle multiple devices (singleton)?
>

I found a fix for this it was simple.
add const here as you suggested
and in other function parameters every time we use this variable.

> Best regards,
> Krzysztof
>

Thank you for the review!

Best regards,
Balsam

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ