All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eduardo Valentin <eduardo.valentin@ti.com>
To: <gregkh@linuxfoundation.org>
Cc: <devel@driverdev.osuosl.org>, <linux-omap@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <linux-pm@vger.kernel.org>,
	Eduardo Valentin <eduardo.valentin@ti.com>
Subject: [PATCHv2 11/12] staging: ti-soc-thermal: fix bitfield writing while updating thresholds
Date: Tue, 19 Mar 2013 10:54:27 -0400	[thread overview]
Message-ID: <1363704868-11843-12-git-send-email-eduardo.valentin@ti.com> (raw)
In-Reply-To: <1363704868-11843-1-git-send-email-eduardo.valentin@ti.com>

Wrong threshold cold values may be written with current implementation.
This patch fixes the threshold update function by simplifying the
bitfield manipulation sequence.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/ti-soc-thermal/ti-bandgap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index d075186..5c946cd 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -418,10 +418,10 @@ static int ti_bandgap_update_alert_threshold(struct ti_bandgap *bgp, int id,
 	}
 
 	/* write the new threshold values */
-	reg_val = thresh_val & ~tsr->threshold_thot_mask;
-	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
-	reg_val |= thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
+	reg_val = thresh_val &
+		  ~(tsr->threshold_thot_mask | tsr->threshold_tcold_mask);
+	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask)) |
+		   (t_cold << __ffs(tsr->threshold_tcold_mask));
 	ti_bandgap_writel(bgp, reg_val, tsr->bgap_threshold);
 
 	if (err) {
-- 
1.7.7.1.488.ge8e1c


WARNING: multiple messages have this Message-ID (diff)
From: Eduardo Valentin <eduardo.valentin@ti.com>
To: gregkh@linuxfoundation.org
Cc: devel@driverdev.osuosl.org, linux-omap@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org,
	Eduardo Valentin <eduardo.valentin@ti.com>
Subject: [PATCHv2 11/12] staging: ti-soc-thermal: fix bitfield writing while updating thresholds
Date: Tue, 19 Mar 2013 10:54:27 -0400	[thread overview]
Message-ID: <1363704868-11843-12-git-send-email-eduardo.valentin@ti.com> (raw)
In-Reply-To: <1363704868-11843-1-git-send-email-eduardo.valentin@ti.com>

Wrong threshold cold values may be written with current implementation.
This patch fixes the threshold update function by simplifying the
bitfield manipulation sequence.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/ti-soc-thermal/ti-bandgap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/ti-soc-thermal/ti-bandgap.c b/drivers/staging/ti-soc-thermal/ti-bandgap.c
index d075186..5c946cd 100644
--- a/drivers/staging/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/staging/ti-soc-thermal/ti-bandgap.c
@@ -418,10 +418,10 @@ static int ti_bandgap_update_alert_threshold(struct ti_bandgap *bgp, int id,
 	}
 
 	/* write the new threshold values */
-	reg_val = thresh_val & ~tsr->threshold_thot_mask;
-	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
-	reg_val |= thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
+	reg_val = thresh_val &
+		  ~(tsr->threshold_thot_mask | tsr->threshold_tcold_mask);
+	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask)) |
+		   (t_cold << __ffs(tsr->threshold_tcold_mask));
 	ti_bandgap_writel(bgp, reg_val, tsr->bgap_threshold);
 
 	if (err) {
-- 
1.7.7.1.488.ge8e1c


  parent reply	other threads:[~2013-03-19 14:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-19 14:54 [PATCHv2 00/12] staging: [omap,ti-soc]-thermal: fixes and renaming Eduardo Valentin
2013-03-19 14:54 ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 01/12] staging: omap-thermal: fix return value Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 02/12] staging: omap-thermal: rename bg_ptr to bgp Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 03/12] staging: rename omap-thermal driver to ti-soc-thermal Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 04/12] staging: ti-soc-thermal: rename Kconfig options Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 05/12] staging: ti-soc-thermal: rename symbols to use better prefix Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 06/12] staging: ti-soc-thermal: make unexported functions local Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 07/12] staging: ti-soc-thermal: split writable data from readonly data Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 08/12] stating: ti-soc-thermal: use sizeof(*pointer) while allocating Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 09/12] staging: ti-soc-thermal: fix several kernel-doc warnings and error Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 19:22   ` Nishanth Menon
2013-03-19 19:22     ` Nishanth Menon
2013-03-20 11:56     ` Eduardo Valentin
2013-03-20 11:56       ` Eduardo Valentin
2013-03-20 12:50       ` Nishanth Menon
2013-03-25 18:22   ` Greg KH
2013-03-26  0:24     ` Eduardo Valentin
2013-03-26  0:24       ` Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 10/12] staging: ti-soc-thermal: fix condition to apply hyst Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-19 14:54 ` Eduardo Valentin [this message]
2013-03-19 14:54   ` [PATCHv2 11/12] staging: ti-soc-thermal: fix bitfield writing while updating thresholds Eduardo Valentin
2013-03-19 14:54 ` [PATCHv2 12/12] staging: ti-soc-thermal: propagate error code Eduardo Valentin
2013-03-19 14:54   ` Eduardo Valentin
2013-03-20  9:15 ` [PATCHv2 00/12] staging: [omap,ti-soc]-thermal: fixes and renaming Dan Carpenter

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=1363704868-11843-12-git-send-email-eduardo.valentin@ti.com \
    --to=eduardo.valentin@ti.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.