Re: [PATCH v12] thermal: drivers: mediatek: Add the Low Voltage Thermal Sensor driver

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

 



Hi Krzysztof,

On Wed, Feb 1, 2023 at 6:12 PM Krzysztof Kozlowski
<krzysztof.kozlowski@xxxxxxxxxx> 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux