All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/50] staging: omap-thermal: several code refactoring
@ 2013-03-15 12:59 ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Hello Greg,

Here is a series of patches improving the way the omap-thermal driver
is written. There is a mix of added documentation, with functions rewrites
and cleanups regarding coding style. I am also adding myself as maintainer
of this driver.

Next I will be still improving the code in this way, but also working
on the policy readiness and  testing on other devices. I will probably
rename the driver also to something that reflect the support to AMxx devices
as well.

Hopefully, it should be soon ready for moving to drivers/thermal/.

All these are based on your staging/staging-next branch.

For those interested in testing and trying the driver, these patches are
also available, as usual, here:
git@gitorious.org:thermal-framework/thermal-framework.git thermal_work/omap/omap-thermal-optimizations
https://git.gitorious.org/thermal-framework/thermal-framework.git thermal_work/omap/omap-thermal-optimizations

For lo guys, I will appreciate your testing results on other devices.

Cheers,


Eduardo Valentin (50):
  staging: omap-thermal: use BIT() macro
  staging: omap-thermal: remove unused _SHIFT macros
  staging: omap-thermal: create header for register, bitfields and
    definitions
  staging: omap-thermal: update documentation of omap-bandgap.h
  staging: omap-thermal: style cleanup on omap-bandgap.c
  staging: omap-thermal: fix error checking
  staging: omap-thermal: introduce RMW_BITS macro
  staging: omap-thermal: add documentation for register access
    functions
  staging: omap-thermal: make a omap_bandgap_power with only one exit
    point
  staging: omap-thermal: add documentation for omap_bandgap_power
  staging: omap-thermal: add documentation for omap_bandgap_read_temp
  staging: omap-thermal: rename talert handler
  staging: omap-thermal: update documentation for talert irq handler
  staging: omap-thermal: update tshut IRQ handler documentation
  staging: omap-thermal: remove duplicated code
  staging: omap-thermal: read status only once inside alert IRQ
  staging: omap-thermal: add a section of register manipulation
  staging: omap-thermal: section of basic helpers
  staging: omap-thermal: IRQ handler section
  staging: omap-thermal: ADC section
  staging: omap-thermal: name adc_to_temp_conversion in a better way
  staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel
    coding style
  staging: omap-thermal: add documentation for
    omap_bandgap_adc_to_mcelsius
  staging: omap-thermal: name temp_to_adc_conversion in a better way
  staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel
    coding style
  staging: omap-thermal: move conv table limits out of sensor data
  staging: omap-thermal: add documentation for
    omap_bandgap_mcelsius_to_adc
  staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst
  staging: omap-thermal: document omap_bandgap_add_hyst function
  staging: omap-thermal: threshold manipulation section
  staging: omap-thermal: refactor temp_sensor_unmask_interrupts
  staging: omap-thermal: update omap_bandgap_unmask_interrupts
    documentation
  staging: omap-thermal: refactor APIs handling threshold values
  staging: omap-thermal: device initialization section
  staging: omap-thermal: section of device driver callbacks
  staging: omap-thermal: rename enable_continuous_mode
  staging: omap-thermal: update omap_bandgap_set_continous_mode
    documentation
  staging: omap-thermal: document omap_bandgap_force_single_read
  staging: omap-thermal: document omap_bandgap_update_alert_threshold
    function
  staging: omap-thermal: document _omap_bandgap_write_threshold
    function
  staging: omap-thermal: document _omap_bandgap_read_threshold function
  staging: omap-thermal: document omap_bandgap_tshut_init function
  staging: omap-thermal: document omap_bandgap_alert_init function
  staging: omap-thermal: document omap_bandgap_build function
  staging: omap-thermal: change Kconfig dependency method
  staging: Add a MAINTAINERS entry for TI bandgap and thermal driver
  staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  staging: omap-thermal: remove TODO entry suggesting regmap usage
  staging: omap-thermal: remove TODO entry for exposed APIs
  staging: omap-thermal: add documentation for omap_bandgap_validate

 MAINTAINERS                                        |    6 +
 drivers/staging/omap-thermal/Kconfig               |    2 +-
 drivers/staging/omap-thermal/TODO                  |    4 -
 drivers/staging/omap-thermal/omap-bandgap.c        |  793 +++++++++++---------
 drivers/staging/omap-thermal/omap-bandgap.h        |  498 +++++--------
 drivers/staging/omap-thermal/omap-thermal-common.c |    4 +-
 drivers/staging/omap-thermal/omap4-thermal-data.c  |   11 +-
 drivers/staging/omap-thermal/omap4xxx-bandgap.h    |  175 +++++
 drivers/staging/omap-thermal/omap5-thermal-data.c  |    9 +-
 drivers/staging/omap-thermal/omap5xxx-bandgap.h    |  199 +++++
 10 files changed, 1030 insertions(+), 671 deletions(-)
 create mode 100644 drivers/staging/omap-thermal/omap4xxx-bandgap.h
 create mode 100644 drivers/staging/omap-thermal/omap5xxx-bandgap.h

-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [PATCH 00/50] staging: omap-thermal: several code refactoring
@ 2013-03-15 12:59 ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Hello Greg,

Here is a series of patches improving the way the omap-thermal driver
is written. There is a mix of added documentation, with functions rewrites
and cleanups regarding coding style. I am also adding myself as maintainer
of this driver.

Next I will be still improving the code in this way, but also working
on the policy readiness and  testing on other devices. I will probably
rename the driver also to something that reflect the support to AMxx devices
as well.

Hopefully, it should be soon ready for moving to drivers/thermal/.

All these are based on your staging/staging-next branch.

For those interested in testing and trying the driver, these patches are
also available, as usual, here:
git@gitorious.org:thermal-framework/thermal-framework.git thermal_work/omap/omap-thermal-optimizations
https://git.gitorious.org/thermal-framework/thermal-framework.git thermal_work/omap/omap-thermal-optimizations

For lo guys, I will appreciate your testing results on other devices.

Cheers,


Eduardo Valentin (50):
  staging: omap-thermal: use BIT() macro
  staging: omap-thermal: remove unused _SHIFT macros
  staging: omap-thermal: create header for register, bitfields and
    definitions
  staging: omap-thermal: update documentation of omap-bandgap.h
  staging: omap-thermal: style cleanup on omap-bandgap.c
  staging: omap-thermal: fix error checking
  staging: omap-thermal: introduce RMW_BITS macro
  staging: omap-thermal: add documentation for register access
    functions
  staging: omap-thermal: make a omap_bandgap_power with only one exit
    point
  staging: omap-thermal: add documentation for omap_bandgap_power
  staging: omap-thermal: add documentation for omap_bandgap_read_temp
  staging: omap-thermal: rename talert handler
  staging: omap-thermal: update documentation for talert irq handler
  staging: omap-thermal: update tshut IRQ handler documentation
  staging: omap-thermal: remove duplicated code
  staging: omap-thermal: read status only once inside alert IRQ
  staging: omap-thermal: add a section of register manipulation
  staging: omap-thermal: section of basic helpers
  staging: omap-thermal: IRQ handler section
  staging: omap-thermal: ADC section
  staging: omap-thermal: name adc_to_temp_conversion in a better way
  staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel
    coding style
  staging: omap-thermal: add documentation for
    omap_bandgap_adc_to_mcelsius
  staging: omap-thermal: name temp_to_adc_conversion in a better way
  staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel
    coding style
  staging: omap-thermal: move conv table limits out of sensor data
  staging: omap-thermal: add documentation for
    omap_bandgap_mcelsius_to_adc
  staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst
  staging: omap-thermal: document omap_bandgap_add_hyst function
  staging: omap-thermal: threshold manipulation section
  staging: omap-thermal: refactor temp_sensor_unmask_interrupts
  staging: omap-thermal: update omap_bandgap_unmask_interrupts
    documentation
  staging: omap-thermal: refactor APIs handling threshold values
  staging: omap-thermal: device initialization section
  staging: omap-thermal: section of device driver callbacks
  staging: omap-thermal: rename enable_continuous_mode
  staging: omap-thermal: update omap_bandgap_set_continous_mode
    documentation
  staging: omap-thermal: document omap_bandgap_force_single_read
  staging: omap-thermal: document omap_bandgap_update_alert_threshold
    function
  staging: omap-thermal: document _omap_bandgap_write_threshold
    function
  staging: omap-thermal: document _omap_bandgap_read_threshold function
  staging: omap-thermal: document omap_bandgap_tshut_init function
  staging: omap-thermal: document omap_bandgap_alert_init function
  staging: omap-thermal: document omap_bandgap_build function
  staging: omap-thermal: change Kconfig dependency method
  staging: Add a MAINTAINERS entry for TI bandgap and thermal driver
  staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  staging: omap-thermal: remove TODO entry suggesting regmap usage
  staging: omap-thermal: remove TODO entry for exposed APIs
  staging: omap-thermal: add documentation for omap_bandgap_validate

 MAINTAINERS                                        |    6 +
 drivers/staging/omap-thermal/Kconfig               |    2 +-
 drivers/staging/omap-thermal/TODO                  |    4 -
 drivers/staging/omap-thermal/omap-bandgap.c        |  793 +++++++++++---------
 drivers/staging/omap-thermal/omap-bandgap.h        |  498 +++++--------
 drivers/staging/omap-thermal/omap-thermal-common.c |    4 +-
 drivers/staging/omap-thermal/omap4-thermal-data.c  |   11 +-
 drivers/staging/omap-thermal/omap4xxx-bandgap.h    |  175 +++++
 drivers/staging/omap-thermal/omap5-thermal-data.c  |    9 +-
 drivers/staging/omap-thermal/omap5xxx-bandgap.h    |  199 +++++
 10 files changed, 1030 insertions(+), 671 deletions(-)
 create mode 100644 drivers/staging/omap-thermal/omap4xxx-bandgap.h
 create mode 100644 drivers/staging/omap-thermal/omap5xxx-bandgap.h

-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply	[flat|nested] 128+ messages in thread

* [PATCH 01/50] staging: omap-thermal: use BIT() macro
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

For code readability, this patch changes the bit definition
under omap-bandgap.h to use the BIT() macro.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |   96 +++++++++++++-------------
 1 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 3e9072c..8d3ee2b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -29,17 +29,17 @@
 
 /* TEMP_SENSOR OMAP4430 */
 #define OMAP4430_BGAP_TSHUT_SHIFT			11
-#define OMAP4430_BGAP_TSHUT_MASK			(1 << 11)
+#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
 
 /* TEMP_SENSOR OMAP4430 */
 #define OMAP4430_BGAP_TEMPSOFF_SHIFT			12
-#define OMAP4430_BGAP_TEMPSOFF_MASK			(1 << 12)
+#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
 #define OMAP4430_SINGLE_MODE_SHIFT			10
-#define OMAP4430_SINGLE_MODE_MASK			(1 << 10)
+#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
 #define OMAP4430_BGAP_TEMP_SENSOR_SOC_SHIFT		9
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 9)
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
 #define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		8
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 8)
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
 
@@ -53,21 +53,21 @@
 
 /* TEMP_SENSOR OMAP4460 */
 #define OMAP4460_BGAP_TEMPSOFF_SHIFT			13
-#define OMAP4460_BGAP_TEMPSOFF_MASK			(1 << 13)
+#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
 #define OMAP4460_BGAP_TEMP_SENSOR_SOC_SHIFT		11
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 11)
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
 #define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 10)
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
 #define OMAP4460_SINGLE_MODE_SHIFT			31
-#define OMAP4460_SINGLE_MODE_MASK			(1 << 31)
+#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
 #define OMAP4460_MASK_HOT_SHIFT				1
-#define OMAP4460_MASK_HOT_MASK				(1 << 1)
+#define OMAP4460_MASK_HOT_MASK				BIT(1)
 #define OMAP4460_MASK_COLD_SHIFT			0
-#define OMAP4460_MASK_COLD_MASK				(1 << 0)
+#define OMAP4460_MASK_COLD_MASK				BIT(0)
 
 /* BANDGAP_COUNTER */
 #define OMAP4460_COUNTER_SHIFT				0
@@ -87,57 +87,57 @@
 
 /* BANDGAP_STATUS */
 #define OMAP4460_CLEAN_STOP_SHIFT			3
-#define OMAP4460_CLEAN_STOP_MASK			(1 << 3)
+#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
 #define OMAP4460_BGAP_ALERT_SHIFT			2
-#define OMAP4460_BGAP_ALERT_MASK			(1 << 2)
+#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
 #define OMAP4460_HOT_FLAG_SHIFT				1
-#define OMAP4460_HOT_FLAG_MASK				(1 << 1)
+#define OMAP4460_HOT_FLAG_MASK				BIT(1)
 #define OMAP4460_COLD_FLAG_SHIFT			0
-#define OMAP4460_COLD_FLAG_MASK				(1 << 0)
+#define OMAP4460_COLD_FLAG_MASK				BIT(0)
 
 /* TEMP_SENSOR OMAP5430 */
 #define OMAP5430_BGAP_TEMP_SENSOR_SOC_SHIFT		12
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 12)
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
 #define OMAP5430_BGAP_TEMPSOFF_SHIFT			11
-#define OMAP5430_BGAP_TEMPSOFF_MASK			(1 << 11)
+#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
 #define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 10)
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
 #define OMAP5430_MASK_HOT_CORE_SHIFT			5
-#define OMAP5430_MASK_HOT_CORE_MASK			(1 << 5)
+#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
 #define OMAP5430_MASK_COLD_CORE_SHIFT			4
-#define OMAP5430_MASK_COLD_CORE_MASK			(1 << 4)
+#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
 #define OMAP5430_MASK_HOT_GPU_SHIFT			3
-#define OMAP5430_MASK_HOT_GPU_MASK			(1 << 3)
+#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
 #define OMAP5430_MASK_COLD_GPU_SHIFT			2
-#define OMAP5430_MASK_COLD_GPU_MASK			(1 << 2)
+#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
 #define OMAP5430_MASK_HOT_MPU_SHIFT			1
-#define OMAP5430_MASK_HOT_MPU_MASK			(1 << 1)
+#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
 #define OMAP5430_MASK_COLD_MPU_SHIFT			0
-#define OMAP5430_MASK_COLD_MPU_MASK			(1 << 0)
+#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
 #define OMAP5430_MASK_SIDLEMODE_SHIFT			30
 #define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
 #define OMAP5430_MASK_FREEZE_CORE_SHIFT			23
-#define OMAP5430_MASK_FREEZE_CORE_MASK			(1 << 23)
+#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
 #define OMAP5430_MASK_FREEZE_GPU_SHIFT			22
-#define OMAP5430_MASK_FREEZE_GPU_MASK			(1 << 22)
+#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
 #define OMAP5430_MASK_FREEZE_MPU_SHIFT			21
-#define OMAP5430_MASK_FREEZE_MPU_MASK			(1 << 21)
+#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
 #define OMAP5430_MASK_CLEAR_CORE_SHIFT			20
-#define OMAP5430_MASK_CLEAR_CORE_MASK			(1 << 20)
+#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
 #define OMAP5430_MASK_CLEAR_GPU_SHIFT			19
-#define OMAP5430_MASK_CLEAR_GPU_MASK			(1 << 19)
+#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
 #define OMAP5430_MASK_CLEAR_MPU_SHIFT			18
-#define OMAP5430_MASK_CLEAR_MPU_MASK			(1 << 18)
+#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
 #define OMAP5430_MASK_CLEAR_ACCUM_CORE_SHIFT		17
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		(1 << 17)
+#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
 #define OMAP5430_MASK_CLEAR_ACCUM_GPU_SHIFT		16
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		(1 << 16)
+#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
 #define OMAP5430_MASK_CLEAR_ACCUM_MPU_SHIFT		15
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		(1 << 15)
+#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
 
 /* BANDGAP_COUNTER */
 #define OMAP5430_COUNTER_SHIFT				0
@@ -169,19 +169,19 @@
 
 /* BANDGAP_STATUS */
 #define OMAP5430_BGAP_ALERT_SHIFT			31
-#define OMAP5430_BGAP_ALERT_MASK			(1 << 31)
+#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
 #define OMAP5430_HOT_CORE_FLAG_SHIFT			5
-#define OMAP5430_HOT_CORE_FLAG_MASK			(1 << 5)
+#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
 #define OMAP5430_COLD_CORE_FLAG_SHIFT			4
-#define OMAP5430_COLD_CORE_FLAG_MASK			(1 << 4)
+#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
 #define OMAP5430_HOT_GPU_FLAG_SHIFT			3
-#define OMAP5430_HOT_GPU_FLAG_MASK			(1 << 3)
+#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
 #define OMAP5430_COLD_GPU_FLAG_SHIFT			2
-#define OMAP5430_COLD_GPU_FLAG_MASK			(1 << 2)
+#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
 #define OMAP5430_HOT_MPU_FLAG_SHIFT			1
-#define OMAP5430_HOT_MPU_FLAG_MASK			(1 << 1)
+#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
 #define OMAP5430_COLD_MPU_FLAG_SHIFT			0
-#define OMAP5430_COLD_MPU_FLAG_MASK			(1 << 0)
+#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
 
 /* Offsets from the base of temperature sensor registers */
 
@@ -434,14 +434,14 @@ struct omap_temp_sensor {
  * @expose_sensor: callback to export sensor to thermal API
  */
 struct omap_bandgap_data {
-#define OMAP_BANDGAP_FEATURE_TSHUT		(1 << 0)
-#define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	(1 << 1)
-#define OMAP_BANDGAP_FEATURE_TALERT		(1 << 2)
-#define OMAP_BANDGAP_FEATURE_MODE_CONFIG	(1 << 3)
-#define OMAP_BANDGAP_FEATURE_COUNTER		(1 << 4)
-#define OMAP_BANDGAP_FEATURE_POWER_SWITCH	(1 << 5)
-#define OMAP_BANDGAP_FEATURE_CLK_CTRL		(1 << 6)
-#define OMAP_BANDGAP_FEATURE_FREEZE_BIT		(1 << 7)
+#define OMAP_BANDGAP_FEATURE_TSHUT		BIT(0)
+#define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	BIT(1)
+#define OMAP_BANDGAP_FEATURE_TALERT		BIT(2)
+#define OMAP_BANDGAP_FEATURE_MODE_CONFIG	BIT(3)
+#define OMAP_BANDGAP_FEATURE_COUNTER		BIT(4)
+#define OMAP_BANDGAP_FEATURE_POWER_SWITCH	BIT(5)
+#define OMAP_BANDGAP_FEATURE_CLK_CTRL		BIT(6)
+#define OMAP_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define OMAP_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
 	unsigned int			features;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 01/50] staging: omap-thermal: use BIT() macro
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

For code readability, this patch changes the bit definition
under omap-bandgap.h to use the BIT() macro.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |   96 +++++++++++++-------------
 1 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 3e9072c..8d3ee2b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -29,17 +29,17 @@
 
 /* TEMP_SENSOR OMAP4430 */
 #define OMAP4430_BGAP_TSHUT_SHIFT			11
-#define OMAP4430_BGAP_TSHUT_MASK			(1 << 11)
+#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
 
 /* TEMP_SENSOR OMAP4430 */
 #define OMAP4430_BGAP_TEMPSOFF_SHIFT			12
-#define OMAP4430_BGAP_TEMPSOFF_MASK			(1 << 12)
+#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
 #define OMAP4430_SINGLE_MODE_SHIFT			10
-#define OMAP4430_SINGLE_MODE_MASK			(1 << 10)
+#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
 #define OMAP4430_BGAP_TEMP_SENSOR_SOC_SHIFT		9
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 9)
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
 #define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		8
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 8)
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
 
@@ -53,21 +53,21 @@
 
 /* TEMP_SENSOR OMAP4460 */
 #define OMAP4460_BGAP_TEMPSOFF_SHIFT			13
-#define OMAP4460_BGAP_TEMPSOFF_MASK			(1 << 13)
+#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
 #define OMAP4460_BGAP_TEMP_SENSOR_SOC_SHIFT		11
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 11)
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
 #define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 10)
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
 #define OMAP4460_SINGLE_MODE_SHIFT			31
-#define OMAP4460_SINGLE_MODE_MASK			(1 << 31)
+#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
 #define OMAP4460_MASK_HOT_SHIFT				1
-#define OMAP4460_MASK_HOT_MASK				(1 << 1)
+#define OMAP4460_MASK_HOT_MASK				BIT(1)
 #define OMAP4460_MASK_COLD_SHIFT			0
-#define OMAP4460_MASK_COLD_MASK				(1 << 0)
+#define OMAP4460_MASK_COLD_MASK				BIT(0)
 
 /* BANDGAP_COUNTER */
 #define OMAP4460_COUNTER_SHIFT				0
@@ -87,57 +87,57 @@
 
 /* BANDGAP_STATUS */
 #define OMAP4460_CLEAN_STOP_SHIFT			3
-#define OMAP4460_CLEAN_STOP_MASK			(1 << 3)
+#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
 #define OMAP4460_BGAP_ALERT_SHIFT			2
-#define OMAP4460_BGAP_ALERT_MASK			(1 << 2)
+#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
 #define OMAP4460_HOT_FLAG_SHIFT				1
-#define OMAP4460_HOT_FLAG_MASK				(1 << 1)
+#define OMAP4460_HOT_FLAG_MASK				BIT(1)
 #define OMAP4460_COLD_FLAG_SHIFT			0
-#define OMAP4460_COLD_FLAG_MASK				(1 << 0)
+#define OMAP4460_COLD_FLAG_MASK				BIT(0)
 
 /* TEMP_SENSOR OMAP5430 */
 #define OMAP5430_BGAP_TEMP_SENSOR_SOC_SHIFT		12
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		(1 << 12)
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
 #define OMAP5430_BGAP_TEMPSOFF_SHIFT			11
-#define OMAP5430_BGAP_TEMPSOFF_MASK			(1 << 11)
+#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
 #define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		(1 << 10)
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
 #define OMAP5430_MASK_HOT_CORE_SHIFT			5
-#define OMAP5430_MASK_HOT_CORE_MASK			(1 << 5)
+#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
 #define OMAP5430_MASK_COLD_CORE_SHIFT			4
-#define OMAP5430_MASK_COLD_CORE_MASK			(1 << 4)
+#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
 #define OMAP5430_MASK_HOT_GPU_SHIFT			3
-#define OMAP5430_MASK_HOT_GPU_MASK			(1 << 3)
+#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
 #define OMAP5430_MASK_COLD_GPU_SHIFT			2
-#define OMAP5430_MASK_COLD_GPU_MASK			(1 << 2)
+#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
 #define OMAP5430_MASK_HOT_MPU_SHIFT			1
-#define OMAP5430_MASK_HOT_MPU_MASK			(1 << 1)
+#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
 #define OMAP5430_MASK_COLD_MPU_SHIFT			0
-#define OMAP5430_MASK_COLD_MPU_MASK			(1 << 0)
+#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
 #define OMAP5430_MASK_SIDLEMODE_SHIFT			30
 #define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
 #define OMAP5430_MASK_FREEZE_CORE_SHIFT			23
-#define OMAP5430_MASK_FREEZE_CORE_MASK			(1 << 23)
+#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
 #define OMAP5430_MASK_FREEZE_GPU_SHIFT			22
-#define OMAP5430_MASK_FREEZE_GPU_MASK			(1 << 22)
+#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
 #define OMAP5430_MASK_FREEZE_MPU_SHIFT			21
-#define OMAP5430_MASK_FREEZE_MPU_MASK			(1 << 21)
+#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
 #define OMAP5430_MASK_CLEAR_CORE_SHIFT			20
-#define OMAP5430_MASK_CLEAR_CORE_MASK			(1 << 20)
+#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
 #define OMAP5430_MASK_CLEAR_GPU_SHIFT			19
-#define OMAP5430_MASK_CLEAR_GPU_MASK			(1 << 19)
+#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
 #define OMAP5430_MASK_CLEAR_MPU_SHIFT			18
-#define OMAP5430_MASK_CLEAR_MPU_MASK			(1 << 18)
+#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
 #define OMAP5430_MASK_CLEAR_ACCUM_CORE_SHIFT		17
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		(1 << 17)
+#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
 #define OMAP5430_MASK_CLEAR_ACCUM_GPU_SHIFT		16
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		(1 << 16)
+#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
 #define OMAP5430_MASK_CLEAR_ACCUM_MPU_SHIFT		15
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		(1 << 15)
+#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
 
 /* BANDGAP_COUNTER */
 #define OMAP5430_COUNTER_SHIFT				0
@@ -169,19 +169,19 @@
 
 /* BANDGAP_STATUS */
 #define OMAP5430_BGAP_ALERT_SHIFT			31
-#define OMAP5430_BGAP_ALERT_MASK			(1 << 31)
+#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
 #define OMAP5430_HOT_CORE_FLAG_SHIFT			5
-#define OMAP5430_HOT_CORE_FLAG_MASK			(1 << 5)
+#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
 #define OMAP5430_COLD_CORE_FLAG_SHIFT			4
-#define OMAP5430_COLD_CORE_FLAG_MASK			(1 << 4)
+#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
 #define OMAP5430_HOT_GPU_FLAG_SHIFT			3
-#define OMAP5430_HOT_GPU_FLAG_MASK			(1 << 3)
+#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
 #define OMAP5430_COLD_GPU_FLAG_SHIFT			2
-#define OMAP5430_COLD_GPU_FLAG_MASK			(1 << 2)
+#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
 #define OMAP5430_HOT_MPU_FLAG_SHIFT			1
-#define OMAP5430_HOT_MPU_FLAG_MASK			(1 << 1)
+#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
 #define OMAP5430_COLD_MPU_FLAG_SHIFT			0
-#define OMAP5430_COLD_MPU_FLAG_MASK			(1 << 0)
+#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
 
 /* Offsets from the base of temperature sensor registers */
 
@@ -434,14 +434,14 @@ struct omap_temp_sensor {
  * @expose_sensor: callback to export sensor to thermal API
  */
 struct omap_bandgap_data {
-#define OMAP_BANDGAP_FEATURE_TSHUT		(1 << 0)
-#define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	(1 << 1)
-#define OMAP_BANDGAP_FEATURE_TALERT		(1 << 2)
-#define OMAP_BANDGAP_FEATURE_MODE_CONFIG	(1 << 3)
-#define OMAP_BANDGAP_FEATURE_COUNTER		(1 << 4)
-#define OMAP_BANDGAP_FEATURE_POWER_SWITCH	(1 << 5)
-#define OMAP_BANDGAP_FEATURE_CLK_CTRL		(1 << 6)
-#define OMAP_BANDGAP_FEATURE_FREEZE_BIT		(1 << 7)
+#define OMAP_BANDGAP_FEATURE_TSHUT		BIT(0)
+#define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	BIT(1)
+#define OMAP_BANDGAP_FEATURE_TALERT		BIT(2)
+#define OMAP_BANDGAP_FEATURE_MODE_CONFIG	BIT(3)
+#define OMAP_BANDGAP_FEATURE_COUNTER		BIT(4)
+#define OMAP_BANDGAP_FEATURE_POWER_SWITCH	BIT(5)
+#define OMAP_BANDGAP_FEATURE_CLK_CTRL		BIT(6)
+#define OMAP_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define OMAP_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
 	unsigned int			features;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 02/50] staging: omap-thermal: remove unused _SHIFT macros
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

As these macros are not used on any part of the code,
this patch removes all the *_SHIT defines.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |   57 ---------------------------
 1 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 8d3ee2b..5ce1659 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -28,19 +28,13 @@
 #include <linux/err.h>
 
 /* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TSHUT_SHIFT			11
 #define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
 
 /* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TEMPSOFF_SHIFT			12
 #define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
-#define OMAP4430_SINGLE_MODE_SHIFT			10
 #define OMAP4430_SINGLE_MODE_MASK			BIT(10)
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_SHIFT		9
 #define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		8
 #define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
-#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
 
 #define OMAP4430_ADC_START_VALUE			0
@@ -52,135 +46,84 @@
 #define OMAP4430_HYST_VAL				5000
 
 /* TEMP_SENSOR OMAP4460 */
-#define OMAP4460_BGAP_TEMPSOFF_SHIFT			13
 #define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_SHIFT		11
 #define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
 #define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
-#define OMAP4460_SINGLE_MODE_SHIFT			31
 #define OMAP4460_SINGLE_MODE_MASK			BIT(31)
-#define OMAP4460_MASK_HOT_SHIFT				1
 #define OMAP4460_MASK_HOT_MASK				BIT(1)
-#define OMAP4460_MASK_COLD_SHIFT			0
 #define OMAP4460_MASK_COLD_MASK				BIT(0)
 
 /* BANDGAP_COUNTER */
-#define OMAP4460_COUNTER_SHIFT				0
 #define OMAP4460_COUNTER_MASK				(0xffffff << 0)
 
 /* BANDGAP_THRESHOLD */
-#define OMAP4460_T_HOT_SHIFT				16
 #define OMAP4460_T_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_T_COLD_SHIFT				0
 #define OMAP4460_T_COLD_MASK				(0x3ff << 0)
 
 /* TSHUT_THRESHOLD */
-#define OMAP4460_TSHUT_HOT_SHIFT			16
 #define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_TSHUT_COLD_SHIFT			0
 #define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
 
 /* BANDGAP_STATUS */
-#define OMAP4460_CLEAN_STOP_SHIFT			3
 #define OMAP4460_CLEAN_STOP_MASK			BIT(3)
-#define OMAP4460_BGAP_ALERT_SHIFT			2
 #define OMAP4460_BGAP_ALERT_MASK			BIT(2)
-#define OMAP4460_HOT_FLAG_SHIFT				1
 #define OMAP4460_HOT_FLAG_MASK				BIT(1)
-#define OMAP4460_COLD_FLAG_SHIFT			0
 #define OMAP4460_COLD_FLAG_MASK				BIT(0)
 
 /* TEMP_SENSOR OMAP5430 */
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_SHIFT		12
 #define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
-#define OMAP5430_BGAP_TEMPSOFF_SHIFT			11
 #define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
 #define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
-#define OMAP5430_MASK_HOT_CORE_SHIFT			5
 #define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
-#define OMAP5430_MASK_COLD_CORE_SHIFT			4
 #define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
-#define OMAP5430_MASK_HOT_GPU_SHIFT			3
 #define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
-#define OMAP5430_MASK_COLD_GPU_SHIFT			2
 #define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
-#define OMAP5430_MASK_HOT_MPU_SHIFT			1
 #define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
-#define OMAP5430_MASK_COLD_MPU_SHIFT			0
 #define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
-#define OMAP5430_MASK_SIDLEMODE_SHIFT			30
 #define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
-#define OMAP5430_MASK_FREEZE_CORE_SHIFT			23
 #define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
-#define OMAP5430_MASK_FREEZE_GPU_SHIFT			22
 #define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
-#define OMAP5430_MASK_FREEZE_MPU_SHIFT			21
 #define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
-#define OMAP5430_MASK_CLEAR_CORE_SHIFT			20
 #define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
-#define OMAP5430_MASK_CLEAR_GPU_SHIFT			19
 #define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
-#define OMAP5430_MASK_CLEAR_MPU_SHIFT			18
 #define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_SHIFT		17
 #define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_SHIFT		16
 #define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_SHIFT		15
 #define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
 
 /* BANDGAP_COUNTER */
-#define OMAP5430_COUNTER_SHIFT				0
 #define OMAP5430_COUNTER_MASK				(0xffffff << 0)
 
 /* BANDGAP_THRESHOLD */
-#define OMAP5430_T_HOT_SHIFT				16
 #define OMAP5430_T_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_T_COLD_SHIFT				0
 #define OMAP5430_T_COLD_MASK				(0x3ff << 0)
 
 /* TSHUT_THRESHOLD */
-#define OMAP5430_TSHUT_HOT_SHIFT			16
 #define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_TSHUT_COLD_SHIFT			0
 #define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_MPU */
-#define OMAP5430_CUMUL_DTEMP_MPU_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_GPU */
-#define OMAP5430_CUMUL_DTEMP_GPU_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_CORE */
-#define OMAP5430_CUMUL_DTEMP_CORE_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
 
 /* BANDGAP_STATUS */
-#define OMAP5430_BGAP_ALERT_SHIFT			31
 #define OMAP5430_BGAP_ALERT_MASK			BIT(31)
-#define OMAP5430_HOT_CORE_FLAG_SHIFT			5
 #define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
-#define OMAP5430_COLD_CORE_FLAG_SHIFT			4
 #define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
-#define OMAP5430_HOT_GPU_FLAG_SHIFT			3
 #define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
-#define OMAP5430_COLD_GPU_FLAG_SHIFT			2
 #define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
-#define OMAP5430_HOT_MPU_FLAG_SHIFT			1
 #define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
-#define OMAP5430_COLD_MPU_FLAG_SHIFT			0
 #define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
 
 /* Offsets from the base of temperature sensor registers */
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 02/50] staging: omap-thermal: remove unused _SHIFT macros
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

As these macros are not used on any part of the code,
this patch removes all the *_SHIT defines.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |   57 ---------------------------
 1 files changed, 0 insertions(+), 57 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 8d3ee2b..5ce1659 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -28,19 +28,13 @@
 #include <linux/err.h>
 
 /* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TSHUT_SHIFT			11
 #define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
 
 /* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TEMPSOFF_SHIFT			12
 #define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
-#define OMAP4430_SINGLE_MODE_SHIFT			10
 #define OMAP4430_SINGLE_MODE_MASK			BIT(10)
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_SHIFT		9
 #define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		8
 #define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
-#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
 
 #define OMAP4430_ADC_START_VALUE			0
@@ -52,135 +46,84 @@
 #define OMAP4430_HYST_VAL				5000
 
 /* TEMP_SENSOR OMAP4460 */
-#define OMAP4460_BGAP_TEMPSOFF_SHIFT			13
 #define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_SHIFT		11
 #define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
 #define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
-#define OMAP4460_SINGLE_MODE_SHIFT			31
 #define OMAP4460_SINGLE_MODE_MASK			BIT(31)
-#define OMAP4460_MASK_HOT_SHIFT				1
 #define OMAP4460_MASK_HOT_MASK				BIT(1)
-#define OMAP4460_MASK_COLD_SHIFT			0
 #define OMAP4460_MASK_COLD_MASK				BIT(0)
 
 /* BANDGAP_COUNTER */
-#define OMAP4460_COUNTER_SHIFT				0
 #define OMAP4460_COUNTER_MASK				(0xffffff << 0)
 
 /* BANDGAP_THRESHOLD */
-#define OMAP4460_T_HOT_SHIFT				16
 #define OMAP4460_T_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_T_COLD_SHIFT				0
 #define OMAP4460_T_COLD_MASK				(0x3ff << 0)
 
 /* TSHUT_THRESHOLD */
-#define OMAP4460_TSHUT_HOT_SHIFT			16
 #define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_TSHUT_COLD_SHIFT			0
 #define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
 
 /* BANDGAP_STATUS */
-#define OMAP4460_CLEAN_STOP_SHIFT			3
 #define OMAP4460_CLEAN_STOP_MASK			BIT(3)
-#define OMAP4460_BGAP_ALERT_SHIFT			2
 #define OMAP4460_BGAP_ALERT_MASK			BIT(2)
-#define OMAP4460_HOT_FLAG_SHIFT				1
 #define OMAP4460_HOT_FLAG_MASK				BIT(1)
-#define OMAP4460_COLD_FLAG_SHIFT			0
 #define OMAP4460_COLD_FLAG_MASK				BIT(0)
 
 /* TEMP_SENSOR OMAP5430 */
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_SHIFT		12
 #define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
-#define OMAP5430_BGAP_TEMPSOFF_SHIFT			11
 #define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_SHIFT		10
 #define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_SHIFT		0
 #define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
 
 /* BANDGAP_CTRL */
-#define OMAP5430_MASK_HOT_CORE_SHIFT			5
 #define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
-#define OMAP5430_MASK_COLD_CORE_SHIFT			4
 #define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
-#define OMAP5430_MASK_HOT_GPU_SHIFT			3
 #define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
-#define OMAP5430_MASK_COLD_GPU_SHIFT			2
 #define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
-#define OMAP5430_MASK_HOT_MPU_SHIFT			1
 #define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
-#define OMAP5430_MASK_COLD_MPU_SHIFT			0
 #define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
-#define OMAP5430_MASK_SIDLEMODE_SHIFT			30
 #define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
-#define OMAP5430_MASK_FREEZE_CORE_SHIFT			23
 #define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
-#define OMAP5430_MASK_FREEZE_GPU_SHIFT			22
 #define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
-#define OMAP5430_MASK_FREEZE_MPU_SHIFT			21
 #define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
-#define OMAP5430_MASK_CLEAR_CORE_SHIFT			20
 #define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
-#define OMAP5430_MASK_CLEAR_GPU_SHIFT			19
 #define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
-#define OMAP5430_MASK_CLEAR_MPU_SHIFT			18
 #define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_SHIFT		17
 #define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_SHIFT		16
 #define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_SHIFT		15
 #define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
 
 /* BANDGAP_COUNTER */
-#define OMAP5430_COUNTER_SHIFT				0
 #define OMAP5430_COUNTER_MASK				(0xffffff << 0)
 
 /* BANDGAP_THRESHOLD */
-#define OMAP5430_T_HOT_SHIFT				16
 #define OMAP5430_T_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_T_COLD_SHIFT				0
 #define OMAP5430_T_COLD_MASK				(0x3ff << 0)
 
 /* TSHUT_THRESHOLD */
-#define OMAP5430_TSHUT_HOT_SHIFT			16
 #define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_TSHUT_COLD_SHIFT			0
 #define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_MPU */
-#define OMAP5430_CUMUL_DTEMP_MPU_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_GPU */
-#define OMAP5430_CUMUL_DTEMP_GPU_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
 
 /* BANDGAP_CUMUL_DTEMP_CORE */
-#define OMAP5430_CUMUL_DTEMP_CORE_SHIFT			0
 #define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
 
 /* BANDGAP_STATUS */
-#define OMAP5430_BGAP_ALERT_SHIFT			31
 #define OMAP5430_BGAP_ALERT_MASK			BIT(31)
-#define OMAP5430_HOT_CORE_FLAG_SHIFT			5
 #define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
-#define OMAP5430_COLD_CORE_FLAG_SHIFT			4
 #define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
-#define OMAP5430_HOT_GPU_FLAG_SHIFT			3
 #define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
-#define OMAP5430_COLD_GPU_FLAG_SHIFT			2
 #define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
-#define OMAP5430_HOT_MPU_FLAG_SHIFT			1
 #define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
-#define OMAP5430_COLD_MPU_FLAG_SHIFT			0
 #define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
 
 /* Offsets from the base of temperature sensor registers */
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 03/50] staging: omap-thermal: create header for register, bitfields and definitions
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

In order to have a better code readability and organization, this patch
splits omap-bandgap.h into three headers.
. omap-bandgap.h will contain only the driver related data structures
definitions and macros
. omap4xxx-bandgap.h will contain only defines and bitfields
related to OMAP4 based devices
. omap5xxx-bandgap.h will contain only defines and bitfields
related to OMAP5 based devices

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h       |  195 --------------------
 drivers/staging/omap-thermal/omap4-thermal-data.c |    1 +
 drivers/staging/omap-thermal/omap4xxx-bandgap.h   |  175 ++++++++++++++++++
 drivers/staging/omap-thermal/omap5-thermal-data.c |    1 +
 drivers/staging/omap-thermal/omap5xxx-bandgap.h   |  199 +++++++++++++++++++++
 5 files changed, 376 insertions(+), 195 deletions(-)
 create mode 100644 drivers/staging/omap-thermal/omap4xxx-bandgap.h
 create mode 100644 drivers/staging/omap-thermal/omap5xxx-bandgap.h

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 5ce1659..7d5ac3f 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -27,201 +27,6 @@
 #include <linux/types.h>
 #include <linux/err.h>
 
-/* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
-
-/* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
-#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
-#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
-
-#define OMAP4430_ADC_START_VALUE			0
-#define OMAP4430_ADC_END_VALUE				127
-#define OMAP4430_MAX_FREQ				32768
-#define OMAP4430_MIN_FREQ				32768
-#define OMAP4430_MIN_TEMP				-40000
-#define OMAP4430_MAX_TEMP				125000
-#define OMAP4430_HYST_VAL				5000
-
-/* TEMP_SENSOR OMAP4460 */
-#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
-
-/* BANDGAP_CTRL */
-#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
-#define OMAP4460_MASK_HOT_MASK				BIT(1)
-#define OMAP4460_MASK_COLD_MASK				BIT(0)
-
-/* BANDGAP_COUNTER */
-#define OMAP4460_COUNTER_MASK				(0xffffff << 0)
-
-/* BANDGAP_THRESHOLD */
-#define OMAP4460_T_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_T_COLD_MASK				(0x3ff << 0)
-
-/* TSHUT_THRESHOLD */
-#define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
-
-/* BANDGAP_STATUS */
-#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
-#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
-#define OMAP4460_HOT_FLAG_MASK				BIT(1)
-#define OMAP4460_COLD_FLAG_MASK				BIT(0)
-
-/* TEMP_SENSOR OMAP5430 */
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
-#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
-
-/* BANDGAP_CTRL */
-#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
-#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
-#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
-#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
-#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
-#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
-#define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
-#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
-#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
-#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
-#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
-#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
-#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
-
-/* BANDGAP_COUNTER */
-#define OMAP5430_COUNTER_MASK				(0xffffff << 0)
-
-/* BANDGAP_THRESHOLD */
-#define OMAP5430_T_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_T_COLD_MASK				(0x3ff << 0)
-
-/* TSHUT_THRESHOLD */
-#define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_MPU */
-#define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_GPU */
-#define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_CORE */
-#define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
-
-/* BANDGAP_STATUS */
-#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
-#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
-#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
-#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
-#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
-#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
-#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
-
-/* Offsets from the base of temperature sensor registers */
-
-/* 4430 - All goes relative to OPP_BGAP */
-#define OMAP4430_FUSE_OPP_BGAP				0x0
-#define OMAP4430_TEMP_SENSOR_CTRL_OFFSET		0xCC
-
-/* 4460 - All goes relative to OPP_BGAP */
-#define OMAP4460_FUSE_OPP_BGAP				0x0
-#define OMAP4460_TEMP_SENSOR_CTRL_OFFSET		0xCC
-#define OMAP4460_BGAP_CTRL_OFFSET			0x118
-#define OMAP4460_BGAP_COUNTER_OFFSET			0x11C
-#define OMAP4460_BGAP_THRESHOLD_OFFSET			0x120
-#define OMAP4460_BGAP_TSHUT_OFFSET			0x124
-#define OMAP4460_BGAP_STATUS_OFFSET			0x128
-
-/* 5430 - All goes relative to OPP_BGAP_GPU */
-#define OMAP5430_FUSE_OPP_BGAP_GPU			0x0
-#define OMAP5430_TEMP_SENSOR_GPU_OFFSET			0x150
-#define OMAP5430_BGAP_THRESHOLD_GPU_OFFSET		0x1A8
-#define OMAP5430_BGAP_TSHUT_GPU_OFFSET			0x1B4
-#define OMAP5430_BGAP_CUMUL_DTEMP_GPU_OFFSET		0x1C0
-#define OMAP5430_BGAP_DTEMP_GPU_0_OFFSET		0x1F4
-#define OMAP5430_BGAP_DTEMP_GPU_1_OFFSET		0x1F8
-#define OMAP5430_BGAP_DTEMP_GPU_2_OFFSET		0x1FC
-#define OMAP5430_BGAP_DTEMP_GPU_3_OFFSET		0x200
-#define OMAP5430_BGAP_DTEMP_GPU_4_OFFSET		0x204
-
-#define OMAP5430_FUSE_OPP_BGAP_MPU			0x4
-#define OMAP5430_TEMP_SENSOR_MPU_OFFSET			0x14C
-#define OMAP5430_BGAP_CTRL_OFFSET			0x1A0
-#define OMAP5430_BGAP_THRESHOLD_MPU_OFFSET		0x1A4
-#define OMAP5430_BGAP_TSHUT_MPU_OFFSET			0x1B0
-#define OMAP5430_BGAP_CUMUL_DTEMP_MPU_OFFSET		0x1BC
-#define OMAP5430_BGAP_DTEMP_MPU_0_OFFSET		0x1E0
-#define OMAP5430_BGAP_DTEMP_MPU_1_OFFSET		0x1E4
-#define OMAP5430_BGAP_DTEMP_MPU_2_OFFSET		0x1E8
-#define OMAP5430_BGAP_DTEMP_MPU_3_OFFSET		0x1EC
-#define OMAP5430_BGAP_DTEMP_MPU_4_OFFSET		0x1F0
-
-#define OMAP5430_FUSE_OPP_BGAP_CORE			0x8
-#define OMAP5430_TEMP_SENSOR_CORE_OFFSET		0x154
-#define OMAP5430_BGAP_THRESHOLD_CORE_OFFSET		0x1AC
-#define OMAP5430_BGAP_TSHUT_CORE_OFFSET			0x1B8
-#define OMAP5430_BGAP_CUMUL_DTEMP_CORE_OFFSET		0x1C4
-#define OMAP5430_BGAP_DTEMP_CORE_0_OFFSET		0x208
-#define OMAP5430_BGAP_DTEMP_CORE_1_OFFSET		0x20C
-#define OMAP5430_BGAP_DTEMP_CORE_2_OFFSET		0x210
-#define OMAP5430_BGAP_DTEMP_CORE_3_OFFSET		0x214
-#define OMAP5430_BGAP_DTEMP_CORE_4_OFFSET		0x218
-
-#define OMAP5430_BGAP_STATUS_OFFSET			0x1C8
-
-#define OMAP4460_TSHUT_HOT				900	/* 122 deg C */
-#define OMAP4460_TSHUT_COLD				895	/* 100 deg C */
-#define OMAP4460_T_HOT					800	/* 73 deg C */
-#define OMAP4460_T_COLD					795	/* 71 deg C */
-#define OMAP4460_MAX_FREQ				1500000
-#define OMAP4460_MIN_FREQ				1000000
-#define OMAP4460_MIN_TEMP				-40000
-#define OMAP4460_MAX_TEMP				123000
-#define OMAP4460_HYST_VAL				5000
-#define OMAP4460_ADC_START_VALUE			530
-#define OMAP4460_ADC_END_VALUE				932
-
-#define OMAP5430_MPU_TSHUT_HOT				915
-#define OMAP5430_MPU_TSHUT_COLD				900
-#define OMAP5430_MPU_T_HOT				800
-#define OMAP5430_MPU_T_COLD				795
-#define OMAP5430_MPU_MAX_FREQ				1500000
-#define OMAP5430_MPU_MIN_FREQ				1000000
-#define OMAP5430_MPU_MIN_TEMP				-40000
-#define OMAP5430_MPU_MAX_TEMP				125000
-#define OMAP5430_MPU_HYST_VAL				5000
-#define OMAP5430_ADC_START_VALUE			540
-#define OMAP5430_ADC_END_VALUE				945
-
-#define OMAP5430_GPU_TSHUT_HOT				915
-#define OMAP5430_GPU_TSHUT_COLD				900
-#define OMAP5430_GPU_T_HOT				800
-#define OMAP5430_GPU_T_COLD				795
-#define OMAP5430_GPU_MAX_FREQ				1500000
-#define OMAP5430_GPU_MIN_FREQ				1000000
-#define OMAP5430_GPU_MIN_TEMP				-40000
-#define OMAP5430_GPU_MAX_TEMP				125000
-#define OMAP5430_GPU_HYST_VAL				5000
-
-#define OMAP5430_CORE_TSHUT_HOT				915
-#define OMAP5430_CORE_TSHUT_COLD			900
-#define OMAP5430_CORE_T_HOT				800
-#define OMAP5430_CORE_T_COLD				795
-#define OMAP5430_CORE_MAX_FREQ				1500000
-#define OMAP5430_CORE_MIN_FREQ				1000000
-#define OMAP5430_CORE_MIN_TEMP				-40000
-#define OMAP5430_CORE_MAX_TEMP				125000
-#define OMAP5430_CORE_HYST_VAL				5000
-
 /**
  * The register offsets and bit fields might change across
  * OMAP versions hence populating them in this structure.
diff --git a/drivers/staging/omap-thermal/omap4-thermal-data.c b/drivers/staging/omap-thermal/omap4-thermal-data.c
index 732c853..7ec5570 100644
--- a/drivers/staging/omap-thermal/omap4-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap4-thermal-data.c
@@ -18,6 +18,7 @@
 
 #include "omap-thermal.h"
 #include "omap-bandgap.h"
+#include "omap4xxx-bandgap.h"
 
 /*
  * OMAP4430 has one instance of thermal sensor for MPU
diff --git a/drivers/staging/omap-thermal/omap4xxx-bandgap.h b/drivers/staging/omap-thermal/omap4xxx-bandgap.h
new file mode 100644
index 0000000..6f2de3a
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap4xxx-bandgap.h
@@ -0,0 +1,175 @@
+/*
+ * OMAP4xxx bandgap registers, bitfields and temperature definitions
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ *   Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP4XXX_BANDGAP_H
+#define __OMAP4XXX_BANDGAP_H
+
+/**
+ * *** OMAP4430 ***
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP4430.
+ */
+
+/**
+ * OMAP4430 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP on 4430.
+ */
+
+/* OMAP4430.FUSE_OPP_BGAP */
+#define OMAP4430_FUSE_OPP_BGAP				0x0
+
+/* OMAP4430.TEMP_SENSOR  */
+#define OMAP4430_TEMP_SENSOR_CTRL_OFFSET		0xCC
+
+/**
+ * Register and bit definitions for OMAP4430
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP4430. Bit defines are
+ * grouped by register.
+ */
+
+/* OMAP4430.TEMP_SENSOR bits */
+#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
+#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
+#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
+#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
+
+/**
+ * Temperature limits and thresholds for OMAP4430
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP4430.
+ */
+
+/* ADC conversion table limits */
+#define OMAP4430_ADC_START_VALUE			0
+#define OMAP4430_ADC_END_VALUE				127
+/* bandgap clock limits (no control on 4430) */
+#define OMAP4430_MAX_FREQ				32768
+#define OMAP4430_MIN_FREQ				32768
+/* sensor limits */
+#define OMAP4430_MIN_TEMP				-40000
+#define OMAP4430_MAX_TEMP				125000
+#define OMAP4430_HYST_VAL				5000
+
+/**
+ * *** OMAP4460 *** Applicable for OMAP4470
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP4460.
+ */
+
+/**
+ * OMAP4460 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP on 4460.
+ */
+
+/* OMAP4460.FUSE_OPP_BGAP */
+#define OMAP4460_FUSE_OPP_BGAP				0x0
+
+/* OMAP4460.TEMP_SENSOR */
+#define OMAP4460_TEMP_SENSOR_CTRL_OFFSET		0xCC
+
+/* OMAP4460.BANDGAP_CTRL */
+#define OMAP4460_BGAP_CTRL_OFFSET			0x118
+
+/* OMAP4460.BANDGAP_COUNTER */
+#define OMAP4460_BGAP_COUNTER_OFFSET			0x11C
+
+/* OMAP4460.BANDGAP_THRESHOLD */
+#define OMAP4460_BGAP_THRESHOLD_OFFSET			0x120
+
+/* OMAP4460.TSHUT_THRESHOLD */
+#define OMAP4460_BGAP_TSHUT_OFFSET			0x124
+
+/* OMAP4460.BANDGAP_STATUS */
+#define OMAP4460_BGAP_STATUS_OFFSET			0x128
+
+/**
+ * Register bitfields for OMAP4460
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP4460. Bit defines are
+ * grouped by register.
+ */
+/* OMAP4460.TEMP_SENSOR bits */
+#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
+#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
+
+/* OMAP4460.BANDGAP_CTRL bits */
+#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
+#define OMAP4460_MASK_HOT_MASK				BIT(1)
+#define OMAP4460_MASK_COLD_MASK				BIT(0)
+
+/* OMAP4460.BANDGAP_COUNTER bits */
+#define OMAP4460_COUNTER_MASK				(0xffffff << 0)
+
+/* OMAP4460.BANDGAP_THRESHOLD bits */
+#define OMAP4460_T_HOT_MASK				(0x3ff << 16)
+#define OMAP4460_T_COLD_MASK				(0x3ff << 0)
+
+/* OMAP4460.TSHUT_THRESHOLD bits */
+#define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
+#define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
+
+/* OMAP4460.BANDGAP_STATUS bits */
+#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
+#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
+#define OMAP4460_HOT_FLAG_MASK				BIT(1)
+#define OMAP4460_COLD_FLAG_MASK				BIT(0)
+
+/**
+ * Temperature limits and thresholds for OMAP4460
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP4460.
+ */
+
+/* ADC conversion table limits */
+#define OMAP4460_ADC_START_VALUE			530
+#define OMAP4460_ADC_END_VALUE				932
+/* bandgap clock limits */
+#define OMAP4460_MAX_FREQ				1500000
+#define OMAP4460_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP4460_MIN_TEMP				-40000
+#define OMAP4460_MAX_TEMP				123000
+#define OMAP4460_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP4460_TSHUT_HOT				900	/* 122 deg C */
+#define OMAP4460_TSHUT_COLD				895	/* 100 deg C */
+#define OMAP4460_T_HOT					800	/* 73 deg C */
+#define OMAP4460_T_COLD					795	/* 71 deg C */
+
+#endif /* __OMAP4XXX_BANDGAP_H */
diff --git a/drivers/staging/omap-thermal/omap5-thermal-data.c b/drivers/staging/omap-thermal/omap5-thermal-data.c
index b20db0c..3d10704 100644
--- a/drivers/staging/omap-thermal/omap5-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap5-thermal-data.c
@@ -17,6 +17,7 @@
  */
 
 #include "omap-bandgap.h"
+#include "omap5xxx-bandgap.h"
 #include "omap-thermal.h"
 
 /*
diff --git a/drivers/staging/omap-thermal/omap5xxx-bandgap.h b/drivers/staging/omap-thermal/omap5xxx-bandgap.h
new file mode 100644
index 0000000..8824db4
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap5xxx-bandgap.h
@@ -0,0 +1,199 @@
+/*
+ * OMAP5xxx bandgap registers, bitfields and temperature definitions
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ *   Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP5XXX_BANDGAP_H
+#define __OMAP5XXX_BANDGAP_H
+
+/**
+ * *** OMAP5430 ***
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP5430.
+ */
+
+/**
+ * OMAP5430 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP_GPU on 5430.
+ *
+ * Register below are grouped by domain (not necessarily in offset order)
+ */
+
+/* OMAP5430.GPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_GPU			0x0
+#define OMAP5430_TEMP_SENSOR_GPU_OFFSET			0x150
+#define OMAP5430_BGAP_THRESHOLD_GPU_OFFSET		0x1A8
+#define OMAP5430_BGAP_TSHUT_GPU_OFFSET			0x1B4
+#define OMAP5430_BGAP_CUMUL_DTEMP_GPU_OFFSET		0x1C0
+#define OMAP5430_BGAP_DTEMP_GPU_0_OFFSET		0x1F4
+#define OMAP5430_BGAP_DTEMP_GPU_1_OFFSET		0x1F8
+#define OMAP5430_BGAP_DTEMP_GPU_2_OFFSET		0x1FC
+#define OMAP5430_BGAP_DTEMP_GPU_3_OFFSET		0x200
+#define OMAP5430_BGAP_DTEMP_GPU_4_OFFSET		0x204
+
+/* OMAP5430.MPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_MPU			0x4
+#define OMAP5430_TEMP_SENSOR_MPU_OFFSET			0x14C
+#define OMAP5430_BGAP_THRESHOLD_MPU_OFFSET		0x1A4
+#define OMAP5430_BGAP_TSHUT_MPU_OFFSET			0x1B0
+#define OMAP5430_BGAP_CUMUL_DTEMP_MPU_OFFSET		0x1BC
+#define OMAP5430_BGAP_DTEMP_MPU_0_OFFSET		0x1E0
+#define OMAP5430_BGAP_DTEMP_MPU_1_OFFSET		0x1E4
+#define OMAP5430_BGAP_DTEMP_MPU_2_OFFSET		0x1E8
+#define OMAP5430_BGAP_DTEMP_MPU_3_OFFSET		0x1EC
+#define OMAP5430_BGAP_DTEMP_MPU_4_OFFSET		0x1F0
+
+/* OMAP5430.MPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_CORE			0x8
+#define OMAP5430_TEMP_SENSOR_CORE_OFFSET		0x154
+#define OMAP5430_BGAP_THRESHOLD_CORE_OFFSET		0x1AC
+#define OMAP5430_BGAP_TSHUT_CORE_OFFSET			0x1B8
+#define OMAP5430_BGAP_CUMUL_DTEMP_CORE_OFFSET		0x1C4
+#define OMAP5430_BGAP_DTEMP_CORE_0_OFFSET		0x208
+#define OMAP5430_BGAP_DTEMP_CORE_1_OFFSET		0x20C
+#define OMAP5430_BGAP_DTEMP_CORE_2_OFFSET		0x210
+#define OMAP5430_BGAP_DTEMP_CORE_3_OFFSET		0x214
+#define OMAP5430_BGAP_DTEMP_CORE_4_OFFSET		0x218
+
+/* OMAP5430.common register offsets */
+#define OMAP5430_BGAP_CTRL_OFFSET			0x1A0
+#define OMAP5430_BGAP_STATUS_OFFSET			0x1C8
+
+/**
+ * Register bitfields for OMAP5430
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP5430. Bit defines are
+ * grouped by register.
+ */
+
+/* OMAP5430.TEMP_SENSOR */
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
+#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
+#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
+
+/* OMAP5430.BANDGAP_CTRL */
+#define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
+#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
+#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
+#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
+#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
+#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
+#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
+#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
+#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
+#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
+#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
+#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
+#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
+#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
+#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
+#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
+
+/* OMAP5430.BANDGAP_COUNTER */
+#define OMAP5430_COUNTER_MASK				(0xffffff << 0)
+
+/* OMAP5430.BANDGAP_THRESHOLD */
+#define OMAP5430_T_HOT_MASK				(0x3ff << 16)
+#define OMAP5430_T_COLD_MASK				(0x3ff << 0)
+
+/* OMAP5430.TSHUT_THRESHOLD */
+#define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
+#define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_MPU */
+#define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_GPU */
+#define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_CORE */
+#define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_STATUS */
+#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
+#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
+#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
+#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
+#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
+#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
+#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
+
+/**
+ * Temperature limits and thresholds for OMAP5430
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP5430. Definitions are grouped
+ * by temperature domain.
+ */
+
+/* OMAP5430.common temperature definitions */
+/* ADC conversion table limits */
+#define OMAP5430_ADC_START_VALUE			540
+#define OMAP5430_ADC_END_VALUE				945
+
+/* OMAP5430.GPU temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_GPU_MAX_FREQ				1500000
+#define OMAP5430_GPU_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_GPU_MIN_TEMP				-40000
+#define OMAP5430_GPU_MAX_TEMP				125000
+#define OMAP5430_GPU_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_GPU_TSHUT_HOT				915
+#define OMAP5430_GPU_TSHUT_COLD				900
+#define OMAP5430_GPU_T_HOT				800
+#define OMAP5430_GPU_T_COLD				795
+
+/* OMAP5430.MPU temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_MPU_MAX_FREQ				1500000
+#define OMAP5430_MPU_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_MPU_MIN_TEMP				-40000
+#define OMAP5430_MPU_MAX_TEMP				125000
+#define OMAP5430_MPU_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_MPU_TSHUT_HOT				915
+#define OMAP5430_MPU_TSHUT_COLD				900
+#define OMAP5430_MPU_T_HOT				800
+#define OMAP5430_MPU_T_COLD				795
+
+/* OMAP5430.CORE temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_CORE_MAX_FREQ				1500000
+#define OMAP5430_CORE_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_CORE_MIN_TEMP				-40000
+#define OMAP5430_CORE_MAX_TEMP				125000
+#define OMAP5430_CORE_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_CORE_TSHUT_HOT				915
+#define OMAP5430_CORE_TSHUT_COLD			900
+#define OMAP5430_CORE_T_HOT				800
+#define OMAP5430_CORE_T_COLD				795
+
+#endif /* __OMAP5XXX_BANDGAP_H */
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 03/50] staging: omap-thermal: create header for register, bitfields and definitions
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

In order to have a better code readability and organization, this patch
splits omap-bandgap.h into three headers.
. omap-bandgap.h will contain only the driver related data structures
definitions and macros
. omap4xxx-bandgap.h will contain only defines and bitfields
related to OMAP4 based devices
. omap5xxx-bandgap.h will contain only defines and bitfields
related to OMAP5 based devices

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h       |  195 --------------------
 drivers/staging/omap-thermal/omap4-thermal-data.c |    1 +
 drivers/staging/omap-thermal/omap4xxx-bandgap.h   |  175 ++++++++++++++++++
 drivers/staging/omap-thermal/omap5-thermal-data.c |    1 +
 drivers/staging/omap-thermal/omap5xxx-bandgap.h   |  199 +++++++++++++++++++++
 5 files changed, 376 insertions(+), 195 deletions(-)
 create mode 100644 drivers/staging/omap-thermal/omap4xxx-bandgap.h
 create mode 100644 drivers/staging/omap-thermal/omap5xxx-bandgap.h

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 5ce1659..7d5ac3f 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -27,201 +27,6 @@
 #include <linux/types.h>
 #include <linux/err.h>
 
-/* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
-
-/* TEMP_SENSOR OMAP4430 */
-#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
-#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
-#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
-#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
-#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
-
-#define OMAP4430_ADC_START_VALUE			0
-#define OMAP4430_ADC_END_VALUE				127
-#define OMAP4430_MAX_FREQ				32768
-#define OMAP4430_MIN_FREQ				32768
-#define OMAP4430_MIN_TEMP				-40000
-#define OMAP4430_MAX_TEMP				125000
-#define OMAP4430_HYST_VAL				5000
-
-/* TEMP_SENSOR OMAP4460 */
-#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
-#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
-#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
-
-/* BANDGAP_CTRL */
-#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
-#define OMAP4460_MASK_HOT_MASK				BIT(1)
-#define OMAP4460_MASK_COLD_MASK				BIT(0)
-
-/* BANDGAP_COUNTER */
-#define OMAP4460_COUNTER_MASK				(0xffffff << 0)
-
-/* BANDGAP_THRESHOLD */
-#define OMAP4460_T_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_T_COLD_MASK				(0x3ff << 0)
-
-/* TSHUT_THRESHOLD */
-#define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
-
-/* BANDGAP_STATUS */
-#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
-#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
-#define OMAP4460_HOT_FLAG_MASK				BIT(1)
-#define OMAP4460_COLD_FLAG_MASK				BIT(0)
-
-/* TEMP_SENSOR OMAP5430 */
-#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
-#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
-#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
-#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
-
-/* BANDGAP_CTRL */
-#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
-#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
-#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
-#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
-#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
-#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
-#define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
-#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
-#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
-#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
-#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
-#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
-#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
-#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
-#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
-#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
-
-/* BANDGAP_COUNTER */
-#define OMAP5430_COUNTER_MASK				(0xffffff << 0)
-
-/* BANDGAP_THRESHOLD */
-#define OMAP5430_T_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_T_COLD_MASK				(0x3ff << 0)
-
-/* TSHUT_THRESHOLD */
-#define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
-#define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_MPU */
-#define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_GPU */
-#define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
-
-/* BANDGAP_CUMUL_DTEMP_CORE */
-#define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
-
-/* BANDGAP_STATUS */
-#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
-#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
-#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
-#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
-#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
-#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
-#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
-
-/* Offsets from the base of temperature sensor registers */
-
-/* 4430 - All goes relative to OPP_BGAP */
-#define OMAP4430_FUSE_OPP_BGAP				0x0
-#define OMAP4430_TEMP_SENSOR_CTRL_OFFSET		0xCC
-
-/* 4460 - All goes relative to OPP_BGAP */
-#define OMAP4460_FUSE_OPP_BGAP				0x0
-#define OMAP4460_TEMP_SENSOR_CTRL_OFFSET		0xCC
-#define OMAP4460_BGAP_CTRL_OFFSET			0x118
-#define OMAP4460_BGAP_COUNTER_OFFSET			0x11C
-#define OMAP4460_BGAP_THRESHOLD_OFFSET			0x120
-#define OMAP4460_BGAP_TSHUT_OFFSET			0x124
-#define OMAP4460_BGAP_STATUS_OFFSET			0x128
-
-/* 5430 - All goes relative to OPP_BGAP_GPU */
-#define OMAP5430_FUSE_OPP_BGAP_GPU			0x0
-#define OMAP5430_TEMP_SENSOR_GPU_OFFSET			0x150
-#define OMAP5430_BGAP_THRESHOLD_GPU_OFFSET		0x1A8
-#define OMAP5430_BGAP_TSHUT_GPU_OFFSET			0x1B4
-#define OMAP5430_BGAP_CUMUL_DTEMP_GPU_OFFSET		0x1C0
-#define OMAP5430_BGAP_DTEMP_GPU_0_OFFSET		0x1F4
-#define OMAP5430_BGAP_DTEMP_GPU_1_OFFSET		0x1F8
-#define OMAP5430_BGAP_DTEMP_GPU_2_OFFSET		0x1FC
-#define OMAP5430_BGAP_DTEMP_GPU_3_OFFSET		0x200
-#define OMAP5430_BGAP_DTEMP_GPU_4_OFFSET		0x204
-
-#define OMAP5430_FUSE_OPP_BGAP_MPU			0x4
-#define OMAP5430_TEMP_SENSOR_MPU_OFFSET			0x14C
-#define OMAP5430_BGAP_CTRL_OFFSET			0x1A0
-#define OMAP5430_BGAP_THRESHOLD_MPU_OFFSET		0x1A4
-#define OMAP5430_BGAP_TSHUT_MPU_OFFSET			0x1B0
-#define OMAP5430_BGAP_CUMUL_DTEMP_MPU_OFFSET		0x1BC
-#define OMAP5430_BGAP_DTEMP_MPU_0_OFFSET		0x1E0
-#define OMAP5430_BGAP_DTEMP_MPU_1_OFFSET		0x1E4
-#define OMAP5430_BGAP_DTEMP_MPU_2_OFFSET		0x1E8
-#define OMAP5430_BGAP_DTEMP_MPU_3_OFFSET		0x1EC
-#define OMAP5430_BGAP_DTEMP_MPU_4_OFFSET		0x1F0
-
-#define OMAP5430_FUSE_OPP_BGAP_CORE			0x8
-#define OMAP5430_TEMP_SENSOR_CORE_OFFSET		0x154
-#define OMAP5430_BGAP_THRESHOLD_CORE_OFFSET		0x1AC
-#define OMAP5430_BGAP_TSHUT_CORE_OFFSET			0x1B8
-#define OMAP5430_BGAP_CUMUL_DTEMP_CORE_OFFSET		0x1C4
-#define OMAP5430_BGAP_DTEMP_CORE_0_OFFSET		0x208
-#define OMAP5430_BGAP_DTEMP_CORE_1_OFFSET		0x20C
-#define OMAP5430_BGAP_DTEMP_CORE_2_OFFSET		0x210
-#define OMAP5430_BGAP_DTEMP_CORE_3_OFFSET		0x214
-#define OMAP5430_BGAP_DTEMP_CORE_4_OFFSET		0x218
-
-#define OMAP5430_BGAP_STATUS_OFFSET			0x1C8
-
-#define OMAP4460_TSHUT_HOT				900	/* 122 deg C */
-#define OMAP4460_TSHUT_COLD				895	/* 100 deg C */
-#define OMAP4460_T_HOT					800	/* 73 deg C */
-#define OMAP4460_T_COLD					795	/* 71 deg C */
-#define OMAP4460_MAX_FREQ				1500000
-#define OMAP4460_MIN_FREQ				1000000
-#define OMAP4460_MIN_TEMP				-40000
-#define OMAP4460_MAX_TEMP				123000
-#define OMAP4460_HYST_VAL				5000
-#define OMAP4460_ADC_START_VALUE			530
-#define OMAP4460_ADC_END_VALUE				932
-
-#define OMAP5430_MPU_TSHUT_HOT				915
-#define OMAP5430_MPU_TSHUT_COLD				900
-#define OMAP5430_MPU_T_HOT				800
-#define OMAP5430_MPU_T_COLD				795
-#define OMAP5430_MPU_MAX_FREQ				1500000
-#define OMAP5430_MPU_MIN_FREQ				1000000
-#define OMAP5430_MPU_MIN_TEMP				-40000
-#define OMAP5430_MPU_MAX_TEMP				125000
-#define OMAP5430_MPU_HYST_VAL				5000
-#define OMAP5430_ADC_START_VALUE			540
-#define OMAP5430_ADC_END_VALUE				945
-
-#define OMAP5430_GPU_TSHUT_HOT				915
-#define OMAP5430_GPU_TSHUT_COLD				900
-#define OMAP5430_GPU_T_HOT				800
-#define OMAP5430_GPU_T_COLD				795
-#define OMAP5430_GPU_MAX_FREQ				1500000
-#define OMAP5430_GPU_MIN_FREQ				1000000
-#define OMAP5430_GPU_MIN_TEMP				-40000
-#define OMAP5430_GPU_MAX_TEMP				125000
-#define OMAP5430_GPU_HYST_VAL				5000
-
-#define OMAP5430_CORE_TSHUT_HOT				915
-#define OMAP5430_CORE_TSHUT_COLD			900
-#define OMAP5430_CORE_T_HOT				800
-#define OMAP5430_CORE_T_COLD				795
-#define OMAP5430_CORE_MAX_FREQ				1500000
-#define OMAP5430_CORE_MIN_FREQ				1000000
-#define OMAP5430_CORE_MIN_TEMP				-40000
-#define OMAP5430_CORE_MAX_TEMP				125000
-#define OMAP5430_CORE_HYST_VAL				5000
-
 /**
  * The register offsets and bit fields might change across
  * OMAP versions hence populating them in this structure.
diff --git a/drivers/staging/omap-thermal/omap4-thermal-data.c b/drivers/staging/omap-thermal/omap4-thermal-data.c
index 732c853..7ec5570 100644
--- a/drivers/staging/omap-thermal/omap4-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap4-thermal-data.c
@@ -18,6 +18,7 @@
 
 #include "omap-thermal.h"
 #include "omap-bandgap.h"
+#include "omap4xxx-bandgap.h"
 
 /*
  * OMAP4430 has one instance of thermal sensor for MPU
diff --git a/drivers/staging/omap-thermal/omap4xxx-bandgap.h b/drivers/staging/omap-thermal/omap4xxx-bandgap.h
new file mode 100644
index 0000000..6f2de3a
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap4xxx-bandgap.h
@@ -0,0 +1,175 @@
+/*
+ * OMAP4xxx bandgap registers, bitfields and temperature definitions
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ *   Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP4XXX_BANDGAP_H
+#define __OMAP4XXX_BANDGAP_H
+
+/**
+ * *** OMAP4430 ***
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP4430.
+ */
+
+/**
+ * OMAP4430 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP on 4430.
+ */
+
+/* OMAP4430.FUSE_OPP_BGAP */
+#define OMAP4430_FUSE_OPP_BGAP				0x0
+
+/* OMAP4430.TEMP_SENSOR  */
+#define OMAP4430_TEMP_SENSOR_CTRL_OFFSET		0xCC
+
+/**
+ * Register and bit definitions for OMAP4430
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP4430. Bit defines are
+ * grouped by register.
+ */
+
+/* OMAP4430.TEMP_SENSOR bits */
+#define OMAP4430_BGAP_TEMPSOFF_MASK			BIT(12)
+#define OMAP4430_BGAP_TSHUT_MASK			BIT(11)
+#define OMAP4430_SINGLE_MODE_MASK			BIT(10)
+#define OMAP4430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(9)
+#define OMAP4430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(8)
+#define OMAP4430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0xff << 0)
+
+/**
+ * Temperature limits and thresholds for OMAP4430
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP4430.
+ */
+
+/* ADC conversion table limits */
+#define OMAP4430_ADC_START_VALUE			0
+#define OMAP4430_ADC_END_VALUE				127
+/* bandgap clock limits (no control on 4430) */
+#define OMAP4430_MAX_FREQ				32768
+#define OMAP4430_MIN_FREQ				32768
+/* sensor limits */
+#define OMAP4430_MIN_TEMP				-40000
+#define OMAP4430_MAX_TEMP				125000
+#define OMAP4430_HYST_VAL				5000
+
+/**
+ * *** OMAP4460 *** Applicable for OMAP4470
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP4460.
+ */
+
+/**
+ * OMAP4460 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP on 4460.
+ */
+
+/* OMAP4460.FUSE_OPP_BGAP */
+#define OMAP4460_FUSE_OPP_BGAP				0x0
+
+/* OMAP4460.TEMP_SENSOR */
+#define OMAP4460_TEMP_SENSOR_CTRL_OFFSET		0xCC
+
+/* OMAP4460.BANDGAP_CTRL */
+#define OMAP4460_BGAP_CTRL_OFFSET			0x118
+
+/* OMAP4460.BANDGAP_COUNTER */
+#define OMAP4460_BGAP_COUNTER_OFFSET			0x11C
+
+/* OMAP4460.BANDGAP_THRESHOLD */
+#define OMAP4460_BGAP_THRESHOLD_OFFSET			0x120
+
+/* OMAP4460.TSHUT_THRESHOLD */
+#define OMAP4460_BGAP_TSHUT_OFFSET			0x124
+
+/* OMAP4460.BANDGAP_STATUS */
+#define OMAP4460_BGAP_STATUS_OFFSET			0x128
+
+/**
+ * Register bitfields for OMAP4460
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP4460. Bit defines are
+ * grouped by register.
+ */
+/* OMAP4460.TEMP_SENSOR bits */
+#define OMAP4460_BGAP_TEMPSOFF_MASK			BIT(13)
+#define OMAP4460_BGAP_TEMP_SENSOR_SOC_MASK		BIT(11)
+#define OMAP4460_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
+#define OMAP4460_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
+
+/* OMAP4460.BANDGAP_CTRL bits */
+#define OMAP4460_SINGLE_MODE_MASK			BIT(31)
+#define OMAP4460_MASK_HOT_MASK				BIT(1)
+#define OMAP4460_MASK_COLD_MASK				BIT(0)
+
+/* OMAP4460.BANDGAP_COUNTER bits */
+#define OMAP4460_COUNTER_MASK				(0xffffff << 0)
+
+/* OMAP4460.BANDGAP_THRESHOLD bits */
+#define OMAP4460_T_HOT_MASK				(0x3ff << 16)
+#define OMAP4460_T_COLD_MASK				(0x3ff << 0)
+
+/* OMAP4460.TSHUT_THRESHOLD bits */
+#define OMAP4460_TSHUT_HOT_MASK				(0x3ff << 16)
+#define OMAP4460_TSHUT_COLD_MASK			(0x3ff << 0)
+
+/* OMAP4460.BANDGAP_STATUS bits */
+#define OMAP4460_CLEAN_STOP_MASK			BIT(3)
+#define OMAP4460_BGAP_ALERT_MASK			BIT(2)
+#define OMAP4460_HOT_FLAG_MASK				BIT(1)
+#define OMAP4460_COLD_FLAG_MASK				BIT(0)
+
+/**
+ * Temperature limits and thresholds for OMAP4460
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP4460.
+ */
+
+/* ADC conversion table limits */
+#define OMAP4460_ADC_START_VALUE			530
+#define OMAP4460_ADC_END_VALUE				932
+/* bandgap clock limits */
+#define OMAP4460_MAX_FREQ				1500000
+#define OMAP4460_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP4460_MIN_TEMP				-40000
+#define OMAP4460_MAX_TEMP				123000
+#define OMAP4460_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP4460_TSHUT_HOT				900	/* 122 deg C */
+#define OMAP4460_TSHUT_COLD				895	/* 100 deg C */
+#define OMAP4460_T_HOT					800	/* 73 deg C */
+#define OMAP4460_T_COLD					795	/* 71 deg C */
+
+#endif /* __OMAP4XXX_BANDGAP_H */
diff --git a/drivers/staging/omap-thermal/omap5-thermal-data.c b/drivers/staging/omap-thermal/omap5-thermal-data.c
index b20db0c..3d10704 100644
--- a/drivers/staging/omap-thermal/omap5-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap5-thermal-data.c
@@ -17,6 +17,7 @@
  */
 
 #include "omap-bandgap.h"
+#include "omap5xxx-bandgap.h"
 #include "omap-thermal.h"
 
 /*
diff --git a/drivers/staging/omap-thermal/omap5xxx-bandgap.h b/drivers/staging/omap-thermal/omap5xxx-bandgap.h
new file mode 100644
index 0000000..8824db4
--- /dev/null
+++ b/drivers/staging/omap-thermal/omap5xxx-bandgap.h
@@ -0,0 +1,199 @@
+/*
+ * OMAP5xxx bandgap registers, bitfields and temperature definitions
+ *
+ * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
+ * Contact:
+ *   Eduardo Valentin <eduardo.valentin@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+#ifndef __OMAP5XXX_BANDGAP_H
+#define __OMAP5XXX_BANDGAP_H
+
+/**
+ * *** OMAP5430 ***
+ *
+ * Below, in sequence, are the Register definitions,
+ * the bitfields and the temperature definitions for OMAP5430.
+ */
+
+/**
+ * OMAP5430 register definitions
+ *
+ * Registers are defined as offsets. The offsets are
+ * relative to FUSE_OPP_BGAP_GPU on 5430.
+ *
+ * Register below are grouped by domain (not necessarily in offset order)
+ */
+
+/* OMAP5430.GPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_GPU			0x0
+#define OMAP5430_TEMP_SENSOR_GPU_OFFSET			0x150
+#define OMAP5430_BGAP_THRESHOLD_GPU_OFFSET		0x1A8
+#define OMAP5430_BGAP_TSHUT_GPU_OFFSET			0x1B4
+#define OMAP5430_BGAP_CUMUL_DTEMP_GPU_OFFSET		0x1C0
+#define OMAP5430_BGAP_DTEMP_GPU_0_OFFSET		0x1F4
+#define OMAP5430_BGAP_DTEMP_GPU_1_OFFSET		0x1F8
+#define OMAP5430_BGAP_DTEMP_GPU_2_OFFSET		0x1FC
+#define OMAP5430_BGAP_DTEMP_GPU_3_OFFSET		0x200
+#define OMAP5430_BGAP_DTEMP_GPU_4_OFFSET		0x204
+
+/* OMAP5430.MPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_MPU			0x4
+#define OMAP5430_TEMP_SENSOR_MPU_OFFSET			0x14C
+#define OMAP5430_BGAP_THRESHOLD_MPU_OFFSET		0x1A4
+#define OMAP5430_BGAP_TSHUT_MPU_OFFSET			0x1B0
+#define OMAP5430_BGAP_CUMUL_DTEMP_MPU_OFFSET		0x1BC
+#define OMAP5430_BGAP_DTEMP_MPU_0_OFFSET		0x1E0
+#define OMAP5430_BGAP_DTEMP_MPU_1_OFFSET		0x1E4
+#define OMAP5430_BGAP_DTEMP_MPU_2_OFFSET		0x1E8
+#define OMAP5430_BGAP_DTEMP_MPU_3_OFFSET		0x1EC
+#define OMAP5430_BGAP_DTEMP_MPU_4_OFFSET		0x1F0
+
+/* OMAP5430.MPU register offsets */
+#define OMAP5430_FUSE_OPP_BGAP_CORE			0x8
+#define OMAP5430_TEMP_SENSOR_CORE_OFFSET		0x154
+#define OMAP5430_BGAP_THRESHOLD_CORE_OFFSET		0x1AC
+#define OMAP5430_BGAP_TSHUT_CORE_OFFSET			0x1B8
+#define OMAP5430_BGAP_CUMUL_DTEMP_CORE_OFFSET		0x1C4
+#define OMAP5430_BGAP_DTEMP_CORE_0_OFFSET		0x208
+#define OMAP5430_BGAP_DTEMP_CORE_1_OFFSET		0x20C
+#define OMAP5430_BGAP_DTEMP_CORE_2_OFFSET		0x210
+#define OMAP5430_BGAP_DTEMP_CORE_3_OFFSET		0x214
+#define OMAP5430_BGAP_DTEMP_CORE_4_OFFSET		0x218
+
+/* OMAP5430.common register offsets */
+#define OMAP5430_BGAP_CTRL_OFFSET			0x1A0
+#define OMAP5430_BGAP_STATUS_OFFSET			0x1C8
+
+/**
+ * Register bitfields for OMAP5430
+ *
+ * All the macros bellow define the required bits for
+ * controlling temperature on OMAP5430. Bit defines are
+ * grouped by register.
+ */
+
+/* OMAP5430.TEMP_SENSOR */
+#define OMAP5430_BGAP_TEMP_SENSOR_SOC_MASK		BIT(12)
+#define OMAP5430_BGAP_TEMPSOFF_MASK			BIT(11)
+#define OMAP5430_BGAP_TEMP_SENSOR_EOCZ_MASK		BIT(10)
+#define OMAP5430_BGAP_TEMP_SENSOR_DTEMP_MASK		(0x3ff << 0)
+
+/* OMAP5430.BANDGAP_CTRL */
+#define OMAP5430_MASK_SIDLEMODE_MASK			(0x3 << 30)
+#define OMAP5430_MASK_FREEZE_CORE_MASK			BIT(23)
+#define OMAP5430_MASK_FREEZE_GPU_MASK			BIT(22)
+#define OMAP5430_MASK_FREEZE_MPU_MASK			BIT(21)
+#define OMAP5430_MASK_CLEAR_CORE_MASK			BIT(20)
+#define OMAP5430_MASK_CLEAR_GPU_MASK			BIT(19)
+#define OMAP5430_MASK_CLEAR_MPU_MASK			BIT(18)
+#define OMAP5430_MASK_CLEAR_ACCUM_CORE_MASK		BIT(17)
+#define OMAP5430_MASK_CLEAR_ACCUM_GPU_MASK		BIT(16)
+#define OMAP5430_MASK_CLEAR_ACCUM_MPU_MASK		BIT(15)
+#define OMAP5430_MASK_HOT_CORE_MASK			BIT(5)
+#define OMAP5430_MASK_COLD_CORE_MASK			BIT(4)
+#define OMAP5430_MASK_HOT_GPU_MASK			BIT(3)
+#define OMAP5430_MASK_COLD_GPU_MASK			BIT(2)
+#define OMAP5430_MASK_HOT_MPU_MASK			BIT(1)
+#define OMAP5430_MASK_COLD_MPU_MASK			BIT(0)
+
+/* OMAP5430.BANDGAP_COUNTER */
+#define OMAP5430_COUNTER_MASK				(0xffffff << 0)
+
+/* OMAP5430.BANDGAP_THRESHOLD */
+#define OMAP5430_T_HOT_MASK				(0x3ff << 16)
+#define OMAP5430_T_COLD_MASK				(0x3ff << 0)
+
+/* OMAP5430.TSHUT_THRESHOLD */
+#define OMAP5430_TSHUT_HOT_MASK				(0x3ff << 16)
+#define OMAP5430_TSHUT_COLD_MASK			(0x3ff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_MPU */
+#define OMAP5430_CUMUL_DTEMP_MPU_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_GPU */
+#define OMAP5430_CUMUL_DTEMP_GPU_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_CUMUL_DTEMP_CORE */
+#define OMAP5430_CUMUL_DTEMP_CORE_MASK			(0xffffffff << 0)
+
+/* OMAP5430.BANDGAP_STATUS */
+#define OMAP5430_BGAP_ALERT_MASK			BIT(31)
+#define OMAP5430_HOT_CORE_FLAG_MASK			BIT(5)
+#define OMAP5430_COLD_CORE_FLAG_MASK			BIT(4)
+#define OMAP5430_HOT_GPU_FLAG_MASK			BIT(3)
+#define OMAP5430_COLD_GPU_FLAG_MASK			BIT(2)
+#define OMAP5430_HOT_MPU_FLAG_MASK			BIT(1)
+#define OMAP5430_COLD_MPU_FLAG_MASK			BIT(0)
+
+/**
+ * Temperature limits and thresholds for OMAP5430
+ *
+ * All the macros bellow are definitions for handling the
+ * ADC conversions and representation of temperature limits
+ * and thresholds for OMAP5430. Definitions are grouped
+ * by temperature domain.
+ */
+
+/* OMAP5430.common temperature definitions */
+/* ADC conversion table limits */
+#define OMAP5430_ADC_START_VALUE			540
+#define OMAP5430_ADC_END_VALUE				945
+
+/* OMAP5430.GPU temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_GPU_MAX_FREQ				1500000
+#define OMAP5430_GPU_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_GPU_MIN_TEMP				-40000
+#define OMAP5430_GPU_MAX_TEMP				125000
+#define OMAP5430_GPU_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_GPU_TSHUT_HOT				915
+#define OMAP5430_GPU_TSHUT_COLD				900
+#define OMAP5430_GPU_T_HOT				800
+#define OMAP5430_GPU_T_COLD				795
+
+/* OMAP5430.MPU temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_MPU_MAX_FREQ				1500000
+#define OMAP5430_MPU_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_MPU_MIN_TEMP				-40000
+#define OMAP5430_MPU_MAX_TEMP				125000
+#define OMAP5430_MPU_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_MPU_TSHUT_HOT				915
+#define OMAP5430_MPU_TSHUT_COLD				900
+#define OMAP5430_MPU_T_HOT				800
+#define OMAP5430_MPU_T_COLD				795
+
+/* OMAP5430.CORE temperature definitions */
+/* bandgap clock limits */
+#define OMAP5430_CORE_MAX_FREQ				1500000
+#define OMAP5430_CORE_MIN_FREQ				1000000
+/* sensor limits */
+#define OMAP5430_CORE_MIN_TEMP				-40000
+#define OMAP5430_CORE_MAX_TEMP				125000
+#define OMAP5430_CORE_HYST_VAL				5000
+/* interrupts thresholds */
+#define OMAP5430_CORE_TSHUT_HOT				915
+#define OMAP5430_CORE_TSHUT_COLD			900
+#define OMAP5430_CORE_T_HOT				800
+#define OMAP5430_CORE_T_COLD				795
+
+#endif /* __OMAP5XXX_BANDGAP_H */
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 04/50] staging: omap-thermal: update documentation of omap-bandgap.h
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch updates the existing data structures for omap bandgap,
inside omap-bandgap.h.

TODO: remove unused fields.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |  230 ++++++++++++++++++++++-----
 1 files changed, 189 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 7d5ac3f..28d9104 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -28,24 +28,101 @@
 #include <linux/err.h>
 
 /**
- * The register offsets and bit fields might change across
- * OMAP versions hence populating them in this structure.
+ * DOC: bandgap driver data structure
+ * ==================================
+ *   +---------------------+   +-----------------+
+ *   | struct omap_bandgap |-->| struct device * |
+ *   +----------+----------+   +-----------------+
+ *              |
+ *              |
+ *              V
+ *   +--------------------------+
+ *   | struct omap_bandgap_data |
+ *   +--------------------------+
+ *              |
+ *              |
+ *              * (Array of)
+ * +------------+------------------------------------------------------+
+ * | +----------+--------------+   +-------------------------+         |
+ * | | struct omap_temp_sensor |-->| struct temp_sensor_data |         |
+ * | +-------------------------+   +------------+------------+         |
+ * |            |                                                      |
+ * |            +--------------------------+                           |
+ * |            V                          V                           |
+ * | +----------+- --------------+  +----+-------------------------+   |
+ * | | struct temp_sensor_regval |  | struct temp_sensor_registers |   |
+ * | +---------------------------+  +------------------------------+   |
+ * |                                                                   |
+ * +-------------------------------------------------------------------+
+ *
+ * Above is a simple diagram describing how the data structure below
+ * are organized. For each bandgap device there should be a omap_bandgap_data
+ * containing the device instance configuration, as well as, an array of
+ * sensors, representing every sensor instance present in this bandgap.
+ */
+
+/**
+ * struct temp_sensor_registers - descriptor to access registers and bitfields
+ * @temp_sensor_ctrl: TEMP_SENSOR_CTRL register offset
+ * @bgap_tempsoff_mask: mask to temp_sensor_ctrl.tempsoff
+ * @bgap_soc_mask: mask to temp_sensor_ctrl.soc
+ * @bgap_eocz_mask: mask to temp_sensor_ctrl.eocz
+ * @bgap_dtemp_mask: mask to temp_sensor_ctrl.dtemp
+ * @bgap_mask_ctrl: BANDGAP_MASK_CTRL register offset
+ * @mask_hot_mask: mask to bandgap_mask_ctrl.mask_hot
+ * @mask_cold_mask: mask to bandgap_mask_ctrl.mask_cold
+ * @mask_sidlemode_mask: mask to bandgap_mask_ctrl.mask_sidlemode
+ * @mask_freeze_mask: mask to bandgap_mask_ctrl.mask_free
+ * @mask_clear_mask: mask to bandgap_mask_ctrl.mask_clear
+ * @mask_clear_accum_mask: mask to bandgap_mask_ctrl.mask_clear_accum
+ * @bgap_mode_ctrl: BANDGAP_MODE_CTRL register offset
+ * @mode_ctrl_mask: mask to bandgap_mode_ctrl.mode_ctrl
+ * @bgap_counter: BANDGAP_COUNTER register offset
+ * @counter_mask: mask to bandgap_counter.counter
+ * @bgap_threshold: BANDGAP_THRESHOLD register offset (TALERT thresholds)
+ * @threshold_thot_mask: mask to bandgap_threhold.thot
+ * @threshold_tcold_mask: mask to bandgap_threhold.tcold
+ * @tshut_threshold: TSHUT_THRESHOLD register offset (TSHUT thresholds)
+ * @tshut_efuse_mask: mask to tshut_threshold.tshut_efuse
+ * @tshut_efuse_shift: shift to tshut_threshold.tshut_efuse
+ * @tshut_hot_mask: mask to tshut_threhold.thot
+ * @tshut_cold_mask: mask to tshut_threhold.thot
+ * @bgap_status: BANDGAP_STATUS register offset
+ * @status_clean_stop_mask: mask to bandgap_status.clean_stop
+ * @status_bgap_alert_mask: mask to bandgap_status.bandgap_alert
+ * @status_hot_mask: mask to bandgap_status.hot
+ * @status_cold_mask: mask to bandgap_status.cold
+ * @bgap_cumul_dtemp: BANDGAP_CUMUL_DTEMP register offset
+ * @ctrl_dtemp_0: CTRL_DTEMP0 register offset
+ * @ctrl_dtemp_1: CTRL_DTEMP1 register offset
+ * @ctrl_dtemp_2: CTRL_DTEMP2 register offset
+ * @ctrl_dtemp_3: CTRL_DTEMP3 register offset
+ * @ctrl_dtemp_4: CTRL_DTEMP4 register offset
+ * @bgap_efuse: BANDGAP_EFUSE register offset
+ *
+ * The register offsets and bitfields might change across
+ * OMAP and variants versions. Hence this struct serves as a
+ * descriptor map on how to access the registers and the bitfields.
+ *
+ * This descriptor contains registers of all versions of bandgap chips.
+ * Not all versions will use all registers, depending on the available
+ * features. Please read TRMs for descriptive explanation on each bitfield.
  */
 
 struct temp_sensor_registers {
 	u32	temp_sensor_ctrl;
 	u32	bgap_tempsoff_mask;
 	u32	bgap_soc_mask;
-	u32	bgap_eocz_mask;
+	u32	bgap_eocz_mask; /* not used: but needs revisit */
 	u32	bgap_dtemp_mask;
 
 	u32	bgap_mask_ctrl;
 	u32	mask_hot_mask;
 	u32	mask_cold_mask;
-	u32	mask_sidlemode_mask;
+	u32	mask_sidlemode_mask; /* not used: but may be needed for pm */
 	u32	mask_freeze_mask;
-	u32	mask_clear_mask;
-	u32	mask_clear_accum_mask;
+	u32	mask_clear_mask; /* not used: but needed for trending */
+	u32	mask_clear_accum_mask; /* not used: but needed for trending */
 
 	u32	bgap_mode_ctrl;
 	u32	mode_ctrl_mask;
@@ -58,28 +135,45 @@ struct temp_sensor_registers {
 	u32	threshold_tcold_mask;
 
 	u32	tshut_threshold;
-	u32	tshut_efuse_mask;
-	u32	tshut_efuse_shift;
+	u32	tshut_efuse_mask; /* not used */
+	u32	tshut_efuse_shift; /* not used */
 	u32	tshut_hot_mask;
 	u32	tshut_cold_mask;
 
 	u32	bgap_status;
-	u32	status_clean_stop_mask;
-	u32	status_bgap_alert_mask;
+	u32	status_clean_stop_mask; /* not used: but needed for trending */
+	u32	status_bgap_alert_mask; /* not used */
 	u32	status_hot_mask;
 	u32	status_cold_mask;
 
-	u32	bgap_cumul_dtemp;
-	u32	ctrl_dtemp_0;
-	u32	ctrl_dtemp_1;
-	u32	ctrl_dtemp_2;
-	u32	ctrl_dtemp_3;
-	u32	ctrl_dtemp_4;
+	u32	bgap_cumul_dtemp; /* not used: but needed for trending */
+	u32	ctrl_dtemp_0; /* not used: but needed for trending */
+	u32	ctrl_dtemp_1; /* not used: but needed for trending */
+	u32	ctrl_dtemp_2; /* not used: but needed for trending */
+	u32	ctrl_dtemp_3; /* not used: but needed for trending */
+	u32	ctrl_dtemp_4; /* not used: but needed for trending */
 	u32	bgap_efuse;
 };
 
 /**
- * The thresholds and limits for temperature sensors.
+ * struct temp_sensor_data - The thresholds and limits for temperature sensors.
+ * @tshut_hot: temperature to trigger a thermal reset (initial value)
+ * @tshut_cold: temp to get the plat out of reset due to thermal (init val)
+ * @t_hot: temperature to trigger a thermal alert (high initial value)
+ * @t_cold: temperature to trigger a thermal alert (low initial value)
+ * @min_freq: sensor minimum clock rate
+ * @max_freq: sensor maximum clock rate
+ * @max_temp: sensor maximum temperature
+ * @min_temp: sensor minimum temperature
+ * @hyst_val: temperature hysteresis considered while converting ADC values
+ * @adc_start_val: ADC conversion table starting value
+ * @adc_end_val: ADC conversion table ending value
+ * @update_int1: update interval
+ * @update_int2: update interval
+ *
+ * This data structure will hold the required thresholds and temperature limits
+ * for a specific temperature sensor, like shutdown temperature, alert
+ * temperature, clock / rate used, ADC conversion limits and update intervals
  */
 struct temp_sensor_data {
 	u32	tshut_hot;
@@ -93,23 +187,27 @@ struct temp_sensor_data {
 	int     hyst_val;
 	u32     adc_start_val;
 	u32     adc_end_val;
-	u32     update_int1;
-	u32     update_int2;
+	u32     update_int1; /* not used */
+	u32     update_int2; /* not used */
 };
 
 struct omap_bandgap_data;
 
 /**
  * struct omap_bandgap - bandgap device structure
- * @dev: device pointer
- * @conf: platform data with sensor data
+ * @dev: struct device pointer
+ * @base: io memory base address
+ * @conf: struct with bandgap configuration set (# sensors, conv_table, etc)
  * @fclock: pointer to functional clock of temperature sensor
- * @div_clk: pointer to parent clock of temperature sensor fclk
- * @conv_table: Pointer to adc to temperature conversion table
- * @bg_mutex: Mutex for sysfs, irq and PM
- * @irq: MPU Irq number for thermal alert
+ * @div_clk: pointer to divider clock of temperature sensor fclk
+ * @bg_mutex: mutex for omap_bandgap structure
+ * @irq: MPU IRQ number for thermal alert
  * @tshut_gpio: GPIO where Tshut signal is routed
  * @clk_rate: Holds current clock rate
+ *
+ * The bandgap device structure representing the bandgap device instance.
+ * It holds most of the dynamic stuff. Configurations and sensor specific
+ * entries are inside the @conf structure.
  */
 struct omap_bandgap {
 	struct device			*dev;
@@ -117,7 +215,7 @@ struct omap_bandgap {
 	struct omap_bandgap_data	*conf;
 	struct clk			*fclock;
 	struct clk			*div_clk;
-	struct mutex			bg_mutex; /* Mutex for irq and PM */
+	struct mutex			bg_mutex; /* shields this struct */
 	int				irq;
 	int				tshut_gpio;
 	u32				clk_rate;
@@ -130,6 +228,9 @@ struct omap_bandgap {
  * @bg_counter: bandgap counter value
  * @bg_threshold: bandgap threshold register value
  * @tshut_threshold: bandgap tshut register value
+ *
+ * Data structure to save and restore bandgap register set context. Only
+ * required registers are shadowed, when needed.
  */
 struct temp_sensor_regval {
 	u32			bg_mode_ctrl;
@@ -140,21 +241,26 @@ struct temp_sensor_regval {
 };
 
 /**
- * struct omap_temp_sensor - bandgap temperature sensor platform data
+ * struct omap_temp_sensor - bandgap temperature sensor configuration data
  * @ts_data: pointer to struct with thresholds, limits of temperature sensor
  * @registers: pointer to the list of register offsets and bitfields
  * @regval: temperature sensor register values
  * @domain: the name of the domain where the sensor is located
- * @cooling_data: description on how the zone should be cooled off.
- * @slope: sensor gradient slope info for hotspot extrapolation
- * @const: sensor gradient const info for hotspot extrapolation
- * @slope_pcb: sensor gradient slope info for hotspot extrapolation
+ * @slope: sensor gradient slope info for hotspot extrapolation equation
+ * @const: sensor gradient const info for hotspot extrapolation equation
+ * @slope_pcb: sensor gradient slope info for hotspot extrapolation equation
  *             with no external influence
- * @const_pcb: sensor gradient const info for hotspot extrapolation
+ * @constant_pcb: sensor gradient const info for hotspot extrapolation equation
  *             with no external influence
  * @data: private data
  * @register_cooling: function to describe how this sensor is going to be cooled
  * @unregister_cooling: function to release cooling data
+ *
+ * Data structure to describe a temperature sensor handled by a bandgap device.
+ * It should provide configuration details on this sensor, such as how to
+ * access the registers affecting this sensor, shadow register buffer, how to
+ * assess the gradient from hotspot, how to cooldown the domain when sensor
+ * reports too hot temperature.
  */
 struct omap_temp_sensor {
 	struct temp_sensor_data		*ts_data;
@@ -172,16 +278,38 @@ struct omap_temp_sensor {
 };
 
 /**
- * struct omap_bandgap_data - bandgap platform data structure
- * @features: a bitwise flag set to describe the device features
- * @conv_table: Pointer to adc to temperature conversion table
- * @fclock_name: clock name of the functional clock
- * @div_ck_nme: clock name of the clock divisor
- * @sensor_count: count of temperature sensor device in scm
- * @sensors: array of sensors present in this bandgap instance
- * @expose_sensor: callback to export sensor to thermal API
+ * DOC: omap bandgap feature types
+ *
+ * OMAP_BANDGAP_FEATURE_TSHUT - used when the thermal shutdown signal output
+ *      of a bandgap device instance is routed to the processor. This means
+ *      the system must react and perform the shutdown by itself (handle an
+ *      IRQ, for instance).
+ *
+ * OMAP_BANDGAP_FEATURE_TSHUT_CONFIG - used when the bandgap device has control
+ *      over the thermal shutdown configuration. This means that the thermal
+ *      shutdown thresholds are programmable, for instance.
+ *
+ * OMAP_BANDGAP_FEATURE_TALERT - used when the bandgap device instance outputs
+ *      a signal representing violation of programmable alert thresholds.
+ *
+ * OMAP_BANDGAP_FEATURE_MODE_CONFIG - used when it is possible to choose which
+ *      mode, continuous or one shot, the bandgap device instance will operate.
+ *
+ * OMAP_BANDGAP_FEATURE_COUNTER - used when the bandgap device instance allows
+ *      programming the update interval of its internal state machine.
+ *
+ * OMAP_BANDGAP_FEATURE_POWER_SWITCH - used when the bandgap device allows
+ *      itself to be switched on/off.
+ *
+ * OMAP_BANDGAP_FEATURE_CLK_CTRL - used when the clocks feeding the bandgap
+ *      device are gateable or not.
+ *
+ * OMAP_BANDGAP_FEATURE_FREEZE_BIT - used when the bandgap device features
+ *      a history buffer that its update can be freezed/unfreezed.
+ *
+ * OMAP_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
+ *      specific feature (above) or not. Return non-zero, if yes.
  */
-struct omap_bandgap_data {
 #define OMAP_BANDGAP_FEATURE_TSHUT		BIT(0)
 #define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	BIT(1)
 #define OMAP_BANDGAP_FEATURE_TALERT		BIT(2)
@@ -192,6 +320,26 @@ struct omap_bandgap_data {
 #define OMAP_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define OMAP_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
+
+/**
+ * struct omap_bandgap_data - omap bandgap data configuration structure
+ * @features: a bitwise flag set to describe the device features
+ * @conv_table: Pointer to ADC to temperature conversion table
+ * @fclock_name: clock name of the functional clock
+ * @div_ck_name: clock name of the clock divisor
+ * @sensor_count: count of temperature sensor within this bandgap device
+ * @report_temperature: callback to report thermal alert to thermal API
+ * @expose_sensor: callback to export sensor to thermal API
+ * @remove_sensor: callback to destroy sensor from thermal API
+ * @sensors: array of sensors present in this bandgap instance
+ *
+ * This is a data structure which should hold most of the static configuration
+ * of a bandgap device instance. It should describe which features this instance
+ * is capable of, the clock names to feed this device, the amount of sensors and
+ * their configuration representation, and how to export and unexport them to
+ * a thermal API.
+ */
+struct omap_bandgap_data {
 	unsigned int			features;
 	const int			*conv_table;
 	char				*fclock_name;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 04/50] staging: omap-thermal: update documentation of omap-bandgap.h
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch updates the existing data structures for omap bandgap,
inside omap-bandgap.h.

TODO: remove unused fields.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.h |  230 ++++++++++++++++++++++-----
 1 files changed, 189 insertions(+), 41 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 7d5ac3f..28d9104 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -28,24 +28,101 @@
 #include <linux/err.h>
 
 /**
- * The register offsets and bit fields might change across
- * OMAP versions hence populating them in this structure.
+ * DOC: bandgap driver data structure
+ * ==================================
+ *   +---------------------+   +-----------------+
+ *   | struct omap_bandgap |-->| struct device * |
+ *   +----------+----------+   +-----------------+
+ *              |
+ *              |
+ *              V
+ *   +--------------------------+
+ *   | struct omap_bandgap_data |
+ *   +--------------------------+
+ *              |
+ *              |
+ *              * (Array of)
+ * +------------+------------------------------------------------------+
+ * | +----------+--------------+   +-------------------------+         |
+ * | | struct omap_temp_sensor |-->| struct temp_sensor_data |         |
+ * | +-------------------------+   +------------+------------+         |
+ * |            |                                                      |
+ * |            +--------------------------+                           |
+ * |            V                          V                           |
+ * | +----------+- --------------+  +----+-------------------------+   |
+ * | | struct temp_sensor_regval |  | struct temp_sensor_registers |   |
+ * | +---------------------------+  +------------------------------+   |
+ * |                                                                   |
+ * +-------------------------------------------------------------------+
+ *
+ * Above is a simple diagram describing how the data structure below
+ * are organized. For each bandgap device there should be a omap_bandgap_data
+ * containing the device instance configuration, as well as, an array of
+ * sensors, representing every sensor instance present in this bandgap.
+ */
+
+/**
+ * struct temp_sensor_registers - descriptor to access registers and bitfields
+ * @temp_sensor_ctrl: TEMP_SENSOR_CTRL register offset
+ * @bgap_tempsoff_mask: mask to temp_sensor_ctrl.tempsoff
+ * @bgap_soc_mask: mask to temp_sensor_ctrl.soc
+ * @bgap_eocz_mask: mask to temp_sensor_ctrl.eocz
+ * @bgap_dtemp_mask: mask to temp_sensor_ctrl.dtemp
+ * @bgap_mask_ctrl: BANDGAP_MASK_CTRL register offset
+ * @mask_hot_mask: mask to bandgap_mask_ctrl.mask_hot
+ * @mask_cold_mask: mask to bandgap_mask_ctrl.mask_cold
+ * @mask_sidlemode_mask: mask to bandgap_mask_ctrl.mask_sidlemode
+ * @mask_freeze_mask: mask to bandgap_mask_ctrl.mask_free
+ * @mask_clear_mask: mask to bandgap_mask_ctrl.mask_clear
+ * @mask_clear_accum_mask: mask to bandgap_mask_ctrl.mask_clear_accum
+ * @bgap_mode_ctrl: BANDGAP_MODE_CTRL register offset
+ * @mode_ctrl_mask: mask to bandgap_mode_ctrl.mode_ctrl
+ * @bgap_counter: BANDGAP_COUNTER register offset
+ * @counter_mask: mask to bandgap_counter.counter
+ * @bgap_threshold: BANDGAP_THRESHOLD register offset (TALERT thresholds)
+ * @threshold_thot_mask: mask to bandgap_threhold.thot
+ * @threshold_tcold_mask: mask to bandgap_threhold.tcold
+ * @tshut_threshold: TSHUT_THRESHOLD register offset (TSHUT thresholds)
+ * @tshut_efuse_mask: mask to tshut_threshold.tshut_efuse
+ * @tshut_efuse_shift: shift to tshut_threshold.tshut_efuse
+ * @tshut_hot_mask: mask to tshut_threhold.thot
+ * @tshut_cold_mask: mask to tshut_threhold.thot
+ * @bgap_status: BANDGAP_STATUS register offset
+ * @status_clean_stop_mask: mask to bandgap_status.clean_stop
+ * @status_bgap_alert_mask: mask to bandgap_status.bandgap_alert
+ * @status_hot_mask: mask to bandgap_status.hot
+ * @status_cold_mask: mask to bandgap_status.cold
+ * @bgap_cumul_dtemp: BANDGAP_CUMUL_DTEMP register offset
+ * @ctrl_dtemp_0: CTRL_DTEMP0 register offset
+ * @ctrl_dtemp_1: CTRL_DTEMP1 register offset
+ * @ctrl_dtemp_2: CTRL_DTEMP2 register offset
+ * @ctrl_dtemp_3: CTRL_DTEMP3 register offset
+ * @ctrl_dtemp_4: CTRL_DTEMP4 register offset
+ * @bgap_efuse: BANDGAP_EFUSE register offset
+ *
+ * The register offsets and bitfields might change across
+ * OMAP and variants versions. Hence this struct serves as a
+ * descriptor map on how to access the registers and the bitfields.
+ *
+ * This descriptor contains registers of all versions of bandgap chips.
+ * Not all versions will use all registers, depending on the available
+ * features. Please read TRMs for descriptive explanation on each bitfield.
  */
 
 struct temp_sensor_registers {
 	u32	temp_sensor_ctrl;
 	u32	bgap_tempsoff_mask;
 	u32	bgap_soc_mask;
-	u32	bgap_eocz_mask;
+	u32	bgap_eocz_mask; /* not used: but needs revisit */
 	u32	bgap_dtemp_mask;
 
 	u32	bgap_mask_ctrl;
 	u32	mask_hot_mask;
 	u32	mask_cold_mask;
-	u32	mask_sidlemode_mask;
+	u32	mask_sidlemode_mask; /* not used: but may be needed for pm */
 	u32	mask_freeze_mask;
-	u32	mask_clear_mask;
-	u32	mask_clear_accum_mask;
+	u32	mask_clear_mask; /* not used: but needed for trending */
+	u32	mask_clear_accum_mask; /* not used: but needed for trending */
 
 	u32	bgap_mode_ctrl;
 	u32	mode_ctrl_mask;
@@ -58,28 +135,45 @@ struct temp_sensor_registers {
 	u32	threshold_tcold_mask;
 
 	u32	tshut_threshold;
-	u32	tshut_efuse_mask;
-	u32	tshut_efuse_shift;
+	u32	tshut_efuse_mask; /* not used */
+	u32	tshut_efuse_shift; /* not used */
 	u32	tshut_hot_mask;
 	u32	tshut_cold_mask;
 
 	u32	bgap_status;
-	u32	status_clean_stop_mask;
-	u32	status_bgap_alert_mask;
+	u32	status_clean_stop_mask; /* not used: but needed for trending */
+	u32	status_bgap_alert_mask; /* not used */
 	u32	status_hot_mask;
 	u32	status_cold_mask;
 
-	u32	bgap_cumul_dtemp;
-	u32	ctrl_dtemp_0;
-	u32	ctrl_dtemp_1;
-	u32	ctrl_dtemp_2;
-	u32	ctrl_dtemp_3;
-	u32	ctrl_dtemp_4;
+	u32	bgap_cumul_dtemp; /* not used: but needed for trending */
+	u32	ctrl_dtemp_0; /* not used: but needed for trending */
+	u32	ctrl_dtemp_1; /* not used: but needed for trending */
+	u32	ctrl_dtemp_2; /* not used: but needed for trending */
+	u32	ctrl_dtemp_3; /* not used: but needed for trending */
+	u32	ctrl_dtemp_4; /* not used: but needed for trending */
 	u32	bgap_efuse;
 };
 
 /**
- * The thresholds and limits for temperature sensors.
+ * struct temp_sensor_data - The thresholds and limits for temperature sensors.
+ * @tshut_hot: temperature to trigger a thermal reset (initial value)
+ * @tshut_cold: temp to get the plat out of reset due to thermal (init val)
+ * @t_hot: temperature to trigger a thermal alert (high initial value)
+ * @t_cold: temperature to trigger a thermal alert (low initial value)
+ * @min_freq: sensor minimum clock rate
+ * @max_freq: sensor maximum clock rate
+ * @max_temp: sensor maximum temperature
+ * @min_temp: sensor minimum temperature
+ * @hyst_val: temperature hysteresis considered while converting ADC values
+ * @adc_start_val: ADC conversion table starting value
+ * @adc_end_val: ADC conversion table ending value
+ * @update_int1: update interval
+ * @update_int2: update interval
+ *
+ * This data structure will hold the required thresholds and temperature limits
+ * for a specific temperature sensor, like shutdown temperature, alert
+ * temperature, clock / rate used, ADC conversion limits and update intervals
  */
 struct temp_sensor_data {
 	u32	tshut_hot;
@@ -93,23 +187,27 @@ struct temp_sensor_data {
 	int     hyst_val;
 	u32     adc_start_val;
 	u32     adc_end_val;
-	u32     update_int1;
-	u32     update_int2;
+	u32     update_int1; /* not used */
+	u32     update_int2; /* not used */
 };
 
 struct omap_bandgap_data;
 
 /**
  * struct omap_bandgap - bandgap device structure
- * @dev: device pointer
- * @conf: platform data with sensor data
+ * @dev: struct device pointer
+ * @base: io memory base address
+ * @conf: struct with bandgap configuration set (# sensors, conv_table, etc)
  * @fclock: pointer to functional clock of temperature sensor
- * @div_clk: pointer to parent clock of temperature sensor fclk
- * @conv_table: Pointer to adc to temperature conversion table
- * @bg_mutex: Mutex for sysfs, irq and PM
- * @irq: MPU Irq number for thermal alert
+ * @div_clk: pointer to divider clock of temperature sensor fclk
+ * @bg_mutex: mutex for omap_bandgap structure
+ * @irq: MPU IRQ number for thermal alert
  * @tshut_gpio: GPIO where Tshut signal is routed
  * @clk_rate: Holds current clock rate
+ *
+ * The bandgap device structure representing the bandgap device instance.
+ * It holds most of the dynamic stuff. Configurations and sensor specific
+ * entries are inside the @conf structure.
  */
 struct omap_bandgap {
 	struct device			*dev;
@@ -117,7 +215,7 @@ struct omap_bandgap {
 	struct omap_bandgap_data	*conf;
 	struct clk			*fclock;
 	struct clk			*div_clk;
-	struct mutex			bg_mutex; /* Mutex for irq and PM */
+	struct mutex			bg_mutex; /* shields this struct */
 	int				irq;
 	int				tshut_gpio;
 	u32				clk_rate;
@@ -130,6 +228,9 @@ struct omap_bandgap {
  * @bg_counter: bandgap counter value
  * @bg_threshold: bandgap threshold register value
  * @tshut_threshold: bandgap tshut register value
+ *
+ * Data structure to save and restore bandgap register set context. Only
+ * required registers are shadowed, when needed.
  */
 struct temp_sensor_regval {
 	u32			bg_mode_ctrl;
@@ -140,21 +241,26 @@ struct temp_sensor_regval {
 };
 
 /**
- * struct omap_temp_sensor - bandgap temperature sensor platform data
+ * struct omap_temp_sensor - bandgap temperature sensor configuration data
  * @ts_data: pointer to struct with thresholds, limits of temperature sensor
  * @registers: pointer to the list of register offsets and bitfields
  * @regval: temperature sensor register values
  * @domain: the name of the domain where the sensor is located
- * @cooling_data: description on how the zone should be cooled off.
- * @slope: sensor gradient slope info for hotspot extrapolation
- * @const: sensor gradient const info for hotspot extrapolation
- * @slope_pcb: sensor gradient slope info for hotspot extrapolation
+ * @slope: sensor gradient slope info for hotspot extrapolation equation
+ * @const: sensor gradient const info for hotspot extrapolation equation
+ * @slope_pcb: sensor gradient slope info for hotspot extrapolation equation
  *             with no external influence
- * @const_pcb: sensor gradient const info for hotspot extrapolation
+ * @constant_pcb: sensor gradient const info for hotspot extrapolation equation
  *             with no external influence
  * @data: private data
  * @register_cooling: function to describe how this sensor is going to be cooled
  * @unregister_cooling: function to release cooling data
+ *
+ * Data structure to describe a temperature sensor handled by a bandgap device.
+ * It should provide configuration details on this sensor, such as how to
+ * access the registers affecting this sensor, shadow register buffer, how to
+ * assess the gradient from hotspot, how to cooldown the domain when sensor
+ * reports too hot temperature.
  */
 struct omap_temp_sensor {
 	struct temp_sensor_data		*ts_data;
@@ -172,16 +278,38 @@ struct omap_temp_sensor {
 };
 
 /**
- * struct omap_bandgap_data - bandgap platform data structure
- * @features: a bitwise flag set to describe the device features
- * @conv_table: Pointer to adc to temperature conversion table
- * @fclock_name: clock name of the functional clock
- * @div_ck_nme: clock name of the clock divisor
- * @sensor_count: count of temperature sensor device in scm
- * @sensors: array of sensors present in this bandgap instance
- * @expose_sensor: callback to export sensor to thermal API
+ * DOC: omap bandgap feature types
+ *
+ * OMAP_BANDGAP_FEATURE_TSHUT - used when the thermal shutdown signal output
+ *      of a bandgap device instance is routed to the processor. This means
+ *      the system must react and perform the shutdown by itself (handle an
+ *      IRQ, for instance).
+ *
+ * OMAP_BANDGAP_FEATURE_TSHUT_CONFIG - used when the bandgap device has control
+ *      over the thermal shutdown configuration. This means that the thermal
+ *      shutdown thresholds are programmable, for instance.
+ *
+ * OMAP_BANDGAP_FEATURE_TALERT - used when the bandgap device instance outputs
+ *      a signal representing violation of programmable alert thresholds.
+ *
+ * OMAP_BANDGAP_FEATURE_MODE_CONFIG - used when it is possible to choose which
+ *      mode, continuous or one shot, the bandgap device instance will operate.
+ *
+ * OMAP_BANDGAP_FEATURE_COUNTER - used when the bandgap device instance allows
+ *      programming the update interval of its internal state machine.
+ *
+ * OMAP_BANDGAP_FEATURE_POWER_SWITCH - used when the bandgap device allows
+ *      itself to be switched on/off.
+ *
+ * OMAP_BANDGAP_FEATURE_CLK_CTRL - used when the clocks feeding the bandgap
+ *      device are gateable or not.
+ *
+ * OMAP_BANDGAP_FEATURE_FREEZE_BIT - used when the bandgap device features
+ *      a history buffer that its update can be freezed/unfreezed.
+ *
+ * OMAP_BANDGAP_HAS(b, f) - macro to check if a bandgap device is capable of a
+ *      specific feature (above) or not. Return non-zero, if yes.
  */
-struct omap_bandgap_data {
 #define OMAP_BANDGAP_FEATURE_TSHUT		BIT(0)
 #define OMAP_BANDGAP_FEATURE_TSHUT_CONFIG	BIT(1)
 #define OMAP_BANDGAP_FEATURE_TALERT		BIT(2)
@@ -192,6 +320,26 @@ struct omap_bandgap_data {
 #define OMAP_BANDGAP_FEATURE_FREEZE_BIT		BIT(7)
 #define OMAP_BANDGAP_HAS(b, f)			\
 			((b)->conf->features & OMAP_BANDGAP_FEATURE_ ## f)
+
+/**
+ * struct omap_bandgap_data - omap bandgap data configuration structure
+ * @features: a bitwise flag set to describe the device features
+ * @conv_table: Pointer to ADC to temperature conversion table
+ * @fclock_name: clock name of the functional clock
+ * @div_ck_name: clock name of the clock divisor
+ * @sensor_count: count of temperature sensor within this bandgap device
+ * @report_temperature: callback to report thermal alert to thermal API
+ * @expose_sensor: callback to export sensor to thermal API
+ * @remove_sensor: callback to destroy sensor from thermal API
+ * @sensors: array of sensors present in this bandgap instance
+ *
+ * This is a data structure which should hold most of the static configuration
+ * of a bandgap device instance. It should describe which features this instance
+ * is capable of, the clock names to feed this device, the amount of sensors and
+ * their configuration representation, and how to export and unexport them to
+ * a thermal API.
+ */
+struct omap_bandgap_data {
 	unsigned int			features;
 	const int			*conv_table;
 	char				*fclock_name;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 05/50] staging: omap-thermal: style cleanup on omap-bandgap.c
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

simple changes on alignments and white spaces

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d4a3788..9f2d7cc 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -437,7 +437,7 @@ static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
-			      int *thot)
+			   int *thot)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -512,7 +512,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
-			       int *tcold)
+			    int *tcold)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -617,7 +617,7 @@ int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
-					  int id, u32 interval)
+				       int id, u32 interval)
 {
 	int ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
@@ -643,7 +643,7 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
-				     int *temperature)
+				  int *temperature)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -677,7 +677,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_set_sensor_data(struct omap_bandgap *bg_ptr, int id,
-				void *data)
+				 void *data)
 {
 	int ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
@@ -762,7 +762,7 @@ static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
 }
 
 static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
-				      struct platform_device *pdev)
+				   struct platform_device *pdev)
 {
 	int gpio_nr = bg_ptr->tshut_gpio;
 	int status;
@@ -795,7 +795,7 @@ static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 
 /* Initialization of Talert. Call it only if HAS(TALERT) is set */
 static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
-				       struct platform_device *pdev)
+				    struct platform_device *pdev)
 {
 	int ret;
 
@@ -855,7 +855,7 @@ static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 			bg_ptr->base = chunk;
 		if (IS_ERR(chunk))
 			return ERR_CAST(chunk);
-		
+
 		i++;
 	} while (res);
 
@@ -1108,9 +1108,8 @@ static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
 			val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
 
 		if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
-			omap_bandgap_writel(bg_ptr,
-				rval->tshut_threshold,
-					   tsr->tshut_threshold);
+			omap_bandgap_writel(bg_ptr, rval->tshut_threshold,
+					    tsr->tshut_threshold);
 		/* Force immediate temperature measurement and update
 		 * of the DTEMP field
 		 */
@@ -1118,16 +1117,15 @@ static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
 
 		if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 			omap_bandgap_writel(bg_ptr, rval->bg_counter,
-						   tsr->bgap_counter);
+					    tsr->bgap_counter);
 		if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
 			omap_bandgap_writel(bg_ptr, rval->bg_mode_ctrl,
-						   tsr->bgap_mode_ctrl);
+					    tsr->bgap_mode_ctrl);
 		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
-			omap_bandgap_writel(bg_ptr,
-						   rval->bg_threshold,
-						   tsr->bgap_threshold);
+			omap_bandgap_writel(bg_ptr, rval->bg_threshold,
+					    tsr->bgap_threshold);
 			omap_bandgap_writel(bg_ptr, rval->bg_ctrl,
-						   tsr->bgap_mask_ctrl);
+					    tsr->bgap_mask_ctrl);
 		}
 	}
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 05/50] staging: omap-thermal: style cleanup on omap-bandgap.c
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

simple changes on alignments and white spaces

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d4a3788..9f2d7cc 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -437,7 +437,7 @@ static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
-			      int *thot)
+			   int *thot)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -512,7 +512,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
-			       int *tcold)
+			    int *tcold)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -617,7 +617,7 @@ int omap_bandgap_read_update_interval(struct omap_bandgap *bg_ptr, int id,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
-					  int id, u32 interval)
+				       int id, u32 interval)
 {
 	int ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
@@ -643,7 +643,7 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
-				     int *temperature)
+				  int *temperature)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp;
@@ -677,7 +677,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
  * returns 0 on success or the proper error code
  */
 int omap_bandgap_set_sensor_data(struct omap_bandgap *bg_ptr, int id,
-				void *data)
+				 void *data)
 {
 	int ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
@@ -762,7 +762,7 @@ static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
 }
 
 static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
-				      struct platform_device *pdev)
+				   struct platform_device *pdev)
 {
 	int gpio_nr = bg_ptr->tshut_gpio;
 	int status;
@@ -795,7 +795,7 @@ static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 
 /* Initialization of Talert. Call it only if HAS(TALERT) is set */
 static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
-				       struct platform_device *pdev)
+				    struct platform_device *pdev)
 {
 	int ret;
 
@@ -855,7 +855,7 @@ static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 			bg_ptr->base = chunk;
 		if (IS_ERR(chunk))
 			return ERR_CAST(chunk);
-		
+
 		i++;
 	} while (res);
 
@@ -1108,9 +1108,8 @@ static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
 			val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
 
 		if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG))
-			omap_bandgap_writel(bg_ptr,
-				rval->tshut_threshold,
-					   tsr->tshut_threshold);
+			omap_bandgap_writel(bg_ptr, rval->tshut_threshold,
+					    tsr->tshut_threshold);
 		/* Force immediate temperature measurement and update
 		 * of the DTEMP field
 		 */
@@ -1118,16 +1117,15 @@ static int omap_bandgap_restore_ctxt(struct omap_bandgap *bg_ptr)
 
 		if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 			omap_bandgap_writel(bg_ptr, rval->bg_counter,
-						   tsr->bgap_counter);
+					    tsr->bgap_counter);
 		if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
 			omap_bandgap_writel(bg_ptr, rval->bg_mode_ctrl,
-						   tsr->bgap_mode_ctrl);
+					    tsr->bgap_mode_ctrl);
 		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
-			omap_bandgap_writel(bg_ptr,
-						   rval->bg_threshold,
-						   tsr->bgap_threshold);
+			omap_bandgap_writel(bg_ptr, rval->bg_threshold,
+					    tsr->bgap_threshold);
 			omap_bandgap_writel(bg_ptr, rval->bg_ctrl,
-						   tsr->bgap_mask_ctrl);
+					    tsr->bgap_mask_ctrl);
 		}
 	}
 
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 06/50] staging: omap-thermal: fix error checking
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

The omap_bandgap_get_sensor_data() function returns ERR_PTR(),
but it can also return NULL, in case of initilization, so we need to use
IS_ERR_OR_NULL() rather than only IS_ERR().

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

diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c
index 79a55aa..8aebc6a 100644
--- a/drivers/staging/omap-thermal/omap-thermal-common.c
+++ b/drivers/staging/omap-thermal/omap-thermal-common.c
@@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
 
 	data = omap_bandgap_get_sensor_data(bg_ptr, id);
 
-	if (IS_ERR(data))
+	if (IS_ERR_OR_NULL(data))
 		data = omap_thermal_build_data(bg_ptr, id);
 
 	if (!data)
@@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
 	struct omap_thermal_data *data;
 
 	data = omap_bandgap_get_sensor_data(bg_ptr, id);
-	if (IS_ERR(data))
+	if (IS_ERR_OR_NULL(data))
 		data = omap_thermal_build_data(bg_ptr, id);
 
 	if (!data)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 06/50] staging: omap-thermal: fix error checking
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

The omap_bandgap_get_sensor_data() function returns ERR_PTR(),
but it can also return NULL, in case of initilization, so we need to use
IS_ERR_OR_NULL() rather than only IS_ERR().

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

diff --git a/drivers/staging/omap-thermal/omap-thermal-common.c b/drivers/staging/omap-thermal/omap-thermal-common.c
index 79a55aa..8aebc6a 100644
--- a/drivers/staging/omap-thermal/omap-thermal-common.c
+++ b/drivers/staging/omap-thermal/omap-thermal-common.c
@@ -260,7 +260,7 @@ int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
 
 	data = omap_bandgap_get_sensor_data(bg_ptr, id);
 
-	if (IS_ERR(data))
+	if (IS_ERR_OR_NULL(data))
 		data = omap_thermal_build_data(bg_ptr, id);
 
 	if (!data)
@@ -309,7 +309,7 @@ int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
 	struct omap_thermal_data *data;
 
 	data = omap_bandgap_get_sensor_data(bg_ptr, id);
-	if (IS_ERR(data))
+	if (IS_ERR_OR_NULL(data))
 		data = omap_thermal_build_data(bg_ptr, id);
 
 	if (!data)
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch introduce a macro to read, update, write bitfields.
It will be specific to bandgap data structures.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 9f2d7cc..1c1b905 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -52,25 +52,29 @@ static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
 	writel(val, bg_ptr->base + reg);
 }
 
+/* update bits, value will be shifted */
+#define RMW_BITS(bg_ptr, id, reg, mask, val)			\
+do {								\
+	struct temp_sensor_registers *t;			\
+	u32 r;							\
+								\
+	t = bg_ptr->conf->sensors[(id)].registers;		\
+	r = omap_bandgap_readl(bg_ptr, t->reg);			\
+	r &= ~t->mask;						\
+	r |= (val) << __ffs(t->mask);				\
+	omap_bandgap_writel(bg_ptr, r, t->reg);			\
+} while (0)
+
 static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 {
-	struct temp_sensor_registers *tsr;
 	int i;
-	u32 ctrl;
 
 	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
 		return 0;
 
-	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
-		tsr = bg_ptr->conf->sensors[i].registers;
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-		ctrl &= ~tsr->bgap_tempsoff_mask;
+	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
 		/* active on 0 */
-		ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
-
-		/* write BGAP_TEMPSOFF should be reset to 0 */
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
-	}
+		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
 
 	return 0;
 }
@@ -78,15 +82,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 {
 	struct temp_sensor_registers *tsr;
-	u32 temp, ctrl, reg;
+	u32 temp, reg;
 
 	tsr = bg_ptr->conf->sensors[id].registers;
 	reg = tsr->temp_sensor_ctrl;
 
 	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-		ctrl |= tsr->mask_freeze_mask;
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
+		RMW_BITS(bg_ptr, id, bgap_mask_ctrl, mask_freeze_mask, 1);
 		/*
 		 * In case we cannot read from cur_dtemp / dtemp_0,
 		 * then we read from the last valid temp read
@@ -98,11 +100,8 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	temp = omap_bandgap_readl(bg_ptr, reg);
 	temp &= tsr->bgap_dtemp_mask;
 
-	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-		ctrl &= ~tsr->mask_freeze_mask;
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
-	}
+	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT))
+		RMW_BITS(bg_ptr, id, bgap_mask_ctrl, mask_freeze_mask, 0);
 
 	return temp;
 }
@@ -290,37 +289,6 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	return temp_sensor_unmask_interrupts(bg_ptr, id, t_hot, cold);
 }
 
-/* Talert Thot and Tcold thresholds. Call it only if HAS(TALERT) is set */
-static
-int temp_sensor_init_talert_thresholds(struct omap_bandgap *bg_ptr, int id,
-				       int t_hot, int t_cold)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val, thresh_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-
-	/* write the new t_cold value */
-	reg_val = thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-
-	/* write the new t_hot value */
-	reg_val = thresh_val & ~tsr->threshold_thot_mask;
-	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-	reg_val |= tsr->mask_hot_mask;
-	reg_val |= tsr->mask_cold_mask;
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
-
-	return 0;
-}
-
 /* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
 static
 int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
@@ -359,54 +327,6 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 	return temp_sensor_unmask_interrupts(bg_ptr, id, hot, t_cold);
 }
 
-/* This is Tshut Thot config. Call it only if HAS(TSHUT_CONFIG) is set */
-static int temp_sensor_configure_tshut_hot(struct omap_bandgap *bg_ptr,
-					   int id, int tshut_hot)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
-	reg_val &= ~tsr->tshut_hot_mask;
-	reg_val |= tshut_hot << __ffs(tsr->tshut_hot_mask);
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
-
-	return 0;
-}
-
-/* This is Tshut Tcold config. Call it only if HAS(TSHUT_CONFIG) is set */
-static int temp_sensor_configure_tshut_cold(struct omap_bandgap *bg_ptr,
-					    int id, int tshut_cold)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
-	reg_val &= ~tsr->tshut_cold_mask;
-	reg_val |= tshut_cold << __ffs(tsr->tshut_cold_mask);
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
-
-	return 0;
-}
-
-/* This is counter config. Call it only if HAS(COUNTER) is set */
-static int configure_temp_sensor_counter(struct omap_bandgap *bg_ptr, int id,
-					 u32 counter)
-{
-	struct temp_sensor_registers *tsr;
-	u32 val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
-	val &= ~tsr->counter_mask;
-	val |= counter << __ffs(tsr->counter_mask);
-	omap_bandgap_writel(bg_ptr, val, tsr->bgap_counter);
-
-	return 0;
-}
-
 #define bandgap_is_valid(b)						\
 			(!IS_ERR_OR_NULL(b))
 #define bandgap_is_valid_sensor_id(b, i)				\
@@ -628,7 +548,7 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 
 	interval = interval * bg_ptr->clk_rate / 1000;
 	mutex_lock(&bg_ptr->bg_mutex);
-	configure_temp_sensor_counter(bg_ptr, id, interval);
+	RMW_BITS(bg_ptr, id, bgap_counter, counter_mask, interval);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
 	return 0;
@@ -645,7 +565,6 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 				  int *temperature)
 {
-	struct temp_sensor_registers *tsr;
 	u32 temp;
 	int ret;
 
@@ -653,7 +572,6 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	if (ret)
 		return ret;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
 	mutex_lock(&bg_ptr->bg_mutex);
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
@@ -708,31 +626,23 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-	struct temp_sensor_registers *tsr;
 	u32 temp = 0, counter = 1000;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
 	/* Select single conversion mode */
-	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG)) {
-		temp = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
-		temp &= ~(1 << __ffs(tsr->mode_ctrl_mask));
-		omap_bandgap_writel(bg_ptr, temp, tsr->bgap_mode_ctrl);
-	}
+	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+		RMW_BITS(bg_ptr, id, bgap_mode_ctrl, mode_ctrl_mask, 0);
 
 	/* Start of Conversion = 1 */
-	temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-	temp |= 1 << __ffs(tsr->bgap_soc_mask);
-	omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+	RMW_BITS(bg_ptr, id, temp_sensor_ctrl, bgap_soc_mask, 1);
 	/* Wait until DTEMP is updated */
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 
 	while ((temp == 0) && --counter)
 		temp = omap_bandgap_read_temp(bg_ptr, id);
+	/* REVISIT: Check correct condition for end of conversion */
 
 	/* Start of Conversion = 0 */
-	temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-	temp &= ~(1 << __ffs(tsr->bgap_soc_mask));
-	omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+	RMW_BITS(bg_ptr, id, temp_sensor_ctrl, bgap_soc_mask, 0);
 
 	return 0;
 }
@@ -745,17 +655,12 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
  */
 static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
 {
-	struct temp_sensor_registers *tsr;
 	int i;
-	u32 val;
 
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		/* Perform a single read just before enabling continuous */
 		omap_bandgap_force_single_read(bg_ptr, i);
-		tsr = bg_ptr->conf->sensors[i].registers;
-		val = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
-		val |= 1 << __ffs(tsr->mode_ctrl_mask);
-		omap_bandgap_writel(bg_ptr, val, tsr->bgap_mode_ctrl);
+		RMW_BITS(bg_ptr, i, bgap_mode_ctrl, mode_ctrl_mask, 1);
 	}
 
 	return 0;
@@ -955,22 +860,31 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	/* Set default counter to 1 for now */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 		for (i = 0; i < bg_ptr->conf->sensor_count; i++)
-			configure_temp_sensor_counter(bg_ptr, i, 1);
+			RMW_BITS(bg_ptr, i, bgap_counter, counter_mask, 1);
 
+	/* Set default thresholds for alert and shutdown */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		struct temp_sensor_data *ts_data;
 
 		ts_data = bg_ptr->conf->sensors[i].ts_data;
 
-		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-			temp_sensor_init_talert_thresholds(bg_ptr, i,
-							   ts_data->t_hot,
-							   ts_data->t_cold);
+		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+			/* Set initial Talert thresholds */
+			RMW_BITS(bg_ptr, i, bgap_threshold,
+				 threshold_tcold_mask, ts_data->t_cold);
+			RMW_BITS(bg_ptr, i, bgap_threshold,
+				 threshold_thot_mask, ts_data->t_hot);
+			/* Enable the alert events */
+			RMW_BITS(bg_ptr, i, bgap_mask_ctrl, mask_hot_mask, 1);
+			RMW_BITS(bg_ptr, i, bgap_mask_ctrl, mask_cold_mask, 1);
+		}
+
 		if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG)) {
-			temp_sensor_configure_tshut_hot(bg_ptr, i,
-							ts_data->tshut_hot);
-			temp_sensor_configure_tshut_cold(bg_ptr, i,
-							 ts_data->tshut_cold);
+			/* Set initial Tshut thresholds */
+			RMW_BITS(bg_ptr, i, tshut_threshold,
+				 tshut_hot_mask, ts_data->tshut_hot);
+			RMW_BITS(bg_ptr, i, tshut_threshold,
+				 tshut_cold_mask, ts_data->tshut_cold);
 		}
 	}
 
@@ -980,8 +894,8 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	/* Set .250 seconds time as default counter */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 		for (i = 0; i < bg_ptr->conf->sensor_count; i++)
-			configure_temp_sensor_counter(bg_ptr, i,
-						      bg_ptr->clk_rate / 4);
+			RMW_BITS(bg_ptr, i, bgap_counter, counter_mask,
+				 bg_ptr->clk_rate / 4);
 
 	/* Every thing is good? Then expose the sensors */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch introduce a macro to read, update, write bitfields.
It will be specific to bandgap data structures.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 9f2d7cc..1c1b905 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -52,25 +52,29 @@ static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
 	writel(val, bg_ptr->base + reg);
 }
 
+/* update bits, value will be shifted */
+#define RMW_BITS(bg_ptr, id, reg, mask, val)			\
+do {								\
+	struct temp_sensor_registers *t;			\
+	u32 r;							\
+								\
+	t = bg_ptr->conf->sensors[(id)].registers;		\
+	r = omap_bandgap_readl(bg_ptr, t->reg);			\
+	r &= ~t->mask;						\
+	r |= (val) << __ffs(t->mask);				\
+	omap_bandgap_writel(bg_ptr, r, t->reg);			\
+} while (0)
+
 static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 {
-	struct temp_sensor_registers *tsr;
 	int i;
-	u32 ctrl;
 
 	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
 		return 0;
 
-	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
-		tsr = bg_ptr->conf->sensors[i].registers;
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-		ctrl &= ~tsr->bgap_tempsoff_mask;
+	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
 		/* active on 0 */
-		ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
-
-		/* write BGAP_TEMPSOFF should be reset to 0 */
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
-	}
+		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
 
 	return 0;
 }
@@ -78,15 +82,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 {
 	struct temp_sensor_registers *tsr;
-	u32 temp, ctrl, reg;
+	u32 temp, reg;
 
 	tsr = bg_ptr->conf->sensors[id].registers;
 	reg = tsr->temp_sensor_ctrl;
 
 	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-		ctrl |= tsr->mask_freeze_mask;
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
+		RMW_BITS(bg_ptr, id, bgap_mask_ctrl, mask_freeze_mask, 1);
 		/*
 		 * In case we cannot read from cur_dtemp / dtemp_0,
 		 * then we read from the last valid temp read
@@ -98,11 +100,8 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	temp = omap_bandgap_readl(bg_ptr, reg);
 	temp &= tsr->bgap_dtemp_mask;
 
-	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT)) {
-		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-		ctrl &= ~tsr->mask_freeze_mask;
-		omap_bandgap_writel(bg_ptr, ctrl, tsr->bgap_mask_ctrl);
-	}
+	if (OMAP_BANDGAP_HAS(bg_ptr, FREEZE_BIT))
+		RMW_BITS(bg_ptr, id, bgap_mask_ctrl, mask_freeze_mask, 0);
 
 	return temp;
 }
@@ -290,37 +289,6 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	return temp_sensor_unmask_interrupts(bg_ptr, id, t_hot, cold);
 }
 
-/* Talert Thot and Tcold thresholds. Call it only if HAS(TALERT) is set */
-static
-int temp_sensor_init_talert_thresholds(struct omap_bandgap *bg_ptr, int id,
-				       int t_hot, int t_cold)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val, thresh_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-
-	/* write the new t_cold value */
-	reg_val = thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-
-	/* write the new t_hot value */
-	reg_val = thresh_val & ~tsr->threshold_thot_mask;
-	reg_val |= (t_hot << __ffs(tsr->threshold_thot_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->bgap_mask_ctrl);
-	reg_val |= tsr->mask_hot_mask;
-	reg_val |= tsr->mask_cold_mask;
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
-
-	return 0;
-}
-
 /* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
 static
 int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
@@ -359,54 +327,6 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 	return temp_sensor_unmask_interrupts(bg_ptr, id, hot, t_cold);
 }
 
-/* This is Tshut Thot config. Call it only if HAS(TSHUT_CONFIG) is set */
-static int temp_sensor_configure_tshut_hot(struct omap_bandgap *bg_ptr,
-					   int id, int tshut_hot)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
-	reg_val &= ~tsr->tshut_hot_mask;
-	reg_val |= tshut_hot << __ffs(tsr->tshut_hot_mask);
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
-
-	return 0;
-}
-
-/* This is Tshut Tcold config. Call it only if HAS(TSHUT_CONFIG) is set */
-static int temp_sensor_configure_tshut_cold(struct omap_bandgap *bg_ptr,
-					    int id, int tshut_cold)
-{
-	struct temp_sensor_registers *tsr;
-	u32 reg_val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	reg_val = omap_bandgap_readl(bg_ptr, tsr->tshut_threshold);
-	reg_val &= ~tsr->tshut_cold_mask;
-	reg_val |= tshut_cold << __ffs(tsr->tshut_cold_mask);
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->tshut_threshold);
-
-	return 0;
-}
-
-/* This is counter config. Call it only if HAS(COUNTER) is set */
-static int configure_temp_sensor_counter(struct omap_bandgap *bg_ptr, int id,
-					 u32 counter)
-{
-	struct temp_sensor_registers *tsr;
-	u32 val;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	val = omap_bandgap_readl(bg_ptr, tsr->bgap_counter);
-	val &= ~tsr->counter_mask;
-	val |= counter << __ffs(tsr->counter_mask);
-	omap_bandgap_writel(bg_ptr, val, tsr->bgap_counter);
-
-	return 0;
-}
-
 #define bandgap_is_valid(b)						\
 			(!IS_ERR_OR_NULL(b))
 #define bandgap_is_valid_sensor_id(b, i)				\
@@ -628,7 +548,7 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 
 	interval = interval * bg_ptr->clk_rate / 1000;
 	mutex_lock(&bg_ptr->bg_mutex);
-	configure_temp_sensor_counter(bg_ptr, id, interval);
+	RMW_BITS(bg_ptr, id, bgap_counter, counter_mask, interval);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
 	return 0;
@@ -645,7 +565,6 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 				  int *temperature)
 {
-	struct temp_sensor_registers *tsr;
 	u32 temp;
 	int ret;
 
@@ -653,7 +572,6 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	if (ret)
 		return ret;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
 	mutex_lock(&bg_ptr->bg_mutex);
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
@@ -708,31 +626,23 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-	struct temp_sensor_registers *tsr;
 	u32 temp = 0, counter = 1000;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
 	/* Select single conversion mode */
-	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG)) {
-		temp = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
-		temp &= ~(1 << __ffs(tsr->mode_ctrl_mask));
-		omap_bandgap_writel(bg_ptr, temp, tsr->bgap_mode_ctrl);
-	}
+	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
+		RMW_BITS(bg_ptr, id, bgap_mode_ctrl, mode_ctrl_mask, 0);
 
 	/* Start of Conversion = 1 */
-	temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-	temp |= 1 << __ffs(tsr->bgap_soc_mask);
-	omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+	RMW_BITS(bg_ptr, id, temp_sensor_ctrl, bgap_soc_mask, 1);
 	/* Wait until DTEMP is updated */
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 
 	while ((temp == 0) && --counter)
 		temp = omap_bandgap_read_temp(bg_ptr, id);
+	/* REVISIT: Check correct condition for end of conversion */
 
 	/* Start of Conversion = 0 */
-	temp = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
-	temp &= ~(1 << __ffs(tsr->bgap_soc_mask));
-	omap_bandgap_writel(bg_ptr, temp, tsr->temp_sensor_ctrl);
+	RMW_BITS(bg_ptr, id, temp_sensor_ctrl, bgap_soc_mask, 0);
 
 	return 0;
 }
@@ -745,17 +655,12 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
  */
 static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
 {
-	struct temp_sensor_registers *tsr;
 	int i;
-	u32 val;
 
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		/* Perform a single read just before enabling continuous */
 		omap_bandgap_force_single_read(bg_ptr, i);
-		tsr = bg_ptr->conf->sensors[i].registers;
-		val = omap_bandgap_readl(bg_ptr, tsr->bgap_mode_ctrl);
-		val |= 1 << __ffs(tsr->mode_ctrl_mask);
-		omap_bandgap_writel(bg_ptr, val, tsr->bgap_mode_ctrl);
+		RMW_BITS(bg_ptr, i, bgap_mode_ctrl, mode_ctrl_mask, 1);
 	}
 
 	return 0;
@@ -955,22 +860,31 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	/* Set default counter to 1 for now */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 		for (i = 0; i < bg_ptr->conf->sensor_count; i++)
-			configure_temp_sensor_counter(bg_ptr, i, 1);
+			RMW_BITS(bg_ptr, i, bgap_counter, counter_mask, 1);
 
+	/* Set default thresholds for alert and shutdown */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		struct temp_sensor_data *ts_data;
 
 		ts_data = bg_ptr->conf->sensors[i].ts_data;
 
-		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-			temp_sensor_init_talert_thresholds(bg_ptr, i,
-							   ts_data->t_hot,
-							   ts_data->t_cold);
+		if (OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+			/* Set initial Talert thresholds */
+			RMW_BITS(bg_ptr, i, bgap_threshold,
+				 threshold_tcold_mask, ts_data->t_cold);
+			RMW_BITS(bg_ptr, i, bgap_threshold,
+				 threshold_thot_mask, ts_data->t_hot);
+			/* Enable the alert events */
+			RMW_BITS(bg_ptr, i, bgap_mask_ctrl, mask_hot_mask, 1);
+			RMW_BITS(bg_ptr, i, bgap_mask_ctrl, mask_cold_mask, 1);
+		}
+
 		if (OMAP_BANDGAP_HAS(bg_ptr, TSHUT_CONFIG)) {
-			temp_sensor_configure_tshut_hot(bg_ptr, i,
-							ts_data->tshut_hot);
-			temp_sensor_configure_tshut_cold(bg_ptr, i,
-							 ts_data->tshut_cold);
+			/* Set initial Tshut thresholds */
+			RMW_BITS(bg_ptr, i, tshut_threshold,
+				 tshut_hot_mask, ts_data->tshut_hot);
+			RMW_BITS(bg_ptr, i, tshut_threshold,
+				 tshut_cold_mask, ts_data->tshut_cold);
 		}
 	}
 
@@ -980,8 +894,8 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	/* Set .250 seconds time as default counter */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
 		for (i = 0; i < bg_ptr->conf->sensor_count; i++)
-			configure_temp_sensor_counter(bg_ptr, i,
-						      bg_ptr->clk_rate / 4);
+			RMW_BITS(bg_ptr, i, bgap_counter, counter_mask,
+				 bg_ptr->clk_rate / 4);
 
 	/* Every thing is good? Then expose the sensors */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 08/50] staging: omap-thermal: add documentation for register access functions
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper functions that manipulates registers and their
bitfields. All of them work based of the io mapped area.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 1c1b905..a8d63a2 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -42,17 +42,38 @@
 
 #include "omap-bandgap.h"
 
+/**
+ * omap_bandgap_readl() - simple read helper function
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Helper function to read bandgap registers. It uses the io remapped area.
+ * Returns the register value.
+ */
 static u32 omap_bandgap_readl(struct omap_bandgap *bg_ptr, u32 reg)
 {
 	return readl(bg_ptr->base + reg);
 }
 
+/**
+ * omap_bandgap_writel() - simple write helper function
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @val: desired register value to be written
+ * @reg: desired register (offset) to be written
+ *
+ * Helper function to write bandgap registers. It uses the io remapped area.
+ */
 static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
 {
 	writel(val, bg_ptr->base + reg);
 }
 
-/* update bits, value will be shifted */
+/**
+ * DOC: macro to update bits.
+ *
+ * RMW_BITS() - used to read, modify and update bandgap bitfields.
+ *            The value passed will be shifted.
+ */
 #define RMW_BITS(bg_ptr, id, reg, mask, val)			\
 do {								\
 	struct temp_sensor_registers *t;			\
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 08/50] staging: omap-thermal: add documentation for register access functions
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper functions that manipulates registers and their
bitfields. All of them work based of the io mapped area.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 1c1b905..a8d63a2 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -42,17 +42,38 @@
 
 #include "omap-bandgap.h"
 
+/**
+ * omap_bandgap_readl() - simple read helper function
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @reg: desired register (offset) to be read
+ *
+ * Helper function to read bandgap registers. It uses the io remapped area.
+ * Returns the register value.
+ */
 static u32 omap_bandgap_readl(struct omap_bandgap *bg_ptr, u32 reg)
 {
 	return readl(bg_ptr->base + reg);
 }
 
+/**
+ * omap_bandgap_writel() - simple write helper function
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @val: desired register value to be written
+ * @reg: desired register (offset) to be written
+ *
+ * Helper function to write bandgap registers. It uses the io remapped area.
+ */
 static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
 {
 	writel(val, bg_ptr->base + reg);
 }
 
-/* update bits, value will be shifted */
+/**
+ * DOC: macro to update bits.
+ *
+ * RMW_BITS() - used to read, modify and update bandgap bitfields.
+ *            The value passed will be shifted.
+ */
 #define RMW_BITS(bg_ptr, id, reg, mask, val)			\
 do {								\
 	struct temp_sensor_registers *t;			\
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Change the way the omap_bandgap_power is written so that it has only
one exit entry (Documentation/CodingStyle).

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index a8d63a2..ec79ec1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -91,12 +91,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 	int i;
 
 	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
-		return 0;
+		goto exit;
 
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
 		/* active on 0 */
 		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
 
+exit:
 	return 0;
 }
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Change the way the omap_bandgap_power is written so that it has only
one exit entry (Documentation/CodingStyle).

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index a8d63a2..ec79ec1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -91,12 +91,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 	int i;
 
 	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
-		return 0;
+		goto exit;
 
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
 		/* active on 0 */
 		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
 
+exit:
 	return 0;
 }
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 10/50] staging: omap-thermal: add documentation for omap_bandgap_power
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper function to turn a bandgap device on and off.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index ec79ec1..62a5fb9 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -86,6 +86,14 @@ do {								\
 	omap_bandgap_writel(bg_ptr, r, t->reg);			\
 } while (0)
 
+/**
+ * omap_bandgap_power() - controls the power state of a bandgap device
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @on: desired power state (1 - on, 0 - off)
+ *
+ * Used to power on/off a bandgap device instance. Only used on those
+ * that features tempsoff bit.
+ */
 static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 {
 	int i;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 10/50] staging: omap-thermal: add documentation for omap_bandgap_power
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper function to turn a bandgap device on and off.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index ec79ec1..62a5fb9 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -86,6 +86,14 @@ do {								\
 	omap_bandgap_writel(bg_ptr, r, t->reg);			\
 } while (0)
 
+/**
+ * omap_bandgap_power() - controls the power state of a bandgap device
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @on: desired power state (1 - on, 0 - off)
+ *
+ * Used to power on/off a bandgap device instance. Only used on those
+ * that features tempsoff bit.
+ */
 static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
 {
 	int i;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 11/50] staging: omap-thermal: add documentation for omap_bandgap_read_temp
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 12:59   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function which reads temperature register, depending on
bandgap device version.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 62a5fb9..02817b5 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -109,6 +109,16 @@ exit:
 	return 0;
 }
 
+/**
+ * omap_bandgap_read_temp() - helper function to read sensor temperature
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @id: bandgap sensor id
+ *
+ * Function to concentrate the steps to read sensor temperature register.
+ * This function is desired because, depending on bandgap device version,
+ * it might be needed to freeze the bandgap state machine, before fetching
+ * the register value.
+ */
 static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 {
 	struct temp_sensor_registers *tsr;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 11/50] staging: omap-thermal: add documentation for omap_bandgap_read_temp
@ 2013-03-15 12:59   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 12:59 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function which reads temperature register, depending on
bandgap device version.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 62a5fb9..02817b5 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -109,6 +109,16 @@ exit:
 	return 0;
 }
 
+/**
+ * omap_bandgap_read_temp() - helper function to read sensor temperature
+ * @bg_ptr: pointer to omap_bandgap structure
+ * @id: bandgap sensor id
+ *
+ * Function to concentrate the steps to read sensor temperature register.
+ * This function is desired because, depending on bandgap device version,
+ * it might be needed to freeze the bandgap state machine, before fetching
+ * the register value.
+ */
 static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 {
 	struct temp_sensor_registers *tsr;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 12/50] staging: omap-thermal: rename talert handler
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Simple rename to cope with file naming pattern.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 02817b5..1906ef1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -147,7 +147,7 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 }
 
 /* This is the Talert handler. Call it only if HAS(TALERT) is set */
-static irqreturn_t talert_irq_handler(int irq, void *data)
+static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 {
 	struct omap_bandgap *bg_ptr = data;
 	struct temp_sensor_registers *tsr;
@@ -750,7 +750,7 @@ static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 		return bg_ptr->irq;
 	}
 	ret = request_threaded_irq(bg_ptr->irq, NULL,
-				   talert_irq_handler,
+				   omap_bandgap_talert_irq_handler,
 				   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 				   "talert", bg_ptr);
 	if (ret) {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 12/50] staging: omap-thermal: rename talert handler
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Simple rename to cope with file naming pattern.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 02817b5..1906ef1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -147,7 +147,7 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 }
 
 /* This is the Talert handler. Call it only if HAS(TALERT) is set */
-static irqreturn_t talert_irq_handler(int irq, void *data)
+static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 {
 	struct omap_bandgap *bg_ptr = data;
 	struct temp_sensor_registers *tsr;
@@ -750,7 +750,7 @@ static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 		return bg_ptr->irq;
 	}
 	ret = request_threaded_irq(bg_ptr->irq, NULL,
-				   talert_irq_handler,
+				   omap_bandgap_talert_irq_handler,
 				   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
 				   "talert", bg_ptr);
 	if (ret) {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 13/50] staging: omap-thermal: update documentation for talert irq handler
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the Talert IRQ handler.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 1906ef1..aa60b7b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -146,7 +146,17 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	return temp;
 }
 
-/* This is the Talert handler. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_talert_irq_handler() - handles Temperature alert IRQs
+ * @irq: IRQ number
+ * @data: private data (struct omap_bandgap *)
+ *
+ * This is the Talert handler. Use it only if bandgap device features
+ * HAS(TALERT). This handler goes over all sensors and checks their
+ * conditions and acts accordingly. In case there are events pending,
+ * it will reset the event mask to wait for the opposite event (next event).
+ * Every time there is a new event, it will be reported to thermal layer.
+ */
 static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 {
 	struct omap_bandgap *bg_ptr = data;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 13/50] staging: omap-thermal: update documentation for talert irq handler
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the Talert IRQ handler.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 1906ef1..aa60b7b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -146,7 +146,17 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	return temp;
 }
 
-/* This is the Talert handler. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_talert_irq_handler() - handles Temperature alert IRQs
+ * @irq: IRQ number
+ * @data: private data (struct omap_bandgap *)
+ *
+ * This is the Talert handler. Use it only if bandgap device features
+ * HAS(TALERT). This handler goes over all sensors and checks their
+ * conditions and acts accordingly. In case there are events pending,
+ * it will reset the event mask to wait for the opposite event (next event).
+ * Every time there is a new event, it will be reported to thermal layer.
+ */
 static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 {
 	struct omap_bandgap *bg_ptr = data;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 14/50] staging: omap-thermal: update tshut IRQ handler documentation
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Documents tshut handler better.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index aa60b7b..d0db361 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -207,7 +207,15 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-/* This is the Tshut handler. Call it only if HAS(TSHUT) is set */
+/**
+ * omap_bandgap_tshut_irq_handler() - handles Temperature shutdown signal
+ * @irq: IRQ number
+ * @data: private data (unused)
+ *
+ * This is the Tshut handler. Use it only if bandgap device features
+ * HAS(TSHUT). If any sensor fires the Tshut signal, we simply shutdown
+ * the system.
+ */
 static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 {
 	pr_emerg("%s: TSHUT temperature reached. Needs shut down...\n",
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 14/50] staging: omap-thermal: update tshut IRQ handler documentation
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Documents tshut handler better.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index aa60b7b..d0db361 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -207,7 +207,15 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
-/* This is the Tshut handler. Call it only if HAS(TSHUT) is set */
+/**
+ * omap_bandgap_tshut_irq_handler() - handles Temperature shutdown signal
+ * @irq: IRQ number
+ * @data: private data (unused)
+ *
+ * This is the Tshut handler. Use it only if bandgap device features
+ * HAS(TSHUT). If any sensor fires the Tshut signal, we simply shutdown
+ * the system.
+ */
 static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 {
 	pr_emerg("%s: TSHUT temperature reached. Needs shut down...\n",
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 15/50] staging: omap-thermal: remove duplicated code
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

There is no need to assign twice the same variable with the very same value.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d0db361..531e853 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -164,7 +164,6 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
-	bg_ptr = data;
 	/* Read the status of t_hot */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 15/50] staging: omap-thermal: remove duplicated code
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

There is no need to assign twice the same variable with the very same value.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d0db361..531e853 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -164,7 +164,6 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
-	bg_ptr = data;
 	/* Read the status of t_hot */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 16/50] staging: omap-thermal: read status only once inside alert IRQ
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

There is no need to re-read status register.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 531e853..fce3942 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -164,15 +164,15 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
-	/* Read the status of t_hot */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
-		t_hot = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
-		t_hot &= tsr->status_hot_mask;
+		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
+
+		/* Read the status of t_hot */
+		t_hot = ctrl & tsr->status_hot_mask;
 
 		/* Read the status of t_cold */
-		t_cold = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
-		t_cold &= tsr->status_cold_mask;
+		t_cold = ctrl & tsr->status_cold_mask;
 
 		if (!t_cold && !t_hot)
 			continue;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 16/50] staging: omap-thermal: read status only once inside alert IRQ
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

There is no need to re-read status register.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 531e853..fce3942 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -164,15 +164,15 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
-	/* Read the status of t_hot */
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
-		t_hot = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
-		t_hot &= tsr->status_hot_mask;
+		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
+
+		/* Read the status of t_hot */
+		t_hot = ctrl & tsr->status_hot_mask;
 
 		/* Read the status of t_cold */
-		t_cold = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
-		t_cold &= tsr->status_cold_mask;
+		t_cold = ctrl & tsr->status_cold_mask;
 
 		if (!t_cold && !t_hot)
 			continue;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 17/50] staging: omap-thermal: add a section of register manipulation
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This is introduces a series of marks inside the code to
better organize functions per group, aggregating their
functionality.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index fce3942..77ff495 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -42,6 +42,8 @@
 
 #include "omap-bandgap.h"
 
+/***   Helper functions to access registers and their bitfields   ***/
+
 /**
  * omap_bandgap_readl() - simple read helper function
  * @bg_ptr: pointer to omap_bandgap structure
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 17/50] staging: omap-thermal: add a section of register manipulation
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This is introduces a series of marks inside the code to
better organize functions per group, aggregating their
functionality.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index fce3942..77ff495 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -42,6 +42,8 @@
 
 #include "omap-bandgap.h"
 
+/***   Helper functions to access registers and their bitfields   ***/
+
 /**
  * omap_bandgap_readl() - simple read helper function
  * @bg_ptr: pointer to omap_bandgap structure
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 18/50] staging: omap-thermal: section of basic helpers
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Group of simple functions aggregating basic functionality.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 77ff495..7927c59 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -88,6 +88,8 @@ do {								\
 	omap_bandgap_writel(bg_ptr, r, t->reg);			\
 } while (0)
 
+/***   Basic helper functions   ***/
+
 /**
  * omap_bandgap_power() - controls the power state of a bandgap device
  * @bg_ptr: pointer to omap_bandgap structure
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 18/50] staging: omap-thermal: section of basic helpers
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Group of simple functions aggregating basic functionality.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 77ff495..7927c59 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -88,6 +88,8 @@ do {								\
 	omap_bandgap_writel(bg_ptr, r, t->reg);			\
 } while (0)
 
+/***   Basic helper functions   ***/
+
 /**
  * omap_bandgap_power() - controls the power state of a bandgap device
  * @bg_ptr: pointer to omap_bandgap structure
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 19/50] staging: omap-thermal: IRQ handler section
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of IRQ handlers

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 7927c59..ded2c8c 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -150,6 +150,8 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	return temp;
 }
 
+/***   IRQ handlers   ***/
+
 /**
  * omap_bandgap_talert_irq_handler() - handles Temperature alert IRQs
  * @irq: IRQ number
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 19/50] staging: omap-thermal: IRQ handler section
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of IRQ handlers

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 7927c59..ded2c8c 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -150,6 +150,8 @@ static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
 	return temp;
 }
 
+/***   IRQ handlers   ***/
+
 /**
  * omap_bandgap_talert_irq_handler() - handles Temperature alert IRQs
  * @irq: IRQ number
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 20/50] staging: omap-thermal: ADC section
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of ADC helpers functions

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index ded2c8c..2acd30e 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -231,6 +231,8 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+/***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
+
 static
 int adc_to_temp_conversion(struct omap_bandgap *bg_ptr, int id, int adc_val,
 			   int *t)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 20/50] staging: omap-thermal: ADC section
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of ADC helpers functions

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index ded2c8c..2acd30e 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -231,6 +231,8 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 	return IRQ_HANDLED;
 }
 
+/***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
+
 static
 int adc_to_temp_conversion(struct omap_bandgap *bg_ptr, int id, int adc_val,
 			   int *t)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 21/50] staging: omap-thermal: name adc_to_temp_conversion in a better way
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Rename adc_to_temp_conversion to omap_bandgap_adc_to_mcelsius. This name,
though longer, describes better the function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 2acd30e..a7fd3e8 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -234,8 +234,8 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 /***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
 
 static
-int adc_to_temp_conversion(struct omap_bandgap *bg_ptr, int id, int adc_val,
-			   int *t)
+int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
+				 int adc_val, int *t)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
 
@@ -308,7 +308,7 @@ int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
 {
 	int temp, ret;
 
-	ret = adc_to_temp_conversion(bg_ptr, i, adc_val, &temp);
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, i, adc_val, &temp);
 	if (ret < 0)
 		return ret;
 
@@ -439,7 +439,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_thot_mask) >>
 		__ffs(tsr->threshold_thot_mask);
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
 		return -EIO;
@@ -514,7 +514,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_tcold_mask)
 	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret)
 		return -EIO;
 
@@ -641,7 +641,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret)
 		return -EIO;
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 21/50] staging: omap-thermal: name adc_to_temp_conversion in a better way
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Rename adc_to_temp_conversion to omap_bandgap_adc_to_mcelsius. This name,
though longer, describes better the function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 2acd30e..a7fd3e8 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -234,8 +234,8 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 /***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
 
 static
-int adc_to_temp_conversion(struct omap_bandgap *bg_ptr, int id, int adc_val,
-			   int *t)
+int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
+				 int adc_val, int *t)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
 
@@ -308,7 +308,7 @@ int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
 {
 	int temp, ret;
 
-	ret = adc_to_temp_conversion(bg_ptr, i, adc_val, &temp);
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, i, adc_val, &temp);
 	if (ret < 0)
 		return ret;
 
@@ -439,7 +439,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_thot_mask) >>
 		__ffs(tsr->threshold_thot_mask);
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
 		return -EIO;
@@ -514,7 +514,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_tcold_mask)
 	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret)
 		return -EIO;
 
@@ -641,7 +641,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
-	ret |= adc_to_temp_conversion(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
 	if (ret)
 		return -EIO;
 
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 22/50] staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel coding style
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Follow Documentation/CodingStyle while doing  omap_bandgap_adc_to_mcelsius.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index a7fd3e8..0068c66 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -238,14 +238,19 @@ int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
 				 int adc_val, int *t)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+	int ret = 0;
 
 	/* look up for temperature in the table and return the temperature */
-	if (adc_val < ts_data->adc_start_val || adc_val > ts_data->adc_end_val)
-		return -ERANGE;
+	if (adc_val < ts_data->adc_start_val ||
+	    adc_val > ts_data->adc_end_val) {
+		ret = -ERANGE;
+		goto exit;
+	}
 
 	*t = bg_ptr->conf->conv_table[adc_val - ts_data->adc_start_val];
 
-	return 0;
+exit:
+	return ret;
 }
 
 static int temp_to_adc_conversion(long temp, struct omap_bandgap *bg_ptr, int i,
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 22/50] staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel coding style
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Follow Documentation/CodingStyle while doing  omap_bandgap_adc_to_mcelsius.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index a7fd3e8..0068c66 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -238,14 +238,19 @@ int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
 				 int adc_val, int *t)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+	int ret = 0;
 
 	/* look up for temperature in the table and return the temperature */
-	if (adc_val < ts_data->adc_start_val || adc_val > ts_data->adc_end_val)
-		return -ERANGE;
+	if (adc_val < ts_data->adc_start_val ||
+	    adc_val > ts_data->adc_end_val) {
+		ret = -ERANGE;
+		goto exit;
+	}
 
 	*t = bg_ptr->conf->conv_table[adc_val - ts_data->adc_start_val];
 
-	return 0;
+exit:
+	return ret;
 }
 
 static int temp_to_adc_conversion(long temp, struct omap_bandgap *bg_ptr, int i,
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 23/50] staging: omap-thermal: add documentation for omap_bandgap_adc_to_mcelsius
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the conversion function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 0068c66..8279cca 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -233,6 +233,17 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 
 /***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
 
+/**
+ * omap_bandgap_adc_to_mcelsius() - converts an ADC value to mCelsius scale
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: sensor id
+ * @adc_val: value in ADC representation
+ * @t: address where to write the resulting temperature in mCelsius
+ *
+ * Simple conversion from ADC representation to mCelsius. In case the ADC value
+ * is out of the ADC conv table range, it returns -ERANGE, 0 on success.
+ * The conversion table is indexed by the ADC values.
+ */
 static
 int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
 				 int adc_val, int *t)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 23/50] staging: omap-thermal: add documentation for omap_bandgap_adc_to_mcelsius
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the conversion function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 0068c66..8279cca 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -233,6 +233,17 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 
 /***   Helper functions which manipulate conversion ADC <-> mi Celsius   ***/
 
+/**
+ * omap_bandgap_adc_to_mcelsius() - converts an ADC value to mCelsius scale
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: sensor id
+ * @adc_val: value in ADC representation
+ * @t: address where to write the resulting temperature in mCelsius
+ *
+ * Simple conversion from ADC representation to mCelsius. In case the ADC value
+ * is out of the ADC conv table range, it returns -ERANGE, 0 on success.
+ * The conversion table is indexed by the ADC values.
+ */
 static
 int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
 				 int adc_val, int *t)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 24/50] staging: omap-thermal: name temp_to_adc_conversion in a better way
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Rename temp_to_adc_conversion to omap_bandgap_mcelsius_to_adc. This name,
though longer, describes better the function.

This patch also changes this function signature so the function follows
the style of this file.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8279cca..d5359e3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -264,8 +264,9 @@ exit:
 	return ret;
 }
 
-static int temp_to_adc_conversion(long temp, struct omap_bandgap *bg_ptr, int i,
-				  int *adc)
+static
+int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
+				 int *adc)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
 	const int *conv_table = bg_ptr->conf->conv_table;
@@ -330,7 +331,7 @@ int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
 
 	temp += hyst_val;
 
-	return temp_to_adc_conversion(temp, bg_ptr, i, sum);
+	return omap_bandgap_mcelsius_to_adc(bg_ptr, i, temp, sum);
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -493,7 +494,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 
 	if (val < ts_data->min_temp + ts_data->hyst_val)
 		return -EINVAL;
-	ret = temp_to_adc_conversion(val, bg_ptr, id, &t_hot);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_hot);
 	if (ret < 0)
 		return ret;
 
@@ -566,7 +567,7 @@ int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 	if (val > ts_data->max_temp + ts_data->hyst_val)
 		return -EINVAL;
 
-	ret = temp_to_adc_conversion(val, bg_ptr, id, &t_cold);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_cold);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 24/50] staging: omap-thermal: name temp_to_adc_conversion in a better way
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Rename temp_to_adc_conversion to omap_bandgap_mcelsius_to_adc. This name,
though longer, describes better the function.

This patch also changes this function signature so the function follows
the style of this file.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8279cca..d5359e3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -264,8 +264,9 @@ exit:
 	return ret;
 }
 
-static int temp_to_adc_conversion(long temp, struct omap_bandgap *bg_ptr, int i,
-				  int *adc)
+static
+int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
+				 int *adc)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
 	const int *conv_table = bg_ptr->conf->conv_table;
@@ -330,7 +331,7 @@ int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
 
 	temp += hyst_val;
 
-	return temp_to_adc_conversion(temp, bg_ptr, i, sum);
+	return omap_bandgap_mcelsius_to_adc(bg_ptr, i, temp, sum);
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -493,7 +494,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 
 	if (val < ts_data->min_temp + ts_data->hyst_val)
 		return -EINVAL;
-	ret = temp_to_adc_conversion(val, bg_ptr, id, &t_hot);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_hot);
 	if (ret < 0)
 		return ret;
 
@@ -566,7 +567,7 @@ int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 	if (val > ts_data->max_temp + ts_data->hyst_val)
 		return -EINVAL;
 
-	ret = temp_to_adc_conversion(val, bg_ptr, id, &t_cold);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_cold);
 	if (ret < 0)
 		return ret;
 
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 25/50] staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel coding style
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Follow Documentation/CodingStyle while doing omap_bandgap_mcelsius_to_adc

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d5359e3..e49a115 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -270,14 +270,16 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
 	const int *conv_table = bg_ptr->conf->conv_table;
-	int high, low, mid;
+	int high, low, mid, ret = 0;
 
 	low = 0;
 	high = ts_data->adc_end_val - ts_data->adc_start_val;
 	mid = (high + low) / 2;
 
-	if (temp < conv_table[low] || temp > conv_table[high])
-		return -EINVAL;
+	if (temp < conv_table[low] || temp > conv_table[high]) {
+		ret = -ERANGE;
+		goto exit;
+	}
 
 	while (low < high) {
 		if (temp < conv_table[mid])
@@ -289,7 +291,8 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 
 	*adc = ts_data->adc_start_val + low;
 
-	return 0;
+exit:
+	return ret;
 }
 
 /* Talert masks. Call it only if HAS(TALERT) is set */
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 25/50] staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel coding style
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Follow Documentation/CodingStyle while doing omap_bandgap_mcelsius_to_adc

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d5359e3..e49a115 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -270,14 +270,16 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
 	const int *conv_table = bg_ptr->conf->conv_table;
-	int high, low, mid;
+	int high, low, mid, ret = 0;
 
 	low = 0;
 	high = ts_data->adc_end_val - ts_data->adc_start_val;
 	mid = (high + low) / 2;
 
-	if (temp < conv_table[low] || temp > conv_table[high])
-		return -EINVAL;
+	if (temp < conv_table[low] || temp > conv_table[high]) {
+		ret = -ERANGE;
+		goto exit;
+	}
 
 	while (low < high) {
 		if (temp < conv_table[mid])
@@ -289,7 +291,8 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 
 	*adc = ts_data->adc_start_val + low;
 
-	return 0;
+exit:
+	return ret;
 }
 
 /* Talert masks. Call it only if HAS(TALERT) is set */
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 26/50] staging: omap-thermal: move conv table limits out of sensor data
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

As we have one conv table per bandgap device and not per sensor,
this patch changes the data structures so that the conv table
min and max values are now part of bandgap_data and not sensor_data.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.c       |   39 +++++++++-----------
 drivers/staging/omap-thermal/omap-bandgap.h       |    8 ++--
 drivers/staging/omap-thermal/omap4-thermal-data.c |   10 +++--
 drivers/staging/omap-thermal/omap5-thermal-data.c |    8 +---
 4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index e49a115..963fcaf 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -236,7 +236,6 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 /**
  * omap_bandgap_adc_to_mcelsius() - converts an ADC value to mCelsius scale
  * @bg_ptr: struct omap_bandgap pointer
- * @id: sensor id
  * @adc_val: value in ADC representation
  * @t: address where to write the resulting temperature in mCelsius
  *
@@ -245,35 +244,34 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
  * The conversion table is indexed by the ADC values.
  */
 static
-int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
+int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr,
 				 int adc_val, int *t)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+	struct omap_bandgap_data *conf = bg_ptr->conf;
 	int ret = 0;
 
 	/* look up for temperature in the table and return the temperature */
-	if (adc_val < ts_data->adc_start_val ||
-	    adc_val > ts_data->adc_end_val) {
+	if (adc_val < conf->adc_start_val || adc_val > conf->adc_end_val) {
 		ret = -ERANGE;
 		goto exit;
 	}
 
-	*t = bg_ptr->conf->conv_table[adc_val - ts_data->adc_start_val];
+	*t = bg_ptr->conf->conv_table[adc_val - conf->adc_start_val];
 
 exit:
 	return ret;
 }
 
 static
-int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
+int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, long temp,
 				 int *adc)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
+	struct omap_bandgap_data *conf = bg_ptr->conf;
 	const int *conv_table = bg_ptr->conf->conv_table;
 	int high, low, mid, ret = 0;
 
 	low = 0;
-	high = ts_data->adc_end_val - ts_data->adc_start_val;
+	high = conf->adc_end_val - conf->adc_start_val;
 	mid = (high + low) / 2;
 
 	if (temp < conv_table[low] || temp > conv_table[high]) {
@@ -289,7 +287,7 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 		mid = (low + high) / 2;
 	}
 
-	*adc = ts_data->adc_start_val + low;
+	*adc = conf->adc_start_val + low;
 
 exit:
 	return ret;
@@ -323,18 +321,17 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 }
 
 static
-int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
-	     u32 *sum)
+int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
 {
 	int temp, ret;
 
-	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, i, adc_val, &temp);
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
 	if (ret < 0)
 		return ret;
 
 	temp += hyst_val;
 
-	return omap_bandgap_mcelsius_to_adc(bg_ptr, i, temp, sum);
+	return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -354,7 +351,7 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	    __ffs(tsr->threshold_tcold_mask);
 	if (t_hot <= cold) {
 		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, id, &cold);
+		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold);
 		/* write the new t_cold value */
 		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
 		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
@@ -392,7 +389,7 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 
 	if (t_cold >= hot) {
 		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, id, &hot);
+		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot);
 		/* write the new t_hot value */
 		reg_val = thresh_val & (~tsr->threshold_thot_mask);
 		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
@@ -459,7 +456,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_thot_mask) >>
 		__ffs(tsr->threshold_thot_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
 		return -EIO;
@@ -497,7 +494,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 
 	if (val < ts_data->min_temp + ts_data->hyst_val)
 		return -EINVAL;
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_hot);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_hot);
 	if (ret < 0)
 		return ret;
 
@@ -534,7 +531,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_tcold_mask)
 	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
 		return -EIO;
 
@@ -570,7 +567,7 @@ int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 	if (val > ts_data->max_temp + ts_data->hyst_val)
 		return -EINVAL;
 
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_cold);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_cold);
 	if (ret < 0)
 		return ret;
 
@@ -661,7 +658,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
 		return -EIO;
 
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 28d9104..edcc965 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -166,8 +166,6 @@ struct temp_sensor_registers {
  * @max_temp: sensor maximum temperature
  * @min_temp: sensor minimum temperature
  * @hyst_val: temperature hysteresis considered while converting ADC values
- * @adc_start_val: ADC conversion table starting value
- * @adc_end_val: ADC conversion table ending value
  * @update_int1: update interval
  * @update_int2: update interval
  *
@@ -185,8 +183,6 @@ struct temp_sensor_data {
 	int     max_temp;
 	int     min_temp;
 	int     hyst_val;
-	u32     adc_start_val;
-	u32     adc_end_val;
 	u32     update_int1; /* not used */
 	u32     update_int2; /* not used */
 };
@@ -325,6 +321,8 @@ struct omap_temp_sensor {
  * struct omap_bandgap_data - omap bandgap data configuration structure
  * @features: a bitwise flag set to describe the device features
  * @conv_table: Pointer to ADC to temperature conversion table
+ * @adc_start_val: ADC conversion table starting value
+ * @adc_end_val: ADC conversion table ending value
  * @fclock_name: clock name of the functional clock
  * @div_ck_name: clock name of the clock divisor
  * @sensor_count: count of temperature sensor within this bandgap device
@@ -342,6 +340,8 @@ struct omap_temp_sensor {
 struct omap_bandgap_data {
 	unsigned int			features;
 	const int			*conv_table;
+	u32				adc_start_val;
+	u32				adc_end_val;
 	char				*fclock_name;
 	char				*div_ck_name;
 	int				sensor_count;
diff --git a/drivers/staging/omap-thermal/omap4-thermal-data.c b/drivers/staging/omap-thermal/omap4-thermal-data.c
index 7ec5570..88ed014 100644
--- a/drivers/staging/omap-thermal/omap4-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap4-thermal-data.c
@@ -45,8 +45,6 @@ static struct temp_sensor_data omap4430_mpu_temp_sensor_data = {
 	.max_temp = OMAP4430_MAX_TEMP,
 	.min_temp = OMAP4430_MIN_TEMP,
 	.hyst_val = OMAP4430_HYST_VAL,
-	.adc_start_val = OMAP4430_ADC_START_VALUE,
-	.adc_end_val = OMAP4430_ADC_END_VALUE,
 };
 
 /*
@@ -75,6 +73,8 @@ const struct omap_bandgap_data omap4430_data = {
 	.fclock_name = "bandgap_fclk",
 	.div_ck_name = "bandgap_fclk",
 	.conv_table = omap4430_adc_to_temp,
+	.adc_start_val = OMAP4430_ADC_START_VALUE,
+	.adc_end_val = OMAP4430_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
@@ -142,8 +142,6 @@ static struct temp_sensor_data omap4460_mpu_temp_sensor_data = {
 	.max_temp = OMAP4460_MAX_TEMP,
 	.min_temp = OMAP4460_MIN_TEMP,
 	.hyst_val = OMAP4460_HYST_VAL,
-	.adc_start_val = OMAP4460_ADC_START_VALUE,
-	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -214,6 +212,8 @@ const struct omap_bandgap_data omap4460_data = {
 	.fclock_name = "bandgap_ts_fclk",
 	.div_ck_name = "div_ts_ck",
 	.conv_table = omap4460_adc_to_temp,
+	.adc_start_val = OMAP4460_ADC_START_VALUE,
+	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
@@ -244,6 +244,8 @@ const struct omap_bandgap_data omap4470_data = {
 	.fclock_name = "bandgap_ts_fclk",
 	.div_ck_name = "div_ts_ck",
 	.conv_table = omap4460_adc_to_temp,
+	.adc_start_val = OMAP4460_ADC_START_VALUE,
+	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
diff --git a/drivers/staging/omap-thermal/omap5-thermal-data.c b/drivers/staging/omap-thermal/omap5-thermal-data.c
index 3d10704..a48c286 100644
--- a/drivers/staging/omap-thermal/omap5-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap5-thermal-data.c
@@ -171,8 +171,6 @@ static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
 	.max_temp = OMAP5430_MPU_MAX_TEMP,
 	.min_temp = OMAP5430_MPU_MIN_TEMP,
 	.hyst_val = OMAP5430_MPU_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -188,8 +186,6 @@ static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
 	.max_temp = OMAP5430_GPU_MAX_TEMP,
 	.min_temp = OMAP5430_GPU_MIN_TEMP,
 	.hyst_val = OMAP5430_GPU_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -205,8 +201,6 @@ static struct temp_sensor_data omap5430_core_temp_sensor_data = {
 	.max_temp = OMAP5430_CORE_MAX_TEMP,
 	.min_temp = OMAP5430_CORE_MIN_TEMP,
 	.hyst_val = OMAP5430_CORE_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -325,6 +319,8 @@ const struct omap_bandgap_data omap5430_data = {
 	.fclock_name = "l3instr_ts_gclk_div",
 	.div_ck_name = "l3instr_ts_gclk_div",
 	.conv_table = omap5430_adc_to_temp,
+	.adc_start_val = OMAP5430_ADC_START_VALUE,
+	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 26/50] staging: omap-thermal: move conv table limits out of sensor data
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

As we have one conv table per bandgap device and not per sensor,
this patch changes the data structures so that the conv table
min and max values are now part of bandgap_data and not sensor_data.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/omap-bandgap.c       |   39 +++++++++-----------
 drivers/staging/omap-thermal/omap-bandgap.h       |    8 ++--
 drivers/staging/omap-thermal/omap4-thermal-data.c |   10 +++--
 drivers/staging/omap-thermal/omap5-thermal-data.c |    8 +---
 4 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index e49a115..963fcaf 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -236,7 +236,6 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
 /**
  * omap_bandgap_adc_to_mcelsius() - converts an ADC value to mCelsius scale
  * @bg_ptr: struct omap_bandgap pointer
- * @id: sensor id
  * @adc_val: value in ADC representation
  * @t: address where to write the resulting temperature in mCelsius
  *
@@ -245,35 +244,34 @@ static irqreturn_t omap_bandgap_tshut_irq_handler(int irq, void *data)
  * The conversion table is indexed by the ADC values.
  */
 static
-int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr, int id,
+int omap_bandgap_adc_to_mcelsius(struct omap_bandgap *bg_ptr,
 				 int adc_val, int *t)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
+	struct omap_bandgap_data *conf = bg_ptr->conf;
 	int ret = 0;
 
 	/* look up for temperature in the table and return the temperature */
-	if (adc_val < ts_data->adc_start_val ||
-	    adc_val > ts_data->adc_end_val) {
+	if (adc_val < conf->adc_start_val || adc_val > conf->adc_end_val) {
 		ret = -ERANGE;
 		goto exit;
 	}
 
-	*t = bg_ptr->conf->conv_table[adc_val - ts_data->adc_start_val];
+	*t = bg_ptr->conf->conv_table[adc_val - conf->adc_start_val];
 
 exit:
 	return ret;
 }
 
 static
-int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
+int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, long temp,
 				 int *adc)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[i].ts_data;
+	struct omap_bandgap_data *conf = bg_ptr->conf;
 	const int *conv_table = bg_ptr->conf->conv_table;
 	int high, low, mid, ret = 0;
 
 	low = 0;
-	high = ts_data->adc_end_val - ts_data->adc_start_val;
+	high = conf->adc_end_val - conf->adc_start_val;
 	mid = (high + low) / 2;
 
 	if (temp < conv_table[low] || temp > conv_table[high]) {
@@ -289,7 +287,7 @@ int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, int i, long temp,
 		mid = (low + high) / 2;
 	}
 
-	*adc = ts_data->adc_start_val + low;
+	*adc = conf->adc_start_val + low;
 
 exit:
 	return ret;
@@ -323,18 +321,17 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 }
 
 static
-int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, int i,
-	     u32 *sum)
+int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
 {
 	int temp, ret;
 
-	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, i, adc_val, &temp);
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
 	if (ret < 0)
 		return ret;
 
 	temp += hyst_val;
 
-	return omap_bandgap_mcelsius_to_adc(bg_ptr, i, temp, sum);
+	return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -354,7 +351,7 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	    __ffs(tsr->threshold_tcold_mask);
 	if (t_hot <= cold) {
 		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, id, &cold);
+		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold);
 		/* write the new t_cold value */
 		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
 		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
@@ -392,7 +389,7 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 
 	if (t_cold >= hot) {
 		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, id, &hot);
+		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot);
 		/* write the new t_hot value */
 		reg_val = thresh_val & (~tsr->threshold_thot_mask);
 		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
@@ -459,7 +456,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_thot_mask) >>
 		__ffs(tsr->threshold_thot_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
 		return -EIO;
@@ -497,7 +494,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 
 	if (val < ts_data->min_temp + ts_data->hyst_val)
 		return -EINVAL;
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_hot);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_hot);
 	if (ret < 0)
 		return ret;
 
@@ -534,7 +531,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
 	temp = (temp & tsr->threshold_tcold_mask)
 	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
 		return -EIO;
 
@@ -570,7 +567,7 @@ int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 	if (val > ts_data->max_temp + ts_data->hyst_val)
 		return -EINVAL;
 
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, id, val, &t_cold);
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_cold);
 	if (ret < 0)
 		return ret;
 
@@ -661,7 +658,7 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	temp = omap_bandgap_read_temp(bg_ptr, id);
 	mutex_unlock(&bg_ptr->bg_mutex);
 
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, id, temp, &temp);
+	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
 		return -EIO;
 
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index 28d9104..edcc965 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -166,8 +166,6 @@ struct temp_sensor_registers {
  * @max_temp: sensor maximum temperature
  * @min_temp: sensor minimum temperature
  * @hyst_val: temperature hysteresis considered while converting ADC values
- * @adc_start_val: ADC conversion table starting value
- * @adc_end_val: ADC conversion table ending value
  * @update_int1: update interval
  * @update_int2: update interval
  *
@@ -185,8 +183,6 @@ struct temp_sensor_data {
 	int     max_temp;
 	int     min_temp;
 	int     hyst_val;
-	u32     adc_start_val;
-	u32     adc_end_val;
 	u32     update_int1; /* not used */
 	u32     update_int2; /* not used */
 };
@@ -325,6 +321,8 @@ struct omap_temp_sensor {
  * struct omap_bandgap_data - omap bandgap data configuration structure
  * @features: a bitwise flag set to describe the device features
  * @conv_table: Pointer to ADC to temperature conversion table
+ * @adc_start_val: ADC conversion table starting value
+ * @adc_end_val: ADC conversion table ending value
  * @fclock_name: clock name of the functional clock
  * @div_ck_name: clock name of the clock divisor
  * @sensor_count: count of temperature sensor within this bandgap device
@@ -342,6 +340,8 @@ struct omap_temp_sensor {
 struct omap_bandgap_data {
 	unsigned int			features;
 	const int			*conv_table;
+	u32				adc_start_val;
+	u32				adc_end_val;
 	char				*fclock_name;
 	char				*div_ck_name;
 	int				sensor_count;
diff --git a/drivers/staging/omap-thermal/omap4-thermal-data.c b/drivers/staging/omap-thermal/omap4-thermal-data.c
index 7ec5570..88ed014 100644
--- a/drivers/staging/omap-thermal/omap4-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap4-thermal-data.c
@@ -45,8 +45,6 @@ static struct temp_sensor_data omap4430_mpu_temp_sensor_data = {
 	.max_temp = OMAP4430_MAX_TEMP,
 	.min_temp = OMAP4430_MIN_TEMP,
 	.hyst_val = OMAP4430_HYST_VAL,
-	.adc_start_val = OMAP4430_ADC_START_VALUE,
-	.adc_end_val = OMAP4430_ADC_END_VALUE,
 };
 
 /*
@@ -75,6 +73,8 @@ const struct omap_bandgap_data omap4430_data = {
 	.fclock_name = "bandgap_fclk",
 	.div_ck_name = "bandgap_fclk",
 	.conv_table = omap4430_adc_to_temp,
+	.adc_start_val = OMAP4430_ADC_START_VALUE,
+	.adc_end_val = OMAP4430_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
@@ -142,8 +142,6 @@ static struct temp_sensor_data omap4460_mpu_temp_sensor_data = {
 	.max_temp = OMAP4460_MAX_TEMP,
 	.min_temp = OMAP4460_MIN_TEMP,
 	.hyst_val = OMAP4460_HYST_VAL,
-	.adc_start_val = OMAP4460_ADC_START_VALUE,
-	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -214,6 +212,8 @@ const struct omap_bandgap_data omap4460_data = {
 	.fclock_name = "bandgap_ts_fclk",
 	.div_ck_name = "div_ts_ck",
 	.conv_table = omap4460_adc_to_temp,
+	.adc_start_val = OMAP4460_ADC_START_VALUE,
+	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
@@ -244,6 +244,8 @@ const struct omap_bandgap_data omap4470_data = {
 	.fclock_name = "bandgap_ts_fclk",
 	.div_ck_name = "div_ts_ck",
 	.conv_table = omap4460_adc_to_temp,
+	.adc_start_val = OMAP4460_ADC_START_VALUE,
+	.adc_end_val = OMAP4460_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
diff --git a/drivers/staging/omap-thermal/omap5-thermal-data.c b/drivers/staging/omap-thermal/omap5-thermal-data.c
index 3d10704..a48c286 100644
--- a/drivers/staging/omap-thermal/omap5-thermal-data.c
+++ b/drivers/staging/omap-thermal/omap5-thermal-data.c
@@ -171,8 +171,6 @@ static struct temp_sensor_data omap5430_mpu_temp_sensor_data = {
 	.max_temp = OMAP5430_MPU_MAX_TEMP,
 	.min_temp = OMAP5430_MPU_MIN_TEMP,
 	.hyst_val = OMAP5430_MPU_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -188,8 +186,6 @@ static struct temp_sensor_data omap5430_gpu_temp_sensor_data = {
 	.max_temp = OMAP5430_GPU_MAX_TEMP,
 	.min_temp = OMAP5430_GPU_MIN_TEMP,
 	.hyst_val = OMAP5430_GPU_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -205,8 +201,6 @@ static struct temp_sensor_data omap5430_core_temp_sensor_data = {
 	.max_temp = OMAP5430_CORE_MAX_TEMP,
 	.min_temp = OMAP5430_CORE_MIN_TEMP,
 	.hyst_val = OMAP5430_CORE_HYST_VAL,
-	.adc_start_val = OMAP5430_ADC_START_VALUE,
-	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.update_int1 = 1000,
 	.update_int2 = 2000,
 };
@@ -325,6 +319,8 @@ const struct omap_bandgap_data omap5430_data = {
 	.fclock_name = "l3instr_ts_gclk_div",
 	.div_ck_name = "l3instr_ts_gclk_div",
 	.conv_table = omap5430_adc_to_temp,
+	.adc_start_val = OMAP5430_ADC_START_VALUE,
+	.adc_end_val = OMAP5430_ADC_END_VALUE,
 	.expose_sensor = omap_thermal_expose_sensor,
 	.remove_sensor = omap_thermal_remove_sensor,
 	.sensors = {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 27/50] staging: omap-thermal: add documentation for omap_bandgap_mcelsius_to_adc
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the conversion function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 963fcaf..39bfe8d 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -262,6 +262,16 @@ exit:
 	return ret;
 }
 
+/**
+ * omap_bandgap_mcelsius_to_adc() - converts a mCelsius value to ADC scale
+ * @bg_ptr: struct omap_bandgap pointer
+ * @temp: value in mCelsius
+ * @adc: address where to write the resulting temperature in ADC representation
+ *
+ * Simple conversion from mCelsius to ADC values. In case the temp value
+ * is out of the ADC conv table range, it returns -ERANGE, 0 on success.
+ * The conversion table is indexed by the ADC values.
+ */
 static
 int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, long temp,
 				 int *adc)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 27/50] staging: omap-thermal: add documentation for omap_bandgap_mcelsius_to_adc
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the conversion function.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 963fcaf..39bfe8d 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -262,6 +262,16 @@ exit:
 	return ret;
 }
 
+/**
+ * omap_bandgap_mcelsius_to_adc() - converts a mCelsius value to ADC scale
+ * @bg_ptr: struct omap_bandgap pointer
+ * @temp: value in mCelsius
+ * @adc: address where to write the resulting temperature in ADC representation
+ *
+ * Simple conversion from mCelsius to ADC values. In case the temp value
+ * is out of the ADC conv table range, it returns -ERANGE, 0 on success.
+ * The conversion table is indexed by the ADC values.
+ */
 static
 int omap_bandgap_mcelsius_to_adc(struct omap_bandgap *bg_ptr, long temp,
 				 int *adc)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 28/50] staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch improves the add_hyst function by:
. Renaming it to omap_bandgap_add_hyst
. Moving it to the ADC conversion functions section
. Changing its signature to follow the driver standard

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 39bfe8d..7b10d18 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -303,6 +303,28 @@ exit:
 	return ret;
 }
 
+static
+int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val,
+			  int hyst_val, u32 *sum)
+{
+	int temp, ret;
+
+	/*
+	 * Need to add in the mcelsius domain, so we have a temperature
+	 * the conv_table range
+	 */
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
+	if (ret < 0)
+		goto exit;
+
+	temp += hyst_val;
+
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
+
+exit:
+	return ret;
+}
+
 /* Talert masks. Call it only if HAS(TALERT) is set */
 static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					 u32 t_hot, u32 t_cold)
@@ -330,20 +352,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	return 0;
 }
 
-static
-int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
-{
-	int temp, ret;
-
-	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
-	if (ret < 0)
-		return ret;
-
-	temp += hyst_val;
-
-	return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
-}
-
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
 static
 int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
@@ -361,7 +369,8 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	    __ffs(tsr->threshold_tcold_mask);
 	if (t_hot <= cold) {
 		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold);
+		err |= omap_bandgap_add_hyst(bg_ptr, t_hot,
+					     -ts_data->hyst_val, &cold);
 		/* write the new t_cold value */
 		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
 		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
@@ -399,7 +408,8 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 
 	if (t_cold >= hot) {
 		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot);
+		err |= omap_bandgap_add_hyst(bg_ptr, t_cold,
+					     ts_data->hyst_val, &hot);
 		/* write the new t_hot value */
 		reg_val = thresh_val & (~tsr->threshold_thot_mask);
 		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 28/50] staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch improves the add_hyst function by:
. Renaming it to omap_bandgap_add_hyst
. Moving it to the ADC conversion functions section
. Changing its signature to follow the driver standard

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 39bfe8d..7b10d18 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -303,6 +303,28 @@ exit:
 	return ret;
 }
 
+static
+int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val,
+			  int hyst_val, u32 *sum)
+{
+	int temp, ret;
+
+	/*
+	 * Need to add in the mcelsius domain, so we have a temperature
+	 * the conv_table range
+	 */
+	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
+	if (ret < 0)
+		goto exit;
+
+	temp += hyst_val;
+
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
+
+exit:
+	return ret;
+}
+
 /* Talert masks. Call it only if HAS(TALERT) is set */
 static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					 u32 t_hot, u32 t_cold)
@@ -330,20 +352,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	return 0;
 }
 
-static
-int add_hyst(int adc_val, int hyst_val, struct omap_bandgap *bg_ptr, u32 *sum)
-{
-	int temp, ret;
-
-	ret = omap_bandgap_adc_to_mcelsius(bg_ptr, adc_val, &temp);
-	if (ret < 0)
-		return ret;
-
-	temp += hyst_val;
-
-	return omap_bandgap_mcelsius_to_adc(bg_ptr, temp, sum);
-}
-
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
 static
 int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
@@ -361,7 +369,8 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 	    __ffs(tsr->threshold_tcold_mask);
 	if (t_hot <= cold) {
 		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= add_hyst(t_hot, -ts_data->hyst_val, bg_ptr, &cold);
+		err |= omap_bandgap_add_hyst(bg_ptr, t_hot,
+					     -ts_data->hyst_val, &cold);
 		/* write the new t_cold value */
 		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
 		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
@@ -399,7 +408,8 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 
 	if (t_cold >= hot) {
 		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= add_hyst(t_cold, ts_data->hyst_val, bg_ptr, &hot);
+		err |= omap_bandgap_add_hyst(bg_ptr, t_cold,
+					     ts_data->hyst_val, &hot);
 		/* write the new t_hot value */
 		reg_val = thresh_val & (~tsr->threshold_thot_mask);
 		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 29/50] staging: omap-thermal: document omap_bandgap_add_hyst function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to handle hysteresis.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 7b10d18..bff4b75 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -303,6 +303,16 @@ exit:
 	return ret;
 }
 
+/**
+ * omap_bandgap_add_hyst() - add hysteresis (in mCelsius) to an ADC value
+ * @bg_ptr: struct omap_bandgap pointer
+ * @adc_val: temperature value in ADC representation
+ * @hyst_val: hysteresis value in mCelsius
+ * @sum: address where to write the resulting temperature (in ADC scale)
+ *
+ * Adds an hysteresis value (in mCelsius) to a ADC temperature value.
+ * Returns 0 on success, -ERANGE otherwise.
+ */
 static
 int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val,
 			  int hyst_val, u32 *sum)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 29/50] staging: omap-thermal: document omap_bandgap_add_hyst function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to handle hysteresis.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 7b10d18..bff4b75 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -303,6 +303,16 @@ exit:
 	return ret;
 }
 
+/**
+ * omap_bandgap_add_hyst() - add hysteresis (in mCelsius) to an ADC value
+ * @bg_ptr: struct omap_bandgap pointer
+ * @adc_val: temperature value in ADC representation
+ * @hyst_val: hysteresis value in mCelsius
+ * @sum: address where to write the resulting temperature (in ADC scale)
+ *
+ * Adds an hysteresis value (in mCelsius) to a ADC temperature value.
+ * Returns 0 on success, -ERANGE otherwise.
+ */
 static
 int omap_bandgap_add_hyst(struct omap_bandgap *bg_ptr, int adc_val,
 			  int hyst_val, u32 *sum)
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 30/50] staging: omap-thermal: threshold manipulation section
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of functions manipulating thresholds for Alert and Shutdown.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index bff4b75..f86c104 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -335,6 +335,8 @@ exit:
 	return ret;
 }
 
+/***   Helper functions handling device Alert/Shutdown signals   ***/
+
 /* Talert masks. Call it only if HAS(TALERT) is set */
 static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					 u32 t_hot, u32 t_cold)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 30/50] staging: omap-thermal: threshold manipulation section
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of functions manipulating thresholds for Alert and Shutdown.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index bff4b75..f86c104 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -335,6 +335,8 @@ exit:
 	return ret;
 }
 
+/***   Helper functions handling device Alert/Shutdown signals   ***/
+
 /* Talert masks. Call it only if HAS(TALERT) is set */
 static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					 u32 t_hot, u32 t_cold)
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 31/50] staging: omap-thermal: refactor temp_sensor_unmask_interrupts
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This change improves temp_sensor_unmask_interrupts by:
. renaming it to omap_bandgap_unmask_interrupts
. making it a void function, as there is nothing really to report an error.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index f86c104..26d36f3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -338,8 +338,8 @@ exit:
 /***   Helper functions handling device Alert/Shutdown signals   ***/
 
 /* Talert masks. Call it only if HAS(TALERT) is set */
-static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
-					 u32 t_hot, u32 t_cold)
+static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
+					   u32 t_hot, u32 t_cold)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp, reg_val;
@@ -360,8 +360,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	else
 		reg_val &= ~tsr->mask_cold_mask;
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
-
-	return 0;
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -399,7 +397,9 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 		return -EIO;
 	}
 
-	return temp_sensor_unmask_interrupts(bg_ptr, id, t_hot, cold);
+	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, cold);
+
+	return 0;
 }
 
 /* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
@@ -438,7 +438,9 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 		return -EIO;
 	}
 
-	return temp_sensor_unmask_interrupts(bg_ptr, id, hot, t_cold);
+	omap_bandgap_unmask_interrupts(bg_ptr, id, hot, t_cold);
+
+	return 0;
 }
 
 #define bandgap_is_valid(b)						\
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 31/50] staging: omap-thermal: refactor temp_sensor_unmask_interrupts
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This change improves temp_sensor_unmask_interrupts by:
. renaming it to omap_bandgap_unmask_interrupts
. making it a void function, as there is nothing really to report an error.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index f86c104..26d36f3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -338,8 +338,8 @@ exit:
 /***   Helper functions handling device Alert/Shutdown signals   ***/
 
 /* Talert masks. Call it only if HAS(TALERT) is set */
-static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
-					 u32 t_hot, u32 t_cold)
+static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
+					   u32 t_hot, u32 t_cold)
 {
 	struct temp_sensor_registers *tsr;
 	u32 temp, reg_val;
@@ -360,8 +360,6 @@ static int temp_sensor_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	else
 		reg_val &= ~tsr->mask_cold_mask;
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
-
-	return 0;
 }
 
 /* Talert Thot threshold. Call it only if HAS(TALERT) is set */
@@ -399,7 +397,9 @@ int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
 		return -EIO;
 	}
 
-	return temp_sensor_unmask_interrupts(bg_ptr, id, t_hot, cold);
+	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, cold);
+
+	return 0;
 }
 
 /* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
@@ -438,7 +438,9 @@ int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
 		return -EIO;
 	}
 
-	return temp_sensor_unmask_interrupts(bg_ptr, id, hot, t_cold);
+	omap_bandgap_unmask_interrupts(bg_ptr, id, hot, t_cold);
+
+	return 0;
 }
 
 #define bandgap_is_valid(b)						\
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 32/50] staging: omap-thermal: update omap_bandgap_unmask_interrupts documentation
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Proper document the function to configure the IRQ event masks.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 26d36f3..d001323 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -337,7 +337,15 @@ exit:
 
 /***   Helper functions handling device Alert/Shutdown signals   ***/
 
-/* Talert masks. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_unmask_interrupts() - unmasks the events of thot & tcold
+ * @bg_ptr: struct omap_bandgap pointer
+ * @t_hot: hot temperature value to trigger alert signal
+ * @t_cold: cold temperature value to trigger alert signal
+ *
+ * Checks the requested t_hot and t_cold values and configures the IRQ event
+ * masks accordingly. Call this function only if bandgap features HAS(TALERT).
+ */
 static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					   u32 t_hot, u32 t_cold)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 32/50] staging: omap-thermal: update omap_bandgap_unmask_interrupts documentation
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Proper document the function to configure the IRQ event masks.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 26d36f3..d001323 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -337,7 +337,15 @@ exit:
 
 /***   Helper functions handling device Alert/Shutdown signals   ***/
 
-/* Talert masks. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_unmask_interrupts() - unmasks the events of thot & tcold
+ * @bg_ptr: struct omap_bandgap pointer
+ * @t_hot: hot temperature value to trigger alert signal
+ * @t_cold: cold temperature value to trigger alert signal
+ *
+ * Checks the requested t_hot and t_cold values and configures the IRQ event
+ * masks accordingly. Call this function only if bandgap features HAS(TALERT).
+ */
 static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 					   u32 t_hot, u32 t_cold)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch improves the code that handles threshold values
by creating single functions that are usable for tcold and
thot. This way we won't have duplicated functionality just
because it is handling different bitfields. Now
the added functions are reused in several places where
it is needed to update any threshold.

This patch also removes macros that are used only inside
the _validate helper function.

In this patch there is also an addition of an extra function
section for Exposed APIs, used outside the omap-bandgap.c,
but inside the omap-thermal driver.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d001323..2a13bf0 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -370,145 +370,172 @@ static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
 }
 
-/* Talert Thot threshold. Call it only if HAS(TALERT) is set */
 static
-int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
+int omap_bandgap_update_alert_threshold(struct omap_bandgap *bg_ptr, int id,
+					int val, bool hot)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
 	struct temp_sensor_registers *tsr;
-	u32 thresh_val, reg_val;
-	int cold, err = 0;
+	u32 thresh_val, reg_val, t_hot, t_cold;
+	int err = 0;
 
 	tsr = bg_ptr->conf->sensors[id].registers;
 
-	/* obtain the T cold value */
+	/* obtain the current value */
 	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	cold = (thresh_val & tsr->threshold_tcold_mask) >>
-	    __ffs(tsr->threshold_tcold_mask);
-	if (t_hot <= cold) {
-		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= omap_bandgap_add_hyst(bg_ptr, t_hot,
-					     -ts_data->hyst_val, &cold);
-		/* write the new t_cold value */
-		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
-		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
-		omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-		thresh_val = reg_val;
+	t_cold = (thresh_val & tsr->threshold_tcold_mask) >>
+		__ffs(tsr->threshold_tcold_mask);
+	t_hot = (thresh_val & tsr->threshold_thot_mask) >>
+		__ffs(tsr->threshold_thot_mask);
+	if (hot)
+		t_hot = val;
+	else
+		t_cold = val;
+
+	if (t_cold < t_hot) {
+		if (hot)
+			err = omap_bandgap_add_hyst(bg_ptr, t_hot,
+						    -ts_data->hyst_val,
+						    &t_cold);
+		else
+			err = omap_bandgap_add_hyst(bg_ptr, t_cold,
+						    ts_data->hyst_val,
+						    &t_hot);
 	}
 
-	/* write the new t_hot value */
+	/* 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));
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+
 	if (err) {
 		dev_err(bg_ptr->dev, "failed to reprogram thot threshold\n");
-		return -EIO;
+		err = -EIO;
+		goto exit;
 	}
 
-	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, cold);
-
-	return 0;
+	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, t_cold);
+exit:
+	return err;
 }
 
-/* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
-static
-int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
-				int t_cold)
+static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 thresh_val, reg_val;
-	int hot, err = 0;
+	int ret = 0;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
-	/* obtain the T cold value */
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	hot = (thresh_val & tsr->threshold_thot_mask) >>
-	    __ffs(tsr->threshold_thot_mask);
-
-	if (t_cold >= hot) {
-		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= omap_bandgap_add_hyst(bg_ptr, t_cold,
-					     ts_data->hyst_val, &hot);
-		/* write the new t_hot value */
-		reg_val = thresh_val & (~tsr->threshold_thot_mask);
-		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
-		omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-		thresh_val = reg_val;
+	if (IS_ERR_OR_NULL(bg_ptr)) {
+		pr_err("%s: invalid bandgap pointer\n", __func__);
+		ret = -EINVAL;
+		goto exit;
 	}
 
-	/* write the new t_cold value */
-	reg_val = thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-	if (err) {
-		dev_err(bg_ptr->dev, "failed to reprogram tcold threshold\n");
-		return -EIO;
+	if ((id < 0) || (id >= bg_ptr->conf->sensor_count)) {
+		dev_err(bg_ptr->dev, "%s: sensor id out of range (%d)\n",
+			__func__, id);
+		ret = -ERANGE;
 	}
 
-	omap_bandgap_unmask_interrupts(bg_ptr, id, hot, t_cold);
-
-	return 0;
+exit:
+	return ret;
 }
 
-#define bandgap_is_valid(b)						\
-			(!IS_ERR_OR_NULL(b))
-#define bandgap_is_valid_sensor_id(b, i)				\
-			((i) >= 0 && (i) < (b)->conf->sensor_count)
-static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
+int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
+				  bool hot)
 {
-	if (!bandgap_is_valid(bg_ptr)) {
-		pr_err("%s: invalid bandgap pointer\n", __func__);
-		return -EINVAL;
+	struct temp_sensor_data *ts_data;
+	struct temp_sensor_registers *tsr;
+	u32 adc_val;
+	int ret;
+
+	ret = omap_bandgap_validate(bg_ptr, id);
+	if (ret)
+		goto exit;
+
+	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+		ret = -ENOTSUPP;
+		goto exit;
 	}
 
-	if (!bandgap_is_valid_sensor_id(bg_ptr, id)) {
-		dev_err(bg_ptr->dev, "%s: sensor id out of range (%d)\n",
-			__func__, id);
-		return -ERANGE;
+	ts_data = bg_ptr->conf->sensors[id].ts_data;
+	tsr = bg_ptr->conf->sensors[id].registers;
+	if (hot) {
+		if (val < ts_data->min_temp + ts_data->hyst_val)
+			ret = -EINVAL;
+	} else {
+		if (val > ts_data->max_temp + ts_data->hyst_val)
+			ret = -EINVAL;
 	}
 
-	return 0;
+	if (ret)
+		goto exit;
+
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &adc_val);
+	if (ret < 0)
+		goto exit;
+
+	mutex_lock(&bg_ptr->bg_mutex);
+	omap_bandgap_update_alert_threshold(bg_ptr, id, adc_val, hot);
+	mutex_unlock(&bg_ptr->bg_mutex);
+
+exit:
+	return ret;
 }
 
-/* Exposed APIs */
-/**
- * omap_bandgap_read_thot() - reads sensor current thot
- * @bg_ptr - pointer to bandgap instance
- * @id - sensor id
- * @thot - resulting current thot value
- *
- * returns 0 on success or the proper error code
- */
-int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
-			   int *thot)
+int _omap_bandgap_read_threshold(struct omap_bandgap *bg_ptr, int id,
+				 int *val, bool hot)
 {
 	struct temp_sensor_registers *tsr;
-	u32 temp;
-	int ret;
+	u32 temp, mask;
+	int ret = 0;
 
 	ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
-		return ret;
+		goto exit;
 
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
+	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+		ret = -ENOTSUPP;
+		goto exit;
+	}
 
 	tsr = bg_ptr->conf->sensors[id].registers;
+	if (hot)
+		mask = tsr->threshold_thot_mask;
+	else
+		mask = tsr->threshold_tcold_mask;
+
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	temp = (temp & tsr->threshold_thot_mask) >>
-		__ffs(tsr->threshold_thot_mask);
+	temp = (temp & mask) >> __ffs(mask);
 	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
-		return -EIO;
+		ret = -EIO;
+		goto exit;
 	}
 
-	*thot = temp;
+	*val = temp;
 
+exit:
 	return 0;
 }
 
+/***   Exposed APIs   ***/
+
+/**
+ * omap_bandgap_read_thot() - reads sensor current thot
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @thot - resulting current thot value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
+			   int *thot)
+{
+	return _omap_bandgap_read_threshold(bg_ptr, id, thot, true);
+}
+
 /**
  * omap_bandgap_write_thot() - sets sensor current thot
  * @bg_ptr - pointer to bandgap instance
@@ -519,32 +546,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
  */
 int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 {
-	struct temp_sensor_data *ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 t_hot;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	ts_data = bg_ptr->conf->sensors[id].ts_data;
-	tsr = bg_ptr->conf->sensors[id].registers;
-
-	if (val < ts_data->min_temp + ts_data->hyst_val)
-		return -EINVAL;
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_hot);
-	if (ret < 0)
-		return ret;
-
-	mutex_lock(&bg_ptr->bg_mutex);
-	temp_sensor_configure_thot(bg_ptr, id, t_hot);
-	mutex_unlock(&bg_ptr->bg_mutex);
-
-	return 0;
+	return _omap_bandgap_write_threshold(bg_ptr, id, val, true);
 }
 
 /**
@@ -558,28 +560,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 			    int *tcold)
 {
-	struct temp_sensor_registers *tsr;
-	u32 temp;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	temp = (temp & tsr->threshold_tcold_mask)
-	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
-	if (ret)
-		return -EIO;
-
-	*tcold = temp;
-
-	return 0;
+	return _omap_bandgap_read_threshold(bg_ptr, id, tcold, false);
 }
 
 /**
@@ -592,32 +573,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
  */
 int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 {
-	struct temp_sensor_data *ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 t_cold;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	ts_data = bg_ptr->conf->sensors[id].ts_data;
-	tsr = bg_ptr->conf->sensors[id].registers;
-	if (val > ts_data->max_temp + ts_data->hyst_val)
-		return -EINVAL;
-
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_cold);
-	if (ret < 0)
-		return ret;
-
-	mutex_lock(&bg_ptr->bg_mutex);
-	temp_sensor_configure_tcold(bg_ptr, id, t_cold);
-	mutex_unlock(&bg_ptr->bg_mutex);
-
-	return 0;
+	return _omap_bandgap_write_threshold(bg_ptr, id, val, false);
 }
 
 /**
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch improves the code that handles threshold values
by creating single functions that are usable for tcold and
thot. This way we won't have duplicated functionality just
because it is handling different bitfields. Now
the added functions are reused in several places where
it is needed to update any threshold.

This patch also removes macros that are used only inside
the _validate helper function.

In this patch there is also an addition of an extra function
section for Exposed APIs, used outside the omap-bandgap.c,
but inside the omap-thermal driver.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d001323..2a13bf0 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -370,145 +370,172 @@ static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
 }
 
-/* Talert Thot threshold. Call it only if HAS(TALERT) is set */
 static
-int temp_sensor_configure_thot(struct omap_bandgap *bg_ptr, int id, int t_hot)
+int omap_bandgap_update_alert_threshold(struct omap_bandgap *bg_ptr, int id,
+					int val, bool hot)
 {
 	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
 	struct temp_sensor_registers *tsr;
-	u32 thresh_val, reg_val;
-	int cold, err = 0;
+	u32 thresh_val, reg_val, t_hot, t_cold;
+	int err = 0;
 
 	tsr = bg_ptr->conf->sensors[id].registers;
 
-	/* obtain the T cold value */
+	/* obtain the current value */
 	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	cold = (thresh_val & tsr->threshold_tcold_mask) >>
-	    __ffs(tsr->threshold_tcold_mask);
-	if (t_hot <= cold) {
-		/* change the t_cold to t_hot - 5000 millidegrees */
-		err |= omap_bandgap_add_hyst(bg_ptr, t_hot,
-					     -ts_data->hyst_val, &cold);
-		/* write the new t_cold value */
-		reg_val = thresh_val & (~tsr->threshold_tcold_mask);
-		reg_val |= cold << __ffs(tsr->threshold_tcold_mask);
-		omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-		thresh_val = reg_val;
+	t_cold = (thresh_val & tsr->threshold_tcold_mask) >>
+		__ffs(tsr->threshold_tcold_mask);
+	t_hot = (thresh_val & tsr->threshold_thot_mask) >>
+		__ffs(tsr->threshold_thot_mask);
+	if (hot)
+		t_hot = val;
+	else
+		t_cold = val;
+
+	if (t_cold < t_hot) {
+		if (hot)
+			err = omap_bandgap_add_hyst(bg_ptr, t_hot,
+						    -ts_data->hyst_val,
+						    &t_cold);
+		else
+			err = omap_bandgap_add_hyst(bg_ptr, t_cold,
+						    ts_data->hyst_val,
+						    &t_hot);
 	}
 
-	/* write the new t_hot value */
+	/* 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));
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
+
 	if (err) {
 		dev_err(bg_ptr->dev, "failed to reprogram thot threshold\n");
-		return -EIO;
+		err = -EIO;
+		goto exit;
 	}
 
-	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, cold);
-
-	return 0;
+	omap_bandgap_unmask_interrupts(bg_ptr, id, t_hot, t_cold);
+exit:
+	return err;
 }
 
-/* Talert Tcold threshold. Call it only if HAS(TALERT) is set */
-static
-int temp_sensor_configure_tcold(struct omap_bandgap *bg_ptr, int id,
-				int t_cold)
+static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
 {
-	struct temp_sensor_data *ts_data = bg_ptr->conf->sensors[id].ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 thresh_val, reg_val;
-	int hot, err = 0;
+	int ret = 0;
 
-	tsr = bg_ptr->conf->sensors[id].registers;
-	/* obtain the T cold value */
-	thresh_val = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	hot = (thresh_val & tsr->threshold_thot_mask) >>
-	    __ffs(tsr->threshold_thot_mask);
-
-	if (t_cold >= hot) {
-		/* change the t_hot to t_cold + 5000 millidegrees */
-		err |= omap_bandgap_add_hyst(bg_ptr, t_cold,
-					     ts_data->hyst_val, &hot);
-		/* write the new t_hot value */
-		reg_val = thresh_val & (~tsr->threshold_thot_mask);
-		reg_val |= hot << __ffs(tsr->threshold_thot_mask);
-		omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-		thresh_val = reg_val;
+	if (IS_ERR_OR_NULL(bg_ptr)) {
+		pr_err("%s: invalid bandgap pointer\n", __func__);
+		ret = -EINVAL;
+		goto exit;
 	}
 
-	/* write the new t_cold value */
-	reg_val = thresh_val & ~tsr->threshold_tcold_mask;
-	reg_val |= (t_cold << __ffs(tsr->threshold_tcold_mask));
-	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_threshold);
-	if (err) {
-		dev_err(bg_ptr->dev, "failed to reprogram tcold threshold\n");
-		return -EIO;
+	if ((id < 0) || (id >= bg_ptr->conf->sensor_count)) {
+		dev_err(bg_ptr->dev, "%s: sensor id out of range (%d)\n",
+			__func__, id);
+		ret = -ERANGE;
 	}
 
-	omap_bandgap_unmask_interrupts(bg_ptr, id, hot, t_cold);
-
-	return 0;
+exit:
+	return ret;
 }
 
-#define bandgap_is_valid(b)						\
-			(!IS_ERR_OR_NULL(b))
-#define bandgap_is_valid_sensor_id(b, i)				\
-			((i) >= 0 && (i) < (b)->conf->sensor_count)
-static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
+int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
+				  bool hot)
 {
-	if (!bandgap_is_valid(bg_ptr)) {
-		pr_err("%s: invalid bandgap pointer\n", __func__);
-		return -EINVAL;
+	struct temp_sensor_data *ts_data;
+	struct temp_sensor_registers *tsr;
+	u32 adc_val;
+	int ret;
+
+	ret = omap_bandgap_validate(bg_ptr, id);
+	if (ret)
+		goto exit;
+
+	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+		ret = -ENOTSUPP;
+		goto exit;
 	}
 
-	if (!bandgap_is_valid_sensor_id(bg_ptr, id)) {
-		dev_err(bg_ptr->dev, "%s: sensor id out of range (%d)\n",
-			__func__, id);
-		return -ERANGE;
+	ts_data = bg_ptr->conf->sensors[id].ts_data;
+	tsr = bg_ptr->conf->sensors[id].registers;
+	if (hot) {
+		if (val < ts_data->min_temp + ts_data->hyst_val)
+			ret = -EINVAL;
+	} else {
+		if (val > ts_data->max_temp + ts_data->hyst_val)
+			ret = -EINVAL;
 	}
 
-	return 0;
+	if (ret)
+		goto exit;
+
+	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &adc_val);
+	if (ret < 0)
+		goto exit;
+
+	mutex_lock(&bg_ptr->bg_mutex);
+	omap_bandgap_update_alert_threshold(bg_ptr, id, adc_val, hot);
+	mutex_unlock(&bg_ptr->bg_mutex);
+
+exit:
+	return ret;
 }
 
-/* Exposed APIs */
-/**
- * omap_bandgap_read_thot() - reads sensor current thot
- * @bg_ptr - pointer to bandgap instance
- * @id - sensor id
- * @thot - resulting current thot value
- *
- * returns 0 on success or the proper error code
- */
-int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
-			   int *thot)
+int _omap_bandgap_read_threshold(struct omap_bandgap *bg_ptr, int id,
+				 int *val, bool hot)
 {
 	struct temp_sensor_registers *tsr;
-	u32 temp;
-	int ret;
+	u32 temp, mask;
+	int ret = 0;
 
 	ret = omap_bandgap_validate(bg_ptr, id);
 	if (ret)
-		return ret;
+		goto exit;
 
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
+	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT)) {
+		ret = -ENOTSUPP;
+		goto exit;
+	}
 
 	tsr = bg_ptr->conf->sensors[id].registers;
+	if (hot)
+		mask = tsr->threshold_thot_mask;
+	else
+		mask = tsr->threshold_tcold_mask;
+
 	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	temp = (temp & tsr->threshold_thot_mask) >>
-		__ffs(tsr->threshold_thot_mask);
+	temp = (temp & mask) >> __ffs(mask);
 	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret) {
 		dev_err(bg_ptr->dev, "failed to read thot\n");
-		return -EIO;
+		ret = -EIO;
+		goto exit;
 	}
 
-	*thot = temp;
+	*val = temp;
 
+exit:
 	return 0;
 }
 
+/***   Exposed APIs   ***/
+
+/**
+ * omap_bandgap_read_thot() - reads sensor current thot
+ * @bg_ptr - pointer to bandgap instance
+ * @id - sensor id
+ * @thot - resulting current thot value
+ *
+ * returns 0 on success or the proper error code
+ */
+int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
+			   int *thot)
+{
+	return _omap_bandgap_read_threshold(bg_ptr, id, thot, true);
+}
+
 /**
  * omap_bandgap_write_thot() - sets sensor current thot
  * @bg_ptr - pointer to bandgap instance
@@ -519,32 +546,7 @@ int omap_bandgap_read_thot(struct omap_bandgap *bg_ptr, int id,
  */
 int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 {
-	struct temp_sensor_data *ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 t_hot;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	ts_data = bg_ptr->conf->sensors[id].ts_data;
-	tsr = bg_ptr->conf->sensors[id].registers;
-
-	if (val < ts_data->min_temp + ts_data->hyst_val)
-		return -EINVAL;
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_hot);
-	if (ret < 0)
-		return ret;
-
-	mutex_lock(&bg_ptr->bg_mutex);
-	temp_sensor_configure_thot(bg_ptr, id, t_hot);
-	mutex_unlock(&bg_ptr->bg_mutex);
-
-	return 0;
+	return _omap_bandgap_write_threshold(bg_ptr, id, val, true);
 }
 
 /**
@@ -558,28 +560,7 @@ int omap_bandgap_write_thot(struct omap_bandgap *bg_ptr, int id, int val)
 int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
 			    int *tcold)
 {
-	struct temp_sensor_registers *tsr;
-	u32 temp;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	tsr = bg_ptr->conf->sensors[id].registers;
-	temp = omap_bandgap_readl(bg_ptr, tsr->bgap_threshold);
-	temp = (temp & tsr->threshold_tcold_mask)
-	    >> __ffs(tsr->threshold_tcold_mask);
-	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
-	if (ret)
-		return -EIO;
-
-	*tcold = temp;
-
-	return 0;
+	return _omap_bandgap_read_threshold(bg_ptr, id, tcold, false);
 }
 
 /**
@@ -592,32 +573,7 @@ int omap_bandgap_read_tcold(struct omap_bandgap *bg_ptr, int id,
  */
 int omap_bandgap_write_tcold(struct omap_bandgap *bg_ptr, int id, int val)
 {
-	struct temp_sensor_data *ts_data;
-	struct temp_sensor_registers *tsr;
-	u32 t_cold;
-	int ret;
-
-	ret = omap_bandgap_validate(bg_ptr, id);
-	if (ret)
-		return ret;
-
-	if (!OMAP_BANDGAP_HAS(bg_ptr, TALERT))
-		return -ENOTSUPP;
-
-	ts_data = bg_ptr->conf->sensors[id].ts_data;
-	tsr = bg_ptr->conf->sensors[id].registers;
-	if (val > ts_data->max_temp + ts_data->hyst_val)
-		return -EINVAL;
-
-	ret = omap_bandgap_mcelsius_to_adc(bg_ptr, val, &t_cold);
-	if (ret < 0)
-		return ret;
-
-	mutex_lock(&bg_ptr->bg_mutex);
-	temp_sensor_configure_tcold(bg_ptr, id, t_cold);
-	mutex_unlock(&bg_ptr->bg_mutex);
-
-	return 0;
+	return _omap_bandgap_write_threshold(bg_ptr, id, val, false);
 }
 
 /**
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 34/50] staging: omap-thermal: device initialization section
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of helper functions to initilize the bandgap device

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 2a13bf0..8c7ac0e 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -703,6 +703,8 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 	return bg_ptr->conf->sensors[id].data;
 }
 
+/***   Helper functions used during device initialization   ***/
+
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 34/50] staging: omap-thermal: device initialization section
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section of helper functions to initilize the bandgap device

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 2a13bf0..8c7ac0e 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -703,6 +703,8 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 	return bg_ptr->conf->sensors[id].data;
 }
 
+/***   Helper functions used during device initialization   ***/
+
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 35/50] staging: omap-thermal: section of device driver callbacks
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section with platform device callbacks

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8c7ac0e..8746187 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -862,6 +862,8 @@ static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 	return bg_ptr;
 }
 
+/***   Device driver call backs   ***/
+
 static
 int omap_bandgap_probe(struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 35/50] staging: omap-thermal: section of device driver callbacks
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Section with platform device callbacks

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8c7ac0e..8746187 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -862,6 +862,8 @@ static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 	return bg_ptr;
 }
 
+/***   Device driver call backs   ***/
+
 static
 int omap_bandgap_probe(struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 36/50] staging: omap-thermal: rename enable_continuous_mode
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch names 'enable_continuous_mode' accordingly to the file
standard naming.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8746187..e325269 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -735,7 +735,7 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
  *
  * Call this function only if HAS(MODE_CONFIG) is set
  */
-static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
+static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 {
 	int i;
 
@@ -973,7 +973,7 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	}
 
 	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
-		enable_continuous_mode(bg_ptr);
+		omap_bandgap_set_continuous_mode(bg_ptr);
 
 	/* Set .250 seconds time as default counter */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 36/50] staging: omap-thermal: rename enable_continuous_mode
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

This patch names 'enable_continuous_mode' accordingly to the file
standard naming.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 8746187..e325269 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -735,7 +735,7 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
  *
  * Call this function only if HAS(MODE_CONFIG) is set
  */
-static int enable_continuous_mode(struct omap_bandgap *bg_ptr)
+static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 {
 	int i;
 
@@ -973,7 +973,7 @@ int omap_bandgap_probe(struct platform_device *pdev)
 	}
 
 	if (OMAP_BANDGAP_HAS(bg_ptr, MODE_CONFIG))
-		enable_continuous_mode(bg_ptr);
+		omap_bandgap_set_continuous_mode(bg_ptr);
 
 	/* Set .250 seconds time as default counter */
 	if (OMAP_BANDGAP_HAS(bg_ptr, COUNTER))
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 37/50] staging: omap-thermal: update omap_bandgap_set_continous_mode documentation
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Simple update on function documentation.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index e325269..d893931 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -730,10 +730,13 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 }
 
 /**
- * enable_continuous_mode() - One time enabling of continuous conversion mode
- * @bg_ptr - pointer to scm instance
+ * omap_bandgap_set_continous_mode() - One time enabling of continuous mode
+ * @bg_ptr: pointer to struct omap_bandgap
  *
- * Call this function only if HAS(MODE_CONFIG) is set
+ * Call this function only if HAS(MODE_CONFIG) is set. As this driver may
+ * be used for junction temperature monitoring, it is desirable that the
+ * sensors are operational all the time, so that alerts are generated
+ * properly.
  */
 static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 37/50] staging: omap-thermal: update omap_bandgap_set_continous_mode documentation
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Simple update on function documentation.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index e325269..d893931 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -730,10 +730,13 @@ omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 }
 
 /**
- * enable_continuous_mode() - One time enabling of continuous conversion mode
- * @bg_ptr - pointer to scm instance
+ * omap_bandgap_set_continous_mode() - One time enabling of continuous mode
+ * @bg_ptr: pointer to struct omap_bandgap
  *
- * Call this function only if HAS(MODE_CONFIG) is set
+ * Call this function only if HAS(MODE_CONFIG) is set. As this driver may
+ * be used for junction temperature monitoring, it is desirable that the
+ * sensors are operational all the time, so that alerts are generated
+ * properly.
  */
 static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 {
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 38/50] staging: omap-thermal: document omap_bandgap_force_single_read
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to initialize the conversion state machine.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d893931..065f371 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -705,6 +705,14 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 
 /***   Helper functions used during device initialization   ***/
 
+/**
+ * omap_bandgap_force_single_read() - executes 1 single ADC conversion
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @id: sensor id which it is desired to read 1 temperature
+ *
+ * Used to initialize the conversion state machine and set it to a valid
+ * state. Called during device initialization and context restore events.
+ */
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 38/50] staging: omap-thermal: document omap_bandgap_force_single_read
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to initialize the conversion state machine.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index d893931..065f371 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -705,6 +705,14 @@ void *omap_bandgap_get_sensor_data(struct omap_bandgap *bg_ptr, int id)
 
 /***   Helper functions used during device initialization   ***/
 
+/**
+ * omap_bandgap_force_single_read() - executes 1 single ADC conversion
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @id: sensor id which it is desired to read 1 temperature
+ *
+ * Used to initialize the conversion state machine and set it to a valid
+ * state. Called during device initialization and context restore events.
+ */
 static int
 omap_bandgap_force_single_read(struct omap_bandgap *bg_ptr, int id)
 {
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 39/50] staging: omap-thermal: document omap_bandgap_update_alert_threshold function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to program alert thresholds

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 065f371..0eb21b3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -370,6 +370,20 @@ static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
 }
 
+/**
+ * omap_bandgap_update_alert_threshold() - sequence to update thresholds
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (ADC) of a new threshold
+ * @hot: desired threshold to be updated. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will program the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to update t_hot or t_cold, depending on @hot value.
+ * It checks the resulting t_hot and t_cold values, based on the new passed @val
+ * and configures the thresholds so that t_hot is always greater than t_cold.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 static
 int omap_bandgap_update_alert_threshold(struct omap_bandgap *bg_ptr, int id,
 					int val, bool hot)
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 39/50] staging: omap-thermal: document omap_bandgap_update_alert_threshold function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to program alert thresholds

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 065f371..0eb21b3 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -370,6 +370,20 @@ static void omap_bandgap_unmask_interrupts(struct omap_bandgap *bg_ptr, int id,
 	omap_bandgap_writel(bg_ptr, reg_val, tsr->bgap_mask_ctrl);
 }
 
+/**
+ * omap_bandgap_update_alert_threshold() - sequence to update thresholds
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (ADC) of a new threshold
+ * @hot: desired threshold to be updated. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will program the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to update t_hot or t_cold, depending on @hot value.
+ * It checks the resulting t_hot and t_cold values, based on the new passed @val
+ * and configures the thresholds so that t_hot is always greater than t_cold.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 static
 int omap_bandgap_update_alert_threshold(struct omap_bandgap *bg_ptr, int id,
 					int val, bool hot)
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 40/50] staging: omap-thermal: document _omap_bandgap_write_threshold function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to update alert thresholds.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 0eb21b3..4cacfc1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -455,6 +455,19 @@ exit:
 	return ret;
 }
 
+/**
+ * _omap_bandgap_write_threshold() - helper to update TALERT t_cold or t_hot
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (mCelsius) of a new threshold
+ * @hot: desired threshold to be updated. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will update the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to update t_hot or t_cold, depending on @hot value.
+ * Validates the mCelsius range and update the requested threshold.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
 				  bool hot)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 40/50] staging: omap-thermal: document _omap_bandgap_write_threshold function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to update alert thresholds.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 0eb21b3..4cacfc1 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -455,6 +455,19 @@ exit:
 	return ret;
 }
 
+/**
+ * _omap_bandgap_write_threshold() - helper to update TALERT t_cold or t_hot
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (mCelsius) of a new threshold
+ * @hot: desired threshold to be updated. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will update the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to update t_hot or t_cold, depending on @hot value.
+ * Validates the mCelsius range and update the requested threshold.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
 				  bool hot)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 41/50] staging: omap-thermal: document _omap_bandgap_read_threshold function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Add documentation of the function for reading alert thresholds

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 4cacfc1..aa90539 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -510,6 +510,18 @@ exit:
 	return ret;
 }
 
+/**
+ * _omap_bandgap_read_threshold() - helper to read TALERT t_cold or t_hot
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (mCelsius) of a threshold
+ * @hot: desired threshold to be read. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will fetch the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to read t_hot or t_cold, depending on @hot value.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 int _omap_bandgap_read_threshold(struct omap_bandgap *bg_ptr, int id,
 				 int *val, bool hot)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 41/50] staging: omap-thermal: document _omap_bandgap_read_threshold function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Add documentation of the function for reading alert thresholds

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 4cacfc1..aa90539 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -510,6 +510,18 @@ exit:
 	return ret;
 }
 
+/**
+ * _omap_bandgap_read_threshold() - helper to read TALERT t_cold or t_hot
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ * @val: value (mCelsius) of a threshold
+ * @hot: desired threshold to be read. true if threshold hot, false if
+ *       threshold cold
+ *
+ * It will fetch the required thresholds (hot and cold) for TALERT signal.
+ * This function can be used to read t_hot or t_cold, depending on @hot value.
+ * Call this function only if bandgap features HAS(TALERT).
+ */
 int _omap_bandgap_read_threshold(struct omap_bandgap *bg_ptr, int id,
 				 int *val, bool hot)
 {
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 42/50] staging: omap-thermal: document omap_bandgap_tshut_init function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Add documentation for the function to setup TSHUT handling

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index aa90539..f2ebbcf 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -798,6 +798,18 @@ static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 	return 0;
 }
 
+/**
+ * omap_bandgap_tshut_init() - setup and initialize tshut handling
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Call this function only in case the bandgap features HAS(TSHUT).
+ * In this case, the driver needs to handle the TSHUT signal as an IRQ.
+ * The IRQ is wired as a GPIO, and for this purpose, it is required
+ * to specify which GPIO line is used. TSHUT IRQ is fired anytime
+ * one of the bandgap sensors violates the TSHUT high/hot threshold.
+ * And in that case, the system must go off.
+ */
 static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 				   struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 42/50] staging: omap-thermal: document omap_bandgap_tshut_init function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Add documentation for the function to setup TSHUT handling

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index aa90539..f2ebbcf 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -798,6 +798,18 @@ static int omap_bandgap_set_continuous_mode(struct omap_bandgap *bg_ptr)
 	return 0;
 }
 
+/**
+ * omap_bandgap_tshut_init() - setup and initialize tshut handling
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Call this function only in case the bandgap features HAS(TSHUT).
+ * In this case, the driver needs to handle the TSHUT signal as an IRQ.
+ * The IRQ is wired as a GPIO, and for this purpose, it is required
+ * to specify which GPIO line is used. TSHUT IRQ is fired anytime
+ * one of the bandgap sensors violates the TSHUT high/hot threshold.
+ * And in that case, the system must go off.
+ */
 static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 				   struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 43/50] staging: omap-thermal: document omap_bandgap_alert_init function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function that sets talert handling up.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index f2ebbcf..3150ec2 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -842,7 +842,17 @@ static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 	return 0;
 }
 
-/* Initialization of Talert. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_alert_init() - setup and initialize talert handling
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Call this function only in case the bandgap features HAS(TALERT).
+ * In this case, the driver needs to handle the TALERT signals as an IRQs.
+ * TALERT is a normal IRQ and it is fired any time thresholds (hot or cold)
+ * are violated. In these situation, the driver must reprogram the thresholds,
+ * accordingly to specified policy.
+ */
 static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 				    struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 43/50] staging: omap-thermal: document omap_bandgap_alert_init function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function that sets talert handling up.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index f2ebbcf..3150ec2 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -842,7 +842,17 @@ static int omap_bandgap_tshut_init(struct omap_bandgap *bg_ptr,
 	return 0;
 }
 
-/* Initialization of Talert. Call it only if HAS(TALERT) is set */
+/**
+ * omap_bandgap_alert_init() - setup and initialize talert handling
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Call this function only in case the bandgap features HAS(TALERT).
+ * In this case, the driver needs to handle the TALERT signals as an IRQs.
+ * TALERT is a normal IRQ and it is fired any time thresholds (hot or cold)
+ * are violated. In these situation, the driver must reprogram the thresholds,
+ * accordingly to specified policy.
+ */
 static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 				    struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 44/50] staging: omap-thermal: document omap_bandgap_build function
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to build omap_bandgap structure

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 3150ec2..4b631fd 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -875,6 +875,15 @@ static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 	return 0;
 }
 
+/**
+ * omap_bandgap_build() - parse DT and setup a struct omap_bandgap
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Used to read the device tree properties accordingly to the bandgap
+ * matching version. Based on bandgap version and its capabilities it
+ * will build a struct omap_bandgap out of the required DT entries.
+ */
 static const struct of_device_id of_omap_bandgap_match[];
 static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 44/50] staging: omap-thermal: document omap_bandgap_build function
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document function to build omap_bandgap structure

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 3150ec2..4b631fd 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -875,6 +875,15 @@ static int omap_bandgap_talert_init(struct omap_bandgap *bg_ptr,
 	return 0;
 }
 
+/**
+ * omap_bandgap_build() - parse DT and setup a struct omap_bandgap
+ * @bg_ptr: pointer to struct omap_bandgap
+ * @pdev: pointer to device struct platform_device
+ *
+ * Used to read the device tree properties accordingly to the bandgap
+ * matching version. Based on bandgap version and its capabilities it
+ * will build a struct omap_bandgap out of the required DT entries.
+ */
 static const struct of_device_id of_omap_bandgap_match[];
 static struct omap_bandgap *omap_bandgap_build(struct platform_device *pdev)
 {
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 45/50] staging: omap-thermal: change Kconfig dependency method
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh
  Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin,
	Santosh Shilimkar, Vaibhav Bedia

Now arch code has to specify CONFIG_ARCH_HAS_BANDGAP. So, this driver
will be selectable only if the platform reports itself as having a
bandgap device.

Any OMAP variant or any other OMAP version needs to
	select ARCH_HAS_BANDGAP
so that the driver will be applicable. A part from that it is
required to device the data structures that maps the registers
and their bitfields. The DT compatible list must also be updated.

CC: Santosh Shilimkar <santosh.shilimkar@ti.com>
CC: Vaibhav Bedia <vaibhav.bedia@ti.com>

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/Kconfig |    2 +-
 drivers/staging/omap-thermal/TODO    |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/omap-thermal/Kconfig b/drivers/staging/omap-thermal/Kconfig
index 30cbc3b..52170bf 100644
--- a/drivers/staging/omap-thermal/Kconfig
+++ b/drivers/staging/omap-thermal/Kconfig
@@ -1,7 +1,7 @@
 config OMAP_BANDGAP
 	tristate "Texas Instruments OMAP4+ temperature sensor driver"
 	depends on THERMAL
-	depends on ARCH_OMAP4 || SOC_OMAP5
+	depends on ARCH_HAS_BANDGAP
 	help
 	  If you say yes here you get support for the Texas Instruments
 	  OMAP4460+ on die bandgap temperature sensor support. The register
diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 9e23cc4..77b761b 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -20,7 +20,6 @@ on omap5-thermal.c
 - Add support for GPU cooling
 
 generally:
-- write Kconfig dependencies so that omap variants are covered
 - make checkpatch.pl and sparse happy
 - make sure this code works on OMAP4430, OMAP4460 and OMAP5430
 - update documentation
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 45/50] staging: omap-thermal: change Kconfig dependency method
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh
  Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin,
	Santosh Shilimkar, Vaibhav Bedia

Now arch code has to specify CONFIG_ARCH_HAS_BANDGAP. So, this driver
will be selectable only if the platform reports itself as having a
bandgap device.

Any OMAP variant or any other OMAP version needs to
	select ARCH_HAS_BANDGAP
so that the driver will be applicable. A part from that it is
required to device the data structures that maps the registers
and their bitfields. The DT compatible list must also be updated.

CC: Santosh Shilimkar <santosh.shilimkar@ti.com>
CC: Vaibhav Bedia <vaibhav.bedia@ti.com>

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/Kconfig |    2 +-
 drivers/staging/omap-thermal/TODO    |    1 -
 2 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/omap-thermal/Kconfig b/drivers/staging/omap-thermal/Kconfig
index 30cbc3b..52170bf 100644
--- a/drivers/staging/omap-thermal/Kconfig
+++ b/drivers/staging/omap-thermal/Kconfig
@@ -1,7 +1,7 @@
 config OMAP_BANDGAP
 	tristate "Texas Instruments OMAP4+ temperature sensor driver"
 	depends on THERMAL
-	depends on ARCH_OMAP4 || SOC_OMAP5
+	depends on ARCH_HAS_BANDGAP
 	help
 	  If you say yes here you get support for the Texas Instruments
 	  OMAP4460+ on die bandgap temperature sensor support. The register
diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 9e23cc4..77b761b 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -20,7 +20,6 @@ on omap5-thermal.c
 - Add support for GPU cooling
 
 generally:
-- write Kconfig dependencies so that omap variants are covered
 - make checkpatch.pl and sparse happy
 - make sure this code works on OMAP4430, OMAP4460 and OMAP5430
 - update documentation
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 46/50] staging: Add a MAINTAINERS entry for TI bandgap and thermal driver
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh
  Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin,
	Santosh Shilimkar, Zhang Rui

Add myself as maintainer of the TI bandgap and thermal driver.

CC: Santosh Shilimkar <santosh.shilimkar@ti.com>
CC: Zhang Rui <rui.zhang@intel.com>

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 MAINTAINERS |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6672165..199bb4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7915,6 +7915,12 @@ T:	git git://repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git
 S:	Maintained
 F:	drivers/platform/x86/thinkpad_acpi.c
 
+TI BANDGAP AND THERMAL DRIVER
+M:	Eduardo Valentin <eduardo.valentin@ti.com>
+L:	linux-pm@vger.kernel.org
+S:	Maintained
+F:	drivers/staging/omap-thermal/
+
 TI FLASH MEDIA INTERFACE DRIVER
 M:	Alex Dubov <oakad@yahoo.com>
 S:	Maintained
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 46/50] staging: Add a MAINTAINERS entry for TI bandgap and thermal driver
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh
  Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin,
	Santosh Shilimkar, Zhang Rui

Add myself as maintainer of the TI bandgap and thermal driver.

CC: Santosh Shilimkar <santosh.shilimkar@ti.com>
CC: Zhang Rui <rui.zhang@intel.com>

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 MAINTAINERS |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 6672165..199bb4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -7915,6 +7915,12 @@ T:	git git://repo.or.cz/linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git
 S:	Maintained
 F:	drivers/platform/x86/thinkpad_acpi.c
 
+TI BANDGAP AND THERMAL DRIVER
+M:	Eduardo Valentin <eduardo.valentin@ti.com>
+L:	linux-pm@vger.kernel.org
+S:	Maintained
+F:	drivers/staging/omap-thermal/
+
 TI FLASH MEDIA INTERFACE DRIVER
 M:	Alex Dubov <oakad@yahoo.com>
 S:	Maintained
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Because there is a need to lock inside IRQ handler, this patch
changes the locking mechanism inside the omap-bandgap.[c,h] to
spinlocks. Now this lock is used to protect omap_bandgap struct
during APIs exposed (possibly used in sysfs handling functions)
and inside the ALERT IRQ handler.

Because there are registers shared among the sensors, this lock
is global, not per sensor.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO           |    1 -
 drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
 drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 77b761b..0f24e9b 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -1,7 +1,6 @@
 List of TODOs (by Eduardo Valentin)
 
 on omap-bandgap.c:
-- Rework locking
 - Improve driver code by adding usage of regmap-mmio
 - Test every exposed API to userland
 - Add support to hwmon
diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 4b631fd..846ced6 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -33,7 +33,7 @@
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/types.h>
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 #include <linux/reboot.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
@@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
+	spin_lock(&bg_ptr->lock);
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
 		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
@@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 		if (bg_ptr->conf->report_temperature)
 			bg_ptr->conf->report_temperature(bg_ptr, i);
 	}
+	spin_unlock(&bg_ptr->lock);
 
 	return IRQ_HANDLED;
 }
@@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
 	if (ret < 0)
 		goto exit;
 
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	omap_bandgap_update_alert_threshold(bg_ptr, id, adc_val, hot);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 exit:
 	return ret;
@@ -666,9 +668,9 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 		return -ENOTSUPP;
 
 	interval = interval * bg_ptr->clk_rate / 1000;
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	RMW_BITS(bg_ptr, id, bgap_counter, counter_mask, interval);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 	return 0;
 }
@@ -691,9 +693,9 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	if (ret)
 		return ret;
 
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	temp = omap_bandgap_read_temp(bg_ptr, id);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
@@ -1016,7 +1018,7 @@ int omap_bandgap_probe(struct platform_device *pdev)
 		clk_prepare_enable(bg_ptr->fclock);
 
 
-	mutex_init(&bg_ptr->bg_mutex);
+	spin_lock_init(&bg_ptr->lock);
 	bg_ptr->dev = &pdev->dev;
 	platform_set_drvdata(pdev, bg_ptr);
 
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index edcc965..5700586 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -23,7 +23,7 @@
 #ifndef __OMAP_BANDGAP_H
 #define __OMAP_BANDGAP_H
 
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/err.h>
 
@@ -211,7 +211,7 @@ struct omap_bandgap {
 	struct omap_bandgap_data	*conf;
 	struct clk			*fclock;
 	struct clk			*div_clk;
-	struct mutex			bg_mutex; /* shields this struct */
+	spinlock_t			lock; /* shields this struct */
 	int				irq;
 	int				tshut_gpio;
 	u32				clk_rate;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Because there is a need to lock inside IRQ handler, this patch
changes the locking mechanism inside the omap-bandgap.[c,h] to
spinlocks. Now this lock is used to protect omap_bandgap struct
during APIs exposed (possibly used in sysfs handling functions)
and inside the ALERT IRQ handler.

Because there are registers shared among the sensors, this lock
is global, not per sensor.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO           |    1 -
 drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
 drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 77b761b..0f24e9b 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -1,7 +1,6 @@
 List of TODOs (by Eduardo Valentin)
 
 on omap-bandgap.c:
-- Rework locking
 - Improve driver code by adding usage of regmap-mmio
 - Test every exposed API to userland
 - Add support to hwmon
diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 4b631fd..846ced6 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -33,7 +33,7 @@
 #include <linux/platform_device.h>
 #include <linux/err.h>
 #include <linux/types.h>
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 #include <linux/reboot.h>
 #include <linux/of_device.h>
 #include <linux/of_platform.h>
@@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 	u32 t_hot = 0, t_cold = 0, ctrl;
 	int i;
 
+	spin_lock(&bg_ptr->lock);
 	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
 		tsr = bg_ptr->conf->sensors[i].registers;
 		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
@@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
 		if (bg_ptr->conf->report_temperature)
 			bg_ptr->conf->report_temperature(bg_ptr, i);
 	}
+	spin_unlock(&bg_ptr->lock);
 
 	return IRQ_HANDLED;
 }
@@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
 	if (ret < 0)
 		goto exit;
 
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	omap_bandgap_update_alert_threshold(bg_ptr, id, adc_val, hot);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 exit:
 	return ret;
@@ -666,9 +668,9 @@ int omap_bandgap_write_update_interval(struct omap_bandgap *bg_ptr,
 		return -ENOTSUPP;
 
 	interval = interval * bg_ptr->clk_rate / 1000;
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	RMW_BITS(bg_ptr, id, bgap_counter, counter_mask, interval);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 	return 0;
 }
@@ -691,9 +693,9 @@ int omap_bandgap_read_temperature(struct omap_bandgap *bg_ptr, int id,
 	if (ret)
 		return ret;
 
-	mutex_lock(&bg_ptr->bg_mutex);
+	spin_lock(&bg_ptr->lock);
 	temp = omap_bandgap_read_temp(bg_ptr, id);
-	mutex_unlock(&bg_ptr->bg_mutex);
+	spin_unlock(&bg_ptr->lock);
 
 	ret |= omap_bandgap_adc_to_mcelsius(bg_ptr, temp, &temp);
 	if (ret)
@@ -1016,7 +1018,7 @@ int omap_bandgap_probe(struct platform_device *pdev)
 		clk_prepare_enable(bg_ptr->fclock);
 
 
-	mutex_init(&bg_ptr->bg_mutex);
+	spin_lock_init(&bg_ptr->lock);
 	bg_ptr->dev = &pdev->dev;
 	platform_set_drvdata(pdev, bg_ptr);
 
diff --git a/drivers/staging/omap-thermal/omap-bandgap.h b/drivers/staging/omap-thermal/omap-bandgap.h
index edcc965..5700586 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.h
+++ b/drivers/staging/omap-thermal/omap-bandgap.h
@@ -23,7 +23,7 @@
 #ifndef __OMAP_BANDGAP_H
 #define __OMAP_BANDGAP_H
 
-#include <linux/mutex.h>
+#include <linux/spinlock.h>
 #include <linux/types.h>
 #include <linux/err.h>
 
@@ -211,7 +211,7 @@ struct omap_bandgap {
 	struct omap_bandgap_data	*conf;
 	struct clk			*fclock;
 	struct clk			*div_clk;
-	struct mutex			bg_mutex; /* shields this struct */
+	spinlock_t			lock; /* shields this struct */
 	int				irq;
 	int				tshut_gpio;
 	u32				clk_rate;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 48/50] staging: omap-thermal: remove TODO entry suggesting regmap usage
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

It is hard to use regmap because benefit of using regmap cache
may not be applicable as there is a specific sequence to
restore the bandgap context.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 0f24e9b..91e2070 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -1,7 +1,6 @@
 List of TODOs (by Eduardo Valentin)
 
 on omap-bandgap.c:
-- Improve driver code by adding usage of regmap-mmio
 - Test every exposed API to userland
 - Add support to hwmon
 - Review and revisit all API exposed
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 48/50] staging: omap-thermal: remove TODO entry suggesting regmap usage
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

It is hard to use regmap because benefit of using regmap cache
may not be applicable as there is a specific sequence to
restore the bandgap context.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 0f24e9b..91e2070 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -1,7 +1,6 @@
 List of TODOs (by Eduardo Valentin)
 
 on omap-bandgap.c:
-- Improve driver code by adding usage of regmap-mmio
 - Test every exposed API to userland
 - Add support to hwmon
 - Review and revisit all API exposed
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 49/50] staging: omap-thermal: remove TODO entry for exposed APIs
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Not all APIs exposed today are used. However all unused APIs
will be required once the thermal layer allows IRQ based
policies.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 91e2070..d45f556 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -3,7 +3,6 @@ List of TODOs (by Eduardo Valentin)
 on omap-bandgap.c:
 - Test every exposed API to userland
 - Add support to hwmon
-- Review and revisit all API exposed
 - Revisit PM support
 - Revisit data structures and simplify them
 - Once SCM-core api settles, update this driver accordingly
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 49/50] staging: omap-thermal: remove TODO entry for exposed APIs
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Not all APIs exposed today are used. However all unused APIs
will be required once the thermal layer allows IRQ based
policies.

Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
---
 drivers/staging/omap-thermal/TODO |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
index 91e2070..d45f556 100644
--- a/drivers/staging/omap-thermal/TODO
+++ b/drivers/staging/omap-thermal/TODO
@@ -3,7 +3,6 @@ List of TODOs (by Eduardo Valentin)
 on omap-bandgap.c:
 - Test every exposed API to userland
 - Add support to hwmon
-- Review and revisit all API exposed
 - Revisit PM support
 - Revisit data structures and simplify them
 - Once SCM-core api settles, update this driver accordingly
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 50/50] staging: omap-thermal: add documentation for omap_bandgap_validate
  2013-03-15 12:59 ` Eduardo Valentin
@ 2013-03-15 13:00   ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper to validate a struct omap_bandgap and a sensor id.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 846ced6..33bfe3b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -437,6 +437,14 @@ exit:
 	return err;
 }
 
+/**
+ * omap_bandgap_validate() - helper to check the sanity of a struct omap_bandgap
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ *
+ * Checks if the bandgap pointer is valid and if the sensor id is also
+ * applicable.
+ */
 static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
 {
 	int ret = 0;
-- 
1.7.7.1.488.ge8e1c


^ permalink raw reply related	[flat|nested] 128+ messages in thread

* [PATCH 50/50] staging: omap-thermal: add documentation for omap_bandgap_validate
@ 2013-03-15 13:00   ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-15 13:00 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-omap, linux-kernel, linux-pm, Eduardo Valentin

Document the helper to validate a struct omap_bandgap and a sensor id.

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

diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
index 846ced6..33bfe3b 100644
--- a/drivers/staging/omap-thermal/omap-bandgap.c
+++ b/drivers/staging/omap-thermal/omap-bandgap.c
@@ -437,6 +437,14 @@ exit:
 	return err;
 }
 
+/**
+ * omap_bandgap_validate() - helper to check the sanity of a struct omap_bandgap
+ * @bg_ptr: struct omap_bandgap pointer
+ * @id: bandgap sensor id
+ *
+ * Checks if the bandgap pointer is valid and if the sensor id is also
+ * applicable.
+ */
 static inline int omap_bandgap_validate(struct omap_bandgap *bg_ptr, int id)
 {
 	int ret = 0;
-- 
1.7.7.1.488.ge8e1c

^ permalink raw reply related	[flat|nested] 128+ messages in thread

* Re: [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
  2013-03-15 12:59   ` Eduardo Valentin
  (?)
@ 2013-03-15 21:09   ` Dan Carpenter
  2013-03-16 12:36       ` Eduardo Valentin
  -1 siblings, 1 reply; 128+ messages in thread
From: Dan Carpenter @ 2013-03-15 21:09 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 08:59:55AM -0400, Eduardo Valentin wrote:
> This patch introduce a macro to read, update, write bitfields.
> It will be specific to bandgap data structures.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> ---
>  drivers/staging/omap-thermal/omap-bandgap.c |  178 +++++++--------------------
>  1 files changed, 46 insertions(+), 132 deletions(-)
> 
> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
> index 9f2d7cc..1c1b905 100644
> --- a/drivers/staging/omap-thermal/omap-bandgap.c
> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
> @@ -52,25 +52,29 @@ static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
>  	writel(val, bg_ptr->base + reg);
>  }
>  
> +/* update bits, value will be shifted */
> +#define RMW_BITS(bg_ptr, id, reg, mask, val)			\
> +do {								\
> +	struct temp_sensor_registers *t;			\
> +	u32 r;							\
> +								\
> +	t = bg_ptr->conf->sensors[(id)].registers;		\
> +	r = omap_bandgap_readl(bg_ptr, t->reg);			\
> +	r &= ~t->mask;						\
> +	r |= (val) << __ffs(t->mask);				\
> +	omap_bandgap_writel(bg_ptr, r, t->reg);			\
> +} while (0)
> +
>  static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>  {
> -	struct temp_sensor_registers *tsr;
>  	int i;
> -	u32 ctrl;
>  
>  	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
>  		return 0;
>  
> -	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
> -		tsr = bg_ptr->conf->sensors[i].registers;
> -		ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
> -		ctrl &= ~tsr->bgap_tempsoff_mask;
> +	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
>  		/* active on 0 */
> -		ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
> -
> -		/* write BGAP_TEMPSOFF should be reset to 0 */
> -		omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
> -	}
> +		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
>  
>  	return 0;
>  }
> @@ -78,15 +82,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>  static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
>  {

This patch is fine and it makes it cleaner than before.

But that said, I don't care for the RMW_BITS() very much as a long
term thing.  If we just used pointers instead of passing the offset
into the bg_ptr->conf->sensors[] array then everything would be a
lot cleaner.

In other words, instead of this:

static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)

We would have:

static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr,
				  struct temp_sensor_registers *tsr)

If you have the pointer then it's easy write RMW_BITS() as a
function.

static void rmw_bits(struct omap_bandgap *bg_ptr, u32 reg, u32 mask, u32 val)
{
	u32 r;

	r = omap_bandgap_readl(bg_ptr, reg);
	r &= ~mask;
	r |= val << __ffs(mask);
	omap_bandgap_writel(bg_ptr, r, reg);
}

It's called like:

	rmw_bits(bg_ptr, tsr->bgap_mask_ctrl, tsr->mask_freeze_mask, 1);

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
  2013-03-15 12:59   ` Eduardo Valentin
  (?)
@ 2013-03-15 21:22   ` Dan Carpenter
  2013-03-16 12:39       ` Eduardo Valentin
  -1 siblings, 1 reply; 128+ messages in thread
From: Dan Carpenter @ 2013-03-15 21:22 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 08:59:57AM -0400, Eduardo Valentin wrote:
> Change the way the omap_bandgap_power is written so that it has only
> one exit entry (Documentation/CodingStyle).
> 

It's only if there is an unlock or something that you should do
this.  Otherwise the pointless bunny hop is misleading and annoying.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 22/50] staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel coding style
  2013-03-15 13:00   ` Eduardo Valentin
@ 2013-03-16  8:27     ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:27 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:10AM -0400, Eduardo Valentin wrote:
> Follow Documentation/CodingStyle while doing  omap_bandgap_adc_to_mcelsius.

Someone should probably fix CodingStyle to be more clear.  That's
not what was intended at all...  :/

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 22/50] staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel coding style
@ 2013-03-16  8:27     ` Dan Carpenter
  0 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:27 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: devel, gregkh, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:10AM -0400, Eduardo Valentin wrote:
> Follow Documentation/CodingStyle while doing  omap_bandgap_adc_to_mcelsius.

Someone should probably fix CodingStyle to be more clear.  That's
not what was intended at all...  :/

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 25/50] staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel coding style
  2013-03-15 13:00   ` Eduardo Valentin
  (?)
@ 2013-03-16  8:33   ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:33 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:13AM -0400, Eduardo Valentin wrote:
> Follow Documentation/CodingStyle while doing omap_bandgap_mcelsius_to_adc
> 

I have the same response for all these bunny hop patches.

When you're reading the code and you see a goto then you assume that
it's there for a reason so it's misleading when it doesn't do
anything.  It's simpler if the code is simple.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
  2013-03-15 13:00   ` Eduardo Valentin
  (?)
@ 2013-03-16  8:39   ` Dan Carpenter
  2013-03-16 12:49       ` Eduardo Valentin
  -1 siblings, 1 reply; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:39 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:21AM -0400, Eduardo Valentin wrote:
>  	if (ret) {
>  		dev_err(bg_ptr->dev, "failed to read thot\n");
> -		return -EIO;
> +		ret = -EIO;
> +		goto exit;
>  	}
>  
> -	*thot = temp;
> +	*val = temp;
>  
> +exit:
>  	return 0;
>  }


The bunny hop has introduced a bug and this always returns success.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  2013-03-15 13:00   ` Eduardo Valentin
@ 2013-03-16  8:59     ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:59 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:35AM -0400, Eduardo Valentin wrote:
> Because there is a need to lock inside IRQ handler, this patch
> changes the locking mechanism inside the omap-bandgap.[c,h] to
> spinlocks. Now this lock is used to protect omap_bandgap struct
> during APIs exposed (possibly used in sysfs handling functions)
> and inside the ALERT IRQ handler.
> 
> Because there are registers shared among the sensors, this lock
> is global, not per sensor.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> ---
>  drivers/staging/omap-thermal/TODO           |    1 -
>  drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
>  drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
>  3 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
> index 77b761b..0f24e9b 100644
> --- a/drivers/staging/omap-thermal/TODO
> +++ b/drivers/staging/omap-thermal/TODO
> @@ -1,7 +1,6 @@
>  List of TODOs (by Eduardo Valentin)
>  
>  on omap-bandgap.c:
> -- Rework locking
>  - Improve driver code by adding usage of regmap-mmio
>  - Test every exposed API to userland
>  - Add support to hwmon
> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
> index 4b631fd..846ced6 100644
> --- a/drivers/staging/omap-thermal/omap-bandgap.c
> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
> @@ -33,7 +33,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/err.h>
>  #include <linux/types.h>
> -#include <linux/mutex.h>
> +#include <linux/spinlock.h>
>  #include <linux/reboot.h>
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
> @@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>  	u32 t_hot = 0, t_cold = 0, ctrl;
>  	int i;
>  
> +	spin_lock(&bg_ptr->lock);
>  	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>  		tsr = bg_ptr->conf->sensors[i].registers;
>  		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
> @@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>  		if (bg_ptr->conf->report_temperature)
>  			bg_ptr->conf->report_temperature(bg_ptr, i);
>  	}
> +	spin_unlock(&bg_ptr->lock);
>  
>  	return IRQ_HANDLED;
>  }
> @@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
>  	if (ret < 0)
>  		goto exit;
>  
> -	mutex_lock(&bg_ptr->bg_mutex);
> +	spin_lock(&bg_ptr->lock);

These need to disable interrupts because we take the spin lock in
the IRQ handler.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
@ 2013-03-16  8:59     ` Dan Carpenter
  0 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  8:59 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: devel, gregkh, linux-omap, linux-kernel, linux-pm

On Fri, Mar 15, 2013 at 09:00:35AM -0400, Eduardo Valentin wrote:
> Because there is a need to lock inside IRQ handler, this patch
> changes the locking mechanism inside the omap-bandgap.[c,h] to
> spinlocks. Now this lock is used to protect omap_bandgap struct
> during APIs exposed (possibly used in sysfs handling functions)
> and inside the ALERT IRQ handler.
> 
> Because there are registers shared among the sensors, this lock
> is global, not per sensor.
> 
> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
> ---
>  drivers/staging/omap-thermal/TODO           |    1 -
>  drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
>  drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
>  3 files changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
> index 77b761b..0f24e9b 100644
> --- a/drivers/staging/omap-thermal/TODO
> +++ b/drivers/staging/omap-thermal/TODO
> @@ -1,7 +1,6 @@
>  List of TODOs (by Eduardo Valentin)
>  
>  on omap-bandgap.c:
> -- Rework locking
>  - Improve driver code by adding usage of regmap-mmio
>  - Test every exposed API to userland
>  - Add support to hwmon
> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
> index 4b631fd..846ced6 100644
> --- a/drivers/staging/omap-thermal/omap-bandgap.c
> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
> @@ -33,7 +33,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/err.h>
>  #include <linux/types.h>
> -#include <linux/mutex.h>
> +#include <linux/spinlock.h>
>  #include <linux/reboot.h>
>  #include <linux/of_device.h>
>  #include <linux/of_platform.h>
> @@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>  	u32 t_hot = 0, t_cold = 0, ctrl;
>  	int i;
>  
> +	spin_lock(&bg_ptr->lock);
>  	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>  		tsr = bg_ptr->conf->sensors[i].registers;
>  		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
> @@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>  		if (bg_ptr->conf->report_temperature)
>  			bg_ptr->conf->report_temperature(bg_ptr, i);
>  	}
> +	spin_unlock(&bg_ptr->lock);
>  
>  	return IRQ_HANDLED;
>  }
> @@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
>  	if (ret < 0)
>  		goto exit;
>  
> -	mutex_lock(&bg_ptr->bg_mutex);
> +	spin_lock(&bg_ptr->lock);

These need to disable interrupts because we take the spin lock in
the IRQ handler.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
  2013-03-15 12:59 ` Eduardo Valentin
                   ` (50 preceding siblings ...)
  (?)
@ 2013-03-16  9:05 ` Dan Carpenter
  2013-03-16 12:46     ` Eduardo Valentin
  -1 siblings, 1 reply; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16  9:05 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

I've reviewed this set.

I hate to make people redo whole patchset sets, and I hate
re-reviewing code.  Obviously, I don't really like the bunny hop
patches and I'm trying to discourage that going forward.  ;P  But
I wouldn't say it's a "Redo the whole thing" kind of problem.

Could just resend patch 33 and 47?  You should probably be able to
redo those without changing the rest.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
  2013-03-15 21:09   ` Dan Carpenter
@ 2013-03-16 12:36       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:36 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

Hello Dan,

On 15-03-2013 17:09, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 08:59:55AM -0400, Eduardo Valentin wrote:
>> This patch introduce a macro to read, update, write bitfields.
>> It will be specific to bandgap data structures.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/omap-thermal/omap-bandgap.c |  178 +++++++--------------------
>>   1 files changed, 46 insertions(+), 132 deletions(-)
>>
>> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
>> index 9f2d7cc..1c1b905 100644
>> --- a/drivers/staging/omap-thermal/omap-bandgap.c
>> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
>> @@ -52,25 +52,29 @@ static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
>>   	writel(val, bg_ptr->base + reg);
>>   }
>>
>> +/* update bits, value will be shifted */
>> +#define RMW_BITS(bg_ptr, id, reg, mask, val)			\
>> +do {								\
>> +	struct temp_sensor_registers *t;			\
>> +	u32 r;							\
>> +								\
>> +	t = bg_ptr->conf->sensors[(id)].registers;		\
>> +	r = omap_bandgap_readl(bg_ptr, t->reg);			\
>> +	r &= ~t->mask;						\
>> +	r |= (val) << __ffs(t->mask);				\
>> +	omap_bandgap_writel(bg_ptr, r, t->reg);			\
>> +} while (0)
>> +
>>   static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>>   {
>> -	struct temp_sensor_registers *tsr;
>>   	int i;
>> -	u32 ctrl;
>>
>>   	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
>>   		return 0;
>>
>> -	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>> -		tsr = bg_ptr->conf->sensors[i].registers;
>> -		ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
>> -		ctrl &= ~tsr->bgap_tempsoff_mask;
>> +	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
>>   		/* active on 0 */
>> -		ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
>> -
>> -		/* write BGAP_TEMPSOFF should be reset to 0 */
>> -		omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
>> -	}
>> +		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
>>
>>   	return 0;
>>   }
>> @@ -78,15 +82,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>>   static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
>>   {
>
> This patch is fine and it makes it cleaner than before.
>
> But that said, I don't care for the RMW_BITS() very much as a long
> term thing.  If we just used pointers instead of passing the offset
> into the bg_ptr->conf->sensors[] array then everything would be a
> lot cleaner.
>
> In other words, instead of this:
>
> static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
>
> We would have:
>
> static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr,
> 				  struct temp_sensor_registers *tsr)

I see. That will require a change in the whole driver though. If you 
see, the driver as of today uses the former approach, not only for 
read_temp or rmw_bits.

>
> If you have the pointer then it's easy write RMW_BITS() as a
> function.
>
> static void rmw_bits(struct omap_bandgap *bg_ptr, u32 reg, u32 mask, u32 val)
> {
> 	u32 r;
>
> 	r = omap_bandgap_readl(bg_ptr, reg);
> 	r &= ~mask;
> 	r |= val << __ffs(mask);
> 	omap_bandgap_writel(bg_ptr, r, reg);
> }
>
> It's called like:
>
> 	rmw_bits(bg_ptr, tsr->bgap_mask_ctrl, tsr->mask_freeze_mask, 1);

This is nice, but it will require fetching tsr from .conf before every 
call o rmw_bits. And for that you need the sensor index.

>
> regards,
> dan carpenter

Thanks for your time reviewing this patch and suggesting improvements.

>
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
@ 2013-03-16 12:36       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:36 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: devel, gregkh, linux-omap, linux-kernel, linux-pm

Hello Dan,

On 15-03-2013 17:09, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 08:59:55AM -0400, Eduardo Valentin wrote:
>> This patch introduce a macro to read, update, write bitfields.
>> It will be specific to bandgap data structures.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/omap-thermal/omap-bandgap.c |  178 +++++++--------------------
>>   1 files changed, 46 insertions(+), 132 deletions(-)
>>
>> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
>> index 9f2d7cc..1c1b905 100644
>> --- a/drivers/staging/omap-thermal/omap-bandgap.c
>> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
>> @@ -52,25 +52,29 @@ static void omap_bandgap_writel(struct omap_bandgap *bg_ptr, u32 val, u32 reg)
>>   	writel(val, bg_ptr->base + reg);
>>   }
>>
>> +/* update bits, value will be shifted */
>> +#define RMW_BITS(bg_ptr, id, reg, mask, val)			\
>> +do {								\
>> +	struct temp_sensor_registers *t;			\
>> +	u32 r;							\
>> +								\
>> +	t = bg_ptr->conf->sensors[(id)].registers;		\
>> +	r = omap_bandgap_readl(bg_ptr, t->reg);			\
>> +	r &= ~t->mask;						\
>> +	r |= (val) << __ffs(t->mask);				\
>> +	omap_bandgap_writel(bg_ptr, r, t->reg);			\
>> +} while (0)
>> +
>>   static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>>   {
>> -	struct temp_sensor_registers *tsr;
>>   	int i;
>> -	u32 ctrl;
>>
>>   	if (!OMAP_BANDGAP_HAS(bg_ptr, POWER_SWITCH))
>>   		return 0;
>>
>> -	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>> -		tsr = bg_ptr->conf->sensors[i].registers;
>> -		ctrl = omap_bandgap_readl(bg_ptr, tsr->temp_sensor_ctrl);
>> -		ctrl &= ~tsr->bgap_tempsoff_mask;
>> +	for (i = 0; i < bg_ptr->conf->sensor_count; i++)
>>   		/* active on 0 */
>> -		ctrl |= !on << __ffs(tsr->bgap_tempsoff_mask);
>> -
>> -		/* write BGAP_TEMPSOFF should be reset to 0 */
>> -		omap_bandgap_writel(bg_ptr, ctrl, tsr->temp_sensor_ctrl);
>> -	}
>> +		RMW_BITS(bg_ptr, i, temp_sensor_ctrl, bgap_tempsoff_mask, !on);
>>
>>   	return 0;
>>   }
>> @@ -78,15 +82,13 @@ static int omap_bandgap_power(struct omap_bandgap *bg_ptr, bool on)
>>   static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
>>   {
>
> This patch is fine and it makes it cleaner than before.
>
> But that said, I don't care for the RMW_BITS() very much as a long
> term thing.  If we just used pointers instead of passing the offset
> into the bg_ptr->conf->sensors[] array then everything would be a
> lot cleaner.
>
> In other words, instead of this:
>
> static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
>
> We would have:
>
> static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr,
> 				  struct temp_sensor_registers *tsr)

I see. That will require a change in the whole driver though. If you 
see, the driver as of today uses the former approach, not only for 
read_temp or rmw_bits.

>
> If you have the pointer then it's easy write RMW_BITS() as a
> function.
>
> static void rmw_bits(struct omap_bandgap *bg_ptr, u32 reg, u32 mask, u32 val)
> {
> 	u32 r;
>
> 	r = omap_bandgap_readl(bg_ptr, reg);
> 	r &= ~mask;
> 	r |= val << __ffs(mask);
> 	omap_bandgap_writel(bg_ptr, r, reg);
> }
>
> It's called like:
>
> 	rmw_bits(bg_ptr, tsr->bgap_mask_ctrl, tsr->mask_freeze_mask, 1);

This is nice, but it will require fetching tsr from .conf before every 
call o rmw_bits. And for that you need the sensor index.

>
> regards,
> dan carpenter

Thanks for your time reviewing this patch and suggesting improvements.

>
>
>
>

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
  2013-03-15 21:22   ` Dan Carpenter
@ 2013-03-16 12:39       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:39 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

Hey Dan,

On 15-03-2013 17:22, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 08:59:57AM -0400, Eduardo Valentin wrote:
>> Change the way the omap_bandgap_power is written so that it has only
>> one exit entry (Documentation/CodingStyle).
>>
>
> It's only if there is an unlock or something that you should do
> this.  Otherwise the pointless bunny hop is misleading and annoying.

Well, if that is the case the Chapter 7 needs to be rewritten, don't you 
think? The way it is stated, it is clear that it is a design decision to 
use it for keeping only one exit point (quoting):

"Albeit deprecated by some people, the equivalent of the goto statement is
used frequently by compilers in form of the unconditional jump instruction.

The goto statement comes in handy when a function exits from multiple
locations and some common work such as cleanup has to be done.

The rationale is:

- unconditional statements are easier to understand and follow
- nesting is reduced
- errors by not updating individual exit points when making
     modifications are prevented
- saves the compiler work to optimize redundant code away ;)"

I believe this patch falls into at least three of the above rationale.


>
> regards,
> dan carpenter
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
@ 2013-03-16 12:39       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:39 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

Hey Dan,

On 15-03-2013 17:22, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 08:59:57AM -0400, Eduardo Valentin wrote:
>> Change the way the omap_bandgap_power is written so that it has only
>> one exit entry (Documentation/CodingStyle).
>>
>
> It's only if there is an unlock or something that you should do
> this.  Otherwise the pointless bunny hop is misleading and annoying.

Well, if that is the case the Chapter 7 needs to be rewritten, don't you 
think? The way it is stated, it is clear that it is a design decision to 
use it for keeping only one exit point (quoting):

"Albeit deprecated by some people, the equivalent of the goto statement is
used frequently by compilers in form of the unconditional jump instruction.

The goto statement comes in handy when a function exits from multiple
locations and some common work such as cleanup has to be done.

The rationale is:

- unconditional statements are easier to understand and follow
- nesting is reduced
- errors by not updating individual exit points when making
     modifications are prevented
- saves the compiler work to optimize redundant code away ;)"

I believe this patch falls into at least three of the above rationale.


>
> regards,
> dan carpenter
>
>
>

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  2013-03-16  8:59     ` Dan Carpenter
@ 2013-03-16 12:41       ` Eduardo Valentin
  -1 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:41 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On 16-03-2013 04:59, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 09:00:35AM -0400, Eduardo Valentin wrote:
>> Because there is a need to lock inside IRQ handler, this patch
>> changes the locking mechanism inside the omap-bandgap.[c,h] to
>> spinlocks. Now this lock is used to protect omap_bandgap struct
>> during APIs exposed (possibly used in sysfs handling functions)
>> and inside the ALERT IRQ handler.
>>
>> Because there are registers shared among the sensors, this lock
>> is global, not per sensor.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/omap-thermal/TODO           |    1 -
>>   drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
>>   drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
>>   3 files changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
>> index 77b761b..0f24e9b 100644
>> --- a/drivers/staging/omap-thermal/TODO
>> +++ b/drivers/staging/omap-thermal/TODO
>> @@ -1,7 +1,6 @@
>>   List of TODOs (by Eduardo Valentin)
>>
>>   on omap-bandgap.c:
>> -- Rework locking
>>   - Improve driver code by adding usage of regmap-mmio
>>   - Test every exposed API to userland
>>   - Add support to hwmon
>> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
>> index 4b631fd..846ced6 100644
>> --- a/drivers/staging/omap-thermal/omap-bandgap.c
>> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
>> @@ -33,7 +33,7 @@
>>   #include <linux/platform_device.h>
>>   #include <linux/err.h>
>>   #include <linux/types.h>
>> -#include <linux/mutex.h>
>> +#include <linux/spinlock.h>
>>   #include <linux/reboot.h>
>>   #include <linux/of_device.h>
>>   #include <linux/of_platform.h>
>> @@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>>   	u32 t_hot = 0, t_cold = 0, ctrl;
>>   	int i;
>>
>> +	spin_lock(&bg_ptr->lock);
>>   	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>>   		tsr = bg_ptr->conf->sensors[i].registers;
>>   		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
>> @@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>>   		if (bg_ptr->conf->report_temperature)
>>   			bg_ptr->conf->report_temperature(bg_ptr, i);
>>   	}
>> +	spin_unlock(&bg_ptr->lock);
>>
>>   	return IRQ_HANDLED;
>>   }
>> @@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
>>   	if (ret < 0)
>>   		goto exit;
>>
>> -	mutex_lock(&bg_ptr->bg_mutex);
>> +	spin_lock(&bg_ptr->lock);
>
> These need to disable interrupts because we take the spin lock in
> the IRQ handler.

This IRQ gets masked at the IRQ controller level when served (ONE_SHOT). 
Not sure if your comment is applicable in this case..

>
> regards,
> dan carpenter
>
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
@ 2013-03-16 12:41       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:41 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On 16-03-2013 04:59, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 09:00:35AM -0400, Eduardo Valentin wrote:
>> Because there is a need to lock inside IRQ handler, this patch
>> changes the locking mechanism inside the omap-bandgap.[c,h] to
>> spinlocks. Now this lock is used to protect omap_bandgap struct
>> during APIs exposed (possibly used in sysfs handling functions)
>> and inside the ALERT IRQ handler.
>>
>> Because there are registers shared among the sensors, this lock
>> is global, not per sensor.
>>
>> Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
>> ---
>>   drivers/staging/omap-thermal/TODO           |    1 -
>>   drivers/staging/omap-thermal/omap-bandgap.c |   18 ++++++++++--------
>>   drivers/staging/omap-thermal/omap-bandgap.h |    4 ++--
>>   3 files changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/staging/omap-thermal/TODO b/drivers/staging/omap-thermal/TODO
>> index 77b761b..0f24e9b 100644
>> --- a/drivers/staging/omap-thermal/TODO
>> +++ b/drivers/staging/omap-thermal/TODO
>> @@ -1,7 +1,6 @@
>>   List of TODOs (by Eduardo Valentin)
>>
>>   on omap-bandgap.c:
>> -- Rework locking
>>   - Improve driver code by adding usage of regmap-mmio
>>   - Test every exposed API to userland
>>   - Add support to hwmon
>> diff --git a/drivers/staging/omap-thermal/omap-bandgap.c b/drivers/staging/omap-thermal/omap-bandgap.c
>> index 4b631fd..846ced6 100644
>> --- a/drivers/staging/omap-thermal/omap-bandgap.c
>> +++ b/drivers/staging/omap-thermal/omap-bandgap.c
>> @@ -33,7 +33,7 @@
>>   #include <linux/platform_device.h>
>>   #include <linux/err.h>
>>   #include <linux/types.h>
>> -#include <linux/mutex.h>
>> +#include <linux/spinlock.h>
>>   #include <linux/reboot.h>
>>   #include <linux/of_device.h>
>>   #include <linux/of_platform.h>
>> @@ -170,6 +170,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>>   	u32 t_hot = 0, t_cold = 0, ctrl;
>>   	int i;
>>
>> +	spin_lock(&bg_ptr->lock);
>>   	for (i = 0; i < bg_ptr->conf->sensor_count; i++) {
>>   		tsr = bg_ptr->conf->sensors[i].registers;
>>   		ctrl = omap_bandgap_readl(bg_ptr, tsr->bgap_status);
>> @@ -208,6 +209,7 @@ static irqreturn_t omap_bandgap_talert_irq_handler(int irq, void *data)
>>   		if (bg_ptr->conf->report_temperature)
>>   			bg_ptr->conf->report_temperature(bg_ptr, i);
>>   	}
>> +	spin_unlock(&bg_ptr->lock);
>>
>>   	return IRQ_HANDLED;
>>   }
>> @@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
>>   	if (ret < 0)
>>   		goto exit;
>>
>> -	mutex_lock(&bg_ptr->bg_mutex);
>> +	spin_lock(&bg_ptr->lock);
>
> These need to disable interrupts because we take the spin lock in
> the IRQ handler.

This IRQ gets masked at the IRQ controller level when served (ONE_SHOT). 
Not sure if your comment is applicable in this case..

>
> regards,
> dan carpenter
>
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
  2013-03-16  9:05 ` [PATCH 00/50] staging: omap-thermal: several code refactoring Dan Carpenter
@ 2013-03-16 12:46     ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

Hello Dan,

On 16-03-2013 05:05, Dan Carpenter wrote:
> I've reviewed this set.
>
> I hate to make people redo whole patchset sets, and I hate
> re-reviewing code.  Obviously, I don't really like the bunny hop
> patches and I'm trying to discourage that going forward.  ;P  But
> I wouldn't say it's a "Redo the whole thing" kind of problem.
>
> Could just resend patch 33 and 47?  You should probably be able to
> redo those without changing the rest.

I could of course change them if the comment is better clarified. As I 
mentioned as reply to one of your comments, those changes are following 
what is suggested in CodingStyle file.

I can of course send a diff on top of 33, to fix the introduce bug.

For 47, I'm not sure the comment is fully applicable.

>
> regards,
> dan carpenter
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
@ 2013-03-16 12:46     ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:46 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

Hello Dan,

On 16-03-2013 05:05, Dan Carpenter wrote:
> I've reviewed this set.
>
> I hate to make people redo whole patchset sets, and I hate
> re-reviewing code.  Obviously, I don't really like the bunny hop
> patches and I'm trying to discourage that going forward.  ;P  But
> I wouldn't say it's a "Redo the whole thing" kind of problem.
>
> Could just resend patch 33 and 47?  You should probably be able to
> redo those without changing the rest.

I could of course change them if the comment is better clarified. As I 
mentioned as reply to one of your comments, those changes are following 
what is suggested in CodingStyle file.

I can of course send a diff on top of 33, to fix the introduce bug.

For 47, I'm not sure the comment is fully applicable.

>
> regards,
> dan carpenter
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
  2013-03-16  8:39   ` Dan Carpenter
@ 2013-03-16 12:49       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:49 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On 16-03-2013 04:39, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 09:00:21AM -0400, Eduardo Valentin wrote:
>>   	if (ret) {
>>   		dev_err(bg_ptr->dev, "failed to read thot\n");
>> -		return -EIO;
>> +		ret = -EIO;
>> +		goto exit;
>>   	}
>>
>> -	*thot = temp;
>> +	*val = temp;
>>
>> +exit:
>>   	return 0;
>>   }
>
>
> The bunny hop has introduced a bug and this always returns success.

What was the bug introduced?

I will send a patch to fix the return value.

>
> regards,
> dan carpenter
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
@ 2013-03-16 12:49       ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-16 12:49 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On 16-03-2013 04:39, Dan Carpenter wrote:
> On Fri, Mar 15, 2013 at 09:00:21AM -0400, Eduardo Valentin wrote:
>>   	if (ret) {
>>   		dev_err(bg_ptr->dev, "failed to read thot\n");
>> -		return -EIO;
>> +		ret = -EIO;
>> +		goto exit;
>>   	}
>>
>> -	*thot = temp;
>> +	*val = temp;
>>
>> +exit:
>>   	return 0;
>>   }
>
>
> The bunny hop has introduced a bug and this always returns success.

What was the bug introduced?

I will send a patch to fix the return value.

>
> regards,
> dan carpenter
>
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point
  2013-03-16 12:39       ` Eduardo Valentin
  (?)
@ 2013-03-16 13:56       ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16 13:56 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Sat, Mar 16, 2013 at 08:39:11AM -0400, Eduardo Valentin wrote:
> Hey Dan,
> 
> On 15-03-2013 17:22, Dan Carpenter wrote:
> >On Fri, Mar 15, 2013 at 08:59:57AM -0400, Eduardo Valentin wrote:
> >>Change the way the omap_bandgap_power is written so that it has only
> >>one exit entry (Documentation/CodingStyle).
> >>
> >
> >It's only if there is an unlock or something that you should do
> >this.  Otherwise the pointless bunny hop is misleading and annoying.
> 
> Well, if that is the case the Chapter 7 needs to be rewritten, don't
> you think? The way it is stated, it is clear that it is a design
> decision to use it for keeping only one exit point (quoting):
> 
> "Albeit deprecated by some people, the equivalent of the goto statement is
> used frequently by compilers in form of the unconditional jump instruction.
> 
> The goto statement comes in handy when a function exits from multiple
> locations and some common work such as cleanup has to be done.
> 
> The rationale is:
> 
> - unconditional statements are easier to understand and follow
> - nesting is reduced
> - errors by not updating individual exit points when making
>     modifications are prevented
> - saves the compiler work to optimize redundant code away ;)"
> 
> I believe this patch falls into at least three of the above rationale.

There isn't any cleanup work done.  That's what I was explaining
about.  When I see a goto I expect cleanup work to be done, but in
this case it was misleading.

Where you would do the one exit point is when there is cleanup:

	ret = function_one();
	if (ret)
		goto unlock;

	ret = function_two();
	if (ret)
		goto unlock;


That's better than:
	ret = function_one();
	if (ret) {
		mutex_unlock();
		return ret;
	}

	ret = function_two();
	if (ret) {
		mutex_unlock();
		return ret;
	}

On the one hand, I think the documentation should be updated because
obviously people get confused by it.  But on the other hand, to me
the documentation is already pretty clear.  There is no style
guideline that says every function should only have a single return.
That would be silly.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values
  2013-03-16 12:49       ` Eduardo Valentin
  (?)
@ 2013-03-16 13:58       ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16 13:58 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Sat, Mar 16, 2013 at 08:49:20AM -0400, Eduardo Valentin wrote:
> On 16-03-2013 04:39, Dan Carpenter wrote:
> >On Fri, Mar 15, 2013 at 09:00:21AM -0400, Eduardo Valentin wrote:
> >>  	if (ret) {
> >>  		dev_err(bg_ptr->dev, "failed to read thot\n");
> >>-		return -EIO;
> >>+		ret = -EIO;
> >>+		goto exit;
> >>  	}
> >>
> >>-	*thot = temp;
> >>+	*val = temp;
> >>
> >>+exit:
> >>  	return 0;
> >>  }
> >
> >
> >The bunny hop has introduced a bug and this always returns success.
> 
> What was the bug introduced?
> 
> I will send a patch to fix the return value.

Returning the wrong value *is* the bug.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro
  2013-03-16 12:36       ` Eduardo Valentin
  (?)
@ 2013-03-16 14:00       ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16 14:00 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: gregkh, devel, linux-omap, linux-kernel, linux-pm

On Sat, Mar 16, 2013 at 08:36:51AM -0400, Eduardo Valentin wrote:
> >But that said, I don't care for the RMW_BITS() very much as a long
> >term thing.  If we just used pointers instead of passing the offset
> >into the bg_ptr->conf->sensors[] array then everything would be a
> >lot cleaner.
> >
> >In other words, instead of this:
> >
> >static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr, int id)
> >
> >We would have:
> >
> >static u32 omap_bandgap_read_temp(struct omap_bandgap *bg_ptr,
> >				  struct temp_sensor_registers *tsr)
> 
> I see. That will require a change in the whole driver though. If you
> see, the driver as of today uses the former approach, not only for
> read_temp or rmw_bits.

Yep.

> 
> >
> >If you have the pointer then it's easy write RMW_BITS() as a
> >function.
> >
> >static void rmw_bits(struct omap_bandgap *bg_ptr, u32 reg, u32 mask, u32 val)
> >{
> >	u32 r;
> >
> >	r = omap_bandgap_readl(bg_ptr, reg);
> >	r &= ~mask;
> >	r |= val << __ffs(mask);
> >	omap_bandgap_writel(bg_ptr, r, reg);
> >}
> >
> >It's called like:
> >
> >	rmw_bits(bg_ptr, tsr->bgap_mask_ctrl, tsr->mask_freeze_mask, 1);
> 
> This is nice, but it will require fetching tsr from .conf before
> every call o rmw_bits. And for that you need the sensor index.
> 

No.  I'm suggesting that you re-write the driver to pass the tsr
pointer directly instead of the index.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap
  2013-03-16 12:41       ` Eduardo Valentin
  (?)
@ 2013-03-16 14:22       ` Dan Carpenter
  -1 siblings, 0 replies; 128+ messages in thread
From: Dan Carpenter @ 2013-03-16 14:22 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: devel, gregkh, linux-omap, linux-kernel, linux-pm

On Sat, Mar 16, 2013 at 08:41:30AM -0400, Eduardo Valentin wrote:
> On 16-03-2013 04:59, Dan Carpenter wrote:
> >On Fri, Mar 15, 2013 at 09:00:35AM -0400, Eduardo Valentin wrote:
> >>@@ -502,9 +504,9 @@ int _omap_bandgap_write_threshold(struct omap_bandgap *bg_ptr, int id, int val,
> >>  	if (ret < 0)
> >>  		goto exit;
> >>
> >>-	mutex_lock(&bg_ptr->bg_mutex);
> >>+	spin_lock(&bg_ptr->lock);
> >
> >These need to disable interrupts because we take the spin lock in
> >the IRQ handler.
> 
> This IRQ gets masked at the IRQ controller level when served
> (ONE_SHOT). Not sure if your comment is applicable in this case..

Yes.  It still applies.  We need to disable IRQs from the current
CPU while we are holding a spin_lock which they will need.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
  2013-03-16 12:46     ` Eduardo Valentin
  (?)
@ 2013-03-16 16:16     ` Greg KH
  2013-03-18 14:44         ` Eduardo Valentin
  -1 siblings, 1 reply; 128+ messages in thread
From: Greg KH @ 2013-03-16 16:16 UTC (permalink / raw)
  To: Eduardo Valentin; +Cc: Dan Carpenter, devel, linux-omap, linux-kernel, linux-pm

On Sat, Mar 16, 2013 at 08:46:03AM -0400, Eduardo Valentin wrote:
> Hello Dan,
> 
> On 16-03-2013 05:05, Dan Carpenter wrote:
> >I've reviewed this set.
> >
> >I hate to make people redo whole patchset sets, and I hate
> >re-reviewing code.  Obviously, I don't really like the bunny hop
> >patches and I'm trying to discourage that going forward.  ;P  But
> >I wouldn't say it's a "Redo the whole thing" kind of problem.
> >
> >Could just resend patch 33 and 47?  You should probably be able to
> >redo those without changing the rest.
> 
> I could of course change them if the comment is better clarified. As
> I mentioned as reply to one of your comments, those changes are
> following what is suggested in CodingStyle file.
> 
> I can of course send a diff on top of 33, to fix the introduce bug.
> 
> For 47, I'm not sure the comment is fully applicable.

As I've taken all of these already (sorry Dan, I was fast and I didn't
review them as well as you did), you will have to just send incremental
patches on top of the whole series in order for me to be able to apply
them.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
  2013-03-16 16:16     ` Greg KH
@ 2013-03-18 14:44         ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-18 14:44 UTC (permalink / raw)
  To: Greg KH; +Cc: Dan Carpenter, devel, linux-omap, linux-kernel, linux-pm

Greg, Dan,

On 16-03-2013 12:16, Greg KH wrote:
> On Sat, Mar 16, 2013 at 08:46:03AM -0400, Eduardo Valentin wrote:
>> Hello Dan,
>>
>> On 16-03-2013 05:05, Dan Carpenter wrote:
>>> I've reviewed this set.
>>>
>>> I hate to make people redo whole patchset sets, and I hate
>>> re-reviewing code.  Obviously, I don't really like the bunny hop
>>> patches and I'm trying to discourage that going forward.  ;P  But
>>> I wouldn't say it's a "Redo the whole thing" kind of problem.
>>>
>>> Could just resend patch 33 and 47?  You should probably be able to
>>> redo those without changing the rest.
>>
>> I could of course change them if the comment is better clarified. As
>> I mentioned as reply to one of your comments, those changes are
>> following what is suggested in CodingStyle file.
>>
>> I can of course send a diff on top of 33, to fix the introduce bug.
>>
>> For 47, I'm not sure the comment is fully applicable.
>
> As I've taken all of these already (sorry Dan, I was fast and I didn't
> review them as well as you did), you will have to just send incremental
> patches on top of the whole series in order for me to be able to apply
> them.

No issues here, I am going to send soon incremental patches, copying 
Dan, to fix the above mentioned issues on 33 and 47.

>
> thanks,
>
> greg k-h
>
>


^ permalink raw reply	[flat|nested] 128+ messages in thread

* Re: [PATCH 00/50] staging: omap-thermal: several code refactoring
@ 2013-03-18 14:44         ` Eduardo Valentin
  0 siblings, 0 replies; 128+ messages in thread
From: Eduardo Valentin @ 2013-03-18 14:44 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, linux-omap, linux-kernel, Dan Carpenter, linux-pm

Greg, Dan,

On 16-03-2013 12:16, Greg KH wrote:
> On Sat, Mar 16, 2013 at 08:46:03AM -0400, Eduardo Valentin wrote:
>> Hello Dan,
>>
>> On 16-03-2013 05:05, Dan Carpenter wrote:
>>> I've reviewed this set.
>>>
>>> I hate to make people redo whole patchset sets, and I hate
>>> re-reviewing code.  Obviously, I don't really like the bunny hop
>>> patches and I'm trying to discourage that going forward.  ;P  But
>>> I wouldn't say it's a "Redo the whole thing" kind of problem.
>>>
>>> Could just resend patch 33 and 47?  You should probably be able to
>>> redo those without changing the rest.
>>
>> I could of course change them if the comment is better clarified. As
>> I mentioned as reply to one of your comments, those changes are
>> following what is suggested in CodingStyle file.
>>
>> I can of course send a diff on top of 33, to fix the introduce bug.
>>
>> For 47, I'm not sure the comment is fully applicable.
>
> As I've taken all of these already (sorry Dan, I was fast and I didn't
> review them as well as you did), you will have to just send incremental
> patches on top of the whole series in order for me to be able to apply
> them.

No issues here, I am going to send soon incremental patches, copying 
Dan, to fix the above mentioned issues on 33 and 47.

>
> thanks,
>
> greg k-h
>
>

^ permalink raw reply	[flat|nested] 128+ messages in thread

end of thread, other threads:[~2013-03-18 14:45 UTC | newest]

Thread overview: 128+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-15 12:59 [PATCH 00/50] staging: omap-thermal: several code refactoring Eduardo Valentin
2013-03-15 12:59 ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 01/50] staging: omap-thermal: use BIT() macro Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 02/50] staging: omap-thermal: remove unused _SHIFT macros Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 03/50] staging: omap-thermal: create header for register, bitfields and definitions Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 04/50] staging: omap-thermal: update documentation of omap-bandgap.h Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 05/50] staging: omap-thermal: style cleanup on omap-bandgap.c Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 06/50] staging: omap-thermal: fix error checking Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 07/50] staging: omap-thermal: introduce RMW_BITS macro Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 21:09   ` Dan Carpenter
2013-03-16 12:36     ` Eduardo Valentin
2013-03-16 12:36       ` Eduardo Valentin
2013-03-16 14:00       ` Dan Carpenter
2013-03-15 12:59 ` [PATCH 08/50] staging: omap-thermal: add documentation for register access functions Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 09/50] staging: omap-thermal: make a omap_bandgap_power with only one exit point Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 21:22   ` Dan Carpenter
2013-03-16 12:39     ` Eduardo Valentin
2013-03-16 12:39       ` Eduardo Valentin
2013-03-16 13:56       ` Dan Carpenter
2013-03-15 12:59 ` [PATCH 10/50] staging: omap-thermal: add documentation for omap_bandgap_power Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 12:59 ` [PATCH 11/50] staging: omap-thermal: add documentation for omap_bandgap_read_temp Eduardo Valentin
2013-03-15 12:59   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 12/50] staging: omap-thermal: rename talert handler Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 13/50] staging: omap-thermal: update documentation for talert irq handler Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 14/50] staging: omap-thermal: update tshut IRQ handler documentation Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 15/50] staging: omap-thermal: remove duplicated code Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 16/50] staging: omap-thermal: read status only once inside alert IRQ Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 17/50] staging: omap-thermal: add a section of register manipulation Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 18/50] staging: omap-thermal: section of basic helpers Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 19/50] staging: omap-thermal: IRQ handler section Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 20/50] staging: omap-thermal: ADC section Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 21/50] staging: omap-thermal: name adc_to_temp_conversion in a better way Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 22/50] staging: omap-thermal: rewrite omap_bandgap_adc_to_mcelsius on kernel coding style Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-16  8:27   ` Dan Carpenter
2013-03-16  8:27     ` Dan Carpenter
2013-03-15 13:00 ` [PATCH 23/50] staging: omap-thermal: add documentation for omap_bandgap_adc_to_mcelsius Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 24/50] staging: omap-thermal: name temp_to_adc_conversion in a better way Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 25/50] staging: omap-thermal: rewrite omap_bandgap_mcelsius_to_adc on kernel coding style Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-16  8:33   ` Dan Carpenter
2013-03-15 13:00 ` [PATCH 26/50] staging: omap-thermal: move conv table limits out of sensor data Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 27/50] staging: omap-thermal: add documentation for omap_bandgap_mcelsius_to_adc Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 28/50] staging: omap-thermal: rename add_hyst to omap_bandgap_add_hyst Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 29/50] staging: omap-thermal: document omap_bandgap_add_hyst function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 30/50] staging: omap-thermal: threshold manipulation section Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 31/50] staging: omap-thermal: refactor temp_sensor_unmask_interrupts Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 32/50] staging: omap-thermal: update omap_bandgap_unmask_interrupts documentation Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 33/50] staging: omap-thermal: refactor APIs handling threshold values Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-16  8:39   ` Dan Carpenter
2013-03-16 12:49     ` Eduardo Valentin
2013-03-16 12:49       ` Eduardo Valentin
2013-03-16 13:58       ` Dan Carpenter
2013-03-15 13:00 ` [PATCH 34/50] staging: omap-thermal: device initialization section Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 35/50] staging: omap-thermal: section of device driver callbacks Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 36/50] staging: omap-thermal: rename enable_continuous_mode Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 37/50] staging: omap-thermal: update omap_bandgap_set_continous_mode documentation Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 38/50] staging: omap-thermal: document omap_bandgap_force_single_read Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 39/50] staging: omap-thermal: document omap_bandgap_update_alert_threshold function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 40/50] staging: omap-thermal: document _omap_bandgap_write_threshold function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 41/50] staging: omap-thermal: document _omap_bandgap_read_threshold function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 42/50] staging: omap-thermal: document omap_bandgap_tshut_init function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 43/50] staging: omap-thermal: document omap_bandgap_alert_init function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 44/50] staging: omap-thermal: document omap_bandgap_build function Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 45/50] staging: omap-thermal: change Kconfig dependency method Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 46/50] staging: Add a MAINTAINERS entry for TI bandgap and thermal driver Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 47/50] staging: omap-thermal: switch mutex to spinlock inside omap-bandgap Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-16  8:59   ` Dan Carpenter
2013-03-16  8:59     ` Dan Carpenter
2013-03-16 12:41     ` Eduardo Valentin
2013-03-16 12:41       ` Eduardo Valentin
2013-03-16 14:22       ` Dan Carpenter
2013-03-15 13:00 ` [PATCH 48/50] staging: omap-thermal: remove TODO entry suggesting regmap usage Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 49/50] staging: omap-thermal: remove TODO entry for exposed APIs Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-15 13:00 ` [PATCH 50/50] staging: omap-thermal: add documentation for omap_bandgap_validate Eduardo Valentin
2013-03-15 13:00   ` Eduardo Valentin
2013-03-16  9:05 ` [PATCH 00/50] staging: omap-thermal: several code refactoring Dan Carpenter
2013-03-16 12:46   ` Eduardo Valentin
2013-03-16 12:46     ` Eduardo Valentin
2013-03-16 16:16     ` Greg KH
2013-03-18 14:44       ` Eduardo Valentin
2013-03-18 14:44         ` Eduardo Valentin

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.