From: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
To: Eduardo Valentin <edubezval@gmail.com>
Cc: Eduardo Valentin <eduardo.valentin@ti.com>,
Zhang Rui <rui.zhang@intel.com>,
Amit Daniel Kachhap <amit.daniel@samsung.com>,
Tomasz Figa <t.figa@samsung.com>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
Kyungmin Park <kyungmin.park@samsung.com>,
linux-samsung-soc@vger.kernel.org, linux-pm@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 06/10] thermal: exynos: remove redundant threshold_code checks from exynos_tmu_initialize()
Date: Thu, 15 May 2014 18:56:55 +0200 [thread overview]
Message-ID: <2759070.4B75QlgKJJ@amdc1032> (raw)
In-Reply-To: <20140515145552.GB27690@developer>
On Thursday, May 15, 2014 10:55:52 AM Eduardo Valentin wrote:
> Hello Bartlomiej,
Hi,
> On Mon, May 05, 2014 at 01:15:35PM +0200, Bartlomiej Zolnierkiewicz wrote:
> > Remove runtime checks for negative return values of temp_to_code()
> > from exynos_tmu_initialize(). The current level temperature data
> > hardcoded in pdata will never cause a negative temp_to_code()
> > return values and for the new code potential mistakes should be
> > caught during development/review phases.
> >
> > Theres should be no functional changes caused by this patch.
> >
>
> Same question as in previous patch. Removing defensive code must
Simirarly like in a previous case. Such verification should not be done
at runtime in a production code because it is already too late for such
checking. It should be done during development and review phases.
> be done carefully.
BTW In case of temp_to_code() its users should be audited to pass only
input values that give positive results and later the function itself
may be modified to catch wrong input values by using WARN_ON (or even
BUG_ON).
> > Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
> > ---
> > drivers/thermal/samsung/exynos_tmu.c | 16 +---------------
> > 1 file changed, 1 insertion(+), 15 deletions(-)
> >
> > diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c
> > index 789d745..a415829 100644
> > --- a/drivers/thermal/samsung/exynos_tmu.c
> > +++ b/drivers/thermal/samsung/exynos_tmu.c
> > @@ -170,10 +170,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
> > if (data->soc == SOC_ARCH_EXYNOS4210) {
> > /* Write temperature code for threshold */
> > threshold_code = temp_to_code(data, pdata->threshold);
> > - if (threshold_code < 0) {
> > - ret = threshold_code;
> > - goto out;
> > - }
> > writeb(threshold_code,
> > data->base + reg->threshold_temp);
> > for (i = 0; i < trigger_levs; i++)
> > @@ -187,18 +183,12 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
> > i < trigger_levs && i < EXYNOS_MAX_TRIGGER_PER_REG; i++) {
> > threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > - if (threshold_code < 0) {
> > - ret = threshold_code;
> > - goto out;
> > - }
> > rising_threshold |= threshold_code << 8 * i;
> > if (pdata->threshold_falling) {
> > threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i] -
> > pdata->threshold_falling);
> > - if (threshold_code > 0)
> > - falling_threshold |=
> > - threshold_code << 8 * i;
> > + falling_threshold |= threshold_code << 8 * i;
> > }
> > }
> >
> > @@ -217,10 +207,6 @@ static int exynos_tmu_initialize(struct platform_device *pdev)
> > (pdata->trigger_type[i] == HW_TRIP)) {
> > threshold_code = temp_to_code(data,
> > pdata->trigger_levels[i]);
> > - if (threshold_code < 0) {
> > - ret = threshold_code;
> > - goto out;
> > - }
> > if (i == EXYNOS_MAX_TRIGGER_PER_REG - 1) {
> > /* 1-4 level to be assigned in th0 reg */
> > rising_threshold |= threshold_code << 8 * i;
Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics
next prev parent reply other threads:[~2014-05-15 16:57 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 11:15 [PATCH 00/10] thermal: exynos: various cleanups Bartlomiej Zolnierkiewicz
2014-05-05 11:15 ` [PATCH 01/10] thermal: exynos: remove unused struct exynos_tmu_registers entries Bartlomiej Zolnierkiewicz
2014-05-19 5:12 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 02/10] thermal: exynos: remove unused defines Bartlomiej Zolnierkiewicz
2014-05-15 14:07 ` Eduardo Valentin
2014-05-19 5:17 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 03/10] thermal: exynos: remove dead code for HW_MODE calibration Bartlomiej Zolnierkiewicz
2014-05-15 14:14 ` Eduardo Valentin
2014-05-15 15:06 ` Bartlomiej Zolnierkiewicz
2014-05-19 5:27 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 04/10] thermal: exynos: remove dead code for TYPE_TWO_POINT_TRIMMING calibration Bartlomiej Zolnierkiewicz
2014-05-15 14:31 ` Eduardo Valentin
2014-05-15 15:35 ` Bartlomiej Zolnierkiewicz
2014-05-19 5:40 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 05/10] thermal: exynos: remove redundant pdata checks from exynos_tmu_initialize() Bartlomiej Zolnierkiewicz
2014-05-15 14:47 ` Eduardo Valentin
2014-05-15 16:24 ` Bartlomiej Zolnierkiewicz
2014-05-19 5:47 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 06/10] thermal: exynos: remove redundant threshold_code " Bartlomiej Zolnierkiewicz
2014-05-15 14:55 ` Eduardo Valentin
2014-05-15 16:56 ` Bartlomiej Zolnierkiewicz [this message]
2014-05-19 5:50 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 07/10] thermal: exynos: simplify temp_to_code() and code_to_temp() Bartlomiej Zolnierkiewicz
2014-05-19 5:54 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 08/10] thermal: exynos: cache non_hw_trigger_levels in pdata Bartlomiej Zolnierkiewicz
2014-05-19 5:56 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 09/10] thermal: exynos: remove redundant pdata checks from exynos_tmu_control() Bartlomiej Zolnierkiewicz
2014-05-15 15:03 ` Eduardo Valentin
2014-05-15 17:06 ` Bartlomiej Zolnierkiewicz
2014-05-19 6:05 ` Amit Kachhap
2014-05-05 11:15 ` [PATCH 10/10] thermal: exynos: remove identical values from exynos*_tmu_registers structures Bartlomiej Zolnierkiewicz
2014-05-19 6:11 ` Amit Kachhap
2014-05-15 9:06 ` [PATCH 00/10] thermal: exynos: various cleanups Zhang Rui
2014-05-19 6:16 ` Amit Kachhap
2014-05-19 11:05 ` Bartlomiej Zolnierkiewicz
2014-05-19 11:09 ` Tomasz Figa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2759070.4B75QlgKJJ@amdc1032 \
--to=b.zolnierkie@samsung.com \
--cc=amit.daniel@samsung.com \
--cc=eduardo.valentin@ti.com \
--cc=edubezval@gmail.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
--cc=t.figa@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox