[PATCH] hid-apple.c: Set APPLE_ISO_KEYBOARD at USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO

2012-11-03 Thread Johannes Thumshirn
Set APPLE_ISO_KEYBOARD flag on USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO so we get
the ISO translation on German keyboards for the MacBook4,1 as well.

Signed-off-by: Johannes Thumshirn 
---
 drivers/hid/hid-apple.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 06ebdbb..5df5e20 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -439,7 +439,8 @@ static const struct hid_device_id apple_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
-   .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+   .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+   APPLE_ISO_KEYBOARD },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
APPLE_RDESC_JIS },
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC][PATCH v2] documentation/devicetree: Move DT bindigns from gpio to watchdog

2013-08-27 Thread Johannes Thumshirn
I accidently put the devicetree bindings for the MEN A21 watchdog driver in
Documentation/devicetree/bindings/gpio instead of
Documentation/devicetree/bindings/watchdog, this patch addresses this error.

Signed-off-by: Johannes Thumshirn 
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Stephen Warren 
Cc: Ian Campbell 
Cc: Rob Landley 
Cc: Wim Van Sebroeck 
Cc: Guenter Roeck 
---
 Changes to v1:
 - Use named gpios, as suggested by Stephen Warren

 .../bindings/{gpio => watchdog}/men-a021-wdt.txt   |   12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)
 rename Documentation/devicetree/bindings/{gpio => watchdog}/men-a021-wdt.txt 
(61%)

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/men-a021-wdt.txt
similarity index 61%
rename from Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
rename to Documentation/devicetree/bindings/watchdog/men-a021-wdt.txt
index 370dee3..0008f28 100644
--- a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
+++ b/Documentation/devicetree/bindings/watchdog/men-a021-wdt.txt
@@ -16,10 +16,10 @@ Optional properties:
 Example:
watchdog {
compatible ="men,a021-wdt";
-   gpios = <&gpio3 9  1/* WD_EN */
-&gpio3 10 1/* WD_FAST */
-&gpio3 11 1/* WD_TRIG */
-&gpio3 6  1/* RST_CAUSE[0] */
-&gpio3 7  1/* RST_CAUSE[1] */
-&gpio3 8  1>;  /* RST_CAUSE[2] */
+   enable-gpio = <&gpio3 9 1>; /* WD_EN */
+   fast-gpio = <&gpio3 10 1>;  /* WD_FAST */
+   trig-gpio = <&gpio3 11 1>;  /* WD_TRIG */
+   rst-gpios = <&gpio3 6 1 /* RST_CAUSE[0] */
+&gpio3 7 1 /* RST_CAUSE[1] */
+&gpio3 8 1>;   /* RST_CAUSE[2] */
};
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH v2] documentation/devicetree: Move DT bindigns from gpio to watchdog

2013-08-27 Thread Johannes Thumshirn
On Tue, Aug 27, 2013 at 03:41:42PM -0600, Stephen Warren wrote:
> On 08/27/2013 05:10 AM, Johannes Thumshirn wrote:
> > I accidently put the devicetree bindings for the MEN A21 watchdog driver in
> > Documentation/devicetree/bindings/gpio instead of
> > Documentation/devicetree/bindings/watchdog, this patch addresses this error.
>
> >  Changes to v1:
> >  - Use named gpios, as suggested by Stephen Warren
>
> The move and the change to the binding should probably be separate
> patches since they're logically separate things. I didn't intend you to
> update the rename patch to fix the binding issue I pointed out.
>

Oops. Looks like I've misunderstood you there. I'll re-send the rename patch
then.

> Is the driver updated for this binding change? Are there DTs in released
> kernels that won't work now, or is the driver very new; there may be a
> need for the driver to support the old binding and the binding doc to
> document the old gpios property, but mark it deprecated.

The driver is not yet updated, this is why I've sent it as an RFC. Are the
bindings acceptable this way? If yes I'll update the driver and re-send the
bindings with the driver as a new patch series.

Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC][PATCH v2] documentation/devicetree: Move DT bindigns from gpio to watchdog

2013-08-28 Thread Johannes Thumshirn
On Wed, Aug 28, 2013 at 08:38:56AM -0600, Stephen Warren wrote:
> On 08/28/2013 12:22 AM, Johannes Thumshirn wrote:
> > On Tue, Aug 27, 2013 at 03:41:42PM -0600, Stephen Warren wrote:
> >> On 08/27/2013 05:10 AM, Johannes Thumshirn wrote:
> >>> I accidently put the devicetree bindings for the MEN A21 watchdog driver 
> >>> in
> >>> Documentation/devicetree/bindings/gpio instead of
> >>> Documentation/devicetree/bindings/watchdog, this patch addresses this 
> >>> error.
> >>
> >>>  Changes to v1:
> >>>  - Use named gpios, as suggested by Stephen Warren
> >>
> >> The move and the change to the binding should probably be separate
> >> patches since they're logically separate things. I didn't intend you to
> >> update the rename patch to fix the binding issue I pointed out.
> >>
> >
> > Oops. Looks like I've misunderstood you there. I'll re-send the rename patch
> > then.
> >
> >> Is the driver updated for this binding change? Are there DTs in released
> >> kernels that won't work now, or is the driver very new; there may be a
> >> need for the driver to support the old binding and the binding doc to
> >> document the old gpios property, but mark it deprecated.
> >
> > The driver is not yet updated, this is why I've sent it as an RFC. Are the
> > bindings acceptable this way? If yes I'll update the driver and re-send the
> > bindings with the driver as a new patch series.
>
> Well, XXX says:
>
> > GPIO properties should be named "[-]gpios"
>
> whereas in this patch, some of the renamed properties were "-gpio"
> rather than "-gpios". Aside from that, the new binding looks reasonable.
>
> However, I see that the existing binding will be released as part of
> v3.11. That implies that we should continue to support the old binding
> for compatibility. As such, I'm not convinced whether it's worth
> changing this binding now.

Well I'm be perfectly happy with not changing the bindings and therefore not
changing the driver. If this O.K. for you.

Should I resend my 1st patch, or is it O.K. to pick up the old one?

Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kconfig: Make diffconfig work with Python 3

2013-08-29 Thread Johannes Thumshirn
On Wed, Aug 28, 2013 at 07:29:53AM -0700, Tim Bird wrote:
> On Fri, Aug 9, 2013 at 5:27 AM, Johannes Thumshirn
>  wrote:
> > Adjust diffconfig to run cleanly on Python 3 (Tested with 3.3.2) and
> > Python 2 (2.7.5)
> >
> > Signed-off-by: Johannes Thumshirn 
> > ---
> >  scripts/diffconfig |   26 +-
> >  1 file changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/scripts/diffconfig b/scripts/diffconfig
> > index b91f3e3..dd0e75b 100755
> > --- a/scripts/diffconfig
> > +++ b/scripts/diffconfig
> > @@ -10,7 +10,7 @@
> >  import sys, os
> >
> >  def usage():
> > -print """Usage: diffconfig [-h] [-m] [ ]
> > +print ("""Usage: diffconfig [-h] [-m] [ ]
> >
> >  Diffconfig is a simple utility for comparing two .config files.
> >  Using standard diff to compare .config files often includes extraneous and
> > @@ -33,7 +33,7 @@ Example usage:
> >   EXT2_FS  y -> n
> >   LOG_BUF_SHIFT  14 -> 16
> >   PRINTK_TIME  n -> y
> > -"""
> > +""")
> >  sys.exit(0)
> >
> >  # returns a dictionary of name/value pairs for config items in the file
> > @@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
> >  if merge_style:
> >  if new_value:
> >  if new_value=="n":
> > -print "# CONFIG_%s is not set" % config
> > +print("# CONFIG_%s is not set" % config)
> >  else:
> > -print "CONFIG_%s=%s" % (config, new_value)
> > +print("CONFIG_%s=%s" % (config, new_value))
> >  else:
> >  if op=="-":
> > -print "-%s %s" % (config, value)
> > +print("-%s %s" % (config, value))
> >  elif op=="+":
> > -print "+%s %s" % (config, new_value)
> > +print("+%s %s" % (config, new_value))
> >  else:
> > -print " %s %s -> %s" % (config, value, new_value)
> > +print(" %s %s -> %s" % (config, value, new_value))
> >
> >  def main():
> >  global merge_style
> >
> >  # parse command line args
> >  if ("-h" in sys.argv or "--help" in sys.argv):
> > -   usage()
> > +usage()
> >
> >  merge_style = 0
> >  if "-m" in sys.argv:
> > @@ -79,13 +79,13 @@ def main():
> >
> >  argc = len(sys.argv)
> >  if not (argc==1 or argc == 3):
> > -print "Error: incorrect number of arguments or unrecognized option"
> > +print("Error: incorrect number of arguments or unrecognized 
> > option")
> >  usage()
> >
> >  if argc == 1:
> >  # if no filenames given, assume .config and .config.old
> >  build_dir=""
> > -if os.environ.has_key("KBUILD_OUTPUT"):
> > +if 'KBUILD_OUTPUT' in os.environ:
> >  build_dir = os.environ["KBUILD_OUTPUT"]+"/"
> >
> >  configa_filename = build_dir + ".config.old"
> > @@ -94,8 +94,8 @@ def main():
> >  configa_filename = sys.argv[1]
> >  configb_filename = sys.argv[2]
> >
> > -a = readconfig(file(configa_filename))
> > -b = readconfig(file(configb_filename))
> > +a = readconfig(open(configa_filename))
> > +b = readconfig(open(configb_filename))
> >
> >  # print items in a but not b (accumulate, sort and print)
> >  old = []
> > @@ -121,7 +121,7 @@ def main():
> >
> >  # now print items in b but not in a
> >  # (items from b that were in a were removed above)
> > -new = b.keys()
> > +new = list(b.keys())
> >  new.sort()
> >  for config in new:
> >  print_config("+", config, None, b[config])
> > --
> > 1.7.9.5
>
> Sorry I missed this earlier.  My new e-mail is tim.b...@sonymobile.com, and
> my old am.sony.com address doesn't work any more.
>
> Thanks - this looks great.
>
> Acked-by Tim Bird 
>
>  -- Tim Bird
> Senior Software Engineer, Sony Mobile
> Architecture Group Chair, CE Workgroup, Linux Foundation

Is there any comments from the kbuild maintainers?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RESEND v10 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-07-07 Thread Johannes Thumshirn
On Fri, Jul 05, 2013 at 11:01:19PM +0200, Wim Van Sebroeck wrote:
> Hi Johannes,
>
> > This patch adds the driver for the watchdog devices found on MEN Mikro
> > Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
> > watchdog framework.
> >
> > Signed-off-by: Johannes Thumshirn 
> > Reviewed-by: Guenter Roeck 
>
> I added this patch to linux-watchdog-next.
> I am still thinking about wether or not we shouldn't add a timer to this
> watchdog device driver. But that's something we can change later on.

Probably yes, but that really would be some work for watchdog core imho.

Anyway, tanks for adding the patch.

Thanks,
Johannes

>
> Kind regards,
> Wim.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RESEND v10 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-07-08 Thread Johannes Thumshirn
On Fri, Jul 05, 2013 at 11:03:21PM +0200, Wim Van Sebroeck wrote:
> Hi Johannes,
>
> > This patch adds a sysfs interface for the watchdog
> > device found on MEN A21 Boards.
> >
> > The newly generated files are:
> > * rebootcause:
> > Can be one of:
> > Power on Reset,
> > CPU Reset Request,
> > Push Button,
> > FPGA Reset Request,
> > Watchdog,
> > Local Power Bad,
> > Invalid or
> > BDI
> > and shows the reason of the boards last reboot.
> >
> > * active:
> > Shows if the watchdog CPLD is actually running
> >
> > * allow_disable:
> > Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)
>
> allow_disable should be nowayout because that is the general watchdog
> parameter we will have for all watchdog drivers.
>
> > * fastmode:
> > Shows if the CPLD is running in fast mode (1s timeout), once it is in
> > fastmode it can't be switched back to slow mode (30s timeout) until the
> > next reboot.
> >
> > Signed-off-by: Johannes Thumshirn 
>
> I will not add this patch and put it in my waiting queue.
> Reason: we should first do the sysfs stuff for the wwatchdog_core (since
> active and nowayout are parameters that will be in the sysfs watchdog core).
>
> Kind regards,
> Wim.
>


Ok. If you want to offload it, I think I could spend some time on it the next
weeks, as I'll probably have to write a driver for a Ti TPS3813K33 watchdog
anyway, I can have a look into watchdog core as well.

Byte,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] mpc85xx_edac: Remove unused function

2013-10-07 Thread Johannes Thumshirn
On Mon, Oct 07, 2013 at 05:13:55PM +0200, Thierry Reding wrote:
> Commit 905e75c (powerpc/fsl-pci: Unify pci/pcie initialization code)
> removed the struct platform_driver that held the last reference to the
> mpc85xx_pci_err_remove() function. Remove the function since it is
> effectively dead code.
>
> Signed-off-by: Thierry Reding 
> ---
>  drivers/edac/mpc85xx_edac.c | 23 ---
>  1 file changed, 23 deletions(-)
>
> diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
> index 3eb32f6..b1e7106 100644
> --- a/drivers/edac/mpc85xx_edac.c
> +++ b/drivers/edac/mpc85xx_edac.c
> @@ -326,29 +326,6 @@ err:
>   return res;
>  }
>  EXPORT_SYMBOL(mpc85xx_pci_err_probe);
> -
> -static int mpc85xx_pci_err_remove(struct platform_device *op)
> -{
> - struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev);
> - struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
> -
> - edac_dbg(0, "\n");
> -
> - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR,
> -  orig_pci_err_cap_dr);
> -
> - out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en);
> -
> - edac_pci_del_device(pci->dev);
> -
> - if (edac_op_state == EDAC_OPSTATE_INT)
> - irq_dispose_mapping(pdata->irq);
> -
> - edac_pci_free_ctl_info(pci);
> -
> - return 0;
> -}
> -
>  #endif   /* CONFIG_PCI */
>
>  / L2 Err device ***/
> --
> 1.8.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-edac" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Hi Thierry,

Sorry, but I already have this patch in
http://lkml.indiana.edu/hypermail/linux/kernel/1309.2/03410.html

But anyways, thanks
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] kconfig: Make diffconfig work with Python 3

2013-09-03 Thread Johannes Thumshirn
On Tue, Sep 03, 2013 at 03:08:09PM +0200, Michal Marek wrote:
> On 29.8.2013 17:10, Johannes Thumshirn wrote:
> > On Wed, Aug 28, 2013 at 07:29:53AM -0700, Tim Bird wrote:
> >> On Fri, Aug 9, 2013 at 5:27 AM, Johannes Thumshirn
> >>  wrote:
> >>> Adjust diffconfig to run cleanly on Python 3 (Tested with 3.3.2) and
> >>> Python 2 (2.7.5)
> >>>
> >>> Signed-off-by: Johannes Thumshirn 
> >>> ---
> >>>  scripts/diffconfig |   26 +-
> >>>  1 file changed, 13 insertions(+), 13 deletions(-)
> >>>
> >>> diff --git a/scripts/diffconfig b/scripts/diffconfig
> >>> index b91f3e3..dd0e75b 100755
> >>> --- a/scripts/diffconfig
> >>> +++ b/scripts/diffconfig
> >>> @@ -10,7 +10,7 @@
> >>>  import sys, os
> >>>
> >>>  def usage():
> >>> -print """Usage: diffconfig [-h] [-m] [ ]
> >>> +print ("""Usage: diffconfig [-h] [-m] [ ]
> >>>
> >>>  Diffconfig is a simple utility for comparing two .config files.
> >>>  Using standard diff to compare .config files often includes extraneous 
> >>> and
> >>> @@ -33,7 +33,7 @@ Example usage:
> >>>   EXT2_FS  y -> n
> >>>   LOG_BUF_SHIFT  14 -> 16
> >>>   PRINTK_TIME  n -> y
> >>> -"""
> >>> +""")
> >>>  sys.exit(0)
> >>>
> >>>  # returns a dictionary of name/value pairs for config items in the file
> >>> @@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
> >>>  if merge_style:
> >>>  if new_value:
> >>>  if new_value=="n":
> >>> -print "# CONFIG_%s is not set" % config
> >>> +print("# CONFIG_%s is not set" % config)
> >>>  else:
> >>> -print "CONFIG_%s=%s" % (config, new_value)
> >>> +print("CONFIG_%s=%s" % (config, new_value))
> >>>  else:
> >>>  if op=="-":
> >>> -print "-%s %s" % (config, value)
> >>> +print("-%s %s" % (config, value))
> >>>  elif op=="+":
> >>> -print "+%s %s" % (config, new_value)
> >>> +print("+%s %s" % (config, new_value))
> >>>  else:
> >>> -print " %s %s -> %s" % (config, value, new_value)
> >>> +print(" %s %s -> %s" % (config, value, new_value))
> >>>
> >>>  def main():
> >>>  global merge_style
> >>>
> >>>  # parse command line args
> >>>  if ("-h" in sys.argv or "--help" in sys.argv):
> >>> -   usage()
> >>> +usage()
> >>>
> >>>  merge_style = 0
> >>>  if "-m" in sys.argv:
> >>> @@ -79,13 +79,13 @@ def main():
> >>>
> >>>  argc = len(sys.argv)
> >>>  if not (argc==1 or argc == 3):
> >>> -print "Error: incorrect number of arguments or unrecognized 
> >>> option"
> >>> +print("Error: incorrect number of arguments or unrecognized 
> >>> option")
> >>>  usage()
> >>>
> >>>  if argc == 1:
> >>>  # if no filenames given, assume .config and .config.old
> >>>  build_dir=""
> >>> -if os.environ.has_key("KBUILD_OUTPUT"):
> >>> +if 'KBUILD_OUTPUT' in os.environ:
> >>>  build_dir = os.environ["KBUILD_OUTPUT"]+"/"
> >>>
> >>>  configa_filename = build_dir + ".config.old"
> >>> @@ -94,8 +94,8 @@ def main():
> >>>  configa_filename = sys.argv[1]
> >>>  configb_filename = sys.argv[2]
> >>>
> >>> -a = readconfig(file(configa_filename))
> >>> -b = readconfig(file(configb_filename))
> >>> +a = readconfig(open(configa_filename))
> >>> +b = readconfig(open(configb_filename))
> >>>
> >>>  # print items in a but not b (accumulate, sort and print)
> >>>  old = []
> >>> @@ -121,7 +121,7 @@ def main():
> >>>
> >>>  # now print items in b but not in a
> >>>  # (items from b that were in a were removed above)
> >>> -new = b.keys()
> >>> +new = list(b.keys())
> >>>  new.sort()
> >>>  for config in new:
> >>>  print_config("+", config, None, b[config])
> >>> --
> >>> 1.7.9.5
> >>
> >> Sorry I missed this earlier.  My new e-mail is tim.b...@sonymobile.com, and
> >> my old am.sony.com address doesn't work any more.
> >>
> >> Thanks - this looks great.
> >>
> >> Acked-by Tim Bird 
> >>
> >>  -- Tim Bird
> >> Senior Software Engineer, Sony Mobile
> >> Architecture Group Chair, CE Workgroup, Linux Foundation
> >
> > Is there any comments from the kbuild maintainers?
>
> I merged a nearly identical patch by Mike Pagano
> (http://www.spinics.net/lists/linux-kbuild/msg08503.html), seems like
> you guys had the same idea at the same time.
>
> Michal

lol, ok. At least it doesn't anoy me anymore :-D
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RFC] PWM: Add support for pwm-bcm2835

2013-09-21 Thread Johannes Thumshirn
Add support for the PWM controller of the BCM2835 SoC found on Raspberry PI

The driver isn't as much tested as I wanted it to be and devicetree
support is still missing, but I thought it would be nice to have some
comments if I'm in the right direction.

Signed-off-by: Johannes Thumshirn 
---
 drivers/pwm/Kconfig   |   8 ++
 drivers/pwm/Makefile  |   1 +
 drivers/pwm/pwm-bcm2835.c | 275 ++
 3 files changed, 284 insertions(+)
 create mode 100644 drivers/pwm/pwm-bcm2835.c

diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
index 75840b5..5417159 100644
--- a/drivers/pwm/Kconfig
+++ b/drivers/pwm/Kconfig
@@ -224,4 +224,12 @@ config PWM_VT8500
  To compile this driver as a module, choose M here: the module
  will be called pwm-vt8500.
 
+config PWM_BCM2835
+   tristate "BCM2835 PWM support"
+   help
+Generic PWM framework driver for bcm2835 found on the Rasperry PI
+
+   To compile this driver as a module, choose M here: the module will be
+   called pwm-bcm2835
+
 endif
diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
index 77a8c18..0cf8d4d 100644
--- a/drivers/pwm/Makefile
+++ b/drivers/pwm/Makefile
@@ -20,3 +20,4 @@ obj-$(CONFIG_PWM_TIPWMSS) += pwm-tipwmss.o
 obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
 obj-$(CONFIG_PWM_TWL_LED)  += pwm-twl-led.o
 obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
+obj-$(CONFIG_PWM_BCM2835)  += pwm-bcm2835.o
diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
new file mode 100644
index 000..8a64666
--- /dev/null
+++ b/drivers/pwm/pwm-bcm2835.c
@@ -0,0 +1,275 @@
+/*
+ * BCM2835 PWM driver
+ *
+ * Derived from the Tegra PWM driver by NVIDIA Corporation.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NPWM 2
+
+/* Address Mappings (offsets) from Broadcom BCM2835 ARM Periperals Manual
+ * Section 9.6 Page 141ff
+ */
+#define BCM2835_PWM_CTL0x00 /* Control register */
+#define BCM2835_PWM_STA0x04 /* Status register */
+#define BCM2835_PWM_DMAC   0x08 /* PWM DMA Configuration */
+#define BCM2835_PWM_RNG1   0x10 /* PWM Channel 1 Range */
+#define BCM2835_PWM_DAT1   0x14 /* PWM Channel 1 Data */
+#define BCM2835_PWM_FIF1   0x18 /* PWM FIFO Input */
+#define BCM2835_PWM_RNG2   0x20 /* PWM Channel 2 Range */
+#define BCM2835_PWM_DAT2   0x24 /* PWM Channel 2 Data */
+
+/* Control registers 0 and 1 are mirrored on a distance of 4 bits */
+#define HWPWM(x) ((x) << 4)
+
+/* TODO: We only need this register set once and use HWPWM macro to
+ * access 2nd output
+ */
+/* Control Register Bits */
+#define BCM2835_PWM_CTL_PWEN1  BIT(0)  /* Channel 1 enable (RW) */
+#define BCM2835_PWM_CTL_MODE1  BIT(1)  /* Channel 1 mode (RW) */
+#define BCM2835_PWM_CTL_RPTL1  BIT(2)  /* Channel 1 repeat last data (RW) */
+#define BCM2835_PWM_CTL_SBIT1  BIT(3)  /* Channel 1 silence bit (RW) */
+#define BCM2835_PWM_CTL_POLA1  BIT(4)  /* Channel 1 polarity (RW) */
+#define BCM2835_PWM_CTL_USEF1  BIT(5)  /* Channel 1 use FIFO (RW) */
+#define BCM2835_PWM_CTL_CLRF1  BIT(6)  /* Channel 1 clear FIFO (RO) */
+#define BCM2835_PWM_CTL_MSEN1  BIT(7)  /* Channel 1 M/S enable (RW) */
+#define BCM2835_PWM_CTL_PWEN2  BIT(8)  /* Channel 2 enable (RW) */
+#define BCM2835_PWM_CTL_MODE2  BIT(9)  /* Channel 2 mode (RW) */
+#define BCM2835_PWM_CTL_RPTL2  BIT(10) /* Channel 2 repeat last data (RW) */
+#define BCM2835_PWM_CTL_SBIT2  BIT(11) /* Channel 2 silence bit (RW) */
+#define BCM2835_PWM_CTL_POLA2  BIT(12) /* Channel 2 polarity (RW) */
+#define BCM2835_PWM_CTL_USEF2  BIT(13) /* Channel 2 use FIFO (RW) */
+/* Bit 14 is reserved */
+#define BCM2835_PWM_MSEN2  BIT(15) /* Channel 2 M/S enable (RW) */
+/* Bits 16 - 31 are reserved */
+
+/* Status Register Bits */
+#define BCM2835_PWM_STA_FULL1  BIT(0)  /* FIFO full flag (RW) */
+#define BCM2835_PWM_STA_EMPT1  BIT(1)  /* FIFO empty flag (RW) */
+#define BCM2835_PWM_STA_WERR1  BIT(2)  /* FIFO write error flag (RW) */
+#define BCM2835_PWM_STA_RERR1  BIT(3)  /* FIFO read error flag (RW) */
+#define BCM2835_PWM_STA_GAPO1  BIT(4)  /* Channel 1 gap occured (RW) */
+#define BCM2835_PWM_STA_GAPO2  BIT(5)  /* Channel 2 gap occured (RW) */
+#define BCM2835_PWM_STA_GAPO3  BIT(6)  /* Channel 3 gap occured (RW) */
+#define BCM2835_PWM_STA_GAPO4  BIT(7)  /* Channel 4 gap occured (RW) */
+#define BCM2835_PWM_STA_BERR   BIT(8)  /* Bus error flag (RW) */
+#define BCM2835_PWM_STA

[PATCH 2/3] edac/85xx: Add PCIe error interrupt edac support

2013-09-23 Thread Johannes Thumshirn
From: Chunhe Lan 

Adding pcie error interrupt edac support for mpc85xx, p3041, p4080,
and p5020. The mpc85xx uses the legacy interrupt report mechanism -
the error interrupts are reported directly to mpic. While, the p3041/
p4080/p5020 attaches the most of error interrupts to interrupt zero.
And report error interrupts to mpic via interrupt 0.

This patch can handle both of them.

Signed-off-by: Chunhe Lan 
Cc: Doug Thompson 
Cc: Dave Jiang 
Cc: Borislav Petkov 
Signed-off-by: Johannes Thumshirn 
---
 drivers/edac/mpc85xx_edac.c |   98 ++-
 drivers/edac/mpc85xx_edac.h |7 
 2 files changed, 94 insertions(+), 11 deletions(-)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 3eb32f6..8df5f4d 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -1,6 +1,8 @@
 /*
  * Freescale MPC85xx Memory Controller kenel module
  *
+ * Parts Copyrighted (c) 2013 by Freescale Semiconductor, Inc.
+ *
  * Author: Dave Jiang 
  *
  * 2006-2007 (c) MontaVista Software, Inc. This file is licensed under
@@ -196,6 +198,42 @@ static void mpc85xx_pci_check(struct edac_pci_ctl_info 
*pci)
edac_pci_handle_npe(pci, pci->ctl_name);
 }
 
+static void mpc85xx_pcie_check(struct edac_pci_ctl_info *pci)
+{
+   struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
+   u32 err_detect;
+
+   err_detect = in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR);
+
+   pr_err("PCIe error(s) detected\n");
+   pr_err("PCIe ERR_DR register: 0x%08x\n", err_detect);
+   pr_err("PCIe ERR_CAP_STAT register: 0x%08x\n",
+   in_be32(pdata->pci_vbase + MPC85XX_PCI_GAS_TIMR));
+   pr_err("PCIe ERR_CAP_R0 register: 0x%08x\n",
+   in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R0));
+   pr_err("PCIe ERR_CAP_R1 register: 0x%08x\n",
+   in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R1));
+   pr_err("PCIe ERR_CAP_R2 register: 0x%08x\n",
+   in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R2));
+   pr_err("PCIe ERR_CAP_R3 register: 0x%08x\n",
+   in_be32(pdata->pci_vbase + MPC85XX_PCIE_ERR_CAP_R3));
+
+   /* clear error bits */
+   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_DR, err_detect);
+}
+
+static int mpc85xx_pcie_find_capability(struct device_node *np)
+{
+   struct pci_controller *hose;
+
+   if (!np)
+   return -EINVAL;
+
+   hose = pci_find_hose_for_OF_device(np);
+
+   return early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP);
+}
+
 static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id)
 {
struct edac_pci_ctl_info *pci = dev_id;
@@ -207,7 +245,10 @@ static irqreturn_t mpc85xx_pci_isr(int irq, void *dev_id)
if (!err_detect)
return IRQ_NONE;
 
-   mpc85xx_pci_check(pci);
+   if (pdata->is_pcie)
+   mpc85xx_pcie_check(pci);
+   else
+   mpc85xx_pci_check(pci);
 
return IRQ_HANDLED;
 }
@@ -239,14 +280,22 @@ int mpc85xx_pci_err_probe(struct platform_device *op)
pdata = pci->pvt_info;
pdata->name = "mpc85xx_pci_err";
pdata->irq = NO_IRQ;
+
+   if (mpc85xx_pcie_find_capability(op->dev.of_node) > 0)
+   pdata->is_pcie = true;
+
dev_set_drvdata(&op->dev, pci);
pci->dev = &op->dev;
pci->mod_name = EDAC_MOD_STR;
pci->ctl_name = pdata->name;
pci->dev_name = dev_name(&op->dev);
 
-   if (edac_op_state == EDAC_OPSTATE_POLL)
-   pci->edac_check = mpc85xx_pci_check;
+   if (edac_op_state == EDAC_OPSTATE_POLL) {
+   if (pdata->is_pcie)
+   pci->edac_check = mpc85xx_pcie_check;
+   else
+   pci->edac_check = mpc85xx_pci_check;
+   }
 
pdata->edac_idx = edac_pci_idx++;
 
@@ -275,16 +324,26 @@ int mpc85xx_pci_err_probe(struct platform_device *op)
goto err;
}
 
-   orig_pci_err_cap_dr =
-   in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR);
+   if (pdata->is_pcie) {
+   orig_pci_err_cap_dr =
+   in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR);
+   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_ADDR, ~0);
+   orig_pci_err_en =
+   in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN);
+   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, 0);
+   } else {
+   orig_pci_err_cap_dr =
+   in_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR);
 
-   /* PCI master abort is expected during config cycles */
-   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR, 0x40);
+   /

[PATCH 1/3] MAINTAINERS: Add edac-mpc85xx driver to MAINTAINERS

2013-09-23 Thread Johannes Thumshirn
Add drivers/edac/mpc85xx_edac.[ch] to MAINTAINERS file and me as maintainer.

Signed-off-by: Johannes Thumshirn 
Cc: Doug Thompson 
Cc: Dave Jiang 
Cc: Borislav Petkov 
---
 MAINTAINERS |7 +++
 1 file changed, 7 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index e61c2e8..9c400b4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3097,6 +3097,13 @@ W:   bluesmoke.sourceforge.net
 S: Maintained
 F: drivers/edac/i82975x_edac.c
 
+EDAC-MPC85XX
+M: Johannes Thumshirn 
+L: linux-e...@vger.kernel.org
+W: bluesmoke.sourceforge.net
+S: Maintained
+F: drivers/edac/mpc85xx_edac.[ch]
+
 EDAC-PASEMI
 M: Egor Martovetsky 
 L: linux-e...@vger.kernel.org
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] edac/85xx: New Maintainership for MPC85xx EDAC driver

2013-09-23 Thread Johannes Thumshirn
As already discussed with Borislav Petkov and Dave Jiang on linux-edac I will
take the maintainership of mpc85xx_edac.[ch]. In the following E-Mails I have
put all patches currently known to me.

If anyone else knows of orphaned patches for this driver, please inform me.

The patch "[RFC PATCH] edac/85xx: Request shared interrupts for PCI" by
Barry Grussling  is not included, as Chunhe Lan's patch
incorporates that fix.

Thanks.
Johannes

Chunhe Lan (1):
  edac/85xx: Add PCIe error interrupt edac support

Johannes Thumshirn (2):
  MAINTAINERS: Add edac-mpc85xx driver to MAINTAINERS
  edac/85xx: Remove mpc85xx_pci_err_remove

 MAINTAINERS |7 +++
 drivers/edac/mpc85xx_edac.c |  120 +++
 drivers/edac/mpc85xx_edac.h |7 +++
 3 files changed, 101 insertions(+), 33 deletions(-)

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] edac/85xx: Remove mpc85xx_pci_err_remove

2013-09-23 Thread Johannes Thumshirn
From: Johannes Thumshirn 

Remove mpc85xx_pci_err_remove(...) which is obsolete, this removes the compiler
warning which can be seen when building the driver either statically or as a
module.

Signed-off-by: Johannes Thumshirn 
Signed-off-by: Johannes Thumshirn 
---
 drivers/edac/mpc85xx_edac.c |   22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 8df5f4d..8f91821 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -403,28 +403,6 @@ err:
 }
 EXPORT_SYMBOL(mpc85xx_pci_err_probe);

-static int mpc85xx_pci_err_remove(struct platform_device *op)
-{
-   struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev);
-   struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
-
-   edac_dbg(0, "\n");
-
-   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR,
-orig_pci_err_cap_dr);
-
-   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en);
-
-   edac_pci_del_device(pci->dev);
-
-   if (edac_op_state == EDAC_OPSTATE_INT)
-   irq_dispose_mapping(pdata->irq);
-
-   edac_pci_free_ctl_info(pci);
-
-   return 0;
-}
-
 #endif /* CONFIG_PCI */

 / L2 Err device ***/
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] PWM: Add support for pwm-bcm2835

2013-09-24 Thread Johannes Thumshirn
On Mon, Sep 23, 2013 at 11:45:48AM +0200, Thierry Reding wrote:
> On Sat, Sep 21, 2013 at 12:09:02PM +0200, Johannes Thumshirn wrote:
> 
> The subject prefix should be "pwm: ". Also something like this might be
> better as a subject:
> 
>   pwm: Add BCM2835 SoC PWM driver
> 
> Then go on to describe that the BCM2835 is used in the Raspberry Pi.
> 
> > Add support for the PWM controller of the BCM2835 SoC found on Raspberry PI
> > 
> > The driver isn't as much tested as I wanted it to be and devicetree
> > support is still missing, but I thought it would be nice to have some
> > comments if I'm in the right direction.
> > 
> > Signed-off-by: Johannes Thumshirn 
> > ---
> >  drivers/pwm/Kconfig   |   8 ++
> >  drivers/pwm/Makefile  |   1 +
> >  drivers/pwm/pwm-bcm2835.c | 275 
> > ++
> >  3 files changed, 284 insertions(+)
> >  create mode 100644 drivers/pwm/pwm-bcm2835.c
> > 
> > diff --git a/drivers/pwm/Kconfig b/drivers/pwm/Kconfig
> > index 75840b5..5417159 100644
> > --- a/drivers/pwm/Kconfig
> > +++ b/drivers/pwm/Kconfig
> > @@ -224,4 +224,12 @@ config PWM_VT8500
> >   To compile this driver as a module, choose M here: the module
> >   will be called pwm-vt8500.
> >  
> > +config PWM_BCM2835
> > +   tristate "BCM2835 PWM support"
> > +   help
> > +Generic PWM framework driver for bcm2835 found on the Rasperry PI
> > +
> > +   To compile this driver as a module, choose M here: the module will be
> > +   called pwm-bcm2835
> 
> This uses a mixture of spaces and tabs for indentation. It should use
> tabs to indent, plus another 2 spaces for the help description like all
> the other entries.
> 
> Also, please keep the list sorted alphabetically.
> 
> > diff --git a/drivers/pwm/Makefile b/drivers/pwm/Makefile
> [...]
> > @@ -20,3 +20,4 @@ obj-$(CONFIG_PWM_TIPWMSS) += pwm-tipwmss.o
> >  obj-$(CONFIG_PWM_TWL)  += pwm-twl.o
> >  obj-$(CONFIG_PWM_TWL_LED)  += pwm-twl-led.o
> >  obj-$(CONFIG_PWM_VT8500)   += pwm-vt8500.o
> > +obj-$(CONFIG_PWM_BCM2835)  += pwm-bcm2835.o
> 
> That list should also be ordered alphabetically.
> 
> > diff --git a/drivers/pwm/pwm-bcm2835.c b/drivers/pwm/pwm-bcm2835.c
> [...]
> > new file mode 100644
> > index 000..8a64666
> > --- /dev/null
> > +++ b/drivers/pwm/pwm-bcm2835.c
> > @@ -0,0 +1,275 @@
> > +/*
> > + * BCM2835 PWM driver
> > + *
> > + * Derived from the Tegra PWM driver by NVIDIA Corporation.
> 
> I don't think you necessarily need to credit here. The general structure
> of PWM drivers is dictated by the subsystem, and besides that there's
> nothing in here that borrows from the Tegra PWM driver.
> 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> 
> These are almost sorted alphabetically. =)
> 
> > +
> > +#define NPWM 2
> 
> You only use this once and the context leaves no room for interpretation
> so you might just as well hard-code it.
> 
> > +
> > +/* Address Mappings (offsets) from Broadcom BCM2835 ARM Periperals Manual
> > + * Section 9.6 Page 141ff
> > + */
> > +#define BCM2835_PWM_CTL0x00 /* Control register */
> > +#define BCM2835_PWM_STA0x04 /* Status register */
> > +#define BCM2835_PWM_DMAC   0x08 /* PWM DMA Configuration */
> > +#define BCM2835_PWM_RNG1   0x10 /* PWM Channel 1 Range */
> > +#define BCM2835_PWM_DAT1   0x14 /* PWM Channel 1 Data */
> > +#define BCM2835_PWM_FIF1   0x18 /* PWM FIFO Input */
> > +#define BCM2835_PWM_RNG2   0x20 /* PWM Channel 2 Range */
> > +#define BCM2835_PWM_DAT2   0x24 /* PWM Channel 2 Data */
> > +
> > +/* Control registers 0 and 1 are mirrored on a distance of 4 bits */
> > +#define HWPWM(x) ((x) << 4)
> 
> That doesn't look right. You use this in the readl() and writel()
> functions irrespective of which register is accessed. Given that only
> two registers are per-channel, I think the easiest way would be for you
> to differentiate between channel 0 and 1 when accessing the registers.
> See below.
> 
> > +
> > +/* TODO: We only need this register set once and use HWPWM macro to
> > + * access 2nd output
> > + */
> > +/* Control Register Bits */
> > +#define BCM2835_PWM_CTL_PWEN1  BIT(0)  /* Channel 1 enable (RW) */
> > +#define BCM2835_PWM_CTL_MODE1  BIT(1)  /* Channel 1 mode (RW) */
> > +#defin

Re: [patch 1/2] staging: line6: delete an unused function

2012-12-06 Thread johannes thumshirn
On Thu, Dec 6, 2012 at 6:18 AM, Stefan Hajnoczi  wrote:
> On Wed, Dec 5, 2012 at 7:43 PM, Dan Carpenter  
> wrote:
>> line6_send_sysex_message_async() isn't called from anywhere.
>>
>> Signed-off-by: Dan Carpenter 
>
> Reviewed-by: Stefan Hajnoczi 

Reviewed-by: Johannes Thumshirn 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v8] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-14 Thread Johannes Thumshirn
On Thu, Jun 13, 2013 at 08:55:33PM -0700, Guenter Roeck wrote:
[...]
> > Signed-off-by: Johannes Thumshirn 
>
> Almost good. One comment below.
>
> Thanks,
> Guenter
>
Nice to hear. Thanks for the review by the way.

[...]

> > +
> > +   drv->num_gpios = of_gpio_count(node);
> > +   if (drv->num_gpios <= 0) {
> > +   dev_err(&pdev->dev, "gpios DT property empty / missing");
> > +   return -ENODEV;
> > +   }
>
> Not happy with this. Code accepts one gpio pin, but then assumes throughout 
> the
> driver that all pins are defined. I am quite sure I can get it to crash if I
> specify only a single gpio pin. num_gpios will be 1, you allocate a single
> entry, but then access all 6 of them.
>
> I think it would be easier if you expect a fixed number of gpio pins (6) and 
> abort
> if it is not correct. You can then make drv->gpios an array and don't have to
> allocate it separately, and you don't need drv->num_gpios (which you don't 
> need
> anyway as it is not used outside this function).
>

Yup, you're right. Now that you're saying it I see it as well. This is probably 
a
copy'n'paste error from drivers/hwmon/gpio-fan.c.

@Wim are there any objections from your side?

Byte
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v9] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-14 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Signed-off-by: Johannes Thumshirn 
---

 Revision 2:
 * Removed unneeded open flag in struct a21_wdt_drv
 * Corrected 3bit reason code from gpio
 * Additional sysfs files are now part of watchdog sysfs
 * Changed OFF/ON delay in ping from 400ms to 10ns
 * Reworked timeout setting
 * Removed a21_wdt_ioctl(...)

 Revision 3:
 * Changed pr_{err,info} to dev_{err,info}
 * Removed out of memory error print
 * Transition from "fast" to "slow" mode not allowed by chip

 Revision 4:
 * Remove reboot_notifier and place disable code into platform_device's 
shutdown function
 * Removed sysfs interface

 Revision 5:
 * Added setting of .bootstatus on driver init
 * Added initial timeout on driver init

 Revision 6:
 * Use watchdog_init_timeout() to initialize timeout

 Revision 7:
 * Fix possible get_bootstatus race condition

 Revision 8:
 * a21_wdt_get_bootstatus() should return reset code
 * GPIOs are supplied via DT instead of being hardcoded. Code derived from
   (drivers/hwmon/gpio-fan.c)
 * Added Devicetree binding document
 * Driver now depends on GPIOLIB

 Revision 9:
 * We need 6 GPIOs not only 1 to work
 * GPIO_WD_RST[0..2] are inputs

 .../devicetree/bindings/gpio/men-a021-wdt.txt  |   25 ++
 MAINTAINERS|6 +
 drivers/watchdog/Kconfig   |   12 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/mena21_wdt.c  |  276 
 5 files changed, 320 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
new file mode 100644
index 000..370dee3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
@@ -0,0 +1,25 @@
+Bindings for MEN A21 Watchdog device connected to GPIO lines
+
+Required properties:
+- compatible: "men,a021-wdt"
+- gpios: Specifies the pins that control the Watchdog, order:
+  1: Watchdog enable
+  2: Watchdog fast-mode
+  3: Watchdog trigger
+  4: Watchdog reset cause bit 0
+  5: Watchdog reset cause bit 1
+  6: Watchdog reset cause bit 2
+
+Optional properties:
+- None
+
+Example:
+   watchdog {
+   compatible ="men,a021-wdt";
+   gpios = <&gpio3 9  1/* WD_EN */
+&gpio3 10 1/* WD_FAST */
+&gpio3 11 1/* WD_TRIG */
+&gpio3 6  1/* RST_CAUSE[0] */
+&gpio3 7  1/* RST_CAUSE[1] */
+&gpio3 8  1>;  /* RST_CAUSE[2] */
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 5be702c..824261e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5317,6 +5317,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..8b143ee 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   depends on GPIOLIB
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   The driver can also be built as a module. If so, the module will be
+   called mena21_wdt.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..0d3409a
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,276 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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 Soft

[PATCH v9 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-06-14 Thread Johannes Thumshirn
This patch adds a sysfs interface for the watchdog
device found on MEN A21 Boards.

The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Signed-off-by: Johannes Thumshirn 
---

 Revision 2:
 * Re-worked sysfs patch to apply on re-worked base

 Revision 3:
 * Re-worked sysfs patch to apply on re-worked base

 Revision 4:
 * Re-worked sysfs patch to apply on re-worked base

 drivers/watchdog/mena21_wdt.c |   88 +
 1 file changed, 88 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index 0d3409a..03165be 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -22,6 +22,17 @@

 #define NUM_GPIOS 6

+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 enum a21_wdt_gpios {
GPIO_WD_ENAB,
GPIO_WD_FAST,
@@ -53,6 +64,73 @@ static unsigned int a21_wdt_get_bootstatus(struct 
a21_wdt_drv *drv)
return reset;
 }

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+   unsigned int reset = 0;
+
+   reset = a21_wdt_get_bootstatus(drv);
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_ENAB]));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_FAST]));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -222,9 +300,18 @@ static int a21_wdt_probe(struct platform_device *pdev)
}

dev_set_drvdata(&pdev->dev, drv);
+   dev_set_drvdata(a21_wdt.dev, drv);
+
+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }

return 0;

+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);

@@ -238,6 +325,7 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");

+   a21_wdt_remove_files(&drv->wdt);

watchdog_unregister_device(&drv->wdt);

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v9] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-16 Thread Johannes Thumshirn
On Sun, Jun 16, 2013 at 03:07:15PM -0700, Guenter Roeck wrote:
> On Fri, Jun 14, 2013 at 12:58:37PM +0200, Johannes Thumshirn wrote:
> > This patch adds the driver for the watchdog devices found on MEN Mikro
> > Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
> > watchdog framework.
> >
> > Signed-off-by: Johannes Thumshirn 
>
> Only nitpicks this time.
>

*g*

> > ---
> >
> >  Revision 2:
> >  * Removed unneeded open flag in struct a21_wdt_drv
> >  * Corrected 3bit reason code from gpio
> >  * Additional sysfs files are now part of watchdog sysfs
> >  * Changed OFF/ON delay in ping from 400ms to 10ns
> >  * Reworked timeout setting
> >  * Removed a21_wdt_ioctl(...)
> >
> >  Revision 3:
> >  * Changed pr_{err,info} to dev_{err,info}
> >  * Removed out of memory error print
> >  * Transition from "fast" to "slow" mode not allowed by chip
> >
> >  Revision 4:
> >  * Remove reboot_notifier and place disable code into platform_device's 
> > shutdown function
> >  * Removed sysfs interface
> >
> >  Revision 5:
> >  * Added setting of .bootstatus on driver init
> >  * Added initial timeout on driver init
> >
> >  Revision 6:
> >  * Use watchdog_init_timeout() to initialize timeout
> >
> >  Revision 7:
> >  * Fix possible get_bootstatus race condition
> >
> >  Revision 8:
> >  * a21_wdt_get_bootstatus() should return reset code
> >  * GPIOs are supplied via DT instead of being hardcoded. Code derived from
> >(drivers/hwmon/gpio-fan.c)
> >  * Added Devicetree binding document
> >  * Driver now depends on GPIOLIB
> >
> >  Revision 9:
> >  * We need 6 GPIOs not only 1 to work
> >  * GPIO_WD_RST[0..2] are inputs
> >
> >  .../devicetree/bindings/gpio/men-a021-wdt.txt  |   25 ++
> >  MAINTAINERS|6 +
> >  drivers/watchdog/Kconfig   |   12 +
> >  drivers/watchdog/Makefile  |1 +
> >  drivers/watchdog/mena21_wdt.c  |  276 
> > 
> >  5 files changed, 320 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
> >  create mode 100644 drivers/watchdog/mena21_wdt.c
> >
> > diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
> > b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
> > new file mode 100644
> > index 000..370dee3
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
> > @@ -0,0 +1,25 @@
> > +Bindings for MEN A21 Watchdog device connected to GPIO lines
> > +
> > +Required properties:
> > +- compatible: "men,a021-wdt"
> > +- gpios: Specifies the pins that control the Watchdog, order:
> > +  1: Watchdog enable
> > +  2: Watchdog fast-mode
> > +  3: Watchdog trigger
> > +  4: Watchdog reset cause bit 0
> > +  5: Watchdog reset cause bit 1
> > +  6: Watchdog reset cause bit 2
> > +
> > +Optional properties:
> > +- None
> > +
> > +Example:
> > +   watchdog {
> > +   compatible ="men,a021-wdt";
> > +   gpios = <&gpio3 9  1/* WD_EN */
> > +    &gpio3 10 1/* WD_FAST */
> > +&gpio3 11 1/* WD_TRIG */
> > +&gpio3 6  1/* RST_CAUSE[0] */
> > +&gpio3 7  1/* RST_CAUSE[1] */
> > +&gpio3 8  1>;  /* RST_CAUSE[2] */
> > +   };
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 5be702c..824261e 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5317,6 +5317,12 @@ F:   drivers/mtd/
> >  F: include/linux/mtd/
> >  F: include/uapi/mtd/
> >
> > +MEN A21 WATCHDOG DRIVER
> > +M: Johannes Thumshirn 
> > +L: linux-watch...@vger.kernel.org
> > +S: Supported
> > +F: drivers/watchdog/mena21_wdt.c
> > +
> >  METAG ARCHITECTURE
> >  M: James Hogan 
> >  S: Supported
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index e89fc31..8b143ee 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -1172,6 +1172,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
> >
> >   The value can be overridden by the wdt_period command-line parameter.
> >
> > +config MEN_A21_WDT
> > +   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer

[PATCH v10 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-17 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Signed-off-by: Johannes Thumshirn 
---

 Revision 2:
 * Removed unneeded open flag in struct a21_wdt_drv
 * Corrected 3bit reason code from gpio
 * Additional sysfs files are now part of watchdog sysfs
 * Changed OFF/ON delay in ping from 400ms to 10ns
 * Reworked timeout setting
 * Removed a21_wdt_ioctl(...)

 Revision 3:
 * Changed pr_{err,info} to dev_{err,info}
 * Removed out of memory error print
 * Transition from "fast" to "slow" mode not allowed by chip

 Revision 4:
 * Remove reboot_notifier and place disable code into platform_device's 
shutdown function
 * Removed sysfs interface

 Revision 5:
 * Added setting of .bootstatus on driver init
 * Added initial timeout on driver init

 Revision 6:
 * Use watchdog_init_timeout() to initialize timeout

 Revision 7:
 * Fix possible get_bootstatus race condition

 Revision 8:
 * a21_wdt_get_bootstatus() should return reset code
 * GPIOs are supplied via DT instead of being hardcoded. Code derived from
   (drivers/hwmon/gpio-fan.c)
 * Added Devicetree binding document
 * Driver now depends on GPIOLIB

 Revision 9:
 * We need 6 GPIOs not only 1 to work
 * GPIO_WD_RST[0..2] are inputs

 Revision 10:
 * Don't perform checks of Watchdog core again.
 * Some style fixes

 .../devicetree/bindings/gpio/men-a021-wdt.txt  |   25 ++
 MAINTAINERS|6 +
 drivers/watchdog/Kconfig   |   12 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/mena21_wdt.c  |  270 
 5 files changed, 314 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
new file mode 100644
index 000..370dee3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
@@ -0,0 +1,25 @@
+Bindings for MEN A21 Watchdog device connected to GPIO lines
+
+Required properties:
+- compatible: "men,a021-wdt"
+- gpios: Specifies the pins that control the Watchdog, order:
+  1: Watchdog enable
+  2: Watchdog fast-mode
+  3: Watchdog trigger
+  4: Watchdog reset cause bit 0
+  5: Watchdog reset cause bit 1
+  6: Watchdog reset cause bit 2
+
+Optional properties:
+- None
+
+Example:
+   watchdog {
+   compatible ="men,a021-wdt";
+   gpios = <&gpio3 9  1/* WD_EN */
+&gpio3 10 1/* WD_FAST */
+&gpio3 11 1/* WD_TRIG */
+&gpio3 6  1/* RST_CAUSE[0] */
+&gpio3 7  1/* RST_CAUSE[1] */
+&gpio3 8  1>;  /* RST_CAUSE[2] */
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 5be702c..824261e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5317,6 +5317,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..8b143ee 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   depends on GPIOLIB
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   The driver can also be built as a module. If so, the module will be
+   called mena21_wdt.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..96dbba9
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,270 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify 

[PATCH v10 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-06-17 Thread Johannes Thumshirn
This patch adds a sysfs interface for the watchdog
device found on MEN A21 Boards.

The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Revision 2:
* Re-worked sysfs patch to apply on re-worked base

Revision 3:
* Re-worked sysfs patch to apply on re-worked base
Signed-off-by: Johannes Thumshirn 
---
 drivers/watchdog/mena21_wdt.c |   89 +
 1 file changed, 89 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index 96dbba9..91cc90b 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -22,6 +22,17 @@

 #define NUM_GPIOS 6

+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 enum a21_wdt_gpios {
GPIO_WD_ENAB,
GPIO_WD_FAST,
@@ -53,6 +64,73 @@ static unsigned int a21_wdt_get_bootstatus(struct 
a21_wdt_drv *drv)
return reset;
 }

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+   unsigned int reset = 0;
+
+   reset = a21_wdt_get_bootstatus(drv);
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_ENAB]));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_FAST]));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -215,11 +293,20 @@ static int a21_wdt_probe(struct platform_device *pdev)
}

dev_set_drvdata(&pdev->dev, drv);
+   dev_set_drvdata(a21_wdt.dev, drv);
+
+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }

dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n");

return 0;

+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);

@@ -233,6 +320,8 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");

+   a21_wdt_remove_files(&drv->wdt);
+
watchdog_unregister_device(&drv

Some problems with sysfs patch (was Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs)

2013-06-06 Thread Johannes Thumshirn
On Mon, Jun 03, 2013 at 11:50:26AM +0200, Johannes Thumshirn wrote:
> On Fri, May 31, 2013 at 09:15:23PM -0700, Guenter Roeck wrote:
> > On Fri, May 31, 2013 at 02:55:19PM +0200, Johannes Thumshirn wrote:
> > > Hi Guenther,
> > > On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > > > > +#define GPIO_WD_ENAB 169
> > > > > +#define GPIO_WD_FAST 170
> > > > > +#define GPIO_WD_TRIG 171
> > > > > +
> > > > > +#define GPIO_RST_CAUSE_BASE 166
> > > > > +
> > > >
> > > > I think I asked that before ... as you are supporting devicetree, gpio 
> > > > pins
> > > > should really be provided through devicetree properties and not be 
> > > > hardcoded.
> > > >
> > > Yes you did and I didn't come up with a solution to this problem yet. I 
> > > understand
> > > and agree to your concerns but I'm lacking example code/documentation for 
> > > it, maybe
> > > you can point me to an example on that and then I'll update my code 
> > > accordingly.
> > >
> >
> > Have a look at Documentation/devicetree/bindings/gpio/gpio-fan.txt and
> > drivers/hwmon/gpio-fan.c.
>
> Thanks a lot, this really helped me out. Updated patch is comming today
> including the bindings document Arnd Bergmann requested. I only need to rebase
> the sysfs patch on top of that changes.
>
> Regards,
> Johannes

Regarding the sysfs patch, I have a funny effect in my (rebased) sysfs code.

Given the following code:

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+   unsigned int reset = 0;
+
+   if (!drv)
+   return -EIO;
+
+   reset = a21_wdt_get_bootstatus(drv);
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);

I actually need the check for if (!drv) to prevent an OOPS, as
dev_get_drvdata(dev) returns NULL., though it is set at the end of my probe
function via:

[...]
+   ret = watchdog_register_device(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot register watchdog device\n");
+   goto err_register_wd;
+   }
+
+   dev_set_drvdata(&pdev->dev, drv);
+
+   return 0;
[...]

The watchdog driver itself is working without any troubles.

Some advice here would be worth its weight in gold.

Thanks,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Some problems with sysfs patch (was Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs)

2013-06-06 Thread Johannes Thumshirn
On Thu, Jun 06, 2013 at 04:31:10AM -0700, Guenter Roeck wrote:
> On Thu, Jun 06, 2013 at 12:51:03PM +0200, Johannes Thumshirn wrote:
> > On Mon, Jun 03, 2013 at 11:50:26AM +0200, Johannes Thumshirn wrote:
> > > On Fri, May 31, 2013 at 09:15:23PM -0700, Guenter Roeck wrote:
> > > > On Fri, May 31, 2013 at 02:55:19PM +0200, Johannes Thumshirn wrote:
> > > > > Hi Guenther,
> > > > > On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > > > > > > +#define GPIO_WD_ENAB 169
> > > > > > > +#define GPIO_WD_FAST 170
> > > > > > > +#define GPIO_WD_TRIG 171
> > > > > > > +
> > > > > > > +#define GPIO_RST_CAUSE_BASE 166
> > > > > > > +
> > > > > >
> > > > > > I think I asked that before ... as you are supporting devicetree, 
> > > > > > gpio pins
> > > > > > should really be provided through devicetree properties and not be 
> > > > > > hardcoded.
> > > > > >
> > > > > Yes you did and I didn't come up with a solution to this problem yet. 
> > > > > I understand
> > > > > and agree to your concerns but I'm lacking example code/documentation 
> > > > > for it, maybe
> > > > > you can point me to an example on that and then I'll update my code 
> > > > > accordingly.
> > > > >
> > > >
> > > > Have a look at Documentation/devicetree/bindings/gpio/gpio-fan.txt and
> > > > drivers/hwmon/gpio-fan.c.
> > >
> > > Thanks a lot, this really helped me out. Updated patch is comming today
> > > including the bindings document Arnd Bergmann requested. I only need to 
> > > rebase
> > > the sysfs patch on top of that changes.
> > >
> > > Regards,
> > > Johannes
> >
> > Regarding the sysfs patch, I have a funny effect in my (rebased) sysfs code.
> >
> > Given the following code:
> >
> > +static ssize_t rebootcause_show(struct device *dev,
> > +   struct device_attribute *attr,
> > +   char *buf)
> > +{
> > +   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
> > +   unsigned int reset = 0;
> > +
> > +   if (!drv)
> > +   return -EIO;
> > +
> > +   reset = a21_wdt_get_bootstatus(drv);
> > +
> > +   return sprintf(buf, "%s\n", reset_causes[reset]);
> > +}
> > +static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
> >
> > I actually need the check for if (!drv) to prevent an OOPS, as
> > dev_get_drvdata(dev) returns NULL., though it is set at the end of my probe
> > function via:
> >
> > [...]
> > +   ret = watchdog_register_device(&a21_wdt);
> > +   if (ret) {
> > +   dev_err(&pdev->dev, "Cannot register watchdog device\n");
> > +   goto err_register_wd;
> > +   }
> > +
> > +   dev_set_drvdata(&pdev->dev, drv);
> > +
> > +   return 0;
> > [...]
> >
> > The watchdog driver itself is working without any troubles.
> >
> > Some advice here would be worth its weight in gold.
> >
> It has to be set before the attribute is created. Are you doing that ? Also, 
> is
> 'dev' the same device pointer (ie is the 'dev' in your function the same as
> &pdev->dev) ?
>
> Guenter

Hi Guenter,

Thanks for the quick reply. Indeed 'dev' in my function is a struct
watchdog_device's dev (for device_create_file) and not &pdev->dev. Which in turn
are not the same.

A call to dev_set_drvdata(a21_wdt.dev, drv); solved the NULL pointer access. So
last question, is it save to set the drvdata of a dev inside the struct
watchdog_device or do I break something vital that way?

Thanks a lot,
Johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Some problems with sysfs patch (was Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs)

2013-06-07 Thread Johannes Thumshirn
On Thu, Jun 06, 2013 at 10:08:28AM -0700, Guenter Roeck wrote:
> On Thu, Jun 06, 2013 at 03:00:55PM +0200, Johannes Thumshirn wrote:
> > On Thu, Jun 06, 2013 at 04:31:10AM -0700, Guenter Roeck wrote:
> > > On Thu, Jun 06, 2013 at 12:51:03PM +0200, Johannes Thumshirn wrote:
> > > > On Mon, Jun 03, 2013 at 11:50:26AM +0200, Johannes Thumshirn wrote:
> > > > > On Fri, May 31, 2013 at 09:15:23PM -0700, Guenter Roeck wrote:
> > > > > > On Fri, May 31, 2013 at 02:55:19PM +0200, Johannes Thumshirn wrote:
> > > > > > > Hi Guenther,
> > > > > > > On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > > > > > > > > +#define GPIO_WD_ENAB 169
> > > > > > > > > +#define GPIO_WD_FAST 170
> > > > > > > > > +#define GPIO_WD_TRIG 171
> > > > > > > > > +
> > > > > > > > > +#define GPIO_RST_CAUSE_BASE 166
> > > > > > > > > +
> > > > > > > >
> > > > > > > > I think I asked that before ... as you are supporting 
> > > > > > > > devicetree, gpio pins
> > > > > > > > should really be provided through devicetree properties and not 
> > > > > > > > be hardcoded.
> > > > > > > >
> > > > > > > Yes you did and I didn't come up with a solution to this problem 
> > > > > > > yet. I understand
> > > > > > > and agree to your concerns but I'm lacking example 
> > > > > > > code/documentation for it, maybe
> > > > > > > you can point me to an example on that and then I'll update my 
> > > > > > > code accordingly.
> > > > > > >
> > > > > >
> > > > > > Have a look at Documentation/devicetree/bindings/gpio/gpio-fan.txt 
> > > > > > and
> > > > > > drivers/hwmon/gpio-fan.c.
> > > > >
> > > > > Thanks a lot, this really helped me out. Updated patch is comming 
> > > > > today
> > > > > including the bindings document Arnd Bergmann requested. I only need 
> > > > > to rebase
> > > > > the sysfs patch on top of that changes.
> > > > >
> > > > > Regards,
> > > > > Johannes
> > > >
> > > > Regarding the sysfs patch, I have a funny effect in my (rebased) sysfs 
> > > > code.
> > > >
> > > > Given the following code:
> > > >
> > > > +static ssize_t rebootcause_show(struct device *dev,
> > > > +   struct device_attribute *attr,
> > > > +   char *buf)
> > > > +{
> > > > +   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
> > > > +   unsigned int reset = 0;
> > > > +
> > > > +   if (!drv)
> > > > +   return -EIO;
> > > > +
> > > > +   reset = a21_wdt_get_bootstatus(drv);
> > > > +
> > > > +   return sprintf(buf, "%s\n", reset_causes[reset]);
> > > > +}
> > > > +static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
> > > >
> > > > I actually need the check for if (!drv) to prevent an OOPS, as
> > > > dev_get_drvdata(dev) returns NULL., though it is set at the end of my 
> > > > probe
> > > > function via:
> > > >
> > > > [...]
> > > > +   ret = watchdog_register_device(&a21_wdt);
> > > > +   if (ret) {
> > > > +   dev_err(&pdev->dev, "Cannot register watchdog 
> > > > device\n");
> > > > +   goto err_register_wd;
> > > > +   }
> > > > +
> > > > +   dev_set_drvdata(&pdev->dev, drv);
> > > > +
> > > > +   return 0;
> > > > [...]
> > > >
> > > > The watchdog driver itself is working without any troubles.
> > > >
> > > > Some advice here would be worth its weight in gold.
> > > >
> > > It has to be set before the attribute is created. Are you doing that ? 
> > > Also, is
> > > 'dev' the same device pointer (ie is the 'dev' in your function the same 
> > > as
> > > &pdev->dev) ?
> > >
> > > Gu

Re: Some problems with sysfs patch (was Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs)

2013-06-07 Thread Johannes Thumshirn
On Fri, Jun 07, 2013 at 02:14:19AM -0700, Guenter Roeck wrote:
> On Fri, Jun 07, 2013 at 09:45:19AM +0200, Johannes Thumshirn wrote:
> > On Thu, Jun 06, 2013 at 10:08:28AM -0700, Guenter Roeck wrote:
> > > On Thu, Jun 06, 2013 at 03:00:55PM +0200, Johannes Thumshirn wrote:
> > > > On Thu, Jun 06, 2013 at 04:31:10AM -0700, Guenter Roeck wrote:
> > > > > On Thu, Jun 06, 2013 at 12:51:03PM +0200, Johannes Thumshirn wrote:
> > > > > > On Mon, Jun 03, 2013 at 11:50:26AM +0200, Johannes Thumshirn wrote:
> > > > > > > On Fri, May 31, 2013 at 09:15:23PM -0700, Guenter Roeck wrote:
> > > > > > > > On Fri, May 31, 2013 at 02:55:19PM +0200, Johannes Thumshirn 
> > > > > > > > wrote:
> > > > > > > > > Hi Guenther,
> > > > > > > > > On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > > > > > > > > > > +#define GPIO_WD_ENAB 169
> > > > > > > > > > > +#define GPIO_WD_FAST 170
> > > > > > > > > > > +#define GPIO_WD_TRIG 171
> > > > > > > > > > > +
> > > > > > > > > > > +#define GPIO_RST_CAUSE_BASE 166
> > > > > > > > > > > +
> > > > > > > > > >
> > > > > > > > > > I think I asked that before ... as you are supporting 
> > > > > > > > > > devicetree, gpio pins
> > > > > > > > > > should really be provided through devicetree properties and 
> > > > > > > > > > not be hardcoded.
> > > > > > > > > >
> > > > > > > > > Yes you did and I didn't come up with a solution to this 
> > > > > > > > > problem yet. I understand
> > > > > > > > > and agree to your concerns but I'm lacking example 
> > > > > > > > > code/documentation for it, maybe
> > > > > > > > > you can point me to an example on that and then I'll update 
> > > > > > > > > my code accordingly.
> > > > > > > > >
> > > > > > > >
> > > > > > > > Have a look at 
> > > > > > > > Documentation/devicetree/bindings/gpio/gpio-fan.txt and
> > > > > > > > drivers/hwmon/gpio-fan.c.
> > > > > > >
> > > > > > > Thanks a lot, this really helped me out. Updated patch is comming 
> > > > > > > today
> > > > > > > including the bindings document Arnd Bergmann requested. I only 
> > > > > > > need to rebase
> > > > > > > the sysfs patch on top of that changes.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Johannes
> > > > > >
> > > > > > Regarding the sysfs patch, I have a funny effect in my (rebased) 
> > > > > > sysfs code.
> > > > > >
> > > > > > Given the following code:
> > > > > >
> > > > > > +static ssize_t rebootcause_show(struct device *dev,
> > > > > > +   struct device_attribute *attr,
> > > > > > +   char *buf)
> > > > > > +{
> > > > > > +   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
> > > > > > +   unsigned int reset = 0;
> > > > > > +
> > > > > > +   if (!drv)
> > > > > > +   return -EIO;
> > > > > > +
> > > > > > +   reset = a21_wdt_get_bootstatus(drv);
> > > > > > +
> > > > > > +   return sprintf(buf, "%s\n", reset_causes[reset]);
> > > > > > +}
> > > > > > +static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
> > > > > >
> > > > > > I actually need the check for if (!drv) to prevent an OOPS, as
> > > > > > dev_get_drvdata(dev) returns NULL., though it is set at the end of 
> > > > > > my probe
> > > > > > function via:
> > > > > >
> > > > > > [...]
> > > > > > +   ret = watchdog_register_device(&a21_wdt);
> > > > > > +   if (ret) {
> > > &

[PATCH v8 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-06-07 Thread Johannes Thumshirn
This patch adds a sysfs interface for the watchdog
device found on MEN A21 Boards.

The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Revision 2:
* Re-worked sysfs patch to apply on re-worked base

Revision 3:
* Re-worked sysfs patch to apply on re-worked base
Signed-off-by: Johannes Thumshirn 
---
 drivers/watchdog/mena21_wdt.c |   88 +
 1 file changed, 88 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index 29f9c0d..cae5462 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -20,6 +20,17 @@
 #include 
 #include 

+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 enum a21_wdt_gpios {
GPIO_WD_ENAB,
GPIO_WD_FAST,
@@ -52,6 +63,73 @@ static unsigned int a21_wdt_get_bootstatus(struct 
a21_wdt_drv *drv)
return reset;
 }

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+   unsigned int reset = 0;
+
+   reset = a21_wdt_get_bootstatus(drv);
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_ENAB]));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_FAST]));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -223,9 +301,18 @@ static int a21_wdt_probe(struct platform_device *pdev)
}

dev_set_drvdata(&pdev->dev, drv);
+   dev_set_drvdata(a21_wdt.dev, drv);
+
+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }

return 0;

+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);

@@ -239,6 +326,7 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");

+   a21_wdt_remove_files(&drv->wdt);

watchdog_unregister_device(&drv->wdt);

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH RESEND v10 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-06-18 Thread Johannes Thumshirn
This patch adds a sysfs interface for the watchdog
device found on MEN A21 Boards.

The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Signed-off-by: Johannes Thumshirn 
---

 Revision 2:
 * Re-worked sysfs patch to apply on re-worked base

 Revision 3:
 * Re-worked sysfs patch to apply on re-worked base

 drivers/watchdog/mena21_wdt.c |   89 +
 1 file changed, 89 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index 96dbba9..91cc90b 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -22,6 +22,17 @@

 #define NUM_GPIOS 6

+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 enum a21_wdt_gpios {
GPIO_WD_ENAB,
GPIO_WD_FAST,
@@ -53,6 +64,73 @@ static unsigned int a21_wdt_get_bootstatus(struct 
a21_wdt_drv *drv)
return reset;
 }

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+   unsigned int reset = 0;
+
+   reset = a21_wdt_get_bootstatus(drv);
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_ENAB]));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   struct a21_wdt_drv *drv = dev_get_drvdata(dev);
+
+   return sprintf(buf, "%d\n", !!gpio_get_value(drv->gpios[GPIO_WD_FAST]));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -215,11 +293,20 @@ static int a21_wdt_probe(struct platform_device *pdev)
}

dev_set_drvdata(&pdev->dev, drv);
+   dev_set_drvdata(a21_wdt.dev, drv);
+
+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }

dev_info(&pdev->dev, "MEN A21 watchdog timer driver enabled\n");

return 0;

+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);

@@ -233,6 +320,8 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");

+   a21_wdt_remove_files(&drv->wdt);
+
watchdog_unregister_device(&

[PATCH RESEND v10 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-18 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Signed-off-by: Johannes Thumshirn 
Reviewed-by: Guenter Roeck 
---

 Revision 2:
 * Removed unneeded open flag in struct a21_wdt_drv
 * Corrected 3bit reason code from gpio
 * Additional sysfs files are now part of watchdog sysfs
 * Changed OFF/ON delay in ping from 400ms to 10ns
 * Reworked timeout setting
 * Removed a21_wdt_ioctl(...)

 Revision 3:
 * Changed pr_{err,info} to dev_{err,info}
 * Removed out of memory error print
 * Transition from "fast" to "slow" mode not allowed by chip

 Revision 4:
 * Remove reboot_notifier and place disable code into platform_device's 
shutdown function
 * Removed sysfs interface

 Revision 5:
 * Added setting of .bootstatus on driver init
 * Added initial timeout on driver init

 Revision 6:
 * Use watchdog_init_timeout() to initialize timeout

 Revision 7:
 * Fix possible get_bootstatus race condition

 Revision 8:
 * a21_wdt_get_bootstatus() should return reset code
 * GPIOs are supplied via DT instead of being hardcoded. Code derived from
   (drivers/hwmon/gpio-fan.c)
 * Added Devicetree binding document
 * Driver now depends on GPIOLIB

 Revision 9:
 * We need 6 GPIOs not only 1 to work
 * GPIO_WD_RST[0..2] are inputs

 Revision 10:
 * Don't perform checks of Watchdog core again.
 * Some style fixes

 .../devicetree/bindings/gpio/men-a021-wdt.txt  |   25 ++
 MAINTAINERS|6 +
 drivers/watchdog/Kconfig   |   12 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/mena21_wdt.c  |  270 
 5 files changed, 314 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
new file mode 100644
index 000..370dee3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
@@ -0,0 +1,25 @@
+Bindings for MEN A21 Watchdog device connected to GPIO lines
+
+Required properties:
+- compatible: "men,a021-wdt"
+- gpios: Specifies the pins that control the Watchdog, order:
+  1: Watchdog enable
+  2: Watchdog fast-mode
+  3: Watchdog trigger
+  4: Watchdog reset cause bit 0
+  5: Watchdog reset cause bit 1
+  6: Watchdog reset cause bit 2
+
+Optional properties:
+- None
+
+Example:
+   watchdog {
+   compatible ="men,a021-wdt";
+   gpios = <&gpio3 9  1/* WD_EN */
+&gpio3 10 1/* WD_FAST */
+&gpio3 11 1/* WD_TRIG */
+&gpio3 6  1/* RST_CAUSE[0] */
+&gpio3 7  1/* RST_CAUSE[1] */
+&gpio3 8  1>;  /* RST_CAUSE[2] */
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index 5be702c..824261e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5317,6 +5317,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..8b143ee 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   depends on GPIOLIB
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   The driver can also be built as a module. If so, the module will be
+   called mena21_wdt.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..96dbba9
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,270 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * This program is free software; you can redistribute 

Re: [PATCH v4 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
Hi Guenther,

On Thu, May 30, 2013 at 03:02:47PM -0700, Guenter Roeck wrote:
> On Thu, May 30, 2013 at 11:59:28PM +0200, Wim Van Sebroeck wrote:
> > Hi Guenter,
> >
[...]
>
> I even thought about adding this capability to the infrastructure.

Actually this would be pretty nice to have
>
> Thanks,
> Guenter

Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v5 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Revision 4:
* Remove reboot_notifier and place disable code into platform_device's shutdown 
function
* Removed sysfs interface

Revision 5:

* Added setting of .bootstatus on driver init
* Added initial timeout on driver init

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 ++
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  234 +
 4 files changed, 249 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 7714c3c..023945a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5307,6 +5307,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..e586c2e
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,234 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static int a21_wdt_get_bootstatus(unsigned int *reset)
+{
+   int i;
+
+   for (i = 0; i < 3; i++)
+   *reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+   ? (1 << i) : 0;
+
+   if (*reset >= 8)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int a21_wdt_start(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 1);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_stop(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   /* We don't stop if WDOG_NO_WAY_OUT is set */
+   if (test_bit(WDOG_NO_WAY_OUT, &wdt->status))
+   return -EINVAL;
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 0);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_ping(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_TRIG, 0);
+   ndelay(10);
+   gpio_set_value(GPIO_WD_TRIG, 1);
+
+   mutex_unlock(&drv->lock);
+
+ 

[PATCH v2 2/2] This patch adds a sysfs interface for the watchdog device found on MEN A21 Boards.

2013-05-31 Thread Johannes Thumshirn
The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Revision 2:
* Re-worked sysfs patch to apply on re-worked base

Signed-off-by: Johannes Thumshirn 
---
 drivers/watchdog/mena21_wdt.c |   88 +
 1 file changed, 88 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index e586c2e..e11d869 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -19,6 +19,17 @@
 #include 
 #include 

+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 #define GPIO_WD_ENAB   169
 #define GPIO_WD_FAST   170
 #define GPIO_WD_TRIG   171
@@ -49,6 +60,74 @@ static int a21_wdt_get_bootstatus(unsigned int *reset)
return 0;
 }

+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   unsigned int reset = 0;
+   int i;
+
+   for (i = 0; i < 3; i++)
+   reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+? (1 << i) : 0;
+
+   if (reset >= 8)
+   return -EIO;
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_ENAB));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_FAST));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -181,10 +260,18 @@ static int a21_wdt_probe(struct platform_device *pdev)
a21_wdt.bootstatus |= WDIOF_EXTERN2;
}

+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }
+
dev_set_drvdata(&pdev->dev, drv);

return 0;

+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);

@@ -198,6 +285,7 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");

+   a21_wdt_remove_files(&drv->wdt);

watchdog_unregister_device(&drv->wdt);

--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
On Fri, May 31, 2013 at 10:58:48AM +0200, Johannes Thumshirn wrote:
> This patch adds the driver for the watchdog devices found on MEN Mikro
> Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
> watchdog framework.
[...]
> +MODULE_DESCRIPTION("MEN A21 Watchdog");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS("platform:a21-watchdog");
> --
> 1.7.9.5
>


Args, sorry messed up the thread :-(.

I'm not so firm with using mutt for patches, but git send-email doesn't seem
to like Exchange here...


Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v5 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
On Fri, May 31, 2013 at 03:36:54AM -0700, Guenter Roeck wrote:
> On Fri, May 31, 2013 at 10:58:48AM +0200, Johannes Thumshirn wrote:
> > This patch adds the driver for the watchdog devices found on MEN Mikro
> > Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
> > watchdog framework.
> >
> > Revision 2:
> > * Removed unneeded open flag in struct a21_wdt_drv
> > * Corrected 3bit reason code from gpio
> > * Additional sysfs files are now part of watchdog sysfs
> > * Changed OFF/ON delay in ping from 400ms to 10ns
> > * Reworked timeout setting
> > * Removed a21_wdt_ioctl(...)
> >
> > Revision 3:
> > * Changed pr_{err,info} to dev_{err,info}
> > * Removed out of memory error print
> > * Transition from "fast" to "slow" mode not allowed by chip
> >
> > Revision 4:
> > * Remove reboot_notifier and place disable code into platform_device's 
> > shutdown function
> > * Removed sysfs interface
> >
> > Revision 5:
> >
> > * Added setting of .bootstatus on driver init
> > * Added initial timeout on driver init
> >
> > Signed-off-by: Johannes Thumshirn 
> > ---
> >  MAINTAINERS   |6 ++
> >  drivers/watchdog/Kconfig  |8 ++
> >  drivers/watchdog/Makefile |1 +
> >  drivers/watchdog/mena21_wdt.c |  234 
> > +
> >  4 files changed, 249 insertions(+)
> >  create mode 100644 drivers/watchdog/mena21_wdt.c
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 7714c3c..023945a 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -5307,6 +5307,12 @@ F:   drivers/mtd/
> >  F: include/linux/mtd/
> >  F: include/uapi/mtd/
> >
> > +MEN A21 WATCHDOG DRIVER
> > +M: Johannes Thumshirn 
> > +L: linux-watch...@vger.kernel.org
> > +S: Supported
> > +F: drivers/watchdog/mena21_wdt.c
> > +
> >  METAG ARCHITECTURE
> >  M: James Hogan 
> >  S: Supported
> > diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
> > index e89fc31..192b84d 100644
> > --- a/drivers/watchdog/Kconfig
> > +++ b/drivers/watchdog/Kconfig
> > @@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
> >
> >   The value can be overridden by the wdt_period command-line parameter.
> >
> > +config MEN_A21_WDT
> > +   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
> > +   select WATCHDOG_CORE
> > +   help
> > +Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
> > +
> > +   If unsure select N here.
> > +
> >  # PPC64 Architecture
> >
> >  config WATCHDOG_RTAS
> > diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
> > index a300b94..bffdcb1 100644
> > --- a/drivers/watchdog/Makefile
> > +++ b/drivers/watchdog/Makefile
> > @@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
> >  obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
> >  obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
> >  obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
> > +obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
> >
> >  # PPC64 Architecture
> >  obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
> > diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
> > new file mode 100644
> > index 000..e586c2e
> > --- /dev/null
> > +++ b/drivers/watchdog/mena21_wdt.c
> > @@ -0,0 +1,234 @@
> > +/*
> > + * Watchdog driver for the A21 VME CPU Boards
> > + *
> > + * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
> > + *
> > + * 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
> > + */
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +#define GPIO_WD_ENAB   169
> > +#define GPIO_WD_FAST   170
> > +#define GPIO_WD_TRIG   171
> > +
> > +#define GPIO_RST_CAUSE_BASE 166
> > +
> > +struct a21_wdt_drv {
> > +   struct watchdog_device wdt;
> > +   struct mutex lock;
> > +};
> > +
> > +static bool nowayout = WATCHDOG_NOWAYOUT;
> > +module_param(nowayout, bool, 0);
> > +MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started 
> > (default="
> > +   __MOD

[PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Revision 4:
* Remove reboot_notifier and place disable code into platform_device's shutdown 
function
* Removed sysfs interface

Revision 5:

* Added setting of .bootstatus on driver init
* Added initial timeout on driver init

Revision 6:
* Use watchdog_init_timeout() to initialize timeout

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 ++
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  234 +
 4 files changed, 249 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 7714c3c..023945a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5307,6 +5307,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..9874c63
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,234 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static int a21_wdt_get_bootstatus(unsigned int *reset)
+{
+   int i;
+
+   for (i = 0; i < 3; i++)
+   *reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+   ? (1 << i) : 0;
+
+   if (*reset >= 8)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int a21_wdt_start(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 1);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_stop(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   /* We don't stop if WDOG_NO_WAY_OUT is set */
+   if (test_bit(WDOG_NO_WAY_OUT, &wdt->status))
+   return -EINVAL;
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 0);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_ping(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_TRIG, 0);
+   ndelay(10);
+   gpio_set_value(GPI

Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
Hi Guenther,
On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > +#define GPIO_WD_ENAB   169
> > +#define GPIO_WD_FAST   170
> > +#define GPIO_WD_TRIG   171
> > +
> > +#define GPIO_RST_CAUSE_BASE 166
> > +
>
> I think I asked that before ... as you are supporting devicetree, gpio pins
> should really be provided through devicetree properties and not be hardcoded.
>
Yes you did and I didn't come up with a solution to this problem yet. I 
understand
and agree to your concerns but I'm lacking example code/documentation for it, 
maybe
you can point me to an example on that and then I'll update my code accordingly.

> > +struct a21_wdt_drv {
> > +   struct watchdog_device wdt;
> > +   struct mutex lock;
> > +   }
> > +
> > +   if (timeout == 30 && wdt->timeout == 1) {
> > +   dev_err(wdt->dev,
> > +   "Transition from fast to slow mode not allowed\n");
> > +   return -EINVAL;
> > +   }
> > +
> I dislike that [2 .. 29] timeout values are not supported, and would rather 
> have
> you accept that range and set the timeout to 30. Also, it is somewhat 
> undesirable
> that the timeout can not be changed back to 30 after being set to 1.

The not changing back issue was a hardware design criterion and I have no
influence on that one. I've already checked with the IC developer and he said,
this is intended. I don't quite understand why I should accept the timeout and
set it to 30? In my opinion this only introduces some magic the user won't
understand. Instead failing and giving an error message is something a user can
take as a hint for investigating.

> As Wim recommended, a softdog on top of the hardware watchdog would be the 
> best
> solution. I'll leave it up to him to decide if he wants to accept the code
> as-is.

Yes let's see what he's saying.

>
> > +   mutex_lock(&drv->lock);
> > +
> > +   ret = watchdog_register_device(&a21_wdt);
> > +   if (ret) {
> > +   dev_err(&pdev->dev, "Cannot register watchdog device\n");
> > +   goto err_register_wd;
> > +   }
> > +
> > +   ret = a21_wdt_get_bootstatus(&reset);
> > +   if (ret)
> > +   dev_warn(&pdev->dev, "Reset Cause contains invalid data\n");
> > +   else {
> > +   if (reset == 2)
> > +   a21_wdt.bootstatus |= WDIOF_EXTERN1;
> > +   else if (reset == 4)
> > +   a21_wdt.bootstatus |= WDIOF_CARDRESET;
> > +   else if (reset == 5)
> > +   a21_wdt.bootstatus |= WDIOF_POWERUNDER;
> > +   else if (reset == 7)
> > +   a21_wdt.bootstatus |= WDIOF_EXTERN2;
>
> What about other causes ? No useful match ?
>

None I could find. Actually WDIOF_EXTERN[12] already are a pretty creative
mapping in my opinion. EXTERN1 is a "Push Button" event, EXTERN2 is a reset
caused by a JTAG/BDM adapter...

> I think bootstatus should be set prior to registering the watchdog device
> to avoid race conditions where an application reads it prior to being set.
>
Agreed, didn't see that one *doh*, must be fixed before inclusion.
> > +   }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v7] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-31 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Revision 4:
* Remove reboot_notifier and place disable code into platform_device's shutdown 
function
* Removed sysfs interface

Revision 5:

* Added setting of .bootstatus on driver init
* Added initial timeout on driver init

Revision 6:
* Use watchdog_init_timeout() to initialize timeout

Revision 7:
* Fix possible get_bootstatus race condition

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 ++
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  234 +
 4 files changed, 249 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 7714c3c..023945a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5307,6 +5307,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..dec35ec
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,234 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static int a21_wdt_get_bootstatus(unsigned int *reset)
+{
+   int i;
+
+   for (i = 0; i < 3; i++)
+   *reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+   ? (1 << i) : 0;
+
+   if (*reset >= 8)
+   return -EINVAL;
+
+   return 0;
+}
+
+static int a21_wdt_start(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 1);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_stop(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   /* We don't stop if WDOG_NO_WAY_OUT is set */
+   if (test_bit(WDOG_NO_WAY_OUT, &wdt->status))
+   return -EINVAL;
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 0);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_ping(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_valu

Re: [PATCH v6] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-03 Thread Johannes Thumshirn
On Fri, May 31, 2013 at 09:15:23PM -0700, Guenter Roeck wrote:
> On Fri, May 31, 2013 at 02:55:19PM +0200, Johannes Thumshirn wrote:
> > Hi Guenther,
> > On Fri, May 31, 2013 at 04:40:37AM -0700, Guenter Roeck wrote:
> > > > +#define GPIO_WD_ENAB   169
> > > > +#define GPIO_WD_FAST   170
> > > > +#define GPIO_WD_TRIG   171
> > > > +
> > > > +#define GPIO_RST_CAUSE_BASE 166
> > > > +
> > >
> > > I think I asked that before ... as you are supporting devicetree, gpio 
> > > pins
> > > should really be provided through devicetree properties and not be 
> > > hardcoded.
> > >
> > Yes you did and I didn't come up with a solution to this problem yet. I 
> > understand
> > and agree to your concerns but I'm lacking example code/documentation for 
> > it, maybe
> > you can point me to an example on that and then I'll update my code 
> > accordingly.
> >
>
> Have a look at Documentation/devicetree/bindings/gpio/gpio-fan.txt and
> drivers/hwmon/gpio-fan.c.

Thanks a lot, this really helped me out. Updated patch is comming today
including the bindings document Arnd Bergmann requested. I only need to rebase
the sysfs patch on top of that changes.

Regards,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v8] watchdog: New watchdog driver for MEN A21 watchdogs

2013-06-03 Thread Johannes Thumshirn
This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Revision 4:
* Remove reboot_notifier and place disable code into platform_device's shutdown 
function
* Removed sysfs interface

Revision 5:
* Added setting of .bootstatus on driver init
* Added initial timeout on driver init

Revision 6:
* Use watchdog_init_timeout() to initialize timeout

Revision 7:
* Fix possible get_bootstatus race condition

Revision 8:
* a21_wdt_get_bootstatus() should return reset code
* GPIOs are supplied via DT instead of being hardcoded. Code derived from
  (drivers/hwmon/gpio-fan.c)
* Added Devicetree binding document
* Driver now depends on GPIOLIB

Signed-off-by: Johannes Thumshirn 
---
 .../devicetree/bindings/gpio/men-a021-wdt.txt  |   25 ++
 MAINTAINERS|6 +
 drivers/watchdog/Kconfig   |   12 +
 drivers/watchdog/Makefile  |1 +
 drivers/watchdog/mena21_wdt.c  |  277 
 5 files changed, 321 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
new file mode 100644
index 000..370dee3
--- /dev/null
+++ b/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
@@ -0,0 +1,25 @@
+Bindings for MEN A21 Watchdog device connected to GPIO lines
+
+Required properties:
+- compatible: "men,a021-wdt"
+- gpios: Specifies the pins that control the Watchdog, order:
+  1: Watchdog enable
+  2: Watchdog fast-mode
+  3: Watchdog trigger
+  4: Watchdog reset cause bit 0
+  5: Watchdog reset cause bit 1
+  6: Watchdog reset cause bit 2
+
+Optional properties:
+- None
+
+Example:
+   watchdog {
+   compatible ="men,a021-wdt";
+   gpios = <&gpio3 9  1/* WD_EN */
+&gpio3 10 1/* WD_FAST */
+&gpio3 11 1/* WD_TRIG */
+&gpio3 6  1/* RST_CAUSE[0] */
+&gpio3 7  1/* RST_CAUSE[1] */
+&gpio3 8  1>;  /* RST_CAUSE[2] */
+   };
diff --git a/MAINTAINERS b/MAINTAINERS
index f35a259..bd86661 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5307,6 +5307,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/

+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..8b143ee 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,18 @@ config BOOKE_WDT_DEFAULT_TIMEOUT

  The value can be overridden by the wdt_period command-line parameter.

+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   depends on GPIOLIB
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   The driver can also be built as a module. If so, the module will be
+   called mena21_wdt.
+
+   If unsure select N here.
+
 # PPC64 Architecture

 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o

 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..29f9c0d
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,277 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#i

[PATCH] edac: mpc85xx_edac.c: Remove mpc85xx_pci_err_remove

2013-06-24 Thread Johannes Thumshirn
Remove mpc85xx_pci_err_remove(...) which is obsolete, this removes the compiler
warning which can be seen when building the driver either statically or as a
module.

Signed-off-by: Johannes Thumshirn 
---
 drivers/edac/mpc85xx_edac.c | 22 --
 1 file changed, 22 deletions(-)

diff --git a/drivers/edac/mpc85xx_edac.c b/drivers/edac/mpc85xx_edac.c
index 3eb32f6..fd46b0b 100644
--- a/drivers/edac/mpc85xx_edac.c
+++ b/drivers/edac/mpc85xx_edac.c
@@ -327,28 +327,6 @@ err:
 }
 EXPORT_SYMBOL(mpc85xx_pci_err_probe);
 
-static int mpc85xx_pci_err_remove(struct platform_device *op)
-{
-   struct edac_pci_ctl_info *pci = dev_get_drvdata(&op->dev);
-   struct mpc85xx_pci_pdata *pdata = pci->pvt_info;
-
-   edac_dbg(0, "\n");
-
-   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_CAP_DR,
-orig_pci_err_cap_dr);
-
-   out_be32(pdata->pci_vbase + MPC85XX_PCI_ERR_EN, orig_pci_err_en);
-
-   edac_pci_del_device(pci->dev);
-
-   if (edac_op_state == EDAC_OPSTATE_INT)
-   irq_dispose_mapping(pdata->irq);
-
-   edac_pci_free_ctl_info(pci);
-
-   return 0;
-}
-
 #endif /* CONFIG_PCI */
 
 / L2 Err device ***/
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH RESEND v10 2/2] watchdog: Sysfs interface for MEN A21 watchdog

2013-07-01 Thread Johannes Thumshirn
Hi Wim,

I just wanted to know if you already had time to review the driver?  With
Guenter's help I got rid of some of the quirks still in and he issued his
Reviewed-by. I also imporoved devicetree support and wrote the dts binding
document as Arnd Bergmann suggested. I know you're probably quite busy and 3.10
just came out, but it would be cool to know the current status.

Thanks,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] documentation/devicetree: Move DT bindigns from gpio to watchdog

2013-08-21 Thread Johannes Thumshirn
I accidently put the devicetree bindings for the MEN A21 watchdog driver in
Documentation/devicetree/bindings/gpio instead of
Documentation/devicetree/bindings/watchdog, this patch addresses this error.

Signed-off-by: Johannes Thumshirn 
Cc: Rob Herring 
Cc: Pawel Moll 
Cc: Mark Rutland 
Cc: Stephen Warren 
Cc: Ian Campbell 
Cc: Rob Landley 
Cc: Wim Van Sebroeck 
Cc: Guenter Roeck 
---
 .../bindings/{gpio => watchdog}/men-a021-wdt.txt   |0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{gpio => watchdog}/men-a021-wdt.txt 
(100%)

diff --git a/Documentation/devicetree/bindings/gpio/men-a021-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/men-a021-wdt.txt
similarity index 100%
rename from Documentation/devicetree/bindings/gpio/men-a021-wdt.txt
rename to Documentation/devicetree/bindings/watchdog/men-a021-wdt.txt
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] documentation/devicetree: Move DT bindigns from gpio to watchdog

2013-08-22 Thread Johannes Thumshirn
On Wed, Aug 21, 2013 at 11:34:00AM -0600, Stephen Warren wrote:
> On 08/21/2013 06:42 AM, Johannes Thumshirn wrote:
> > I accidently put the devicetree bindings for the MEN A21 watchdog driver in
> > Documentation/devicetree/bindings/gpio instead of
> > Documentation/devicetree/bindings/watchdog, this patch addresses this error.
>
> The rename sounds fine, so that part,
> Acked-by: Stephen Warren 
>
> However, the binding itself doesn't look right; it appears to have a
> single "gpios" property rather than using separate named xxx-gpios
> properties for different things...

Ok, so I'll need something like the following?

watchdog {
compatible ="men,a021-wdt";
enable-gpios = <&gpio3 9 1>; /* WD_EN */
fast-gpios = <&gpio3 10 1>;  /* WD_FAST */
trig-gpios = <&gpio3 11 1>;  /* WD_TRIG */
rst0-gpio = <&gpio3 6 1>;/* RST_CAUSE[0] */
rst1-gpio = <&gpio3 7 1>;/* RST_CAUSE[1] */
rst2-gpio = <&gpio3 8 1>;/* RST_CAUSE[2] */
};

Or is there something like of_get_named_gpios(...) so I can put all 3 rst-gpios
into one property? A quick grep only revealed of_get_named_gpio(...).

Thanks,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] kconfig: Make diffconfig work with Python 3

2013-08-09 Thread Johannes Thumshirn
Adjust diffconfig to run cleanly on Python 3 (Tested with 3.3.2) and
Python 2 (2.7.5)

Signed-off-by: Johannes Thumshirn 
---
 scripts/diffconfig |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/scripts/diffconfig b/scripts/diffconfig
index b91f3e3..dd0e75b 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -10,7 +10,7 @@
 import sys, os

 def usage():
-print """Usage: diffconfig [-h] [-m] [ ]
+print ("""Usage: diffconfig [-h] [-m] [ ]

 Diffconfig is a simple utility for comparing two .config files.
 Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage:
  EXT2_FS  y -> n
  LOG_BUF_SHIFT  14 -> 16
  PRINTK_TIME  n -> y
-"""
+""")
 sys.exit(0)

 # returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
 if merge_style:
 if new_value:
 if new_value=="n":
-print "# CONFIG_%s is not set" % config
+print("# CONFIG_%s is not set" % config)
 else:
-print "CONFIG_%s=%s" % (config, new_value)
+print("CONFIG_%s=%s" % (config, new_value))
 else:
 if op=="-":
-print "-%s %s" % (config, value)
+print("-%s %s" % (config, value))
 elif op=="+":
-print "+%s %s" % (config, new_value)
+print("+%s %s" % (config, new_value))
 else:
-print " %s %s -> %s" % (config, value, new_value)
+print(" %s %s -> %s" % (config, value, new_value))

 def main():
 global merge_style

 # parse command line args
 if ("-h" in sys.argv or "--help" in sys.argv):
-   usage()
+usage()

 merge_style = 0
 if "-m" in sys.argv:
@@ -79,13 +79,13 @@ def main():

 argc = len(sys.argv)
 if not (argc==1 or argc == 3):
-print "Error: incorrect number of arguments or unrecognized option"
+print("Error: incorrect number of arguments or unrecognized option")
 usage()

 if argc == 1:
 # if no filenames given, assume .config and .config.old
 build_dir=""
-if os.environ.has_key("KBUILD_OUTPUT"):
+if 'KBUILD_OUTPUT' in os.environ:
 build_dir = os.environ["KBUILD_OUTPUT"]+"/"

 configa_filename = build_dir + ".config.old"
@@ -94,8 +94,8 @@ def main():
 configa_filename = sys.argv[1]
 configb_filename = sys.argv[2]

-a = readconfig(file(configa_filename))
-b = readconfig(file(configb_filename))
+a = readconfig(open(configa_filename))
+b = readconfig(open(configb_filename))

 # print items in a but not b (accumulate, sort and print)
 old = []
@@ -121,7 +121,7 @@ def main():

 # now print items in b but not in a
 # (items from b that were in a were removed above)
-new = b.keys()
+new = list(b.keys())
 new.sort()
 for config in new:
 print_config("+", config, None, b[config])
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[RESEND PATCH] kconfig: Make diffconfig work with Python 3

2013-08-09 Thread Johannes Thumshirn
Adjust diffconfig to run cleanly on Python 3 (Tested with 3.3.2) and
Python 2 (2.7.5)

Signed-off-by: Johannes Thumshirn 
---
 scripts/diffconfig |   26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/scripts/diffconfig b/scripts/diffconfig
index b91f3e3..dd0e75b 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -10,7 +10,7 @@
 import sys, os

 def usage():
-print """Usage: diffconfig [-h] [-m] [ ]
+print ("""Usage: diffconfig [-h] [-m] [ ]

 Diffconfig is a simple utility for comparing two .config files.
 Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage:
  EXT2_FS  y -> n
  LOG_BUF_SHIFT  14 -> 16
  PRINTK_TIME  n -> y
-"""
+""")
 sys.exit(0)

 # returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
 if merge_style:
 if new_value:
 if new_value=="n":
-print "# CONFIG_%s is not set" % config
+print("# CONFIG_%s is not set" % config)
 else:
-print "CONFIG_%s=%s" % (config, new_value)
+print("CONFIG_%s=%s" % (config, new_value))
 else:
 if op=="-":
-print "-%s %s" % (config, value)
+print("-%s %s" % (config, value))
 elif op=="+":
-print "+%s %s" % (config, new_value)
+print("+%s %s" % (config, new_value))
 else:
-print " %s %s -> %s" % (config, value, new_value)
+print(" %s %s -> %s" % (config, value, new_value))

 def main():
 global merge_style

 # parse command line args
 if ("-h" in sys.argv or "--help" in sys.argv):
-   usage()
+usage()

 merge_style = 0
 if "-m" in sys.argv:
@@ -79,13 +79,13 @@ def main():

 argc = len(sys.argv)
 if not (argc==1 or argc == 3):
-print "Error: incorrect number of arguments or unrecognized option"
+print("Error: incorrect number of arguments or unrecognized option")
 usage()

 if argc == 1:
 # if no filenames given, assume .config and .config.old
 build_dir=""
-if os.environ.has_key("KBUILD_OUTPUT"):
+if 'KBUILD_OUTPUT' in os.environ:
 build_dir = os.environ["KBUILD_OUTPUT"]+"/"

 configa_filename = build_dir + ".config.old"
@@ -94,8 +94,8 @@ def main():
 configa_filename = sys.argv[1]
 configb_filename = sys.argv[2]

-a = readconfig(file(configa_filename))
-b = readconfig(file(configb_filename))
+a = readconfig(open(configa_filename))
+b = readconfig(open(configb_filename))

 # print items in a but not b (accumulate, sort and print)
 old = []
@@ -121,7 +121,7 @@ def main():

 # now print items in b but not in a
 # (items from b that were in a were removed above)
-new = b.keys()
+new = list(b.keys())
 new.sort()
 for config in new:
 print_config("+", config, None, b[config])
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-13 Thread johannes . thumshirn
From: Johannes Thumshirn 

This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 +
 drivers/watchdog/Kconfig  |8 +
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  351 +
 4 files changed, 366 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..3e5b3f1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5291,6 +5291,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/
 
+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
 
  The value can be overridden by the wdt_period command-line parameter.
 
+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture
 
 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
 
 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..d534f81
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,351 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+   bool open;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   unsigned int reset = 0;
+   int i;
+
+   for (i = 0; i < 3; i++)
+   reset |= !!gpio_get_value(GPIO_RST_CAUSE_BASE + i);
+
+   if (reset >= 8)
+   return -EIO;
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_ENAB));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_FAST));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct device *dev)
+{
+   int ret;
+
+   ret = device_create_file(dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(dev, &dev_attr_active);
+   if (ret)
+

[PATCH v2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-14 Thread johannes . thumshirn
From: Johannes Thumshirn 

This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 +
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  305 +
 4 files changed, 320 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..3e5b3f1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5291,6 +5291,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/
 
+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
 
  The value can be overridden by the wdt_period command-line parameter.
 
+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture
 
 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
 
 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..9c5bf32
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,305 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   unsigned int reset = 0;
+   int i;
+
+   for (i = 0; i < 3; i++)
+   reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+? (1 << i) : 0;
+
+   if (reset >= 8)
+   return -EIO;
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_ENAB));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_FAST));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_sho

[PATCH v3] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-15 Thread johannes . thumshirn
From: Johannes Thumshirn 

This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 +
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  309 +
 4 files changed, 324 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 3d7782b..3e5b3f1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5291,6 +5291,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/
 
+MEN A21 WATCHDOG DRIVER
+M:     Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
 
  The value can be overridden by the wdt_period command-line parameter.
 
+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture
 
 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
 
 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..389bd59
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,309 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   unsigned int reset = 0;
+   int i;
+
+   for (i = 0; i < 3; i++)
+   reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+? (1 << i) : 0;
+
+   if (reset >= 8)
+   return -EIO;
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_ENAB));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+

[PATCH v4 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-27 Thread johannes . thumshirn
From: Johannes Thumshirn 

This patch adds the driver for the watchdog devices found on MEN Mikro
Elektronik A21 VMEbus CPU Carrier Boards. It has DT-support and uses the
watchdog framework.

Revision 2:
* Removed unneeded open flag in struct a21_wdt_drv
* Corrected 3bit reason code from gpio
* Additional sysfs files are now part of watchdog sysfs
* Changed OFF/ON delay in ping from 400ms to 10ns
* Reworked timeout setting
* Removed a21_wdt_ioctl(...)

Revision 3:
* Changed pr_{err,info} to dev_{err,info}
* Removed out of memory error print
* Transition from "fast" to "slow" mode not allowed by chip

Revision 4:
* Remove reboot_notifier and place disable code into platform_device's shutdown 
function
* Removed sysfs interface

Signed-off-by: Johannes Thumshirn 
---
 MAINTAINERS   |6 ++
 drivers/watchdog/Kconfig  |8 ++
 drivers/watchdog/Makefile |1 +
 drivers/watchdog/mena21_wdt.c |  204 +
 4 files changed, 219 insertions(+)
 create mode 100644 drivers/watchdog/mena21_wdt.c

diff --git a/MAINTAINERS b/MAINTAINERS
index fd3a495..1ca147a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5306,6 +5306,12 @@ F:   drivers/mtd/
 F: include/linux/mtd/
 F: include/uapi/mtd/
 
+MEN A21 WATCHDOG DRIVER
+M: Johannes Thumshirn 
+L: linux-watch...@vger.kernel.org
+S: Supported
+F: drivers/watchdog/mena21_wdt.c
+
 METAG ARCHITECTURE
 M: James Hogan 
 S: Supported
diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index e89fc31..192b84d 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -1172,6 +1172,14 @@ config BOOKE_WDT_DEFAULT_TIMEOUT
 
  The value can be overridden by the wdt_period command-line parameter.
 
+config MEN_A21_WDT
+   tristate "MEN A21 VME CPU Carrier Board Watchdog Timer"
+   select WATCHDOG_CORE
+   help
+Watchdog driver for MEN A21 VMEbus CPU Carrier Boards.
+
+   If unsure select N here.
+
 # PPC64 Architecture
 
 config WATCHDOG_RTAS
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index a300b94..bffdcb1 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -143,6 +143,7 @@ obj-$(CONFIG_8xxx_WDT) += mpc8xxx_wdt.o
 obj-$(CONFIG_MV64X60_WDT) += mv64x60_wdt.o
 obj-$(CONFIG_PIKA_WDT) += pika_wdt.o
 obj-$(CONFIG_BOOKE_WDT) += booke_wdt.o
+obj-$(CONFIG_MEN_A21_WDT) += mena21_wdt.o
 
 # PPC64 Architecture
 obj-$(CONFIG_WATCHDOG_RTAS) += wdrtas.o
diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
new file mode 100644
index 000..4fe65ec
--- /dev/null
+++ b/drivers/watchdog/mena21_wdt.c
@@ -0,0 +1,204 @@
+/*
+ * Watchdog driver for the A21 VME CPU Boards
+ *
+ * Copyright (C) 2013 MEN Mikro Elektronik Nuernberg GmbH
+ *
+ * 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
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define GPIO_WD_ENAB   169
+#define GPIO_WD_FAST   170
+#define GPIO_WD_TRIG   171
+
+#define GPIO_RST_CAUSE_BASE 166
+
+struct a21_wdt_drv {
+   struct watchdog_device wdt;
+   struct mutex lock;
+};
+
+static bool nowayout = WATCHDOG_NOWAYOUT;
+module_param(nowayout, bool, 0);
+MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
+   __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+
+static int a21_wdt_start(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 1);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_stop(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   /* We don't stop if WDOG_NO_WAY_OUT is set */
+   if (test_bit(WDOG_NO_WAY_OUT, &wdt->status))
+   return -EINVAL;
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_ENAB, 0);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_ping(struct watchdog_device *wdt)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   mutex_lock(&drv->lock);
+
+   gpio_set_value(GPIO_WD_TRIG, 0);
+   ndelay(10);
+   gpio_set_value(GPIO_WD_TRIG, 1);
+
+   mutex_unlock(&drv->lock);
+
+   return 0;
+}
+
+static int a21_wdt_set_timeout(struct watchdog_device *wdt,
+  unsigned int timeout)
+{
+   struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
+
+   if (timeout != 1 && timeout != 30) {
+   dev_err(wdt->dev, "Only 1 and 30 allowed as timeout\n");
+   return -EINVAL;
+   }
+
+ 

[PATCH v4 2/2] watchdog: Add sysfs interface for MEN A21 watchdog

2013-05-27 Thread johannes . thumshirn
From: Johannes Thumshirn 

This patch adds a sysfs interface for the watchdog device found on MEN A21
Boards.

The newly generated files are:
* rebootcause:
Can be one of:
Power on Reset,
CPU Reset Request,
Push Button,
FPGA Reset Request,
Watchdog,
Local Power Bad,
Invalid or
BDI
and shows the reason of the boards last reboot.

* active:
Shows if the watchdog CPLD is actually running

* allow_disable:
Shows if the watchdog is allowed to be disabled (NOWAYOUT disabled)

* fastmode:
Shows if the CPLD is running in fast mode (1s timeout), once it is in
fastmode it can't be switched back to slow mode (30s timeout) until the
next reboot.

Signed-off-by: Johannes Thumshirn 
---
 drivers/watchdog/mena21_wdt.c |   88 +
 1 file changed, 88 insertions(+)

diff --git a/drivers/watchdog/mena21_wdt.c b/drivers/watchdog/mena21_wdt.c
index 4fe65ec..c97c5f4 100644
--- a/drivers/watchdog/mena21_wdt.c
+++ b/drivers/watchdog/mena21_wdt.c
@@ -19,6 +19,17 @@
 #include 
 #include 
 
+static char *reset_causes[] = {
+   "Power On Reset",
+   "CPU Reset Request",
+   "Push Button",
+   "FPGA Reset Request",
+   "Watchdog",
+   "Local Power Bad",
+   "Invalid",
+   "BDI",
+};
+
 #define GPIO_WD_ENAB   169
 #define GPIO_WD_FAST   170
 #define GPIO_WD_TRIG   171
@@ -35,6 +46,74 @@ module_param(nowayout, bool, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+static ssize_t rebootcause_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   unsigned int reset = 0;
+   int i;
+
+   for (i = 0; i < 3; i++)
+   reset |= gpio_get_value(GPIO_RST_CAUSE_BASE + i)
+? (1 << i) : 0;
+
+   if (reset >= 8)
+   return -EIO;
+
+   return sprintf(buf, "%s\n", reset_causes[reset]);
+}
+static DEVICE_ATTR(rebootcause, S_IRUGO, rebootcause_show, NULL);
+
+static ssize_t active_show(struct device *dev, struct device_attribute *attr,
+  char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_ENAB));
+}
+static DEVICE_ATTR(active, S_IRUGO, active_show, NULL);
+
+static ssize_t allow_disable_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+   return sprintf(buf, "%d\n", !nowayout);
+}
+static DEVICE_ATTR(allow_disable, S_IRUGO, allow_disable_show, NULL);
+
+static ssize_t fastmode_show(struct device *dev, struct device_attribute *attr,
+char *buf)
+{
+   return sprintf(buf, "%d\n", !!gpio_get_value(GPIO_WD_FAST));
+}
+static DEVICE_ATTR(fastmode, S_IRUGO, fastmode_show, NULL);
+
+static int a21_wdt_create_files(struct watchdog_device *wdev)
+{
+   int ret;
+
+   ret = device_create_file(wdev->dev, &dev_attr_rebootcause);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_active);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_allow_disable);
+   if (ret)
+   return ret;
+   ret = device_create_file(wdev->dev, &dev_attr_fastmode);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static void a21_wdt_remove_files(struct watchdog_device *wdev)
+{
+   device_remove_file(wdev->dev, &dev_attr_rebootcause);
+   device_remove_file(wdev->dev, &dev_attr_active);
+   device_remove_file(wdev->dev, &dev_attr_allow_disable);
+   device_remove_file(wdev->dev, &dev_attr_fastmode);
+}
+
 static int a21_wdt_start(struct watchdog_device *wdt)
 {
struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
@@ -151,10 +230,18 @@ static int a21_wdt_probe(struct platform_device *pdev)
goto err_register_wd;
}
 
+   ret = a21_wdt_create_files(&a21_wdt);
+   if (ret) {
+   dev_err(&pdev->dev, "Cannot create sysfs entries\n");
+   goto err_create_sysfs;
+   }
+
dev_set_drvdata(&pdev->dev, drv);
 
return 0;
 
+err_create_sysfs:
+   watchdog_unregister_device(&drv->wdt);
 err_register_wd:
mutex_destroy(&drv->lock);
 
@@ -168,6 +255,7 @@ static int a21_wdt_remove(struct platform_device *pdev)
dev_warn(&pdev->dev,
"Unregistering A21 watchdog driver, board may reboot\n");
 
+   a21_wdt_remove_files(&drv->wdt);
 
watchdog_unregister_device(&drv->wdt);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-28 Thread Johannes Thumshirn
On Mon, May 27, 2013 at 08:25:54PM +0200, Wim Van Sebroeck wrote:
[...]
> > +   watchdog_set_drvdata(&a21_wdt, drv);
>
> I am missing the initialisation of the watchdog's timeout value here...

This watchdog only knows two timeout values, 1s and 30s with the constraint
that you can't go back to 30s once your in a 1s timeout without a reset of the
CPLD. I could initially set it to 30s but that would be redundant.

> For the rest this looks OK.
>
> Kind regards,
> wim.
>

This sounds pretty good.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 1/2] watchdog: New watchdog driver for MEN A21 watchdogs

2013-05-29 Thread Johannes Thumshirn
On Tue, May 28, 2013 at 09:22:18AM -0700, Guenter Roeck wrote:
> On Tue, May 28, 2013 at 10:10:53AM +0200, Johannes Thumshirn wrote:
> > On Mon, May 27, 2013 at 08:25:54PM +0200, Wim Van Sebroeck wrote:
> > [...]
> > > > +   watchdog_set_drvdata(&a21_wdt, drv);
> > >
> > > I am missing the initialisation of the watchdog's timeout value here...
> >
> > This watchdog only knows two timeout values, 1s and 30s with the constraint
> > that you can't go back to 30s once your in a 1s timeout without a reset of 
> > the
> > CPLD. I could initially set it to 30s but that would be redundant.
> >
> I wonder - why bother with supporting one-second timeouts ?
>
> Is this realistic, ie can you guarantee that the watchdog will be pinged fast
> enough to keep the system alive under all load conditions ? As far as I know
> you can not even configure the watchdog application for less than 1 second
> ping intervals.
>
> Thanks,
> Guenter

Well in my tests it was possible, maybe not under extremely high load. But
considering the application these boards (the VME CPU board the watchdogs chip
is on) are usually used by our customers, I hope they can react within a single
second. Another reason why I want to support the 1s timeout is, the VxWorks BSP
does it too and we don't want a Linux driver have less features than it's
VxWorks counterpart, do we ;-). Just kidding. My opinion is, the hardware
supports it and so should the driver, especially for the (safety critical)
industrial control and automation applications our customers usually do. Just
my point of view though.

Regards,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v4 2/2] watchdog: Add sysfs interface for MEN A21 watchdog

2013-05-29 Thread Johannes Thumshirn
On Mon, May 27, 2013 at 09:41:54PM +0200, Wim Van Sebroeck wrote:
> Hi Johannes,
>
> > This patch adds a sysfs interface for the watchdog device found on MEN A21
> > Boards.
> >
> > The newly generated files are:
> > * rebootcause:
> > Can be one of:
> > Power on Reset,
> > CPU Reset Request,
> > Push Button,
> > FPGA Reset Request,
> > Watchdog,
> > Local Power Bad,
> > Invalid or
> > BDI
> > and shows the reason of the boards last reboot.
>
> Question: why don't you use the detection of the reboot cause in your driver
> initialization so that you can:
> 1) report the reboot cause at the start of the driver (like we do in most
> drivers that support these kind of features)
> 2) set the .bootstatus info in the watchdog_device struct data?
> (See the WDIOF flags in #include 
> #define   WDIOF_OVERHEAT  0x0001  /* Reset due to CPU overheat */
> #define   WDIOF_FANFAULT  0x0002  /* Fan failed */
> #define   WDIOF_EXTERN1   0x0004  /* External relay 1 */
> #define   WDIOF_EXTERN2   0x0008  /* External relay 2 */
> #define   WDIOF_POWERUNDER0x0010  /* Power bad/power fault */
> #define   WDIOF_CARDRESET 0x0020  /* Card previously reset the 
> CPU */
> #define   WDIOF_POWEROVER 0x0040  /* Power over voltage */
> #define   WDIOF_SETTIMEOUT0x0080  /* Set timeout (in seconds) */
> #define   WDIOF_MAGICCLOSE0x0100  /* Supports magic close char */
> #define   WDIOF_PRETIMEOUT0x0200  /* Pretimeout (in seconds), 
> get/set */
> #define   WDIOF_ALARMONLY 0x0400  /* Watchdog triggers a 
> management or
>  other external alarm not a reboot */
> #define   WDIOF_KEEPALIVEPING 0x8000  /* Keep alive ping reply */
> (Example driver: wdt_pci.c )).
>
> Kind regards,
> Wim.
>

Ok I'll do. Should I repost this as a change of this patch or the "add driver"
patch?

Regards,
Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] line6: pcm.c: Changed simple_strtoul to kstrtoint

2012-08-06 Thread Johannes Thumshirn
Changed call to simple_strtoul to kstrtoint in pcm_set_impulse_volume(...)

Signed-off-by: Johannes Thumshirn 
---
 drivers/staging/line6/pcm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/line6/pcm.c b/drivers/staging/line6/pcm.c
index 5e319e3..7fe44a6 100644
--- a/drivers/staging/line6/pcm.c
+++ b/drivers/staging/line6/pcm.c
@@ -48,7 +48,13 @@ static ssize_t pcm_set_impulse_volume(struct device *dev,
  const char *buf, size_t count)
 {
struct snd_line6_pcm *line6pcm = dev2pcm(dev);
-   int value = simple_strtoul(buf, NULL, 10);
+   int value;
+   int rv;
+
+   rv = kstrtoint(buf, 10, &value);
+   if (rv < 0)
+   return rv;
+
line6pcm->impulse_volume = value;
 
if (value > 0)
-- 
1.7.11.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


staging: Line6 - Steps needed to get driver out of staging area

2012-09-16 Thread Johannes Thumshirn

Hi LKML,

I wanted to ask for the steps that are needed to get the line6 driver 
out of the staging area (apart from minor getpatch.pl fixes).


Regards,
Johannes Thumshirn
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: staging: Line6 - Steps needed to get driver out of staging area

2012-09-18 Thread Johannes Thumshirn

On 09/17/2012 10:22 PM, Greg KH wrote:

On Sun, Sep 16, 2012 at 07:29:03PM +0200, Johannes Thumshirn wrote:

Hi LKML,

I wanted to ask for the steps that are needed to get the line6
driver out of the staging area (apart from minor getpatch.pl fixes).

First try asking on the proper mailing list :)

Second, it needs to be submitted to the subsystem that it should be in
(i.e. sound, right?)  It's up to those maintainers to say what's left to
do.

Are you willing to help out with this?  Right now it doesn't seem like
anyone is using the driver, or helping to clean it up.

thanks,

greg k-h

Ok, then I'll ask on the sound mailing list for a todo-list.

Yes I'm willing to do the maintenance of this driver if the original
author doesn't want to take it up again.

Thanks for your answer.

Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging: line6: variax.c: Eliminated remaining strict_stroul()s

2012-08-14 Thread Johannes Thumshirn
Eliminated remaining calls to strict_stroul() and replaced them with
strict_kstrtou8().

Signed-off-by: Johannes Thumshirn 
---
 drivers/staging/line6/variax.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/line6/variax.c b/drivers/staging/line6/variax.c
index bb99ee4..f97416b 100644
--- a/drivers/staging/line6/variax.c
+++ b/drivers/staging/line6/variax.c
@@ -353,10 +353,10 @@ static ssize_t variax_set_model(struct device *dev,
 {
struct usb_line6_variax *variax =
usb_get_intfdata(to_usb_interface(dev));
-   unsigned long value;
+   u8 value;
int ret;
 
-   ret = strict_strtoul(buf, 10, &value);
+   ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
 
@@ -387,10 +387,10 @@ static ssize_t variax_set_active(struct device *dev,
 {
struct usb_line6_variax *variax =
usb_get_intfdata(to_usb_interface(dev));
-   unsigned long value;
+   u8 value;
int ret;
 
-   ret = strict_strtoul(buf, 10, &value);
+   ret = kstrtou8(buf, 10, &value);
if (ret)
return ret;
 
-- 
1.7.11.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pwm: twl: Use to_twl() instead of container_of()

2013-02-16 Thread Johannes Thumshirn
In twl6030_pwm_disable() use to_twl() instead of container_of() like in the
rest of the driver.

Signed-off-by: Johannes Thumshirn 
---
 drivers/pwm/pwm-twl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index f783efc..a34c235 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -255,8 +255,7 @@ out:
 
 static void twl6030_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   struct twl_pwm_chip *twl = container_of(chip, struct twl_pwm_chip,
-   chip);
+   struct twl_pwm_chip *twl = to_twl(chip);
int ret;
u8 val;
 
-- 
1.8.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pwm: twl: Use to_twl() instead of container_of()

2013-02-16 Thread Johannes Thumshirn
On Sat, Feb 16, 2013 at 07:56:18PM +0100, Thierry Reding wrote:
> On Sat, Feb 16, 2013 at 07:20:51PM +0100, Johannes Thumshirn wrote:
> > In twl6030_pwm_disable() use to_twl() instead of container_of() like in the
> > rest of the driver.
> > 
> > Signed-off-by: Johannes Thumshirn 
> > ---
> >  drivers/pwm/pwm-twl.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> Hi Johannes,
> 
> I see that container_of() is also still used in twl4030_pwm_free() and
> twl6030_pwm_enable(). Would you mind fixing those up as well?
> 
> Thierry

Oh sorry haven't seen them, I'll take care of it.

Johannes
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pwm: twl: Use to_twl() instead of container_of()

2013-02-16 Thread Johannes Thumshirn
Always use to_twl() for converting into private data instead of container_of()

Signed-off-by: Johannes Thumshirn 
---
 drivers/pwm/pwm-twl.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index a34c235..9cd2c9a 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -200,8 +200,7 @@ out:
 
 static void twl4030_pwm_free(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   struct twl_pwm_chip *twl = container_of(chip, struct twl_pwm_chip,
-   chip);
+   struct twl_pwm_chip *twl = to_twl(chip);
int ret;
u8 val, mask;
 
@@ -231,8 +230,7 @@ out:
 
 static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   struct twl_pwm_chip *twl = container_of(chip, struct twl_pwm_chip,
-   chip);
+   struct twm_pwm_chip *twl = to_twl(chip);
int ret;
u8 val;
 
-- 
1.8.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] pwm: twl: Fix typo that broke build

2013-02-17 Thread Johannes Thumshirn
Fix a little type that unfortunately broke the build :-(
Signed-off-by: Johannes Thumshirn 
---
 drivers/pwm/pwm-twl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-twl.c b/drivers/pwm/pwm-twl.c
index 9cd2c9a..bf3fda2 100644
--- a/drivers/pwm/pwm-twl.c
+++ b/drivers/pwm/pwm-twl.c
@@ -230,7 +230,7 @@ out:
 
 static int twl6030_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)
 {
-   struct twm_pwm_chip *twl = to_twl(chip);
+   struct twl_pwm_chip *twl = to_twl(chip);
int ret;
u8 val;
 
-- 
1.8.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] pwm: twl: Fix typo that broke build

2013-02-17 Thread Johannes Thumshirn
On Sun, Feb 17, 2013 at 11:26:30AM +0100, Thierry Reding wrote:
> On Sun, Feb 17, 2013 at 11:08:13AM +0100, Johannes Thumshirn wrote:
> > Fix a little type that unfortunately broke the build :-(
> > Signed-off-by: Johannes Thumshirn 
> > ---
> >  drivers/pwm/pwm-twl.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Uh... I hadn't noticed and deemed the patch trivial enough so I didn't
> even build test. That'll teach me. =\
> 
> Thierry

Me too.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] radix-tree: fix comment about "exceptional" bits

2016-07-20 Thread Johannes Thumshirn
On Wed, Jul 20, 2016 at 12:55:31AM -0600, Ross Zwisler wrote:
> The bottom two bits of radix tree entries are reserved for special use by
> the radix tree code itself.  A comment detailing their usage was added by:
> 
> commit 3bcadd6fa6c4 ("radix-tree: free up the bottom bit of exceptional
> entries for reuse")
> 
> This comment states that if the bottom two bits are '11', this means that
> this is a locked exceptional entry.
> 
> It turns out that this bit combination was never actually used.  Radix tree
> locking for DAX was indeed implemented, but it actually used the third LSB:
> 
>   /* We use lowest available exceptional entry bit for locking */
>   #define RADIX_DAX_ENTRY_LOCK (1 << RADIX_TREE_EXCEPTIONAL_SHIFT)
> 
> This locking code was also made specific to the DAX code instead of being
> generally implemented in radix-tree.h.
> 
> So, fix the comment.
> 
> Signed-off-by: Ross Zwisler 

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] x86/mm: only allow memmap=XX!YY over existing RAM

2016-06-21 Thread Johannes Thumshirn
On Mon, Jun 20, 2016 at 10:33:59AM +0300, Yigal Korman wrote:
> Before this patch, passing a range that is beyond the physical memory
> range will succeed, the user will see a /dev/pmem0 and will be able to
> access it. Reads will always return 0 and writes will be silently
> ignored.
> 
> I've gotten more than one bug report about mkfs.{xfs,ext4} or nvml
> failing that were eventually tracked down to be wrong values passed to
> memmap.
> 
> This patch prevents the above issue by instead of adding a new memory
> range, only update a RAM memory range with the PRAM type. This way,
> passing the wrong memmap will either not give you a pmem at all or give
> you a smaller one that actually has RAM behind it.
> 
> And if someone still needs to fake a pmem that doesn't have RAM behind
> it, they can simply do memmap=XX@YY,XX!YY.
> 
> Signed-off-by: Yigal Korman 

Acked-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] [SCSI] mvsas: mark symbols static where possible

2016-09-26 Thread Johannes Thumshirn
On Sun, Sep 25, 2016 at 01:48:50PM +0800, Baoyou Xie wrote:
> We get a few warnings when building kernel with W=1:
> drivers/scsi/mvsas/mv_sas.c:77:18: warning: no previous prototype for 
> 'mvs_find_dev_mvi' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:105:5: warning: no previous prototype for 
> 'mvs_find_dev_phyno' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1161:20: warning: no previous prototype for 
> 'mvs_alloc_dev' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1178:6: warning: no previous prototype for 
> 'mvs_free_dev' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1188:5: warning: no previous prototype for 
> 'mvs_dev_found_notify' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1244:6: warning: no previous prototype for 
> 'mvs_dev_gone_notify' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1614:6: warning: no previous prototype for 
> 'mvs_set_sense' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_sas.c:1653:6: warning: no previous prototype for 
> 'mvs_fill_ssp_resp_iu' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_64xx.c:139:6: warning: no previous prototype for 
> 'mvs_64xx_clear_srs_irq' [-Wmissing-prototypes]
> drivers/scsi/mvsas/mv_64xx.c:566:6: warning: no previous prototype for 
> 'mvs_64xx_make_prd' [-Wmissing-prototypes]
> 
> 
> In fact, these functions are only used in the file in which they are
> declared and don't need a declaration, but can be made static.
> so this patch marks these functions with 'static'.
> 
> Signed-off-by: Baoyou Xie 
> ---

Looks good,
Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH v2] sysfs print name of undiscoverable attribute group

2016-09-27 Thread Johannes Thumshirn
On Mon, Sep 19, 2016 at 10:14:54AM +0200, Johannes Thumshirn wrote:
> Print the name of an undiscoverable attribute group and not the
> pointer's address.
> 
> Signed-off-by: Johannes Thumshirn 
> ---
>  fs/sysfs/group.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
> index dc1358b..ac2de0e 100644
> --- a/fs/sysfs/group.c
> +++ b/fs/sysfs/group.c
> @@ -233,8 +233,8 @@ void sysfs_remove_group(struct kobject *kobj,
>   kn = kernfs_find_and_get(parent, grp->name);
>   if (!kn) {
>   WARN(!kn, KERN_WARNING
> -  "sysfs group %p not found for kobject '%s'\n",
> -  grp, kobject_name(kobj));
> +  "sysfs group '%s' not found for kobject '%s'\n",
> +  grp->name, kobject_name(kobj));
>   return;
>   }
>   } else {
> -- 
> 1.8.5.6
>

Ping?

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 0/2] MCB patches for v4.9

2016-09-27 Thread Johannes Thumshirn
On Wed, Sep 14, 2016 at 12:05:22PM +0200, Johannes Thumshirn wrote:
> Hi Greg,
> 
> Here are the additional MCB patches for v4.9.
> 
> They're around enabling of DMA for devices on an MCBus, are tested and
> apply cleanly against your char-misc-next tree.
> 
> Thanks,
>   Johannes
> 
> Michael Moese (2):
>   Enable PCI bus mastering by default
>   Add a dma_device to mcb_device
> 
>  drivers/mcb/mcb-core.c | 1 +
>  drivers/mcb/mcb-pci.c  | 1 +
>  include/linux/mcb.h| 1 +
>  3 files changed, 3 insertions(+)
> 
> -- 
> 1.8.5.6
> 

Gentle ping on this...

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 0/2] MCB patches for v4.9

2016-09-27 Thread Johannes Thumshirn
On Tue, Sep 27, 2016 at 12:32:34PM +0200, Greg KH wrote:
> On Tue, Sep 27, 2016 at 10:30:45AM +0200, Johannes Thumshirn wrote:
> > On Wed, Sep 14, 2016 at 12:05:22PM +0200, Johannes Thumshirn wrote:
> > > Hi Greg,
> > > 
> > > Here are the additional MCB patches for v4.9.
> > > 
> > > They're around enabling of DMA for devices on an MCBus, are tested and
> > > apply cleanly against your char-misc-next tree.
> > > 
> > > Thanks,
> > >   Johannes
> > > 
> > > Michael Moese (2):
> > >   Enable PCI bus mastering by default
> > >   Add a dma_device to mcb_device
> > > 
> > >  drivers/mcb/mcb-core.c | 1 +
> > >  drivers/mcb/mcb-pci.c  | 1 +
> > >  include/linux/mcb.h| 1 +
> > >  3 files changed, 3 insertions(+)
> > > 
> > > -- 
> > > 1.8.5.6
> > > 
> > 
> > Gentle ping on this...
> 
> Sorry about that, will get to it today...

Thanks :-)

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] lpfc: Fix possible NULL pointer dereference

2016-07-29 Thread Johannes Thumshirn
On Thu, Jul 28, 2016 at 09:21:47PM -0400, Martin K . Petersen wrote:
> >>>>> "James" == James Smart  writes:
> 
> James> This patch is good.
> 
> Johannes: You were going to tweak a few things and resubmit. Please do.

Oh yes, sorry totally forgot about this one.

My bad.

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 1/3] storvsc: use tagged SRB requests if supported by the device

2016-09-07 Thread Johannes Thumshirn
On Tue, Sep 06, 2016 at 02:25:41PM -0700, Long Li wrote:
> From: Long Li 
> 
> Properly set SRB flags when hosting device supports tagged queuing. This 
> patch improves the performance on Fiber Channel disks.

ENOSIGNEDOFF and please use checkpatch.pl on the patch. 

> 
> ---
>  drivers/scsi/storvsc_drv.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 8ccfc9e..a8f3e4c 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -136,6 +136,8 @@ struct hv_fc_wwn_packet {
>  #define SRB_FLAGS_PORT_DRIVER_RESERVED   0x0F00
>  #define SRB_FLAGS_CLASS_DRIVER_RESERVED  0xF000
>  
> +#define SP_UNTAGGED  ((unsigned char) ~0)
> +#define SRB_SIMPLE_TAG_REQUEST   0x20
>  
>  /*
>   * Platform neutral description of a scsi request -
> @@ -1451,6 +1453,12 @@ static int storvsc_queuecommand(struct Scsi_Host 
> *host, struct scsi_cmnd *scmnd)
>   vm_srb->win8_extension.srb_flags |=
>   SRB_FLAGS_DISABLE_SYNCH_TRANSFER;
>  
> + if(scmnd->device->tagged_supported) {
> + vm_srb->win8_extension.srb_flags |= 
> (SRB_FLAGS_QUEUE_ACTION_ENABLE | SRB_FLAGS_NO_QUEUE_FREEZE);
> + vm_srb->win8_extension.queue_tag = SP_UNTAGGED;
> + vm_srb->win8_extension.queue_action = SRB_SIMPLE_TAG_REQUEST;
> + }
> +
>   /* Build the SRB */
>   switch (scmnd->sc_data_direction) {
>   case DMA_TO_DEVICE:
> -- 
> 1.8.5.6
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] scsi: squash lines for simple wrapper functions

2016-09-08 Thread Johannes Thumshirn
_VERSION);
> - return ret;
> + return _ctl_ioctl_main(file, cmd, (void __user *)arg, 1, MPI2_VERSION);
>  }
>  #endif
>

Looks OK.

> diff --git a/drivers/scsi/osd/osd_initiator.c 
> b/drivers/scsi/osd/osd_initiator.c
> index 2f2a991..86d7092 100644
> --- a/drivers/scsi/osd/osd_initiator.c
> +++ b/drivers/scsi/osd/osd_initiator.c
> @@ -396,11 +396,8 @@ EXPORT_SYMBOL(osd_dev_fini);
>  
>  static struct osd_request *_osd_request_alloc(gfp_t gfp)
>  {
> - struct osd_request *or;
> -
>   /* TODO: Use mempool with one saved request */
> - or = kzalloc(sizeof(*or), gfp);
> - return or;
> + return kzalloc(sizeof(struct osd_request), gfp);
>  }
>  
>  static void _osd_request_free(struct osd_request *or)

Looks OK, though I don't see the reason for having
_osd_request_alloc() at all.

> diff --git a/drivers/scsi/pm8001/pm8001_ctl.c 
> b/drivers/scsi/pm8001/pm8001_ctl.c
> index be8269c..5bf3cb0 100644
> --- a/drivers/scsi/pm8001/pm8001_ctl.c
> +++ b/drivers/scsi/pm8001/pm8001_ctl.c
> @@ -456,10 +456,7 @@ static DEVICE_ATTR(iop_log, S_IRUGO, 
> pm8001_ctl_iop_log_show, NULL);
>  static ssize_t pm8001_ctl_fatal_log_show(struct device *cdev,
>   struct device_attribute *attr, char *buf)
>  {
> - ssize_t count;
> -
> - count = pm80xx_get_fatal_dump(cdev, attr, buf);
> - return count;
> + return pm80xx_get_fatal_dump(cdev, attr, buf);
>  }
>  
>  static DEVICE_ATTR(fatal_log, S_IRUGO, pm8001_ctl_fatal_log_show, NULL);

One could argue it's not needed but it actually makes the arch a bit
cleaner with the wrapper, so OK.

> @@ -474,10 +471,7 @@ static DEVICE_ATTR(fatal_log, S_IRUGO, 
> pm8001_ctl_fatal_log_show, NULL);
>  static ssize_t pm8001_ctl_gsm_log_show(struct device *cdev,
>   struct device_attribute *attr, char *buf)
>  {
> - ssize_t count;
> -
> - count = pm8001_get_gsm_dump(cdev, SYSFS_OFFSET, buf);
> - return count;
> + return pm8001_get_gsm_dump(cdev, SYSFS_OFFSET, buf);
>  }
>  
>  static DEVICE_ATTR(gsm_log, S_IRUGO, pm8001_ctl_gsm_log_show, NULL);

Probably just like the above, haven't checked.

> diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
> index ae7d9bd..181dad0 100644
> --- a/drivers/scsi/sg.c
> +++ b/drivers/scsi/sg.c
> @@ -1129,13 +1129,9 @@ static long sg_compat_ioctl(struct file *filp, 
> unsigned int cmd_in, unsigned lon
>   return -ENXIO;
>  
>   sdev = sdp->device;
> - if (sdev->host->hostt->compat_ioctl) { 
> - int ret;
> -
> - ret = sdev->host->hostt->compat_ioctl(sdev, cmd_in, (void 
> __user *)arg);
> -
> - return ret;
> - }
> + if (sdev->host->hostt->compat_ioctl)
> + return sdev->host->hostt->compat_ioctl(sdev, cmd_in,
> +(void __user *)arg);
>   
>   return -ENOIOCTLCMD;
>  }
> -- 
> 1.9.1
> 

Looks OK.

For the re-consider cases, please have a look at them and re-send as
individual patches (can be in a series).

Thanks,
Johannes
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH 0/2] MCB patches for v4.9

2016-09-14 Thread Johannes Thumshirn
Hi Greg,

Here are the additional MCB patches for v4.9.

They're around enabling of DMA for devices on an MCBus, are tested and
apply cleanly against your char-misc-next tree.

Thanks,
Johannes

Michael Moese (2):
  Enable PCI bus mastering by default
  Add a dma_device to mcb_device

 drivers/mcb/mcb-core.c | 1 +
 drivers/mcb/mcb-pci.c  | 1 +
 include/linux/mcb.h| 1 +
 3 files changed, 3 insertions(+)

-- 
1.8.5.6



[PATCH 2/2] Add a dma_device to mcb_device

2016-09-14 Thread Johannes Thumshirn
From: Michael Moese 

When performing DMA operations on a MCB device, the device needed
for using the DMA API is "mcb_device->bus_carrier".
This is rather lengthy, so a shortcut is introduced to struct mcb_device
in order to ensure the MCB device driver uses the correct device for DMA
operations.

Signed-off-by: Michael Moese 
Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-core.c | 1 +
 include/linux/mcb.h| 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 5306966..921a5d2 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -233,6 +233,7 @@ int mcb_device_register(struct mcb_bus *bus, struct 
mcb_device *dev)
dev->dev.bus = &mcb_bus_type;
dev->dev.parent = bus->dev.parent;
dev->dev.release = mcb_release_dev;
+   dev->dma_dev = bus->carrier;
 
device_id = dev->id;
dev_set_name(&dev->dev, "mcb%d-16z%03d-%d:%d:%d",
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ee5200d..4097ac9 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -76,6 +76,7 @@ struct mcb_device {
int rev;
struct resource irq;
struct resource mem;
+   struct device *dma_dev;
 };
 
 static inline struct mcb_device *to_mcb_device(struct device *dev)
-- 
1.8.5.6



[PATCH 1/2] Enable PCI bus mastering by default

2016-09-14 Thread Johannes Thumshirn
From: Michael Moese 

In order to successfully perform DMA operations on PCI devices,
it is necessary to enble PCI bus mastering, so enable it by default.

Signed-off-by: Michael Moese 
Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-pci.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mcb/mcb-pci.c b/drivers/mcb/mcb-pci.c
index b15a034..af4d2f2 100644
--- a/drivers/mcb/mcb-pci.c
+++ b/drivers/mcb/mcb-pci.c
@@ -46,6 +46,7 @@ static int mcb_pci_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
dev_err(&pdev->dev, "Failed to enable PCI device\n");
return -ENODEV;
}
+   pci_set_master(pdev);
 
priv->mapbase = pci_resource_start(pdev, 0);
if (!priv->mapbase) {
-- 
1.8.5.6



[PATCH] sysfs print name of undiscoverable attribute group as well

2016-09-15 Thread Johannes Thumshirn
Print the name of an undiscoverable attribute group as well, not just
the pointer's address.

Signed-off-by: Johannes Thumshirn 
---
 fs/sysfs/group.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index dc1358b..b1a3557 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -233,8 +233,8 @@ void sysfs_remove_group(struct kobject *kobj,
kn = kernfs_find_and_get(parent, grp->name);
if (!kn) {
WARN(!kn, KERN_WARNING
-"sysfs group %p not found for kobject '%s'\n",
-grp, kobject_name(kobj));
+"sysfs group '%s' %p not found for kobject '%s'\n",
+grp->name, grp, kobject_name(kobj));
return;
}
} else {
-- 
1.8.5.6



Re: [PATCH v2 1/2] Enable PCI bus mastering by default

2016-08-31 Thread Johannes Thumshirn
On Mon, Aug 29, 2016 at 02:45:13PM +0200, Michael Moese wrote:
> In order to successfully perform DMA operations on PCI devices,
> it is necessary to enble PCI bus mastering, so enable it by default.
> 
> Signed-off-by: Michael Moese 
> ---

Applied thanks.

I'm not pushing the commit's out, as I'll wait if Greg to applies the
mcb-for-4.8 patches before or not. This would remove the burden of a
rebase and force-push.

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH v2 2/2] Add a dma_device to mcb_device

2016-08-31 Thread Johannes Thumshirn
On Mon, Aug 29, 2016 at 02:45:14PM +0200, Michael Moese wrote:
> When performing DMA operations on a MCB device, the device needed
> for using the DMA API is "mcb_device->bus_carrier".
> This is rather lengthy, so a shortcut is introduced to struct mcb_device
> in order to ensure the MCB device driver uses the correct device for DMA
> operations.
> 
> Signed-off-by: Michael Moese 
> ---

Applied, thanks.

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] bfa: do not dereference port before it is null checked

2016-08-31 Thread Johannes Thumshirn
On Tue, Aug 30, 2016 at 05:36:16PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> port is deferenced before it is null sanity checked, hence
> we potentially have a null pointer dereference bug. Instead,
> initialise trl_enabled from port->fcs->bfa after we are sure
> port is not null.
> 
> Signed-off-by: Colin Ian King 
> ---

Reviewed-by: Johannes Thumshirn 

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 1/8] block: add WRITE_BG

2016-09-01 Thread Johannes Thumshirn
On Wed, Aug 31, 2016 at 11:05:44AM -0600, Jens Axboe wrote:
> This adds a new request flag, REQ_BG, that callers can use to tell
> the block layer that this is background (non-urgent) IO.
> 
> Signed-off-by: Jens Axboe 
> ---

s/WRITE_BG/REQ_BG/ in Subject?

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH 1/8] block: add WRITE_BG

2016-09-01 Thread Johannes Thumshirn
On Thu, Sep 01, 2016 at 09:55:18AM +0200, Johannes Thumshirn wrote:
> On Wed, Aug 31, 2016 at 11:05:44AM -0600, Jens Axboe wrote:
> > This adds a new request flag, REQ_BG, that callers can use to tell
> > the block layer that this is background (non-urgent) IO.
> > 
> > Signed-off-by: Jens Axboe 
> > ---
> 
> s/WRITE_BG/REQ_BG/ in Subject?

Gah rm $LAST_MAIL

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [Patch v3 01/11] arch/powerpc/pci: Fix compiling error for mpc85xx_edac

2016-08-05 Thread Johannes Thumshirn
On Fri, Aug 05, 2016 at 09:01:26AM +0200, Borislav Petkov wrote:
> On Fri, Aug 05, 2016 at 04:26:26AM +, york sun wrote:
> > I don't have deep knowledge of this driver. What I am trying is to 
> > separate the common DDR part and share it with ARM platforms. Along the 
> > way, I found the compiling error if build a module. If exposing these 
> > functions becomes a concern, I can live without it.
> 
> Perhaps you or Johannes could fix this properly to use pci_get_device()
> as the rest of the EDAC drivers do, instead of exporting core PCI
> functions...

I can give it a shot, but I don't have too much spare time atm and no hardware
to test, so it'll have a strong RFC smell attached to it.

Byte,
Johannes

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH v4 2/3] ses: use scsi_is_sas_rphy instead of is_sas_attached

2016-08-24 Thread Johannes Thumshirn
On Mon, Aug 22, 2016 at 04:57:39PM +0800, kbuild test robot wrote:
> Hi Johannes,
> 
> [auto build test ERROR on scsi/for-next]
> [also build test ERROR on v4.8-rc3]
> [cannot apply to next-20160822]
> [if your patch is applied to the wrong git tree, please drop us a note to 
> help improve the system]
> [Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
> convenience) to record what (public, well-known) commit your patch series was 
> built on]
> [Check https://git-scm.com/docs/git-format-patch for more information]
> 
> url:
> https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Fix-panic-when-a-SES-device-is-attached-to-a-hpsa-logical-volume/20160815-231901
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
> config: x86_64-randconfig-n0-08182202 (attached as .config)
> compiler: gcc-4.8 (Debian 4.8.4-1) 4.8.4
> reproduce:
> # save the attached .config to linux build tree
> make ARCH=x86_64 
> 
> All errors (new ones prefixed by >>):
> 
>drivers/built-in.o: In function `ses_match_to_enclosure':
> >> ses.c:(.text+0x548dae): undefined reference to `scsi_is_sas_rphy'

Sorry I was not able to reproduce this using the provided config
(neither with James' tree nor Martin's).

Johannes

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[RESEND PATCH 0/4] mcb changes for v4.8 or v4.9

2016-08-26 Thread Johannes Thumshirn
Hi Greg,

This is a re-send for my mcb-for-v4.8 series from Tue, 5 Jul 2016
15:39:49 +0200. I understand that it might be to late to in the rc
phase to include it in v4.8 so I think it's good to target them to
v4.9.

A highlight would be Andy's patches to support MCB FPGA carrier
devices on the LPC bus.

There are two more patches by me that just do removal of dead code or
add some type safety.

All this is tested on real hardware as well as on a prototyped Qemu
implementation, and passes a 'make C=1 W=1' run.

The changes are also available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git tags/for-v4.8

Thanks,
Johannes


Andreas Werner (2):
  mcb: Added support for LPC or non PCI based MCB carrier
  mcb: Added bar descriptor support for non PCI bus MCB carrier

Johannes Thumshirn (2):
  mcb: Introduce type safety for to_mcb_*
  mcb: remove sub-device handling code

 drivers/mcb/Kconfig|   9 +++
 drivers/mcb/Makefile   |   1 +
 drivers/mcb/mcb-core.c |  17 -
 drivers/mcb/mcb-internal.h |   9 +++
 drivers/mcb/mcb-lpc.c  | 158 +
 drivers/mcb/mcb-parse.c| 126 
 include/linux/mcb.h|  22 +--
 7 files changed, 304 insertions(+), 38 deletions(-)
 create mode 100644 drivers/mcb/mcb-lpc.c

-- 
2.9.3



[RESEND PATCH 3/4] mcb: Introduce type safety for to_mcb_*

2016-08-26 Thread Johannes Thumshirn
The to_mcb_{bus,device,driver}() macros lacked type safety, so convert them to
inline functions to enforce compile time type checking.

Signed-off-by: Johannes Thumshirn 
---
 include/linux/mcb.h | 18 +++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index ead13d2..a6733d3 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -41,7 +41,11 @@ struct mcb_bus {
char name[CHAMELEON_FILENAME_LEN + 1];
int (*get_irq)(struct mcb_device *dev);
 };
-#define to_mcb_bus(b) container_of((b), struct mcb_bus, dev)
+
+static inline struct mcb_bus *to_mcb_bus(struct device *dev)
+{
+   return container_of(dev, struct mcb_bus, dev);
+}
 
 /**
  * struct mcb_device - MEN Chameleon Bus device
@@ -77,7 +81,11 @@ struct mcb_device {
struct resource irq;
struct resource mem;
 };
-#define to_mcb_device(x) container_of((x), struct mcb_device, dev)
+
+static inline struct mcb_device *to_mcb_device(struct device *dev)
+{
+   return container_of(dev, struct mcb_device, dev);
+}
 
 /**
  * struct mcb_driver - MEN Chameleon Bus device driver
@@ -95,7 +103,11 @@ struct mcb_driver {
void (*remove)(struct mcb_device *mdev);
void (*shutdown)(struct mcb_device *mdev);
 };
-#define to_mcb_driver(x) container_of((x), struct mcb_driver, driver)
+
+static inline struct mcb_driver *to_mcb_driver(struct device_driver *drv)
+{
+   return container_of(drv, struct mcb_driver, driver);
+}
 
 static inline void *mcb_get_drvdata(struct mcb_device *dev)
 {
-- 
2.9.3



[RESEND PATCH 2/4] mcb: Added bar descriptor support for non PCI bus MCB carrier

2016-08-26 Thread Johannes Thumshirn
From: Andreas Werner 

Added support for the bar descriptor. This type is used for FPGAs
connect to the LPC or to a non PCI bus.

The Bar descriptor could have a maximum of 6 BARs. Each of the
devices within the FPGA could be mapped to a different BAR.
The BAR descriptor is comparable to the PCI header.

Signed-off-by: Andreas Werner 
[ free bar descriptor in the non-error case ]
Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-internal.h |   9 
 drivers/mcb/mcb-parse.c| 126 -
 2 files changed, 121 insertions(+), 14 deletions(-)

diff --git a/drivers/mcb/mcb-internal.h b/drivers/mcb/mcb-internal.h
index 5254e02..d6e6933 100644
--- a/drivers/mcb/mcb-internal.h
+++ b/drivers/mcb/mcb-internal.h
@@ -112,6 +112,15 @@ struct chameleon_bdd {
u32 size;
 } __packed;
 
+struct chameleon_bar {
+   u32 addr;
+   u32 size;
+};
+
+#define BAR_CNT(x) ((x) & 0x07)
+#define CHAMELEON_BAR_MAX  6
+#define BAR_DESC_SIZE(x)   ((x) * sizeof(struct chameleon_bar) + 
sizeof(__le32))
+
 int chameleon_parse_cells(struct mcb_bus *bus, phys_addr_t mapbase,
  void __iomem *base);
 
diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index dbecbed..4ca2739 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -26,19 +26,20 @@ static inline uint32_t get_next_dtype(void __iomem *p)
 }
 
 static int chameleon_parse_bdd(struct mcb_bus *bus,
-   phys_addr_t mapbase,
+   struct chameleon_bar *cb,
void __iomem *base)
 {
return 0;
 }
 
 static int chameleon_parse_gdd(struct mcb_bus *bus,
-   phys_addr_t mapbase,
-   void __iomem *base)
+   struct chameleon_bar *cb,
+   void __iomem *base, int bar_count)
 {
struct chameleon_gdd __iomem *gdd =
(struct chameleon_gdd __iomem *) base;
struct mcb_device *mdev;
+   u32 dev_mapbase;
u32 offset;
u32 size;
int ret;
@@ -61,13 +62,39 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
mdev->group = GDD_GRP(reg2);
mdev->inst = GDD_INS(reg2);
 
+   /*
+* If the BAR is missing, dev_mapbase is zero, or if the
+* device is IO mapped we just print a warning and go on with the
+* next device, instead of completely stop the gdd parser
+*/
+   if (mdev->bar > bar_count - 1) {
+   pr_info("No BAR for 16z%03d\n", mdev->id);
+   ret = 0;
+   goto err;
+   }
+
+   dev_mapbase = cb[mdev->bar].addr;
+   if (!dev_mapbase) {
+   pr_info("BAR not assigned for 16z%03d\n", mdev->id);
+   ret = 0;
+   goto err;
+   }
+
+   if (dev_mapbase & 0x01) {
+   pr_info("IO mapped Device (16z%03d) not yet supported\n",
+   mdev->id);
+   ret = 0;
+   goto err;
+   }
+
pr_debug("Found a 16z%03d\n", mdev->id);
 
mdev->irq.start = GDD_IRQ(reg1);
mdev->irq.end = GDD_IRQ(reg1);
mdev->irq.flags = IORESOURCE_IRQ;
 
-   mdev->mem.start = mapbase + offset;
+   mdev->mem.start = dev_mapbase + offset;
+
mdev->mem.end = mdev->mem.start + size - 1;
mdev->mem.flags = IORESOURCE_MEM;
 
@@ -85,13 +112,76 @@ err:
return ret;
 }
 
+static void chameleon_parse_bar(void __iomem *base,
+   struct chameleon_bar *cb, int bar_count)
+{
+   char __iomem *p = base;
+   int i;
+
+   /* skip reg1 */
+   p += sizeof(__le32);
+
+   for (i = 0; i < bar_count; i++) {
+   cb[i].addr = readl(p);
+   cb[i].size = readl(p + 4);
+
+   p += sizeof(struct chameleon_bar);
+   }
+}
+
+static int chameleon_get_bar(char __iomem **base, phys_addr_t mapbase,
+struct chameleon_bar **cb)
+{
+   struct chameleon_bar *c;
+   int bar_count;
+   __le32 reg;
+   u32 dtype;
+
+   /*
+* For those devices which are not connected
+* to the PCI Bus (e.g. LPC) there is a bar
+* descriptor located directly after the
+* chameleon header. This header is comparable
+* to a PCI header.
+*/
+   dtype = get_next_dtype(*base);
+   if (dtype == CHAMELEON_DTYPE_BAR) {
+   reg = readl(*base);
+
+   bar_count = BAR_CNT(reg);
+   if (bar_count <= 0 && bar_count > CHAMELEON_BAR_MAX)
+   return -ENODEV;
+
+   c = kcalloc(bar_count, sizeof(struct chameleon_bar),
+   GFP_KERNEL);
+   if (!c)
+   return -ENOMEM;
+
+   chameleon_parse_bar(*base, c, bar_c

[RESEND PATCH 1/4] mcb: Added support for LPC or non PCI based MCB carrier

2016-08-26 Thread Johannes Thumshirn
From: Andreas Werner 

Add support for MCB bases FPGAs connected to the LPC or
non PCI Bus.

This driver currently supports the SC24 board. The FPGA
is connected to the LPC bus and is identified using the BIOS
DMI string.

Signed-off-by: Andreas Werner 
Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/Kconfig   |   9 +++
 drivers/mcb/Makefile  |   1 +
 drivers/mcb/mcb-lpc.c | 158 ++
 3 files changed, 168 insertions(+)
 create mode 100644 drivers/mcb/mcb-lpc.c

diff --git a/drivers/mcb/Kconfig b/drivers/mcb/Kconfig
index e9a6976..76d9c51 100644
--- a/drivers/mcb/Kconfig
+++ b/drivers/mcb/Kconfig
@@ -28,4 +28,13 @@ config MCB_PCI
 
   If build as a module, the module is called mcb-pci.ko
 
+config MCB_LPC
+  tristate "LPC (non PCI) based MCB carrier"
+  default n
+  help
+
+  This is a MCB carrier on a LPC or non PCI device.
+
+  If build as a module, the module is called mcb-lpc.ko
+
 endif # MCB
diff --git a/drivers/mcb/Makefile b/drivers/mcb/Makefile
index 1ae1413..bcc7745 100644
--- a/drivers/mcb/Makefile
+++ b/drivers/mcb/Makefile
@@ -5,3 +5,4 @@ mcb-y += mcb-core.o
 mcb-y += mcb-parse.o
 
 obj-$(CONFIG_MCB_PCI) += mcb-pci.o
+obj-$(CONFIG_MCB_LPC) += mcb-lpc.o
diff --git a/drivers/mcb/mcb-lpc.c b/drivers/mcb/mcb-lpc.c
new file mode 100644
index 000..d072c08
--- /dev/null
+++ b/drivers/mcb/mcb-lpc.c
@@ -0,0 +1,158 @@
+/*
+ * MEN Chameleon Bus.
+ *
+ * Copyright (C) 2014 MEN Mikroelektronik GmbH (www.men.de)
+ * Author: Andreas Werner 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "mcb-internal.h"
+
+struct priv {
+   struct mcb_bus *bus;
+   struct resource *mem;
+   void __iomem *base;
+};
+
+static int mcb_lpc_probe(struct platform_device *pdev)
+{
+   struct resource *res;
+   struct priv *priv;
+   int ret = 0;
+
+   priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+   if (!priv)
+   return -ENOMEM;
+
+   priv->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+   if (!priv->mem) {
+   dev_err(&pdev->dev, "No Memory resource\n");
+   return -ENODEV;
+   }
+
+   res = devm_request_mem_region(&pdev->dev, priv->mem->start,
+ resource_size(priv->mem),
+ KBUILD_MODNAME);
+   if (!res) {
+   dev_err(&pdev->dev, "Failed to request IO memory\n");
+   return -EBUSY;
+   }
+
+   priv->base = devm_ioremap(&pdev->dev, priv->mem->start,
+ resource_size(priv->mem));
+   if (!priv->base) {
+   dev_err(&pdev->dev, "Cannot ioremap\n");
+   return -ENOMEM;
+   }
+
+   platform_set_drvdata(pdev, priv);
+
+   priv->bus = mcb_alloc_bus(&pdev->dev);
+   if (IS_ERR(priv->bus))
+   return PTR_ERR(priv->bus);
+
+   ret = chameleon_parse_cells(priv->bus, priv->mem->start, priv->base);
+   if (ret < 0) {
+   mcb_release_bus(priv->bus);
+   return ret;
+   }
+
+   dev_dbg(&pdev->dev, "Found %d cells\n", ret);
+
+   mcb_bus_add_devices(priv->bus);
+
+   return 0;
+
+}
+
+static int mcb_lpc_remove(struct platform_device *pdev)
+{
+   struct priv *priv = platform_get_drvdata(pdev);
+
+   mcb_release_bus(priv->bus);
+
+   return 0;
+}
+
+static struct platform_device *mcb_lpc_pdev;
+
+static int mcb_lpc_create_platform_device(const struct dmi_system_id *id)
+{
+   struct resource *res = id->driver_data;
+   int ret;
+
+   mcb_lpc_pdev = platform_device_alloc("mcb-lpc", -1);
+   if (!mcb_lpc_pdev)
+   return -ENOMEM;
+
+   ret = platform_device_add_resources(mcb_lpc_pdev, res, 1);
+   if (ret)
+   goto out_put;
+
+   ret = platform_device_add(mcb_lpc_pdev);
+   if (ret)
+   goto out_put;
+
+   return 0;
+
+out_put:
+   platform_device_put(mcb_lpc_pdev);
+   return ret;
+}
+
+static struct resource sc24_fpga_resource = {
+   .start = 0xe000e000,
+   .end = 0xe000e000 + CHAM_HEADER_SIZE,
+   .flags = IORESOURCE_MEM,
+};
+
+static struct platform_driver mcb_lpc_driver = {
+   .driver = {
+   .name = "mcb-lpc",
+   },
+   .probe  = mcb_lpc_probe,
+   .remove = mcb_lpc_remove,
+};
+
+static const struct dmi_system_id mcb_lpc_dmi_table[] = {
+   {
+   .ident = "SC24",
+   .m

[RESEND PATCH 4/4] mcb: remove sub-device handling code

2016-08-26 Thread Johannes Thumshirn
The MEN Chameleon specification states that a chameleon FPGA can include a
bridge descriptor, which then opens up a new bus behind this bridge. MCB
included subdevice handling code in the core, but no support for bus
descriptors in the parser, due to a lack of hardware access.

As this is technically dead code, but it gets executed on a device add,
I've decided to remove it.

Signed-off-by: Johannes Thumshirn 
---
 drivers/mcb/mcb-core.c | 17 -
 include/linux/mcb.h|  4 
 2 files changed, 21 deletions(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 6f2c852..5306966 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -369,7 +369,6 @@ struct mcb_device *mcb_alloc_dev(struct mcb_bus *bus)
if (!dev)
return NULL;
 
-   INIT_LIST_HEAD(&dev->bus_list);
dev->bus = bus;
 
return dev;
@@ -405,20 +404,6 @@ static int __mcb_bus_add_devices(struct device *dev, void 
*data)
return 0;
 }
 
-static int __mcb_bus_add_child(struct device *dev, void *data)
-{
-   struct mcb_device *mdev = to_mcb_device(dev);
-   struct mcb_bus *child;
-
-   BUG_ON(!mdev->is_added);
-   child = mdev->subordinate;
-
-   if (child)
-   mcb_bus_add_devices(child);
-
-   return 0;
-}
-
 /**
  * mcb_bus_add_devices() - Add devices in the bus' internal device list
  * @bus: The @mcb_bus we add the devices
@@ -428,8 +413,6 @@ static int __mcb_bus_add_child(struct device *dev, void 
*data)
 void mcb_bus_add_devices(const struct mcb_bus *bus)
 {
bus_for_each_dev(&mcb_bus_type, NULL, NULL, __mcb_bus_add_devices);
-   bus_for_each_dev(&mcb_bus_type, NULL, NULL, __mcb_bus_add_child);
-
 }
 EXPORT_SYMBOL_GPL(mcb_bus_add_devices);
 
diff --git a/include/linux/mcb.h b/include/linux/mcb.h
index a6733d3..ee5200d 100644
--- a/include/linux/mcb.h
+++ b/include/linux/mcb.h
@@ -50,10 +50,8 @@ static inline struct mcb_bus *to_mcb_bus(struct device *dev)
 /**
  * struct mcb_device - MEN Chameleon Bus device
  *
- * @bus_list: internal list handling for bus code
  * @dev: device in kernel representation
  * @bus: mcb bus the device is plugged to
- * @subordinate: subordinate MCBus in case of bridge
  * @is_added: flag to check if device is added to bus
  * @driver: associated mcb_driver
  * @id: mcb device id
@@ -66,10 +64,8 @@ static inline struct mcb_bus *to_mcb_bus(struct device *dev)
  * @memory: memory resource
  */
 struct mcb_device {
-   struct list_head bus_list;
struct device dev;
struct mcb_bus *bus;
-   struct mcb_bus *subordinate;
bool is_added;
struct mcb_driver *driver;
u16 id;
-- 
2.9.3



[PATCH] nvme: add hostid token to fabric options

2017-06-20 Thread Johannes Thumshirn
Currently we have no way to define a stable host-id but always use the one
which is randomly generated when we add the host or use the default host.

Provide a "hostid=%s" for user-space to pass in a persistent host-id which
overrides the randomly generated one.

Signed-off-by: Johannes Thumshirn 
---
 drivers/nvme/host/fabrics.c | 22 +++---
 drivers/nvme/host/fabrics.h |  1 +
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 6e6864516ce6..7ca2d4d70aec 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -58,7 +58,6 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
 
kref_init(&host->ref);
memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
-   uuid_gen(&host->id);
 
list_add_tail(&host->list, &nvmf_hosts);
 out_unlock:
@@ -75,7 +74,6 @@ static struct nvmf_host *nvmf_host_default(void)
return NULL;
 
kref_init(&host->ref);
-   uuid_gen(&host->id);
snprintf(host->nqn, NVMF_NQN_SIZE,
"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
 
@@ -565,6 +563,7 @@ static const match_table_t opt_tokens = {
{ NVMF_OPT_KATO,"keep_alive_tmo=%d" },
{ NVMF_OPT_HOSTNQN, "hostnqn=%s"},
{ NVMF_OPT_HOST_TRADDR, "host_traddr=%s"},
+   { NVMF_OPT_HOST_ID, "hostid=%s" },
{ NVMF_OPT_ERR, NULL}
 };
 
@@ -576,6 +575,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options 
*opts,
int token, ret = 0;
size_t nqnlen  = 0;
int ctrl_loss_tmo = NVMF_DEF_CTRL_LOSS_TMO;
+   uuid_t hostid;
 
/* Set defaults */
opts->queue_size = NVMF_DEF_QUEUE_SIZE;
@@ -586,6 +586,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options 
*opts,
if (!options)
return -ENOMEM;
 
+   uuid_gen(&hostid);
+
while ((p = strsep(&o, ",\n")) != NULL) {
if (!*p)
continue;
@@ -742,6 +744,17 @@ static int nvmf_parse_options(struct nvmf_ctrl_options 
*opts,
}
opts->host_traddr = p;
break;
+   case NVMF_OPT_HOST_ID:
+   p = match_strdup(args);
+   if (!p) {
+   ret = -ENOMEM;
+   goto out;
+   }
+   if (uuid_parse(p, &hostid)) {
+   ret = -EINVAL;
+   goto out;
+   }
+   break;
default:
pr_warn("unknown parameter or missing value '%s' in 
ctrl creation request\n",
p);
@@ -761,6 +774,8 @@ static int nvmf_parse_options(struct nvmf_ctrl_options 
*opts,
opts->host = nvmf_default_host;
}
 
+   uuid_copy(&opts->host->id, &hostid);
+
 out:
if (!opts->discovery_nqn && !opts->kato)
opts->kato = NVME_DEFAULT_KATO;
@@ -821,7 +836,8 @@ EXPORT_SYMBOL_GPL(nvmf_free_options);
 
 #define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN)
 #define NVMF_ALLOWED_OPTS  (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \
-NVMF_OPT_KATO | NVMF_OPT_HOSTNQN)
+NVMF_OPT_KATO | NVMF_OPT_HOSTNQN | \
+NVMF_OPT_HOST_ID)
 
 static struct nvme_ctrl *
 nvmf_create_ctrl(struct device *dev, const char *buf, size_t count)
diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h
index f1c9bd7ae7ff..c8b2f0127ccc 100644
--- a/drivers/nvme/host/fabrics.h
+++ b/drivers/nvme/host/fabrics.h
@@ -56,6 +56,7 @@ enum {
NVMF_OPT_RECONNECT_DELAY = 1 << 9,
NVMF_OPT_HOST_TRADDR= 1 << 10,
NVMF_OPT_CTRL_LOSS_TMO  = 1 << 11,
+   NVMF_OPT_HOST_ID= 1 << 12,
 };
 
 /**
-- 
2.12.3



[PATCH RESEND 4/7] [media] cx25821: use MEDIA_REVISION instead of KERNEL_VERSION

2017-06-21 Thread Johannes Thumshirn
Use MEDIA_REVISION instead of KERNEL_VERSION to encode the
CX25821_VERSION_CODE.

Signed-off-by: Johannes Thumshirn 
---
 drivers/media/pci/cx25821/cx25821.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/cx25821/cx25821.h 
b/drivers/media/pci/cx25821/cx25821.h
index 0f20e89b0cde..7fea6b07cf19 100644
--- a/drivers/media/pci/cx25821/cx25821.h
+++ b/drivers/media/pci/cx25821/cx25821.h
@@ -41,7 +41,7 @@
 #include 
 #include 
 
-#define CX25821_VERSION_CODE KERNEL_VERSION(0, 0, 106)
+#define CX25821_VERSION_CODE MEDIA_REVISION(0, 0, 106)
 
 #define UNSET (-1U)
 #define NO_SYNC_LINE (-1U)
-- 
2.12.3



[PATCH RESEND 1/7] [media] media: introduce MEDIA_REVISION macro

2017-06-21 Thread Johannes Thumshirn
Currently the media code abuses the KERNEL_VERSION macro to encode a
version triplet.

Introduce a MEDIA_REVISION macro to get rid of the confusing and
creative KERNEL_VERSION usage in the media subsystem.

Signed-off-by: Johannes Thumshirn 
---
 include/uapi/linux/media.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4890787731b8..25e2ae4432bd 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -30,7 +30,9 @@
 #include 
 #include 
 
-#define MEDIA_API_VERSION  KERNEL_VERSION(0, 1, 0)
+#define MEDIA_REVISION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+
+#define MEDIA_API_VERSION  MEDIA_REVISION(0, 1, 0)
 
 struct media_device_info {
char driver[16];
-- 
2.12.3



[PATCH RESEND 0/7] Introduce MEDIA_VERSION to end KENREL_VERSION abuse in media

2017-06-21 Thread Johannes Thumshirn
Currently the media subsystem has a very creative abuse of the
KERNEL_VERSION macro to encode an arbitrary version triplet for media
drivers and device hardware revisions.

This series introduces a new macro called MEDIA_REVISION which encodes
a version triplet like KERNEL_VERSION does, but clearly has media
centric semantics and doesn't fool someone into thinking specific
parts are defined for a specific kernel version only like in out of
tree drivers.

Johannes Thumshirn (7):
  [media] media: introduce MEDIA_REVISION macro
  video: fbdev: don't use KERNEL_VERSION macro for MEDIA_REVISION
  [media] media: document the use of MEDIA_REVISION instead of
KERNEL_VERSION
  [media] cx25821: use MEDIA_REVISION instead of KERNEL_VERSION
  [media] media: s3c-camif: Use MEDIA_REVISON instead of KERNEL_VERSION
  [media] media: bcm2048: use MEDIA_REVISION isntead of KERNEL_VERSION
  staging/atomisp: use MEDIA_VERSION instead of KERNEL_VERSION

 Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst| 2 +-
 Documentation/media/uapi/mediactl/media-ioc-device-info.rst | 4 ++--
 Documentation/media/uapi/v4l/vidioc-querycap.rst| 6 +++---
 drivers/media/pci/cx25821/cx25821.h | 2 +-
 drivers/media/platform/s3c-camif/camif-core.c   | 2 +-
 drivers/staging/media/atomisp/include/linux/atomisp.h   | 6 +++---
 drivers/staging/media/bcm2048/radio-bcm2048.c   | 2 +-
 drivers/video/fbdev/matrox/matroxfb_base.c  | 3 ++-
 include/media/media-device.h| 5 ++---
 include/uapi/linux/media.h  | 4 +++-
 10 files changed, 19 insertions(+), 17 deletions(-)

-- 
2.12.3



[PATCH RESEND 6/7] [media] media: bcm2048: use MEDIA_REVISION isntead of KERNEL_VERSION

2017-06-21 Thread Johannes Thumshirn
Use MEDIA_REVISION isntead of KERNEL_VERSION to encode the bcm2048
driver version.

Signed-off-by: Johannes Thumshirn 
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c 
b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 38f72d069e27..ffe9b63cbf59 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -48,7 +48,7 @@
 /* driver definitions */
 #define BCM2048_DRIVER_AUTHOR  "Eero Nurkkala "
 #define BCM2048_DRIVER_NAMEBCM2048_NAME
-#define BCM2048_DRIVER_VERSION KERNEL_VERSION(0, 0, 1)
+#define BCM2048_DRIVER_VERSION MEDIA_REVISION(0, 0, 1)
 #define BCM2048_DRIVER_CARD"Broadcom bcm2048 FM Radio Receiver"
 #define BCM2048_DRIVER_DESC"I2C driver for BCM2048 FM Radio Receiver"
 
-- 
2.12.3



[PATCH RESEND 5/7] [media] media: s3c-camif: Use MEDIA_REVISON instead of KERNEL_VERSION

2017-06-21 Thread Johannes Thumshirn
Use MEDIA_REVISON instead of KERNEL_VERSION to encode the driver
version.

Signed-off-by: Johannes Thumshirn 
---
 drivers/media/platform/s3c-camif/camif-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/s3c-camif/camif-core.c 
b/drivers/media/platform/s3c-camif/camif-core.c
index ec4001970313..98bd5719fdf5 100644
--- a/drivers/media/platform/s3c-camif/camif-core.c
+++ b/drivers/media/platform/s3c-camif/camif-core.c
@@ -317,7 +317,7 @@ static int camif_media_dev_init(struct camif_dev *camif)
 ip_rev == S3C6410_CAMIF_IP_REV ? "6410" : "244X");
strlcpy(md->bus_info, "platform", sizeof(md->bus_info));
md->hw_revision = ip_rev;
-   md->driver_version = KERNEL_VERSION(1, 0, 0);
+   md->driver_version = MEDIA_REVISION(1, 0, 0);
 
md->dev = camif->dev;
 
-- 
2.12.3



[PATCH RESEND 7/7] staging/atomisp: use MEDIA_VERSION instead of KERNEL_VERSION

2017-06-21 Thread Johannes Thumshirn
Use MEDIA_VERSION instead of KERNEL_VERSION to encode the driver
version of the Atom ISP driver.

Signed-off-by: Johannes Thumshirn 
---
 drivers/staging/media/atomisp/include/linux/atomisp.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/include/linux/atomisp.h 
b/drivers/staging/media/atomisp/include/linux/atomisp.h
index 35865462ccf9..0b664ee6f825 100644
--- a/drivers/staging/media/atomisp/include/linux/atomisp.h
+++ b/drivers/staging/media/atomisp/include/linux/atomisp.h
@@ -30,9 +30,9 @@
 
 /* struct media_device_info.driver_version */
 #define ATOMISP_CSS_VERSION_MASK   0x00ff
-#define ATOMISP_CSS_VERSION_15 KERNEL_VERSION(1, 5, 0)
-#define ATOMISP_CSS_VERSION_20 KERNEL_VERSION(2, 0, 0)
-#define ATOMISP_CSS_VERSION_21 KERNEL_VERSION(2, 1, 0)
+#define ATOMISP_CSS_VERSION_15 MEDIA_REVISION(1, 5, 0)
+#define ATOMISP_CSS_VERSION_20 MEDIA_REVISION(2, 0, 0)
+#define ATOMISP_CSS_VERSION_21 MEDIA_REVISION(2, 1, 0)
 
 /* struct media_device_info.hw_revision */
 #define ATOMISP_HW_REVISION_MASK   0xff00
-- 
2.12.3



[PATCH RESEND 2/7] video: fbdev: don't use KERNEL_VERSION macro for MEDIA_REVISION

2017-06-21 Thread Johannes Thumshirn
Don't use the KERNEL_VERSION() macro for the v4l2 capabilities, use
MEDIA_REVISION instead.

Signed-off-by: Johannes Thumshirn 
---
 drivers/video/fbdev/matrox/matroxfb_base.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c 
b/drivers/video/fbdev/matrox/matroxfb_base.c
index 11eb094396ae..eb92a325033c 100644
--- a/drivers/video/fbdev/matrox/matroxfb_base.c
+++ b/drivers/video/fbdev/matrox/matroxfb_base.c
@@ -113,6 +113,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #ifdef CONFIG_PPC_PMAC
 #include 
@@ -1091,7 +1092,7 @@ static int matroxfb_ioctl(struct fb_info *info,
strcpy(r.driver, "matroxfb");
strcpy(r.card, "Matrox");
sprintf(r.bus_info, "PCI:%s", 
pci_name(minfo->pcidev));
-   r.version = KERNEL_VERSION(1,0,0);
+   r.version = MEDIA_REVISION(1, 0, 0);
r.capabilities = V4L2_CAP_VIDEO_OUTPUT;
if (copy_to_user(argp, &r, sizeof(r)))
return -EFAULT;
-- 
2.12.3



[PATCH RESEND 3/7] [media] media: document the use of MEDIA_REVISION instead of KERNEL_VERSION

2017-06-21 Thread Johannes Thumshirn
Update the documentation to introduce the use of MEDIA_REVISON instead
of KERNEL_VERSION for the verison triplets of a media drivers hardware
revision or driver version.

Signed-off-by: Johannes Thumshirn 
---
 Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst| 2 +-
 Documentation/media/uapi/mediactl/media-ioc-device-info.rst | 4 ++--
 Documentation/media/uapi/v4l/vidioc-querycap.rst| 6 +++---
 include/media/media-device.h| 5 ++---
 4 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst 
b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
index a0e961f11017..749054f11c77 100644
--- a/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
+++ b/Documentation/media/uapi/cec/cec-ioc-adap-g-caps.rst
@@ -56,7 +56,7 @@ returns the information to the application. The ioctl never 
fails.
:ref:`cec-capabilities`.
 * - __u32
   - ``version``
-  - CEC Framework API version, formatted with the ``KERNEL_VERSION()``
+  - CEC Framework API version, formatted with the ``MEDIA_REVISION()``
macro.
 
 
diff --git a/Documentation/media/uapi/mediactl/media-ioc-device-info.rst 
b/Documentation/media/uapi/mediactl/media-ioc-device-info.rst
index f690f9afc470..7a18cb6dbe84 100644
--- a/Documentation/media/uapi/mediactl/media-ioc-device-info.rst
+++ b/Documentation/media/uapi/mediactl/media-ioc-device-info.rst
@@ -96,7 +96,7 @@ ioctl never fails.
 
-  ``media_version``
 
-   -  Media API version, formatted with the ``KERNEL_VERSION()`` macro.
+   -  Media API version, formatted with the ``MEDIA_REVISION()`` macro.
 
 -  .. row 6
 
@@ -113,7 +113,7 @@ ioctl never fails.
-  ``driver_version``
 
-  Media device driver version, formatted with the
- ``KERNEL_VERSION()`` macro. Together with the ``driver`` field
+ ``MEDIA_REVISION()`` macro. Together with the ``driver`` field
  this identifies a particular driver.
 
 -  .. row 8
diff --git a/Documentation/media/uapi/v4l/vidioc-querycap.rst 
b/Documentation/media/uapi/v4l/vidioc-querycap.rst
index 12e0d9a63cd8..b66d9caa7211 100644
--- a/Documentation/media/uapi/v4l/vidioc-querycap.rst
+++ b/Documentation/media/uapi/v4l/vidioc-querycap.rst
@@ -90,13 +90,13 @@ specification the ioctl returns an ``EINVAL`` error code.
example, a stable or distribution-modified kernel uses the V4L2
stack from a newer kernel.
 
-   The version number is formatted using the ``KERNEL_VERSION()``
+   The version number is formatted using the ``MEDIA_REVISION()``
macro:
 * - :cspan:`2`
 
-   ``#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
+   ``#define MEDIA_REVISION(a,b,c) (((a) << 16) + ((b) << 8) + (c))``
 
-   ``__u32 version = KERNEL_VERSION(0, 8, 1);``
+   ``__u32 version = MEDIA_REVISION(0, 8, 1);``
 
``printf ("Version: %u.%u.%u\\n",``
 
diff --git a/include/media/media-device.h b/include/media/media-device.h
index 6896266031b9..6b3057266ad1 100644
--- a/include/media/media-device.h
+++ b/include/media/media-device.h
@@ -247,9 +247,9 @@ void media_device_cleanup(struct media_device *mdev);
  *
  *  - &media_entity.hw_revision is the hardware device revision in a
  *driver-specific format. When possible the revision should be formatted
- *with the KERNEL_VERSION() macro.
+ *with the MEDIA_REVISION() macro.
  *
- *  - &media_entity.driver_version is formatted with the KERNEL_VERSION()
+ *  - &media_entity.driver_version is formatted with the MEDIA_REVISION()
  *macro. The version minor must be incremented when new features are added
  *to the userspace API without breaking binary compatibility. The version
  *major must be incremented when binary compatibility is broken.
@@ -265,7 +265,6 @@ void media_device_cleanup(struct media_device *mdev);
 int __must_check __media_device_register(struct media_device *mdev,
 struct module *owner);
 
-
 /**
  * media_device_register() - Registers a media device element
  *
-- 
2.12.3



Re: [PATCH 1/2] hpsa: limit transfer length to 1MB

2017-06-22 Thread Johannes Thumshirn
On Thu, Jun 22, 2017 at 05:58:44PM +0800, Yadan Fan wrote:
> The hpsa firmware will bypass the cache for any request larger
> than 1MB, so we should cap the request size to avoid any
> performance degradation in SLE12-SP2.
Upstream doesn't care too much about SLES. 

> References: bsc#1025461

and our internal Bugzilla IDs


How about:
The hpsa firmware will bypass the cache for any requests larger than 1MB, so
we shoould cap the request size to avoid any performance regressions in
kernels later than 4.3 

The same applies for Patch 2/2

-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


Re: [PATCH] scsi: libfc: Convert timers to use timer_setup()

2017-10-17 Thread Johannes Thumshirn
Looks good,
Acked-by: Johannes Thumshirn 
-- 
Johannes Thumshirn  Storage
jthumsh...@suse.de+49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850


[PATCH 0/7] Implement NVMe Namespace Descriptor Identification

2017-05-30 Thread Johannes Thumshirn
This patchset implemets NVMe Namespace Descriptor Identification as of
NVMe 1.3. The Namespace Descriptor Identification allows a NVMe host
to query several Namespace Identification mechanisms, such as EUI-64,
NGUID and UUID from the target. If more than one value is set by the
target, it can transmit all set values to the host.

The Namespace Identification Descriptor list is the only way a target
can identify itself via the newly introduced UUID to the host (instead
of the EUI-64 or NGUID).

Both the Host and Target side are implemented. In order to get the
Linux Host to send the Linux target implementation a Namespace
Descriptor Identification command, you have to change the target's
announced version code to at least 1.3. 

Unfortunately the host side already did have a sysfs attribute called
'uuid' which represented the NGUID, so precautions have been taken to
not break any existing userspace.

While I was already touching the relevant code paths, I decided to
also include the EUI-64 in the 'Identify Namespace' command response.

The code is tested using the nvme-loop loopback target and cut against
the nvme tree's nvme-4.12 branch.

A patch for nvmetcli will follow shortly.

Johannes Thumshirn (7):
  nvme: rename uuid to nguid in nvme_ns
  nvmet: add uuid field to nvme_ns and populate via configfs
  nvmet: add eui64 field to nvme_ns and populate via configfs
  nvme: also report include the EUI-64 in identify NS report
  nvmet: implement namespace identify descriptor list
  nvme: get list of namespace descriptors
  nvme: provide UUID value to userspace

 drivers/nvme/host/core.c| 116 ++--
 drivers/nvme/host/nvme.h|   1 +
 drivers/nvme/target/admin-cmd.c |  76 ++
 drivers/nvme/target/configfs.c  |  96 +
 drivers/nvme/target/nvmet.h |   2 +
 include/linux/nvme.h|  14 +
 6 files changed, 301 insertions(+), 4 deletions(-)

-- 
2.12.0



[PATCH 2/7] nvmet: add uuid field to nvme_ns and populate via configfs

2017-05-30 Thread Johannes Thumshirn
Add the UUID field from the NVMe Namespace Identification Descriptor
to the nvmet_ns structure and allow it's population via configfs.

Signed-off-by: Johannes Thumshirn 
---
 drivers/nvme/target/configfs.c | 48 ++
 drivers/nvme/target/nvmet.h|  1 +
 2 files changed, 49 insertions(+)

diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c
index be8c800078e2..0529a36501f4 100644
--- a/drivers/nvme/target/configfs.c
+++ b/drivers/nvme/target/configfs.c
@@ -305,11 +305,58 @@ static ssize_t nvmet_ns_device_path_store(struct 
config_item *item,
 
 CONFIGFS_ATTR(nvmet_ns_, device_path);
 
+static ssize_t nvmet_ns_device_uuid_show(struct config_item *item, char *page)
+{
+   return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->uuid);
+}
+
+static ssize_t nvmet_ns_device_uuid_store(struct config_item *item,
+ const char *page, size_t count)
+{
+   struct nvmet_ns *ns = to_nvmet_ns(item);
+   struct nvmet_subsys *subsys = ns->subsys;
+   u8 uuid[16];
+   const char *p = page;
+   int i;
+   int ret = 0;
+
+
+   mutex_lock(&subsys->lock);
+   if (ns->enabled) {
+   ret = -EBUSY;
+   goto out_unlock;
+   }
+
+   for (i = 0; i < 16; i++) {
+   if (p + 2 > page + count) {
+   ret = -EINVAL;
+   goto out_unlock;
+   }
+   if (!isxdigit(p[0]) || !isxdigit(p[1])) {
+   ret = -EINVAL;
+   goto out_unlock;
+   }
+
+   uuid[i] = (hex_to_bin(p[0]) << 4) | hex_to_bin(p[1]);
+   p += 2;
+
+   if (*p == '-' || *p == ':')
+   p++;
+   }
+
+   memcpy(&ns->uuid, uuid, sizeof(uuid));
+out_unlock:
+   mutex_unlock(&subsys->lock);
+   return ret ? ret : count;
+}
+
 static ssize_t nvmet_ns_device_nguid_show(struct config_item *item, char *page)
 {
return sprintf(page, "%pUb\n", &to_nvmet_ns(item)->nguid);
 }
 
+CONFIGFS_ATTR(nvmet_ns_, device_uuid);
+
 static ssize_t nvmet_ns_device_nguid_store(struct config_item *item,
const char *page, size_t count)
 {
@@ -379,6 +426,7 @@ CONFIGFS_ATTR(nvmet_ns_, enable);
 static struct configfs_attribute *nvmet_ns_attrs[] = {
&nvmet_ns_attr_device_path,
&nvmet_ns_attr_device_nguid,
+   &nvmet_ns_attr_device_uuid,
&nvmet_ns_attr_enable,
NULL,
 };
diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h
index cfc5c7fb0ab7..6ef7db521716 100644
--- a/drivers/nvme/target/nvmet.h
+++ b/drivers/nvme/target/nvmet.h
@@ -46,6 +46,7 @@ struct nvmet_ns {
u32 blksize_shift;
loff_t  size;
u8  nguid[16];
+   u8  uuid[16];
 
boolenabled;
struct nvmet_subsys *subsys;
-- 
2.12.0



  1   2   3   4   5   6   7   8   9   10   >