[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Yw9Qq+PIfxgXRIK2@smile.fi.intel.com>
Date: Wed, 31 Aug 2022 15:14:35 +0300
From: Andy Shevchenko <andriy.shevchenko@...el.com>
To: Eliav Farber <farbere@...zon.com>
Cc: jdelvare@...e.com, linux@...ck-us.net, robh+dt@...nel.org,
p.zabel@...gutronix.de, rtanwar@...linear.com,
linux-hwmon@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, talel@...zon.com, hhhawa@...zon.com,
jonnyc@...zon.com, hanochu@...zon.com, ronenk@...zon.com,
itamark@...zon.com, shellykz@...zon.com, shorer@...zon.com,
amitlavi@...zon.com, almogbs@...zon.com, dkl@...zon.com,
rahul.tanwar@...ux.intel.com
Subject: Re: [PATCH v3 18/19] hwmon: (mr75203) add debugfs to read and write
temperature coefficients
On Tue, Aug 30, 2022 at 07:22:11PM +0000, Eliav Farber wrote:
> This change adds debugfs to read and write temperature sensor coefficients
> - g, h, j and cal5.
>
> The coefficients can vary between product and product, so it can be very
> useful to be able to modify them on the fly during the calibration
> process.
>
> e.g.:
>
> cat /sys/kernel/debug/940f23d0000.pvt/ts_coeff_cal5
> 4096
>
> echo 83000 > sys/kernel/debug/940f23d0000.pvt/ts_coeff_g
...
> + pvt->dbgfs_dir = debugfs_create_dir(dev_name(dev), NULL);
> + if (!pvt->dbgfs_dir) {
> + dev_err(dev, "Failed to create dbgfs_dir\n");
> + return -EINVAL;
> + }
No, just don't check the return value of debugfs API calls.
> + debugfs_create_file("ts_coeff_h", 0644, pvt->dbgfs_dir, pvt,
> + &pvt_ts_coeff_h_fops);
> + debugfs_create_file("ts_coeff_g", 0644, pvt->dbgfs_dir, pvt,
> + &pvt_ts_coeff_g_fops);
> + debugfs_create_file("ts_coeff_j", 0644, pvt->dbgfs_dir, pvt,
> + &pvt_ts_coeff_j_fops);
> + debugfs_create_file("ts_coeff_cal5", 0644, pvt->dbgfs_dir, pvt,
> + &pvt_ts_coeff_cal5_fops);
debugfs has helpers for POD types, use them and shrink your code by ~80%.
...
> + ret = devm_add_action_or_reset(dev, devm_pvt_ts_dbgfs_remove, pvt);
> + if (ret) {
> + dev_err(dev, "failed to add action to remove pvt dbgfs (%d)\n",
> + ret);
> + return ret;
> + }
> +
> + return 0;
return devm_add_...
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists