RE: [PATCH 8/8] Thermal: Dummy driver used for testing

2012-12-25 Thread R, Durgadoss


> -Original Message-
> From: Wei Ni [mailto:w...@nvidia.com]
> Sent: Tuesday, December 25, 2012 2:08 PM
> To: R, Durgadoss
> Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org;
> hongbo.zh...@linaro.org
> Subject: Re: [PATCH 8/8] Thermal: Dummy driver used for testing
> 
> On 12/18/2012 05:29 PM, Durgadoss R wrote:
> > This patch has a dummy driver that can be used for
> > testing purposes. This patch is not for merge.
> >
> > Signed-off-by: Durgadoss R 
> > ---
> >  drivers/thermal/Kconfig|5 +
> >  drivers/thermal/Makefile   |3 +
> >  drivers/thermal/thermal_test.c |  315
> 
> >  3 files changed, 323 insertions(+)
> >  create mode 100644 drivers/thermal/thermal_test.c
> >
> > diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> > index c5ba3340..3b92a76 100644
> > --- a/drivers/thermal/Kconfig
> > +++ b/drivers/thermal/Kconfig
> > @@ -136,4 +136,9 @@ config DB8500_CPUFREQ_COOLING
> >   bound cpufreq cooling device turns active to set CPU frequency low
> to
> >   cool down the CPU.
> >
> > +config THERMAL_TEST
> > +   tristate "test driver"
> > +   help
> > + Enable this to test the thermal framework.
> > +
> >  endif
> > diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> > index d8da683..02c3edb 100644
> > --- a/drivers/thermal/Makefile
> > +++ b/drivers/thermal/Makefile
> > @@ -18,3 +18,6 @@ obj-$(CONFIG_RCAR_THERMAL)+=
> rcar_thermal.o
> >  obj-$(CONFIG_EXYNOS_THERMAL)   += exynos_thermal.o
> >  obj-$(CONFIG_DB8500_THERMAL)   += db8500_thermal.o
> >  obj-$(CONFIG_DB8500_CPUFREQ_COOLING)   +=
> db8500_cpufreq_cooling.o
> > +
> > +# dummy driver for testing
> > +obj-$(CONFIG_THERMAL_TEST) += thermal_test.o
> > diff --git a/drivers/thermal/thermal_test.c
> b/drivers/thermal/thermal_test.c
> > new file mode 100644
> > index 000..5a11e34
> > --- /dev/null
> > +++ b/drivers/thermal/thermal_test.c
> > @@ -0,0 +1,315 @@
> > +/*
> > + * thermal_test.c - This driver can be used to test Thermal
> > + *Framework changes. Not specific to any
> > + *platform. Fills the log buffer generously ;)
> > + *
> > + * Copyright (C) 2012 Intel Corporation
> > + *
> > + *
> ~~
> 
> > + *
> > + * This program is free software; you can redistribute it and/or modify
> > + * it under the terms of the GNU General Public License as published by
> > + * the Free Software Foundation; version 2 of the License.
> > + *
> > + * 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.,
> > + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> > + *
> > + *
> ~~
> 
> > + * Author: Durgadoss R 
> > + */
> > +
> > +#define pr_fmt(fmt)  "thermal_test: " fmt
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define MAX_THERMAL_ZONES  2
> > +#define MAX_THERMAL_SENSORS2
> > +#define MAX_COOLING_DEVS   4
> > +#define NUM_THRESHOLDS 3
> > +
> > +static struct ts_data {
> > +   int curr_temp;
> > +   int flag;
> > +} ts_data;
> > +
> > +int active_trips[10] = {100, 90, 80, 70, 60, 50, 40, 30, 20, 10};
> > +int passive_trips[5] = {100, 90, 60, 50, 40};
> > +
> > +static struct platform_device *pdev;
> > +static unsigned long cur_cdev_state = 2;
> > +static struct thermal_sensor *ts, *ts1;
> > +static struct thermal_zone *tz;
> > +static struct thermal_cooling_device *cdev;
> > +
> > +static long thermal_thresholds[NUM_THRESHOLDS] = {3, 4,
> 5};
> > +
> > +static struct thermal_trip_point trip = {
> > +   .hot = 90,
> > +   .crit = 100,
> > +   .num_passive_trips = 5,
> > +   .passi

Re: [PATCH 8/8] Thermal: Dummy driver used for testing

2012-12-25 Thread Wei Ni
On 12/18/2012 05:29 PM, Durgadoss R wrote:
> This patch has a dummy driver that can be used for
> testing purposes. This patch is not for merge.
> 
> Signed-off-by: Durgadoss R 
> ---
>  drivers/thermal/Kconfig|5 +
>  drivers/thermal/Makefile   |3 +
>  drivers/thermal/thermal_test.c |  315 
> 
>  3 files changed, 323 insertions(+)
>  create mode 100644 drivers/thermal/thermal_test.c
> 
> diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
> index c5ba3340..3b92a76 100644
> --- a/drivers/thermal/Kconfig
> +++ b/drivers/thermal/Kconfig
> @@ -136,4 +136,9 @@ config DB8500_CPUFREQ_COOLING
> bound cpufreq cooling device turns active to set CPU frequency low to
> cool down the CPU.
>  
> +config THERMAL_TEST
> + tristate "test driver"
> + help
> +   Enable this to test the thermal framework.
> +
>  endif
> diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
> index d8da683..02c3edb 100644
> --- a/drivers/thermal/Makefile
> +++ b/drivers/thermal/Makefile
> @@ -18,3 +18,6 @@ obj-$(CONFIG_RCAR_THERMAL)  += rcar_thermal.o
>  obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o
>  obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o
>  obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o
> +
> +# dummy driver for testing
> +obj-$(CONFIG_THERMAL_TEST)   += thermal_test.o
> diff --git a/drivers/thermal/thermal_test.c b/drivers/thermal/thermal_test.c
> new file mode 100644
> index 000..5a11e34
> --- /dev/null
> +++ b/drivers/thermal/thermal_test.c
> @@ -0,0 +1,315 @@
> +/*
> + * thermal_test.c - This driver can be used to test Thermal
> + *  Framework changes. Not specific to any
> + *  platform. Fills the log buffer generously ;)
> + *
> + * Copyright (C) 2012 Intel Corporation
> + *
> + * ~~
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; version 2 of the License.
> + *
> + * 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.,
> + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
> + *
> + * ~~
> + * Author: Durgadoss R 
> + */
> +
> +#define pr_fmt(fmt)  "thermal_test: " fmt
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MAX_THERMAL_ZONES2
> +#define MAX_THERMAL_SENSORS  2
> +#define MAX_COOLING_DEVS 4
> +#define NUM_THRESHOLDS   3
> +
> +static struct ts_data {
> + int curr_temp;
> + int flag;
> +} ts_data;
> +
> +int active_trips[10] = {100, 90, 80, 70, 60, 50, 40, 30, 20, 10};
> +int passive_trips[5] = {100, 90, 60, 50, 40};
> +
> +static struct platform_device *pdev;
> +static unsigned long cur_cdev_state = 2;
> +static struct thermal_sensor *ts, *ts1;
> +static struct thermal_zone *tz;
> +static struct thermal_cooling_device *cdev;
> +
> +static long thermal_thresholds[NUM_THRESHOLDS] = {3, 4, 5};
> +
> +static struct thermal_trip_point trip = {
> + .hot = 90,
> + .crit = 100,
> + .num_passive_trips = 5,
> + .passive_trips = passive_trips,
> + .num_active_trips = 10,
> + .active_trips = active_trips,
> + .active_trip_mask = 0xCFF,
> +};
> +
> +static struct thermal_trip_point trip1 = {
> + .hot = 95,
> + .crit = 125,
> + .num_passive_trips = 0,
> + .passive_trips = passive_trips,
> + .num_active_trips = 6,
> + .active_trips = active_trips,
> + .active_trip_mask = 0xFF,
> +};
> +
> +static int read_cur_state(struct thermal_cooling_device *cdev,
> + unsigned long *state)
> +{
> + *state = cur_cdev_state;
> + return 0;
> +}
> +
> +static int write_cur_state(struct thermal_cooling_device *cdev,
> + unsigned long state)
> +{
> + cur_cdev_state = state;
> + return 0;
> +}
> +
> +static int read_max_state(struct thermal_cooling_device *cdev,
> + unsigned long *state)
> +{
> + *state = 5;
> + return 0;
> +}
> +
> +static int read_curr_temp(struct thermal_sensor *ts, long *temp)
> +{
> + *temp = ts_data.curr_temp;
> + return 0;
> +}
> +
> +static ssize_t
> +flag_show(struct device *dev, struct device_attribute *devattr, char *buf)
> +{
> + return sprintf(buf, "%d\n", ts_data.flag);
> +}
> +
> +static ssize_t
> +flag_store(struct device 

Re: [PATCH 8/8] Thermal: Dummy driver used for testing

2012-12-25 Thread Wei Ni
On 12/18/2012 05:29 PM, Durgadoss R wrote:
 This patch has a dummy driver that can be used for
 testing purposes. This patch is not for merge.
 
 Signed-off-by: Durgadoss R durgados...@intel.com
 ---
  drivers/thermal/Kconfig|5 +
  drivers/thermal/Makefile   |3 +
  drivers/thermal/thermal_test.c |  315 
 
  3 files changed, 323 insertions(+)
  create mode 100644 drivers/thermal/thermal_test.c
 
 diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
 index c5ba3340..3b92a76 100644
 --- a/drivers/thermal/Kconfig
 +++ b/drivers/thermal/Kconfig
 @@ -136,4 +136,9 @@ config DB8500_CPUFREQ_COOLING
 bound cpufreq cooling device turns active to set CPU frequency low to
 cool down the CPU.
  
 +config THERMAL_TEST
 + tristate test driver
 + help
 +   Enable this to test the thermal framework.
 +
  endif
 diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
 index d8da683..02c3edb 100644
 --- a/drivers/thermal/Makefile
 +++ b/drivers/thermal/Makefile
 @@ -18,3 +18,6 @@ obj-$(CONFIG_RCAR_THERMAL)  += rcar_thermal.o
  obj-$(CONFIG_EXYNOS_THERMAL) += exynos_thermal.o
  obj-$(CONFIG_DB8500_THERMAL) += db8500_thermal.o
  obj-$(CONFIG_DB8500_CPUFREQ_COOLING) += db8500_cpufreq_cooling.o
 +
 +# dummy driver for testing
 +obj-$(CONFIG_THERMAL_TEST)   += thermal_test.o
 diff --git a/drivers/thermal/thermal_test.c b/drivers/thermal/thermal_test.c
 new file mode 100644
 index 000..5a11e34
 --- /dev/null
 +++ b/drivers/thermal/thermal_test.c
 @@ -0,0 +1,315 @@
 +/*
 + * thermal_test.c - This driver can be used to test Thermal
 + *  Framework changes. Not specific to any
 + *  platform. Fills the log buffer generously ;)
 + *
 + * Copyright (C) 2012 Intel Corporation
 + *
 + * ~~
 + *
 + * This program is free software; you can redistribute it and/or modify
 + * it under the terms of the GNU General Public License as published by
 + * the Free Software Foundation; version 2 of the License.
 + *
 + * 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.,
 + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 + *
 + * ~~
 + * Author: Durgadoss R durgados...@intel.com
 + */
 +
 +#define pr_fmt(fmt)  thermal_test:  fmt
 +
 +#include linux/module.h
 +#include linux/init.h
 +#include linux/err.h
 +#include linux/param.h
 +#include linux/device.h
 +#include linux/slab.h
 +#include linux/pm.h
 +#include linux/platform_device.h
 +#include linux/thermal.h
 +
 +#define MAX_THERMAL_ZONES2
 +#define MAX_THERMAL_SENSORS  2
 +#define MAX_COOLING_DEVS 4
 +#define NUM_THRESHOLDS   3
 +
 +static struct ts_data {
 + int curr_temp;
 + int flag;
 +} ts_data;
 +
 +int active_trips[10] = {100, 90, 80, 70, 60, 50, 40, 30, 20, 10};
 +int passive_trips[5] = {100, 90, 60, 50, 40};
 +
 +static struct platform_device *pdev;
 +static unsigned long cur_cdev_state = 2;
 +static struct thermal_sensor *ts, *ts1;
 +static struct thermal_zone *tz;
 +static struct thermal_cooling_device *cdev;
 +
 +static long thermal_thresholds[NUM_THRESHOLDS] = {3, 4, 5};
 +
 +static struct thermal_trip_point trip = {
 + .hot = 90,
 + .crit = 100,
 + .num_passive_trips = 5,
 + .passive_trips = passive_trips,
 + .num_active_trips = 10,
 + .active_trips = active_trips,
 + .active_trip_mask = 0xCFF,
 +};
 +
 +static struct thermal_trip_point trip1 = {
 + .hot = 95,
 + .crit = 125,
 + .num_passive_trips = 0,
 + .passive_trips = passive_trips,
 + .num_active_trips = 6,
 + .active_trips = active_trips,
 + .active_trip_mask = 0xFF,
 +};
 +
 +static int read_cur_state(struct thermal_cooling_device *cdev,
 + unsigned long *state)
 +{
 + *state = cur_cdev_state;
 + return 0;
 +}
 +
 +static int write_cur_state(struct thermal_cooling_device *cdev,
 + unsigned long state)
 +{
 + cur_cdev_state = state;
 + return 0;
 +}
 +
 +static int read_max_state(struct thermal_cooling_device *cdev,
 + unsigned long *state)
 +{
 + *state = 5;
 + return 0;
 +}
 +
 +static int read_curr_temp(struct thermal_sensor *ts, long *temp)
 +{
 + *temp = ts_data.curr_temp;
 + return 0;
 +}
 +
 +static ssize_t
 +flag_show(struct device *dev, struct device_attribute *devattr, char *buf)
 +{
 + return sprintf(buf, %d\n, ts_data.flag);
 +}
 +
 +static ssize_t
 +flag_store(struct device 

RE: [PATCH 8/8] Thermal: Dummy driver used for testing

2012-12-25 Thread R, Durgadoss


 -Original Message-
 From: Wei Ni [mailto:w...@nvidia.com]
 Sent: Tuesday, December 25, 2012 2:08 PM
 To: R, Durgadoss
 Cc: Zhang, Rui; linux...@vger.kernel.org; linux-kernel@vger.kernel.org;
 hongbo.zh...@linaro.org
 Subject: Re: [PATCH 8/8] Thermal: Dummy driver used for testing
 
 On 12/18/2012 05:29 PM, Durgadoss R wrote:
  This patch has a dummy driver that can be used for
  testing purposes. This patch is not for merge.
 
  Signed-off-by: Durgadoss R durgados...@intel.com
  ---
   drivers/thermal/Kconfig|5 +
   drivers/thermal/Makefile   |3 +
   drivers/thermal/thermal_test.c |  315
 
   3 files changed, 323 insertions(+)
   create mode 100644 drivers/thermal/thermal_test.c
 
  diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig
  index c5ba3340..3b92a76 100644
  --- a/drivers/thermal/Kconfig
  +++ b/drivers/thermal/Kconfig
  @@ -136,4 +136,9 @@ config DB8500_CPUFREQ_COOLING
bound cpufreq cooling device turns active to set CPU frequency low
 to
cool down the CPU.
 
  +config THERMAL_TEST
  +   tristate test driver
  +   help
  + Enable this to test the thermal framework.
  +
   endif
  diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile
  index d8da683..02c3edb 100644
  --- a/drivers/thermal/Makefile
  +++ b/drivers/thermal/Makefile
  @@ -18,3 +18,6 @@ obj-$(CONFIG_RCAR_THERMAL)+=
 rcar_thermal.o
   obj-$(CONFIG_EXYNOS_THERMAL)   += exynos_thermal.o
   obj-$(CONFIG_DB8500_THERMAL)   += db8500_thermal.o
   obj-$(CONFIG_DB8500_CPUFREQ_COOLING)   +=
 db8500_cpufreq_cooling.o
  +
  +# dummy driver for testing
  +obj-$(CONFIG_THERMAL_TEST) += thermal_test.o
  diff --git a/drivers/thermal/thermal_test.c
 b/drivers/thermal/thermal_test.c
  new file mode 100644
  index 000..5a11e34
  --- /dev/null
  +++ b/drivers/thermal/thermal_test.c
  @@ -0,0 +1,315 @@
  +/*
  + * thermal_test.c - This driver can be used to test Thermal
  + *Framework changes. Not specific to any
  + *platform. Fills the log buffer generously ;)
  + *
  + * Copyright (C) 2012 Intel Corporation
  + *
  + *
 ~~
 
  + *
  + * This program is free software; you can redistribute it and/or modify
  + * it under the terms of the GNU General Public License as published by
  + * the Free Software Foundation; version 2 of the License.
  + *
  + * 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.,
  + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  + *
  + *
 ~~
 
  + * Author: Durgadoss R durgados...@intel.com
  + */
  +
  +#define pr_fmt(fmt)  thermal_test:  fmt
  +
  +#include linux/module.h
  +#include linux/init.h
  +#include linux/err.h
  +#include linux/param.h
  +#include linux/device.h
  +#include linux/slab.h
  +#include linux/pm.h
  +#include linux/platform_device.h
  +#include linux/thermal.h
  +
  +#define MAX_THERMAL_ZONES  2
  +#define MAX_THERMAL_SENSORS2
  +#define MAX_COOLING_DEVS   4
  +#define NUM_THRESHOLDS 3
  +
  +static struct ts_data {
  +   int curr_temp;
  +   int flag;
  +} ts_data;
  +
  +int active_trips[10] = {100, 90, 80, 70, 60, 50, 40, 30, 20, 10};
  +int passive_trips[5] = {100, 90, 60, 50, 40};
  +
  +static struct platform_device *pdev;
  +static unsigned long cur_cdev_state = 2;
  +static struct thermal_sensor *ts, *ts1;
  +static struct thermal_zone *tz;
  +static struct thermal_cooling_device *cdev;
  +
  +static long thermal_thresholds[NUM_THRESHOLDS] = {3, 4,
 5};
  +
  +static struct thermal_trip_point trip = {
  +   .hot = 90,
  +   .crit = 100,
  +   .num_passive_trips = 5,
  +   .passive_trips = passive_trips,
  +   .num_active_trips = 10,
  +   .active_trips = active_trips,
  +   .active_trip_mask = 0xCFF,
  +};
  +
  +static struct thermal_trip_point trip1 = {
  +   .hot = 95,
  +   .crit = 125,
  +   .num_passive_trips = 0,
  +   .passive_trips = passive_trips,
  +   .num_active_trips = 6,
  +   .active_trips = active_trips,
  +   .active_trip_mask = 0xFF,
  +};
  +
  +static int read_cur_state(struct thermal_cooling_device *cdev,
  +   unsigned long *state)
  +{
  +   *state = cur_cdev_state;
  +   return 0;
  +}
  +
  +static int write_cur_state(struct thermal_cooling_device *cdev,
  +   unsigned long state)
  +{
  +   cur_cdev_state = state;
  +   return 0;
  +}
  +
  +static int read_max_state(struct thermal_cooling_device *cdev