[PATCH 5/9] [arch/powerpc] replace obsolete strict_strto* calls

2014-06-21 Thread Daniel Walter
Replace strict_strto calls with more appropriate kstrto calls

Signed-off-by: Daniel Walter 
---
 arch/powerpc/kernel/setup_64.c| 6 +++---
 arch/powerpc/kernel/vio.c | 2 +-
 arch/powerpc/platforms/pseries/dlpar.c| 4 ++--
 arch/powerpc/platforms/pseries/mobility.c | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index ee082d7..5257166 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -149,13 +149,13 @@ static void check_smt_enabled(void)
else if (!strcmp(smt_enabled_cmdline, "off"))
smt_enabled_at_boot = 0;
else {
-   long smt;
+   int smt;
int rc;
 
-   rc = strict_strtol(smt_enabled_cmdline, 10, &smt);
+   rc = kstrtoint(smt_enabled_cmdline, 10, &smt);
if (!rc)
smt_enabled_at_boot =
-   min(threads_per_core, (int)smt);
+   min(threads_per_core, smt);
}
} else {
dn = of_find_node_by_path("/options");
diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 904c661..5bfdab9 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -977,7 +977,7 @@ static ssize_t viodev_cmo_desired_set(struct device *dev,
size_t new_desired;
int ret;
 
-   ret = strict_strtoul(buf, 10, &new_desired);
+   ret = kstrtoul(buf, 10, &new_desired);
if (ret)
return ret;
 
diff --git a/arch/powerpc/platforms/pseries/dlpar.c 
b/arch/powerpc/platforms/pseries/dlpar.c
index 022b38e..abc6892 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -399,10 +399,10 @@ out:
 static ssize_t dlpar_cpu_probe(const char *buf, size_t count)
 {
struct device_node *dn, *parent;
-   unsigned long drc_index;
+   u32 drc_index;
int rc;
 
-   rc = strict_strtoul(buf, 0, &drc_index);
+   rc = kstrtou32(buf, 0, &drc_index);
if (rc)
return -EINVAL;
 
diff --git a/arch/powerpc/platforms/pseries/mobility.c 
b/arch/powerpc/platforms/pseries/mobility.c
index bde7eba..0694ac6 100644
--- a/arch/powerpc/platforms/pseries/mobility.c
+++ b/arch/powerpc/platforms/pseries/mobility.c
@@ -319,7 +319,7 @@ static ssize_t migrate_store(struct class *class, struct 
class_attribute *attr,
u64 streamid;
int rc;
 
-   rc = strict_strtoull(buf, 0, &streamid);
+   rc = kstrtou64(buf, 0, &streamid);
if (rc)
return rc;
 
-- 
2.0.0.526.g5318336

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: [PATCH v3] powerpc/powernv: hwmon driver for power, fan rpm, voltage and temperature

2014-06-21 Thread Guenter Roeck

On 06/18/2014 01:35 AM, Neelesh Gupta wrote:

This patch adds basic kernel enablement for reading power values, fan


how about support instead of enablement ?


speed rpm, voltage and temperature data on powernv platforms which will
be exported to user space through sysfs interface.

Test results:
-
[root@ltctul57a-p1 ~]# sensors
ibmpowernv-isa-
Adapter: ISA adapter
fan1:5660 RPM  (min =0 RPM)
fan2:5273 RPM  (min =0 RPM)
fan3:5625 RPM  (min =0 RPM)
fan4:5283 RPM  (min =0 RPM)
fan5:5625 RPM  (min =0 RPM)
fan6:5242 RPM  (min =0 RPM)
fan7:5636 RPM  (min =0 RPM)
fan8:5273 RPM  (min =0 RPM)
fan9:4984 RPM  (min =0 RPM)
fan10:   4984 RPM  (min =0 RPM)
fan11:   4984 RPM  (min =0 RPM)
fan12:   4984 RPM  (min =0 RPM)
temp1:+24.0 C  (high =  +0.0 C)
power1:  573.00 W

[root@ltctul57a-p1 ~]#
[root@ltctul57a-p1 ~]# ls /sys/devices/platform/
alarmtimer  ibmpowernv.0  rtc-generic  serial8250  uevent
[root@ltctul57a-p1 ~]# ls /sys/devices/platform/ibmpowernv.0/hwmon/hwmon0/
device   fan12_input  fan3_fault  fan5_minfan8_input  in4_fault
fan10_fault  fan12_minfan3_input  fan6_fault  fan8_minname
fan10_input  fan1_fault   fan3_minfan6_input  fan9_fault  power1_input
fan10_minfan1_input   fan4_fault  fan6_minfan9_input  subsystem
fan11_fault  fan1_min fan4_input  fan7_fault  fan9_mintemp1_input
fan11_input  fan2_fault   fan4_minfan7_input  in1_fault   temp1_max
fan11_minfan2_input   fan5_fault  fan7_minin2_fault   uevent
fan12_fault  fan2_min fan5_input  fan8_fault  in3_fault
[root@ltctul57a-p1 ~]#
[root@ltctul57a-p1 ~]# ls /sys/class/hwmon/hwmon0/
device   fan12_input  fan3_fault  fan5_minfan8_input  in4_fault
fan10_fault  fan12_minfan3_input  fan6_fault  fan8_minname
fan10_input  fan1_fault   fan3_minfan6_input  fan9_fault  power1_input
fan10_minfan1_input   fan4_fault  fan6_minfan9_input  subsystem
fan11_fault  fan1_min fan4_input  fan7_fault  fan9_mintemp1_input
fan11_input  fan2_fault   fan4_minfan7_input  in1_fault   temp1_max
fan11_minfan2_input   fan5_fault  fan7_minin2_fault   uevent
fan12_fault  fan2_min fan5_input  fan8_fault  in3_fault
[root@ltctul57a-p1 ~]#

Signed-off-by: Neelesh Gupta 
---

Changes in V3
=
- Fixed an endianness bug leading the driver to break on LE.
- Fixed a bug that when one of the 'attribute_group' not populated, following
   groups attributes were dropped.
- Rewrite the get_sensor_index_attr() function to handle all the error scenarios
   like 'sscanf' etc.
- Fixed all the errors/warnings related to coding style/whitespace.
- Added 'Documentation' files.
- Addressed remaining review comments on V2.

Changes in v2
=
- Generic use of devm_* functions in hwmon like using devm_kzalloc() for dynamic
   memory request, avoiding the need to explicit free of memory.
   Adding 'struct attribute_group' as member of platform data structure to be
   populated and then passed to devm_hwmon_device_register_with_groups().

   Note: Having an array of pointers of 'attribute_group' and each group
   corresponds to 'enum sensors' type. Not completely sure, if it's ideal or
   could have just one group populated with attributes of sensor types?

- 'ibmpowernv' is not hot-pluggable device so moving 'platform_driver' callback
   function (probe) as part of __init code.
- Fixed issues related to coding style.
- Other general comments in v1.

  .../devicetree/bindings/hwmon/ibmpowernv.txt   |   27 +
  Documentation/hwmon/ibmpowernv |   41 ++
  drivers/hwmon/Kconfig  |   11 +
  drivers/hwmon/Makefile |1
  drivers/hwmon/ibmpowernv.c |  366 
  5 files changed, 446 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/hwmon/ibmpowernv.txt
  create mode 100644 Documentation/hwmon/ibmpowernv
  create mode 100644 drivers/hwmon/ibmpowernv.c

diff --git a/Documentation/devicetree/bindings/hwmon/ibmpowernv.txt 
b/Documentation/devicetree/bindings/hwmon/ibmpowernv.txt
new file mode 100644
index 000..e3bd1eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/hwmon/ibmpowernv.txt
@@ -0,0 +1,27 @@
+IBM POWERNV platform sensors
+
+
+Required node properties:
+- compatible: must be one of
+   "ibm,opal-sensor-cooling-fan"
+   "ibm,opal-sensor-amb-temp"
+   "ibm,opal-sensor-power-supply"
+   "ibm,opal-sensor-power"
+- sensor-id: an opaque id provided by the firmware to the kernel, identifies a
+given sensor and its attribute data
+
+Example sensors node:
+
+cooling-fan#8-data {
+   sensor-id = <0x7052107>;
+   phandle = <0x1028>;
+   linux,phandle = <0x1028>;
+   compatible = "ibm,opal-senso

Re: [PATCH v2 1/2] flexcan: add err_irq handler for flexcan

2014-06-21 Thread Marc Kleine-Budde
On 06/20/2014 04:01 AM, Zhao Qiang wrote:
> when flexcan is not physically linked, command 'cantest' will
> trigger an err_irq, add err_irq handler for it.
> 
> Signed-off-by: Zhao Qiang 
> ---
> Changes for v2:
>   - use a space instead of tab
>   - use flexcan_poll_state instead of print
> 
>  drivers/net/can/flexcan.c | 31 ++-
>  1 file changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
> index f425ec2..7432ba4 100644
> --- a/drivers/net/can/flexcan.c
> +++ b/drivers/net/can/flexcan.c
> @@ -208,6 +208,7 @@ struct flexcan_priv {
>   void __iomem *base;
>   u32 reg_esr;
>   u32 reg_ctrl_default;
> + unsigned int err_irq;
>  
>   struct clk *clk_ipg;
>   struct clk *clk_per;
> @@ -744,6 +745,23 @@ static irqreturn_t flexcan_irq(int irq, void *dev_id)
>   return IRQ_HANDLED;
>  }
>  
> +static irqreturn_t flexcan_err_irq(int irq, void *dev_id)
> +{
> + struct net_device *dev = dev_id;
> + struct flexcan_priv *priv = netdev_priv(dev);
> + struct flexcan_regs __iomem *regs = priv->base;
> + u32 reg_ctrl, reg_esr;
> +
> + reg_esr = flexcan_read(®s->esr);
> + reg_ctrl = flexcan_read(®s->ctrl);
> + if (reg_esr & FLEXCAN_ESR_TX_WRN) {

When is the err_irq triggered?

> + flexcan_write(reg_esr & ~FLEXCAN_ESR_TX_WRN, ®s->esr);
> + flexcan_write(reg_ctrl & ~FLEXCAN_CTRL_ERR_MSK, ®s->ctrl);
> + flexcan_poll_state(dev, reg_esr);

poll_state() is does not work, if called from an IRQ
handler.Depending when err_irq is triggered, is it worth to just
call the normal interrupt handler?

> + }
> + return IRQ_HANDLED;

Please return IRQ_HANDLED, only if there really was an interrupt.

> +}
> +
>  static void flexcan_set_bittiming(struct net_device *dev)
>  {
>   const struct flexcan_priv *priv = netdev_priv(dev);
> @@ -944,6 +962,12 @@ static int flexcan_open(struct net_device *dev)
>   if (err)
>   goto out_close;
>  
> + if (priv->err_irq)
> + err = request_irq(priv->err_irq, flexcan_err_irq, IRQF_SHARED,
> +   dev->name, dev);
> + if (err)
> + goto out_close;

In case of an error, you don't free() dev->irq.

> +
>   /* start chip and queuing */
>   err = flexcan_chip_start(dev);
>   if (err)
> @@ -1099,7 +1123,7 @@ static int flexcan_probe(struct platform_device *pdev)
>   struct resource *mem;
>   struct clk *clk_ipg = NULL, *clk_per = NULL;
>   void __iomem *base;
> - int err, irq;
> + int err, irq, err_irq;
>   u32 clock_freq = 0;
>  
>   if (pdev->dev.of_node)
> @@ -1126,6 +1150,10 @@ static int flexcan_probe(struct platform_device *pdev)
>   if (irq <= 0)
>   return -ENODEV;
>  
> + err_irq = platform_get_irq(pdev, 1);
> + if (err_irq <= 0)
> + err_irq = 0;
> +
>   base = devm_ioremap_resource(&pdev->dev, mem);
>   if (IS_ERR(base))
>   return PTR_ERR(base);
> @@ -1149,6 +1177,7 @@ static int flexcan_probe(struct platform_device *pdev)
>   dev->flags |= IFF_ECHO;
>  
>   priv = netdev_priv(dev);
> + priv->err_irq = err_irq;
>   priv->can.clock.freq = clock_freq;
>   priv->can.bittiming_const = &flexcan_bittiming_const;
>   priv->can.do_set_mode = flexcan_set_mode;
> 

Marc

-- 
Pengutronix e.K.  | Marc Kleine-Budde   |
Industrial Linux Solutions| Phone: +49-231-2826-924 |
Vertretung West/Dortmund  | Fax:   +49-5121-206917- |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |



signature.asc
Description: OpenPGP digital signature
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev