[PATCH v2] staging: mt7621-gpio: avoid use banks in device tree

2018-06-18 Thread Sergio Paracuellos
Banks shouldn't be defined in DT if number of resources
per bank is not variable. We actually know that this SoC
has three banks so take that into account in order to don't
overspecify the device tree. Device tree will only have one
node making it simple. Update device tree, binding doc and
code accordly.

Signed-off-by: Sergio Paracuellos 
---
Changes in v2:
Last patch in previous 'last cleanups' series is wrong passing
around a not initialized 'bank' to the 'mediatek_gpio_bank_probe'
function. Fix it here and because that patch is the last one in
the series just only resend this.
 drivers/staging/mt7621-dts/gbpc1.dts   | 10 ++--
 drivers/staging/mt7621-dts/mt7621.dtsi | 31 ++--
 drivers/staging/mt7621-gpio/gpio-mt7621.c  | 21 
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   | 59 +-
 4 files changed, 31 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/mt7621-dts/gbpc1.dts 
b/drivers/staging/mt7621-dts/gbpc1.dts
index 6b13d85..352945d 100644
--- a/drivers/staging/mt7621-dts/gbpc1.dts
+++ b/drivers/staging/mt7621-dts/gbpc1.dts
@@ -32,7 +32,7 @@
 
reset {
label = "reset";
-   gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>;
+   gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
linux,code = ;
};
};
@@ -42,22 +42,22 @@
 
system {
label = "gb-pc1:green:system";
-   gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
};
 
status {
label = "gb-pc1:green:status";
-   gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
};
 
lan1 {
label = "gb-pc1:green:lan1";
-   gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
};
 
lan2 {
label = "gb-pc1:green:lan2";
-   gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
};
};
 };
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index acb6b8c..02746af 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -61,37 +61,14 @@
};
 
gpio: gpio@600 {
-   #address-cells = <1>;
-   #size-cells = <0>;
-
+   #gpio-cells = <2>;
+   #interrupt-cells = <2>;
compatible = "mediatek,mt7621-gpio";
+   gpio-controller;
+   interrupt-controller;
reg = <0x600 0x100>;
-
interrupt-parent = <&gic>;
interrupts = ;
-   interrupt-controller;
-   #interrupt-cells = <2>;
-
-   gpio0: bank@0 {
-   reg = <0>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   gpio1: bank@1 {
-   reg = <1>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   gpio2: bank@2 {
-   reg = <2>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
};
 
i2c: i2c@900 {
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 9a4a12f..281e621 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -206,23 +206,20 @@ static inline const char * const 
mediatek_gpio_bank_name(int bank)
 }
 
 static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
+mediatek_gpio_bank_probe(struct platform_device *pdev,
+struct device_node *node, int bank)
 {
struct mtk_data *gpio = dev_get_drvdata(&pdev->dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
struct mtk_gc *rg;
void __iomem *dat, *set, *ctrl, *diro;
int ret;
 
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = &gpio->gc_map[be32_to_cpu(*id)];
+   rg = &gpio->gc_map[bank];
  

Re: [PATCH v3 5/5] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

2018-06-18 Thread Kalle Valo
Greg KH  writes:

> On Sun, Jun 17, 2018 at 01:07:36PM +0300, Omer Efrat wrote:
>> The BIT macro uses unsigned long which some architectures handle as 32 bit
>> and therefore might cause macro's shift to overflow when used on a value
>> equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).
>> 
>> Since 'filled' member in station_info changed to u64, BIT_ULL macro
>> should be used with all NL80211_STA_INFO_* attribute types instead of BIT
>> to prevent future possible bugs when one will use BIT macro for higher
>> attributes by mistake.
>> 
>> This commit cleans up all usages of BIT macro with the above field
>> in cfg80211 by changing it to BIT_ULL instead.
>> 
>> Signed-off-by: Omer Efrat 
>
> Acked-by: Greg Kroah-Hartman 

Via which tree is this supposed to go?

-- 
Kalle Valo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 5/5] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

2018-06-18 Thread Greg KH
On Mon, Jun 18, 2018 at 10:29:43AM +0300, Kalle Valo wrote:
> Greg KH  writes:
> 
> > On Sun, Jun 17, 2018 at 01:07:36PM +0300, Omer Efrat wrote:
> >> The BIT macro uses unsigned long which some architectures handle as 32 bit
> >> and therefore might cause macro's shift to overflow when used on a value
> >> equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).
> >> 
> >> Since 'filled' member in station_info changed to u64, BIT_ULL macro
> >> should be used with all NL80211_STA_INFO_* attribute types instead of BIT
> >> to prevent future possible bugs when one will use BIT macro for higher
> >> attributes by mistake.
> >> 
> >> This commit cleans up all usages of BIT macro with the above field
> >> in cfg80211 by changing it to BIT_ULL instead.
> >> 
> >> Signed-off-by: Omer Efrat 
> >
> > Acked-by: Greg Kroah-Hartman 
> 
> Via which tree is this supposed to go?

Not mine :)

Have fun with it!

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-18 Thread Justin Skists


> On 18 June 2018 at 06:34 Gregory Nowak  wrote:
> 
> 
> On Tue, Jun 12, 2018 at 08:31:06AM +0200, Samuel Thibault wrote:
> > The load/unload is about the module itself, i.e. modprobe speakup_bns ;
> > modprobe speakup_soft, switch between them, then rmmod speakup_bns ;
> > speakup_soft or the converse (to exercise both orders).
> 
> # uname -a
> Linux p41box 4.17.1 #1 SMP Sat Jun 16 11:19:57 MST 2018 i686 GNU/Linux
> # lsmod |grep "speakup"
> speakup_bns16384  0
> speakup_soft   16384  1
> speakup94208  3 speakup_bns,speakup_soft
> 
> With /sys/accessibility/speakup/synth set to bns, I am getting output
> alternately from the bns and from soft. It's as if speakup can't make
> up its mind which synthesizer is being used. When I echo soft
> >/sys/accessibility/speakup/synth, I get no speech at all from either
> synthesizer.

Is this a known issue, or a regression due to the patch?


Justin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-18 Thread Samuel Thibault
Justin Skists, le lun. 18 juin 2018 09:41:44 +0100, a ecrit:
> > On 18 June 2018 at 06:34 Gregory Nowak  wrote:
> > With /sys/accessibility/speakup/synth set to bns, I am getting output
> > alternately from the bns and from soft. It's as if speakup can't make
> > up its mind which synthesizer is being used. When I echo soft
> > >/sys/accessibility/speakup/synth, I get no speech at all from either
> > synthesizer.
> 
> Is this a known issue, or a regression due to the patch?

I don't think it was a known issue, but I don't think it can be a
regression due to the patch, since none of that is handled by the
array/list at stake.

Samuel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH V2] staging: mt7621-eth: Fix memory leak in mtk_add_mac() error path

2018-06-18 Thread Greg Kroah-Hartman
On Sat, Jun 16, 2018 at 01:01:27PM +0300, Kamal Heib wrote:
> Fix memory leak in error path of mtk_add_mac() by make sure to free
> the allocated netdev.
> 
> Fixes: e3cbf478f846 ('staging: mt7621-eth: add the drivers core files')
> Signed-off-by: Kamal Heib 
> ---
> Changes from v1:
>   No need to free the hw_stats.
> 
>  drivers/staging/mt7621-eth/mtk_eth_soc.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/staging/mt7621-eth/mtk_eth_soc.c 
> b/drivers/staging/mt7621-eth/mtk_eth_soc.c
> index 2c7a2e666bfb..c240c27dc654 100644
> --- a/drivers/staging/mt7621-eth/mtk_eth_soc.c
> +++ b/drivers/staging/mt7621-eth/mtk_eth_soc.c
> @@ -2012,8 +2012,11 @@ static int mtk_add_mac(struct mtk_eth *eth, struct 
> device_node *np)
>   mac->hw_stats = devm_kzalloc(eth->dev,
>sizeof(*mac->hw_stats),
>GFP_KERNEL);
> - if (!mac->hw_stats)
> - return -ENOMEM;
> + if (!mac->hw_stats) {
> + dev_err(eth->dev, "failed to allocate hw_stats\n");

No need to shout about an error, when memory allocation fails, there
will be a message sent to the kernel log about it.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: mt7621-gpio: avoid use banks in device tree

2018-06-18 Thread Greg KH
On Mon, Jun 18, 2018 at 09:07:57AM +0200, Sergio Paracuellos wrote:
> Banks shouldn't be defined in DT if number of resources
> per bank is not variable. We actually know that this SoC
> has three banks so take that into account in order to don't
> overspecify the device tree. Device tree will only have one
> node making it simple. Update device tree, binding doc and
> code accordly.
> 
> Signed-off-by: Sergio Paracuellos 
> ---
> Changes in v2:
> Last patch in previous 'last cleanups' series is wrong passing
> around a not initialized 'bank' to the 'mediatek_gpio_bank_probe'
> function. Fix it here and because that patch is the last one in
> the series just only resend this.

Ick, what am I supposed to do here?  I almost missed this :(

Please just resend a whole new versioned series, so that I don't mess
things up.  You want to make it as _simple_ as possible for a brain-dead
maintainer like me, otherwise I will get it wrong :)

I've dropped all of the mt7621-gpio patches from my queue now, please
fix up and resend.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-18 Thread Justin Skists


> On 18 June 2018 at 09:46 Samuel Thibault  wrote:
> 
> 
> Justin Skists, le lun. 18 juin 2018 09:41:44 +0100, a ecrit:
> > > On 18 June 2018 at 06:34 Gregory Nowak  wrote:
> > > With /sys/accessibility/speakup/synth set to bns, I am getting output
> > > alternately from the bns and from soft. It's as if speakup can't make
> > > up its mind which synthesizer is being used. When I echo soft
> > > >/sys/accessibility/speakup/synth, I get no speech at all from either
> > > synthesizer.
> > 
> > Is this a known issue, or a regression due to the patch?
> 
> I don't think it was a known issue, but I don't think it can be a
> regression due to the patch, since none of that is handled by the
> array/list at stake.

OK, thanks. That's what I thought, too.

When I was going through the driver code, to become familiar with it, there
were a few places that I thought needed a closer look. But I need to finish
setting up a regression testing system before I do.

Justin.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: speakup: refactor synths array to use a list

2018-06-18 Thread Samuel Thibault
Justin Skists, le lun. 18 juin 2018 09:55:32 +0100, a ecrit:
> When I was going through the driver code, to become familiar with it, there
> were a few places that I thought needed a closer look.

Yes, cleanup work is probably needed in various places.

Samuel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Question about disabling of CONFIG_ANDROID_BINDER_IPC_32BIT in upcomng kernel 4.18

2018-06-18 Thread Dan Carpenter
You should be asking the author of the patch, Martijn Coenen.  He's also
the maintainer for that.  I have added him to the CC list.

regards,
dan carpenter

On Sun, Jun 17, 2018 at 10:26:09AM +0200, Mauro Rossi wrote:
> + de...@linuxdriverproject.org
> resending to Greg KH as instructed by his mail bot
> 
> I a few words the question is:
> 
> Has  CONFIG_ANDROID_BINDER_IPC_32BIT been removed
> in 1190b4e38f97023154e6b3bef61b251aa5f970d0 ("ANDROID: binder: remove
> 32-bit binder interface")
> for a mandatory reason (incompatibilty with Android P build) or for
> other reason and
> the option could have been left (to be disabled in P builds)?
> 
> Also as android-x86 team contributor I'd like to understand what would
> happen with P
> if besides binder ipc 64bit the concurrent binder ipc 32bit had be
> kept present and enabled.
> 
> Thanks
> Mauro Rossi
> 
> 2018-06-16 11:44 GMT+02:00 Mauro Rossi :
> > Hi Martijn,
> >
> > I wanted to check with you what is the real reason for disabling it,
> > because In my understanding in Android P you could have
> > build 32bit Android image by disabling it, with this setting in the 32bit
> > *_defconfig:
> >
> > # CONFIG_ANDROID_BINDER_IPC_32BIT  is not set
> >
> > (which is ok if 64 binder is enabled in BoardConfig.mk, e.g oreo-x86 branch
> > of android-x86)
> >
> > Are you sure there are no other users of kernel 4.18 for nougat derived
> > builds or android-* fellow projects?
> >
> > It's no problem for me to partially revert
> > 1190b4e38f97023154e6b3bef61b251aa5f970d0
> > to keep the m68k improvement,
> >
> > but is this change due to "Android P need to use the 64-bit binder
> > interface"
> > (which is not mandatory, given the flexibility to disable it in *_defconfig)
> > or just "we want to avoid people doing the mistake to enable it on P"?
> >
> > Mauro Rossi
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] staging: mt7621-gpio: avoid use banks in device tree

2018-06-18 Thread Sergio Paracuellos
On Mon, Jun 18, 2018 at 10:53:31AM +0200, Greg KH wrote:
> On Mon, Jun 18, 2018 at 09:07:57AM +0200, Sergio Paracuellos wrote:
> > Banks shouldn't be defined in DT if number of resources
> > per bank is not variable. We actually know that this SoC
> > has three banks so take that into account in order to don't
> > overspecify the device tree. Device tree will only have one
> > node making it simple. Update device tree, binding doc and
> > code accordly.
> > 
> > Signed-off-by: Sergio Paracuellos 
> > ---
> > Changes in v2:
> > Last patch in previous 'last cleanups' series is wrong passing
> > around a not initialized 'bank' to the 'mediatek_gpio_bank_probe'
> > function. Fix it here and because that patch is the last one in
> > the series just only resend this.
> 
> Ick, what am I supposed to do here?  I almost missed this :(
> 
> Please just resend a whole new versioned series, so that I don't mess
> things up.  You want to make it as _simple_ as possible for a brain-dead
> maintainer like me, otherwise I will get it wrong :)
> 
> I've dropped all of the mt7621-gpio patches from my queue now, please
> fix up and resend.

Ok, Greg, Sorry. Last version of those patches must be tested yet by
Neil and I realized that the last one in the series wasn't good, because
of that I only included this. I'll resend all v4 again including the modify
one.

> 
> thanks,
> 
> greg k-h

Best regards,
Sergio Paracuellos
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 00/18] staging: mt7621-gpio: last cleanups

2018-06-18 Thread Sergio Paracuellos
After submiting this driver to try to get mainlined and get
out of staging some new cleanups seems to be necessary.
According to this mail of Linus Walleij:

http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121742.html

and this mail os Rob Herring:

http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-June/121974.html

this series tries to fix all of the issues in order to send
v2 and give it a new try. Because I don't have to hardware to
test my changes I send new cleanups first in staging to make
easier to NeilBrown test it and get a feedback about them.

Changes in v5:
- PATCH 18 pass 'np' instead of 'bank' which was NULL and
  was wrong. Bank is no more neccesary because now we 
  have only one node in the DT.

Changes in v4:
- Add "last minor cleanups" series to the same patch series.
- Update Kconfig being more specific in description and help
  about the SoC.
- Update dt-bindings, device tree and code to don't use
  banks in the device tree assuming this SoC has 3 banks
  with 32 gpios each.

Changes in v3:
- PATCH 7: refactor irq_type to make better code.
- Add PATCH 8 avoiding the use of custom domain and requesting
  manually a 'IRQF_SHARED'.

Changes in v2:
- Patch where GPIOLIB_IRQCHIP was used avoiding
  the use of a custom irq domain has been dropped to
  be sure after this changes all is working properly.
  (This was PATCH 7 in previous series)
- PATCH 1:
 * avoid introducing new macros and use 'bank'
   field of mtk_gc with register offset.
 * Make correct use of bgpio_init passing new
   void __iomem pointers instead of use the
   macros.
- Previous series PATCH 8 now is PATCH 7. Avoid the
  use of a switch-case statement which was wrong and
  distinc if we have RISSING AND FALLING EDGE interrupt
  or HIGH LOW level ones. This last two are exclusive and
  cannot be generated at the same time.

Hope this helps.

Thanks in advance.

Best regards,
Sergio Paracuellos


Sergio Paracuellos (18):
  staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC
  staging: mt7621-gpio: avoid including 'gpio.h'
  staging: mt7621-gpio: make use of 'builtin_platform_driver'
  staging: mt7621-gpio: implement '.irq_[request|release]_resources'
functions
  staging: mt7621-gpio: add COMPILE_TEST
  staging: mt7621-gpio: add kerneldoc for state data containers
  staging: mt7621-gpio: implement high level and low level irqs
  staging: mt7621-gpio: avoid custom irq_domain for gpio
  staging: mt7621-gpio: remove no more necessary PIN_MASK macro
  staging: mt7621-gpio: update kerneldoc for state containers
  staging: mt7621-gpio: align indentation for all defines
  staging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls
  staging: mt7621-gpio: avoid to set up irqs if not defined in dts
  staging: mt7621-gpio: avoid one level indentation in interrupt handler
  staging: mt7621-gpio: set different names for each gpio_chip and
irq_chip
  staging: mt7621-gpio: avoid long line in a comment
  staging: mt7621-gpio: update Kconfig with SoC details
  staging: mt7621-gpio: avoid use banks in device tree

 drivers/staging/mt7621-dts/gbpc1.dts   |  10 +-
 drivers/staging/mt7621-dts/mt7621.dtsi |  31 +-
 drivers/staging/mt7621-gpio/Kconfig|   8 +-
 drivers/staging/mt7621-gpio/gpio-mt7621.c  | 406 +
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   |  59 +--
 5 files changed, 205 insertions(+), 309 deletions(-)

-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 08/18] staging: mt7621-gpio: avoid custom irq_domain for gpio

2018-06-18 Thread Sergio Paracuellos
Instead of create a custom irq_domain for this chip, use
'gpiochip_set_chained_irqchip' from GPIOLIB_IRQCHIP. It
is ok to call this function several times. We have to
manually mark the line with 'IRQF_SHARED' and then loop
over the three banks until you find a hit. There were
some problems with removing an irqchip like that but this
driver is a bool so it might work just fine. After this
changes the functions 'mediatek_gpio_to_irq' is not needed
anymore and also the 'gpio_irq_domain' field from the state
container. Instead of use the custom irq domain in the irq
handler use the associated domain from the gpio_chip in
'irq_find_mapping' function. Function 'mediatek_gpio_bank_probe'
has been moved a it to the botton to have all the irq related
functions together and avoid some forward declarations to resolve
some symbols along the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig   |   1 +
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 221 +++---
 2 files changed, 81 insertions(+), 141 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index 835998a..e32facb 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -2,6 +2,7 @@ config GPIO_MT7621
bool "Mediatek GPIO Support"
depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
+   select GPIOLIB_IRQCHIP
select ARCH_REQUIRE_GPIOLIB
help
  Say yes here to support the Mediatek SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 0c344a5..d2a7512 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -8,7 +8,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -58,14 +57,12 @@ struct mtk_gc {
  * @dev: device instance
  * @gpio_membase: memory base address
  * @gpio_irq: irq number from the device tree
- * @gpio_irq_domain: irq domain for this chip
  * @gc_map: array of the gpio chips
  */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
-   struct irq_domain *gpio_irq_domain;
struct mtk_gc gc_map[MTK_BANK_CNT];
 };
 
@@ -95,98 +92,36 @@ mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
return gc->read_reg(gpio_data->gpio_membase + offset);
 }
 
-static int
-mediatek_gpio_to_irq(struct gpio_chip *chip, unsigned int pin)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(chip);
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return irq_create_mapping(gpio_data->gpio_irq_domain,
- pin + (rg->bank * MTK_BANK_WIDTH));
-}
-
-static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
-{
-   struct mtk_data *gpio = dev_get_drvdata(&pdev->dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
-   struct mtk_gc *rg;
-   void __iomem *dat, *set, *ctrl, *diro;
-   int ret;
-
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = &gpio->gc_map[be32_to_cpu(*id)];
-   memset(rg, 0, sizeof(*rg));
-
-   spin_lock_init(&rg->lock);
-   rg->chip.of_node = bank;
-   rg->bank = be32_to_cpu(*id);
-
-   dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
-   set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
-   ctrl = gpio->gpio_membase + GPIO_REG_DCLR + (rg->bank * GPIO_BANK_WIDE);
-   diro = gpio->gpio_membase + GPIO_REG_CTRL + (rg->bank * GPIO_BANK_WIDE);
-
-   ret = bgpio_init(&rg->chip, &pdev->dev, 4,
-dat, set, ctrl, diro, NULL, 0);
-   if (ret) {
-   dev_err(&pdev->dev, "bgpio_init() failed\n");
-   return ret;
-   }
-
-   if (gpio->gpio_irq_domain)
-   rg->chip.to_irq = mediatek_gpio_to_irq;
-
-   ret = devm_gpiochip_add_data(&pdev->dev, &rg->chip, gpio);
-   if (ret < 0) {
-   dev_err(&pdev->dev, "Could not register gpio %d, ret=%d\n",
-   rg->chip.ngpio, ret);
-   return ret;
-   }
-
-   /* set polarity to low for all gpios */
-   mtk_gpio_w32(rg, GPIO_REG_POL, 0);
-
-   dev_info(&pdev->dev, "registering %d gpios\n", rg->chip.ngpio);
-
-   return 0;
-}
-
-static void
-mediatek_gpio_irq_handler(struct irq_desc *desc)
+static irqreturn_t
+mediatek_gpio_irq_handler(int irq, void *data)
 {
-   struct mtk_data *gpio_data = irq_desc_get_handler_data(desc);
-   int i;
-
-   for (i = 0; i < MTK_BANK_CNT; i++) {
-   struct mtk_gc *rg = &gpio_data->gc_map[i];
-   unsigned long pending;
-   int bit;
-
-   if (!rg)
-   continue;
+   struct gpio_chip *gc = data;
+   struct mtk_gc *rg = to_medi

[PATCH v5 05/18] staging: mt7621-gpio: add COMPILE_TEST

2018-06-18 Thread Sergio Paracuellos
This driver is actually platform-agnostic.  Add COMPILE_TEST for
the compilation test coverage.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index f4453e8..835998a 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -1,6 +1,6 @@
 config GPIO_MT7621
bool "Mediatek GPIO Support"
-   depends on SOC_MT7620 || SOC_MT7621
+   depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
select ARCH_REQUIRE_GPIOLIB
help
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 01/18] staging: mt7621-gpio: make use 'bgpio_init' from GPIO_GENERIC

2018-06-18 Thread Sergio Paracuellos
Gpio complexity is just masking the fact that offset is always
0..n and writes to bits 0..n of some memory address. Because
of this whole thing can just me converted to use GPIO_GENERIC
and avoid duplications of a lot of driver custom functions.
So use bgpio_init instead of custom code adding GPIO_GENERIC
dependency to the Kconfig file. Also to make easier using
bgpio_init function offset for each gpio bank, enumeration
where register were defined has been replaced in favour of
some macros which handle each gpio offset taking into account
the bank where are located. Because of this change write and
read functions which are being used for remaining irq handling
stuff have been updated also as well as its dependencies along
the code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig   |   1 +
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 136 +-
 2 files changed, 42 insertions(+), 95 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index c741ec3..f4453e8 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -1,6 +1,7 @@
 config GPIO_MT7621
bool "Mediatek GPIO Support"
depends on SOC_MT7620 || SOC_MT7621
+   select GPIO_GENERIC
select ARCH_REQUIRE_GPIOLIB
help
  Say yes here to support the Mediatek SoC GPIO device
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 0c4fb4a..eb60dd4 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -19,19 +19,18 @@
 #define MTK_BANK_WIDTH 32
 #define PIN_MASK(nr)   (1UL << ((nr % MTK_BANK_WIDTH)))
 
-enum mediatek_gpio_reg {
-   GPIO_REG_CTRL = 0,
-   GPIO_REG_POL,
-   GPIO_REG_DATA,
-   GPIO_REG_DSET,
-   GPIO_REG_DCLR,
-   GPIO_REG_REDGE,
-   GPIO_REG_FEDGE,
-   GPIO_REG_HLVL,
-   GPIO_REG_LLVL,
-   GPIO_REG_STAT,
-   GPIO_REG_EDGE,
-};
+#define GPIO_BANK_WIDE 0x04
+#define GPIO_REG_CTRL  0x00
+#define GPIO_REG_POL   0x10
+#define GPIO_REG_DATA  0x20
+#define GPIO_REG_DSET  0x30
+#define GPIO_REG_DCLR  0x40
+#define GPIO_REG_REDGE 0x50
+#define GPIO_REG_FEDGE 0x60
+#define GPIO_REG_HLVL  0x70
+#define GPIO_REG_LLVL  0x80
+#define GPIO_REG_STAT  0x90
+#define GPIO_REG_EDGE  0xA0
 
 struct mtk_gc {
struct gpio_chip chip;
@@ -55,80 +54,23 @@ to_mediatek_gpio(struct gpio_chip *chip)
 }
 
 static inline void
-mtk_gpio_w32(struct mtk_gc *rg, u8 reg, u32 val)
+mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val)
 {
-   struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip);
-   u32 offset = (reg * 0x10) + (rg->bank * 0x4);
+   struct gpio_chip *gc = &rg->chip;
+   struct mtk_data *gpio_data = gpiochip_get_data(gc);
 
-   iowrite32(val, gpio_data->gpio_membase + offset);
+   offset = (rg->bank * GPIO_BANK_WIDE) + offset;
+   gc->write_reg(gpio_data->gpio_membase + offset, val);
 }
 
 static inline u32
-mtk_gpio_r32(struct mtk_gc *rg, u8 reg)
-{
-   struct mtk_data *gpio_data = gpiochip_get_data(&rg->chip);
-   u32 offset = (reg * 0x10) + (rg->bank * 0x4);
-
-   return ioread32(gpio_data->gpio_membase + offset);
-}
-
-static void
-mediatek_gpio_set(struct gpio_chip *chip, unsigned int offset, int value)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   mtk_gpio_w32(rg, (value) ? GPIO_REG_DSET : GPIO_REG_DCLR, BIT(offset));
-}
-
-static int
-mediatek_gpio_get(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-
-   return !!(mtk_gpio_r32(rg, GPIO_REG_DATA) & BIT(offset));
-}
-
-static int
-mediatek_gpio_direction_input(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   unsigned long flags;
-   u32 t;
-
-   spin_lock_irqsave(&rg->lock, flags);
-   t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
-   t &= ~BIT(offset);
-   mtk_gpio_w32(rg, GPIO_REG_CTRL, t);
-   spin_unlock_irqrestore(&rg->lock, flags);
-
-   return 0;
-}
-
-static int
-mediatek_gpio_direction_output(struct gpio_chip *chip,
-   unsigned int offset, int value)
+mtk_gpio_r32(struct mtk_gc *rg, u32 offset)
 {
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   unsigned long flags;
-   u32 t;
+   struct gpio_chip *gc = &rg->chip;
+   struct mtk_data *gpio_data = gpiochip_get_data(gc);
 
-   spin_lock_irqsave(&rg->lock, flags);
-   t = mtk_gpio_r32(rg, GPIO_REG_CTRL);
-   t |= BIT(offset);
-   mtk_gpio_w32(rg, GPIO_REG_CTRL, t);
-   mediatek_gpio_set(chip, offset, value);
-   spin_unlock_irqrestore(&rg->lock, flags);
-
-   return 0;
-}
-
-static int
-mediatek_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
-{
-   struct mtk_gc *rg = to_mediatek_gpio(chip);
-   u32 t = mtk_g

[PATCH v5 12/18] staging: mt7621-gpio: avoid check for NULL in 'to_mediatek_gpio' calls

2018-06-18 Thread Sergio Paracuellos
Function 'to_mediatek_gpio' cannot return NULL, so this NULL
checkings are pointless.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 9 -
 1 file changed, 9 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 853817a..1318003 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -115,9 +115,6 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
unsigned long flags;
u32 rise, fall, high, low;
 
-   if (!rg)
-   return;
-
spin_lock_irqsave(&rg->lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
@@ -139,9 +136,6 @@ mediatek_gpio_irq_mask(struct irq_data *d)
unsigned long flags;
u32 rise, fall, high, low;
 
-   if (!rg)
-   return;
-
spin_lock_irqsave(&rg->lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
@@ -162,9 +156,6 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
int pin = d->hwirq;
u32 mask = BIT(pin);
 
-   if (!rg)
-   return -1;
-
if (type == IRQ_TYPE_PROBE) {
if ((rg->rising | rg->falling |
 rg->hlevel | rg->llevel) & mask)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 04/18] staging: mt7621-gpio: implement '.irq_[request|release]_resources' functions

2018-06-18 Thread Sergio Paracuellos
When implementing custom irqchips it is important to also
implement .irq_request_resources() and .irq_release_resources()
and make sure these call gpiochip_[un]lock_as_irq().
Add those two for this driver. Also store struct device pointer
in global state structure to be able to use 'dev_err' with the
device from 'mediatek_request_resources' function.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 +++
 1 file changed, 37 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 6a31f60..e5a7979 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -40,6 +40,7 @@ struct mtk_gc {
 };
 
 struct mtk_data {
+   struct device *dev;
void __iomem *gpio_membase;
int gpio_irq;
struct irq_domain *gpio_irq_domain;
@@ -231,12 +232,42 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
return 0;
 }
 
+static int mediatek_irq_reqres(struct irq_data *d)
+{
+   struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
+   int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH;
+   struct mtk_gc *rg = &gpio_data->gc_map[bank];
+   struct gpio_chip *gc = &rg->chip;
+   int ret;
+
+   ret = gpiochip_lock_as_irq(gc, irqd_to_hwirq(d));
+   if (ret) {
+   dev_err(gpio_data->dev, "unable to lock HW IRQ %lu for IRQ\n",
+   irqd_to_hwirq(d));
+   return -EINVAL;
+   }
+
+   return 0;
+}
+
+static void mediatek_irq_relres(struct irq_data *d)
+{
+   struct mtk_data *gpio_data = irq_data_get_irq_chip_data(d);
+   int bank = irqd_to_hwirq(d) / MTK_BANK_WIDTH;
+   struct mtk_gc *rg = &gpio_data->gc_map[bank];
+   struct gpio_chip *gc = &rg->chip;
+
+   gpiochip_unlock_as_irq(gc, irqd_to_hwirq(d));
+}
+
 static struct irq_chip mediatek_gpio_irq_chip = {
-   .name   = "GPIO",
-   .irq_unmask = mediatek_gpio_irq_unmask,
-   .irq_mask   = mediatek_gpio_irq_mask,
-   .irq_mask_ack   = mediatek_gpio_irq_mask,
-   .irq_set_type   = mediatek_gpio_irq_type,
+   .name   = "GPIO",
+   .irq_unmask = mediatek_gpio_irq_unmask,
+   .irq_mask   = mediatek_gpio_irq_mask,
+   .irq_mask_ack   = mediatek_gpio_irq_mask,
+   .irq_set_type   = mediatek_gpio_irq_type,
+   .irq_request_resources  = mediatek_irq_reqres,
+   .irq_release_resources  = mediatek_irq_relres,
 };
 
 static int
@@ -284,6 +315,7 @@ mediatek_gpio_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "irq_domain_add_linear failed\n");
}
 
+   gpio_data->dev = &pdev->dev;
platform_set_drvdata(pdev, gpio_data);
 
for_each_child_of_node(np, bank)
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 06/18] staging: mt7621-gpio: add kerneldoc for state data containers

2018-06-18 Thread Sergio Paracuellos
This commit adds kerneldoc for the two data containers in
order to better understanding of its existence.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index e5a7979..54c18c1 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -31,6 +31,14 @@
 #define GPIO_REG_STAT  0x90
 #define GPIO_REG_EDGE  0xA0
 
+/**
+ * struct mtk_gc - data for a single gpio-chip
+ * @chip: gpio chip instance
+ * @lock: spinlock to protect the chip
+ * @bank: gpio bank number for the chip
+ * @rising: mask for rising irqs
+ * @falling: mask for falling irqs
+ */
 struct mtk_gc {
struct gpio_chip chip;
spinlock_t lock;
@@ -39,6 +47,16 @@ struct mtk_gc {
u32 falling;
 };
 
+/**
+ * struct mtk_data - state container for
+ * data of the platform driver. It is a
+ * single irq-chip but 3 separate gpio-chip.
+ * @dev: device instance
+ * @gpio_membase: memory base address
+ * @gpio_irq: irq number from the device tree
+ * @gpio_irq_domain: irq domain for this chip
+ * @gc_map: array of the gpio chips
+ */
 struct mtk_data {
struct device *dev;
void __iomem *gpio_membase;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 03/18] staging: mt7621-gpio: make use of 'builtin_platform_driver'

2018-06-18 Thread Sergio Paracuellos
This driver was being registered using 'module_platform_driver'
but it is not a module at all. Instead of this use
'builtin_platform_driver' which seems to be the correct one.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index f95310c..6a31f60 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -312,4 +312,4 @@ static struct platform_driver mediatek_gpio_driver = {
},
 };
 
-module_platform_driver(mediatek_gpio_driver);
+builtin_platform_driver(mediatek_gpio_driver);
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 02/18] staging: mt7621-gpio: avoid including 'gpio.h'

2018-06-18 Thread Sergio Paracuellos
Including file '' should be avoided in
new drivers code, so just remove it because it is
no necessary at all.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index eb60dd4..f95310c 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -5,7 +5,6 @@
  */
 
 #include 
-#include 
 #include 
 #include 
 #include 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 11/18] staging: mt7621-gpio: align indentation for all defines

2018-06-18 Thread Sergio Paracuellos
There was two remaining defines which weren't properly
aligned with the rest. Align them improving readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 5f7d524c..853817a 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -13,8 +13,8 @@
 #include 
 #include 
 
-#define MTK_BANK_CNT   3
-#define MTK_BANK_WIDTH 32
+#define MTK_BANK_CNT   3
+#define MTK_BANK_WIDTH 32
 
 #define GPIO_BANK_WIDE 0x04
 #define GPIO_REG_CTRL  0x00
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 18/18] staging: mt7621-gpio: avoid use banks in device tree

2018-06-18 Thread Sergio Paracuellos
Banks shouldn't be defined in DT if number of resources
per bank is not variable. We actually know that this SoC
has three banks so take that into account in order to don't
overspecify the device tree. Device tree will only have one
node making it simple. Update device tree, binding doc and
code accordly.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-dts/gbpc1.dts   | 10 ++--
 drivers/staging/mt7621-dts/mt7621.dtsi | 31 ++--
 drivers/staging/mt7621-gpio/gpio-mt7621.c  | 21 
 .../staging/mt7621-gpio/mediatek,mt7621-gpio.txt   | 59 +-
 4 files changed, 31 insertions(+), 90 deletions(-)

diff --git a/drivers/staging/mt7621-dts/gbpc1.dts 
b/drivers/staging/mt7621-dts/gbpc1.dts
index 6b13d85..352945d 100644
--- a/drivers/staging/mt7621-dts/gbpc1.dts
+++ b/drivers/staging/mt7621-dts/gbpc1.dts
@@ -32,7 +32,7 @@
 
reset {
label = "reset";
-   gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>;
+   gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
linux,code = ;
};
};
@@ -42,22 +42,22 @@
 
system {
label = "gb-pc1:green:system";
-   gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
};
 
status {
label = "gb-pc1:green:status";
-   gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
};
 
lan1 {
label = "gb-pc1:green:lan1";
-   gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 24 GPIO_ACTIVE_LOW>;
};
 
lan2 {
label = "gb-pc1:green:lan2";
-   gpios = <&gpio0 25 GPIO_ACTIVE_LOW>;
+   gpios = <&gpio 25 GPIO_ACTIVE_LOW>;
};
};
 };
diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index acb6b8c..02746af 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -61,37 +61,14 @@
};
 
gpio: gpio@600 {
-   #address-cells = <1>;
-   #size-cells = <0>;
-
+   #gpio-cells = <2>;
+   #interrupt-cells = <2>;
compatible = "mediatek,mt7621-gpio";
+   gpio-controller;
+   interrupt-controller;
reg = <0x600 0x100>;
-
interrupt-parent = <&gic>;
interrupts = ;
-   interrupt-controller;
-   #interrupt-cells = <2>;
-
-   gpio0: bank@0 {
-   reg = <0>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   gpio1: bank@1 {
-   reg = <1>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
-
-   gpio2: bank@2 {
-   reg = <2>;
-   compatible = "mediatek,mt7621-gpio-bank";
-   gpio-controller;
-   #gpio-cells = <2>;
-   };
};
 
i2c: i2c@900 {
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 9a4a12f..281e621 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -206,23 +206,20 @@ static inline const char * const 
mediatek_gpio_bank_name(int bank)
 }
 
 static int
-mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
+mediatek_gpio_bank_probe(struct platform_device *pdev,
+struct device_node *node, int bank)
 {
struct mtk_data *gpio = dev_get_drvdata(&pdev->dev);
-   const __be32 *id = of_get_property(bank, "reg", NULL);
struct mtk_gc *rg;
void __iomem *dat, *set, *ctrl, *diro;
int ret;
 
-   if (!id || be32_to_cpu(*id) >= MTK_BANK_CNT)
-   return -EINVAL;
-
-   rg = &gpio->gc_map[be32_to_cpu(*id)];
+   rg = &gpio->gc_map[bank];
memset(rg, 0, sizeof(*rg));
 
spin_lock_init(&rg->lock);
-   rg->chip.of_node = bank;
-   rg->bank = be32_to_cpu(*id);
+   rg->chip.of_node = node;
+   rg->bank = bank;
rg->chip.label = mediatek_gpio_bank_nam

[PATCH v5 13/18] staging: mt7621-gpio: avoid to set up irqs if not defined in dts

2018-06-18 Thread Sergio Paracuellos
If there is no interrupt defined in the dts 'irq_of_parse_and_map'
returns 0 and we should't set up interrupts for each gpio chip in
that case.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 42 ---
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 1318003..96dee10 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -237,30 +237,32 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
return ret;
}
 
-   /*
-* Manually request the irq here instead of passing a flow-handler
-* to gpiochip_set_chained_irqchip, because the irq is shared.
-*/
-   ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
-  mediatek_gpio_irq_handler, IRQF_SHARED,
-  "mt7621", &rg->chip);
+   if (gpio->gpio_irq) {
+   /*
+* Manually request the irq here instead of passing a 
flow-handler
+* to gpiochip_set_chained_irqchip, because the irq is shared.
+*/
+   ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
+  mediatek_gpio_irq_handler, IRQF_SHARED,
+  "mt7621", &rg->chip);
+
+   if (ret) {
+   dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n",
+   gpio->gpio_irq, ret);
+   return ret;
+   }
 
-   if (ret) {
-   dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n",
-   gpio->gpio_irq, ret);
-   return ret;
-   }
+   ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
+  0, handle_simple_irq, IRQ_TYPE_NONE);
+   if (ret) {
+   dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n");
+   return ret;
+   }
 
-   ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
-  0, handle_simple_irq, IRQ_TYPE_NONE);
-   if (ret) {
-   dev_err(&pdev->dev, "failed to add gpiochip_irqchip\n");
-   return ret;
+   gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip,
+gpio->gpio_irq, NULL);
}
 
-   gpiochip_set_chained_irqchip(&rg->chip, &mediatek_gpio_irq_chip,
-gpio->gpio_irq, NULL);
-
/* set polarity to low for all gpios */
mtk_gpio_w32(rg, GPIO_REG_POL, 0);
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 16/18] staging: mt7621-gpio: avoid long line in a comment

2018-06-18 Thread Sergio Paracuellos
Checkpatch script is complaining about a comment line
which exceeds 80 characteres. Just silence it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 63fb5a1..9a4a12f 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -246,8 +246,9 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
 
if (gpio->gpio_irq) {
/*
-* Manually request the irq here instead of passing a 
flow-handler
-* to gpiochip_set_chained_irqchip, because the irq is shared.
+* Manually request the irq here instead of passing
+* a flow-handler to gpiochip_set_chained_irqchip,
+* because the irq is shared.
 */
ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
   mediatek_gpio_irq_handler, IRQF_SHARED,
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 17/18] staging: mt7621-gpio: update Kconfig with SoC details

2018-06-18 Thread Sergio Paracuellos
Kconfig is using a generic 'Mediatek GPIO Support' in
description and help which is not specific at all about
the current SoC which is MT7621. Update it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/Kconfig 
b/drivers/staging/mt7621-gpio/Kconfig
index e32facb..5485dd2 100644
--- a/drivers/staging/mt7621-gpio/Kconfig
+++ b/drivers/staging/mt7621-gpio/Kconfig
@@ -1,8 +1,8 @@
 config GPIO_MT7621
-   bool "Mediatek GPIO Support"
+   bool "Mediatek MT7621 GPIO Support"
depends on SOC_MT7620 || SOC_MT7621 || COMPILE_TEST
select GPIO_GENERIC
select GPIOLIB_IRQCHIP
select ARCH_REQUIRE_GPIOLIB
help
- Say yes here to support the Mediatek SoC GPIO device
+ Say yes here to support the Mediatek MT7621 SoC GPIO device
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 07/18] staging: mt7621-gpio: implement high level and low level irqs

2018-06-18 Thread Sergio Paracuellos
This chip support high level and low level interrupts. Those
have to be implemented also to get a complete and clean driver.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 47 ---
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 54c18c1..0c344a5 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -38,6 +38,8 @@
  * @bank: gpio bank number for the chip
  * @rising: mask for rising irqs
  * @falling: mask for falling irqs
+ * @hlevel: mask for high level irqs
+ * @llevel: mask for low level irqs
  */
 struct mtk_gc {
struct gpio_chip chip;
@@ -45,6 +47,8 @@ struct mtk_gc {
int bank;
u32 rising;
u32 falling;
+   u32 hlevel;
+   u32 llevel;
 };
 
 /**
@@ -184,7 +188,7 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = &gpio_data->gc_map[bank];
unsigned long flags;
-   u32 rise, fall;
+   u32 rise, fall, high, low;
 
if (!rg)
return;
@@ -192,8 +196,12 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
spin_lock_irqsave(&rg->lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
+   high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
+   low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising));
mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel));
spin_unlock_irqrestore(&rg->lock, flags);
 }
 
@@ -205,7 +213,7 @@ mediatek_gpio_irq_mask(struct irq_data *d)
int bank = pin / MTK_BANK_WIDTH;
struct mtk_gc *rg = &gpio_data->gc_map[bank];
unsigned long flags;
-   u32 rise, fall;
+   u32 rise, fall, high, low;
 
if (!rg)
return;
@@ -213,8 +221,12 @@ mediatek_gpio_irq_mask(struct irq_data *d)
spin_lock_irqsave(&rg->lock, flags);
rise = mtk_gpio_r32(rg, GPIO_REG_REDGE);
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
+   high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
+   low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin));
mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin));
spin_unlock_irqrestore(&rg->lock, flags);
 }
 
@@ -231,21 +243,36 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
return -1;
 
if (type == IRQ_TYPE_PROBE) {
-   if ((rg->rising | rg->falling) & mask)
+   if ((rg->rising | rg->falling |
+rg->hlevel | rg->llevel) & mask)
return 0;
 
type = IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING;
}
 
-   if (type & IRQ_TYPE_EDGE_RISING)
-   rg->rising |= mask;
-   else
-   rg->rising &= ~mask;
+   rg->rising &= ~mask;
+   rg->falling &= ~mask;
+   rg->hlevel &= ~mask;
+   rg->llevel &= ~mask;
 
-   if (type & IRQ_TYPE_EDGE_FALLING)
+   switch (type & IRQ_TYPE_SENSE_MASK) {
+   case IRQ_TYPE_EDGE_BOTH:
+   rg->rising |= mask;
rg->falling |= mask;
-   else
-   rg->falling &= ~mask;
+   break;
+   case IRQ_TYPE_EDGE_RISING:
+   rg->rising |= mask;
+   break;
+   case IRQ_TYPE_EDGE_FALLING:
+   rg->falling |= mask;
+   break;
+   case IRQ_TYPE_LEVEL_HIGH:
+   rg->hlevel |= mask;
+   break;
+   case IRQ_TYPE_LEVEL_LOW:
+   rg->llevel |= mask;
+   break;
+   }
 
return 0;
 }
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 10/18] staging: mt7621-gpio: update kerneldoc for state containers

2018-06-18 Thread Sergio Paracuellos
Update kernel doc for mtk_data and also remove no needed
documentation for mtk_gc which is clear enough to don't
need it.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 15 +++
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index a8893e8..5f7d524c 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -29,16 +29,6 @@
 #define GPIO_REG_STAT  0x90
 #define GPIO_REG_EDGE  0xA0
 
-/**
- * struct mtk_gc - data for a single gpio-chip
- * @chip: gpio chip instance
- * @lock: spinlock to protect the chip
- * @bank: gpio bank number for the chip
- * @rising: mask for rising irqs
- * @falling: mask for falling irqs
- * @hlevel: mask for high level irqs
- * @llevel: mask for low level irqs
- */
 struct mtk_gc {
struct gpio_chip chip;
spinlock_t lock;
@@ -51,8 +41,9 @@ struct mtk_gc {
 
 /**
  * struct mtk_data - state container for
- * data of the platform driver. It is a
- * single irq-chip but 3 separate gpio-chip.
+ * data of the platform driver. It is 3
+ * separate gpio-chip each one with its
+ * own irq_chip.
  * @dev: device instance
  * @gpio_membase: memory base address
  * @gpio_irq: irq number from the device tree
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 09/18] staging: mt7621-gpio: remove no more necessary PIN_MASK macro

2018-06-18 Thread Sergio Paracuellos
PIN_MASK macro was being used because of the fact we were only
using one interrupt controller for all of the gpio chips. This
has been changed to use one per gpio chip and each has 32 irqs.
Because of this this macro is not needed anymore. Use BIT macro
instead.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 19 +--
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index d2a7512..a8893e8 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -15,7 +15,6 @@
 
 #define MTK_BANK_CNT   3
 #define MTK_BANK_WIDTH 32
-#define PIN_MASK(nr)   (1UL << ((nr % MTK_BANK_WIDTH)))
 
 #define GPIO_BANK_WIDE 0x04
 #define GPIO_REG_CTRL  0x00
@@ -133,10 +132,10 @@ mediatek_gpio_irq_unmask(struct irq_data *d)
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
-   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (PIN_MASK(pin) & rg->rising));
-   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (PIN_MASK(pin) & rg->falling));
-   mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (PIN_MASK(pin) & rg->hlevel));
-   mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (PIN_MASK(pin) & rg->llevel));
+   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise | (BIT(pin) & rg->rising));
+   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall | (BIT(pin) & rg->falling));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high | (BIT(pin) & rg->hlevel));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low | (BIT(pin) & rg->llevel));
spin_unlock_irqrestore(&rg->lock, flags);
 }
 
@@ -157,10 +156,10 @@ mediatek_gpio_irq_mask(struct irq_data *d)
fall = mtk_gpio_r32(rg, GPIO_REG_FEDGE);
high = mtk_gpio_r32(rg, GPIO_REG_HLVL);
low = mtk_gpio_r32(rg, GPIO_REG_LLVL);
-   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~PIN_MASK(pin));
-   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~PIN_MASK(pin));
-   mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~PIN_MASK(pin));
-   mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~PIN_MASK(pin));
+   mtk_gpio_w32(rg, GPIO_REG_FEDGE, fall & ~BIT(pin));
+   mtk_gpio_w32(rg, GPIO_REG_REDGE, rise & ~BIT(pin));
+   mtk_gpio_w32(rg, GPIO_REG_HLVL, high & ~BIT(pin));
+   mtk_gpio_w32(rg, GPIO_REG_LLVL, low & ~BIT(pin));
spin_unlock_irqrestore(&rg->lock, flags);
 }
 
@@ -170,7 +169,7 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct mtk_gc *rg = to_mediatek_gpio(gc);
int pin = d->hwirq;
-   u32 mask = PIN_MASK(pin);
+   u32 mask = BIT(pin);
 
if (!rg)
return -1;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 14/18] staging: mt7621-gpio: avoid one level indentation in interrupt handler

2018-06-18 Thread Sergio Paracuellos
There is no need to check for 'pending' before loop over the
interrupts using 'for_each_set_bit' if nothing is set the
return values will be the same so just avoid this check avoiding
also one level intentation and improving readability.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 12 +---
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 96dee10..698a95d 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -93,14 +93,12 @@ mediatek_gpio_irq_handler(int irq, void *data)
 
pending = mtk_gpio_r32(rg, GPIO_REG_STAT);
 
-   if (pending) {
-   for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) {
-   u32 map = irq_find_mapping(gc->irq.domain, bit);
+   for_each_set_bit(bit, &pending, MTK_BANK_WIDTH) {
+   u32 map = irq_find_mapping(gc->irq.domain, bit);
 
-   generic_handle_irq(map);
-   mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit));
-   ret |= IRQ_HANDLED;
-   }
+   generic_handle_irq(map);
+   mtk_gpio_w32(rg, GPIO_REG_STAT, BIT(bit));
+   ret |= IRQ_HANDLED;
}
 
return ret;
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v5 15/18] staging: mt7621-gpio: set different names for each gpio_chip and irq_chip

2018-06-18 Thread Sergio Paracuellos
Currently the driver defines 3 gpiochips, one for each bank.

/sys/class/gpio/gpiochip416/label:1e000600.gpio
/sys/class/gpio/gpiochip448/label:1e000600.gpio
/sys/class/gpio/gpiochip480/label:1e000600.gpio

Unfortunately they all have the same label

Interrupts from /proc/interrupt show the same name which is
confusing:

/proc/interrupts:

17: 0  0  0  0  MIPS GIC  19  mt7621, mt7621, mt7621

which is the interrupt from the GPIO controller.
It is a little weird that all three banks are named "mt7621"
here. We also have:

26: 0  0  0  0  GPIO  18  reset

which is the interrupt from GPIO which provides the "reset"
button. I suspect that if I had interrupts form two different
banks they would both be called "GPIO" which would be a little
confusing.

In order to unify all of this set different names for each chip
Use a 'bank-based' name instead the same for all: 'mt7621-bank[0-2]'.
Create a new 'mediatek_gpio_bank_name' function which return the
name depending on the bank number. This function is allways called
with a valid index 0, 1 or 2.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index 698a95d..63fb5a1 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -190,13 +190,21 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int 
type)
 }
 
 static struct irq_chip mediatek_gpio_irq_chip = {
-   .name   = "GPIO",
.irq_unmask = mediatek_gpio_irq_unmask,
.irq_mask   = mediatek_gpio_irq_mask,
.irq_mask_ack   = mediatek_gpio_irq_mask,
.irq_set_type   = mediatek_gpio_irq_type,
 };
 
+static inline const char * const mediatek_gpio_bank_name(int bank)
+{
+   static const char * const bank_names[] = {
+   "mt7621-bank0", "mt7621-bank1", "mt7621-bank2",
+   };
+
+   return bank_names[bank];
+}
+
 static int
 mediatek_gpio_bank_probe(struct platform_device *pdev, struct device_node 
*bank)
 {
@@ -215,6 +223,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
spin_lock_init(&rg->lock);
rg->chip.of_node = bank;
rg->bank = be32_to_cpu(*id);
+   rg->chip.label = mediatek_gpio_bank_name(rg->bank);
 
dat = gpio->gpio_membase + GPIO_REG_DATA + (rg->bank * GPIO_BANK_WIDE);
set = gpio->gpio_membase + GPIO_REG_DSET + (rg->bank * GPIO_BANK_WIDE);
@@ -242,7 +251,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
 */
ret = devm_request_irq(&pdev->dev, gpio->gpio_irq,
   mediatek_gpio_irq_handler, IRQF_SHARED,
-  "mt7621", &rg->chip);
+  rg->chip.label, &rg->chip);
 
if (ret) {
dev_err(&pdev->dev, "Error requesting IRQ %d: %d\n",
@@ -250,6 +259,7 @@ mediatek_gpio_bank_probe(struct platform_device *pdev, 
struct device_node *bank)
return ret;
}
 
+   mediatek_gpio_irq_chip.name = rg->chip.label;
ret = gpiochip_irqchip_add(&rg->chip, &mediatek_gpio_irq_chip,
   0, handle_simple_irq, IRQ_TYPE_NONE);
if (ret) {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


INVESTMENT

2018-06-18 Thread RICHARD LAWRENCE
Hello
 
We are international business advisors operating with the European Community.
At this moment, we have a mandate from one of our international client seeking 
offshore investment in any suitable country with flexible tax laws.
If you are interested, kindly contact us for more information on available 
funds and possibility of working together.
Yours Faithfully,
Mr.Richard Lawrence
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: pi433: fix race condition in pi433_open

2018-06-18 Thread Dan Carpenter
On Sun, Jun 17, 2018 at 10:24:00PM -0400, Hugo Lefeuvre wrote:
> Whenever pi433_open and pi433_remove execute concurrently, a race
> condition potentially resulting in use-after-free might happen.
> 
> Let T1 and T2 be two kernel threads.
> 
> 1. T1 executes pi433_open and stops before "device->users++".
> 2. The pi433 device was removed inbetween, so T2 executes pi433_remove
>and frees device because the user count has not been incremented yet.
> 3. T1 executes "device->users++" (use-after-free).
> 
> This race condition happens because the check of minor number and
> user count increment does not happen atomically.
> 
> Fix: Extend scope of minor_lock in pi433_open().
> 
> Signed-off-by: Hugo Lefeuvre 
> ---
>  drivers/staging/pi433/pi433_if.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/pi433/pi433_if.c 
> b/drivers/staging/pi433/pi433_if.c
> index 94e0bfcec991..73c511249f7f 100644
> --- a/drivers/staging/pi433/pi433_if.c
> +++ b/drivers/staging/pi433/pi433_if.c
> @@ -957,11 +957,13 @@ static int pi433_open(struct inode *inode, struct file 
> *filp)
>  
>   mutex_lock(&minor_lock);
>   device = idr_find(&pi433_idr, iminor(inode));
> - mutex_unlock(&minor_lock);
>   if (!device) {
> + mutex_unlock(&minor_lock);
>   pr_debug("device: minor %d unknown.\n", iminor(inode));
>   return -ENODEV;
>   }
> + device->users++;
> + mutex_unlock(&minor_lock);
>  
>   if (!device->rx_buffer) {
>   device->rx_buffer = kmalloc(MAX_MSG_SIZE, GFP_KERNEL);

We need to decrement device->users-- on the error paths as well.
This function was already slightly broken with respect to counting the
users, but let's not make it worse.

I think it's still a tiny bit racy because it's not an atomic type.

I'm not sure the error handling in open() works either.  It's releasing
device->rx_buffer but there could be another user.  The ->rx_buffer
should be allocated in probe() instead of open() probably, no?  And then
freed in pi433_remove().  Then once we put that in the right layer
it means we can just get rid of ->users...

The lines:

  1008  if (!device->spi)
  1009  kfree(device);

make no sort of sense at all...  Fortunately it's not posssible for
device->spi to be NULL so it's dead code.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: fbtft: Add missing blank line after function definition

2018-06-18 Thread Greg KH
On Mon, Jun 18, 2018 at 04:57:41PM +0530, Jay Buddhabhatti wrote:
> Reslove checkpatch warnings by adding missing blank line after
> function definition.
> 
> Signed-off-by: Jay Buddhabhatti 
> ---
>  drivers/staging/fbtft/fb_s6d1121.c | 1 +
>  drivers/staging/fbtft/fb_ssd1289.c | 1 +
>  drivers/staging/fbtft/fb_st7735r.c | 1 +
>  3 files changed, 3 insertions(+)
> 
> diff --git a/drivers/staging/fbtft/fb_s6d1121.c 
> b/drivers/staging/fbtft/fb_s6d1121.c
> index b902442..b0c7a77 100644
> --- a/drivers/staging/fbtft/fb_s6d1121.c
> +++ b/drivers/staging/fbtft/fb_s6d1121.c
> @@ -154,6 +154,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves)
>  
>   return 0;
>  }
> +
>  #undef CURVE
>  
>  static struct fbtft_display display = {

There already is a blank line here, no need to add another one.  Looks
like checkpatch.pl is being a bit too over-eager here, sorry.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: fbtft: Add missing blank line after function definition

2018-06-18 Thread Jay Buddhabhatti
Reslove checkpatch warnings by adding missing blank line after
function definition.

Signed-off-by: Jay Buddhabhatti 
---
 drivers/staging/fbtft/fb_s6d1121.c | 1 +
 drivers/staging/fbtft/fb_ssd1289.c | 1 +
 drivers/staging/fbtft/fb_st7735r.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/staging/fbtft/fb_s6d1121.c 
b/drivers/staging/fbtft/fb_s6d1121.c
index b902442..b0c7a77 100644
--- a/drivers/staging/fbtft/fb_s6d1121.c
+++ b/drivers/staging/fbtft/fb_s6d1121.c
@@ -154,6 +154,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves)
 
return 0;
 }
+
 #undef CURVE
 
 static struct fbtft_display display = {
diff --git a/drivers/staging/fbtft/fb_ssd1289.c 
b/drivers/staging/fbtft/fb_ssd1289.c
index cbf22e1..b35d5b2 100644
--- a/drivers/staging/fbtft/fb_ssd1289.c
+++ b/drivers/staging/fbtft/fb_ssd1289.c
@@ -153,6 +153,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves)
 
return 0;
 }
+
 #undef CURVE
 
 static struct fbtft_display display = {
diff --git a/drivers/staging/fbtft/fb_st7735r.c 
b/drivers/staging/fbtft/fb_st7735r.c
index 631208b..c2089f4 100644
--- a/drivers/staging/fbtft/fb_st7735r.c
+++ b/drivers/staging/fbtft/fb_st7735r.c
@@ -152,6 +152,7 @@ static int set_gamma(struct fbtft_par *par, u32 *curves)
 
return 0;
 }
+
 #undef CURVE
 
 static struct fbtft_display display = {
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 5/5] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

2018-06-18 Thread Kalle Valo
Greg KH  writes:

> On Mon, Jun 18, 2018 at 10:29:43AM +0300, Kalle Valo wrote:
>> Greg KH  writes:
>> 
>> > On Sun, Jun 17, 2018 at 01:07:36PM +0300, Omer Efrat wrote:
>> >> The BIT macro uses unsigned long which some architectures handle as 32 bit
>> >> and therefore might cause macro's shift to overflow when used on a value
>> >> equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).
>> >> 
>> >> Since 'filled' member in station_info changed to u64, BIT_ULL macro
>> >> should be used with all NL80211_STA_INFO_* attribute types instead of BIT
>> >> to prevent future possible bugs when one will use BIT macro for higher
>> >> attributes by mistake.
>> >> 
>> >> This commit cleans up all usages of BIT macro with the above field
>> >> in cfg80211 by changing it to BIT_ULL instead.
>> >> 
>> >> Signed-off-by: Omer Efrat 
>> >
>> > Acked-by: Greg Kroah-Hartman 
>> 
>> Via which tree is this supposed to go?
>
> Not mine :)
>
> Have fun with it!

Hehe :)

But I don't see why this patch 5 should go either to mac80211 or
wireless-drivers trees as there's no dependency or anything like that,
AFAIK it's just cleanup. So it would simplest to get this patch 5 to
staging tree, less conflicts that way.

Patches 1 and 2 of course go to mac80211 tree and patch 4 goes to
wireless-drivers.

-- 
Kalle Valo
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v3 5/5] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

2018-06-18 Thread Greg KH
On Mon, Jun 18, 2018 at 04:11:51PM +0300, Kalle Valo wrote:
> Greg KH  writes:
> 
> > On Mon, Jun 18, 2018 at 10:29:43AM +0300, Kalle Valo wrote:
> >> Greg KH  writes:
> >> 
> >> > On Sun, Jun 17, 2018 at 01:07:36PM +0300, Omer Efrat wrote:
> >> >> The BIT macro uses unsigned long which some architectures handle as 32 
> >> >> bit
> >> >> and therefore might cause macro's shift to overflow when used on a value
> >> >> equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).
> >> >> 
> >> >> Since 'filled' member in station_info changed to u64, BIT_ULL macro
> >> >> should be used with all NL80211_STA_INFO_* attribute types instead of 
> >> >> BIT
> >> >> to prevent future possible bugs when one will use BIT macro for higher
> >> >> attributes by mistake.
> >> >> 
> >> >> This commit cleans up all usages of BIT macro with the above field
> >> >> in cfg80211 by changing it to BIT_ULL instead.
> >> >> 
> >> >> Signed-off-by: Omer Efrat 
> >> >
> >> > Acked-by: Greg Kroah-Hartman 
> >> 
> >> Via which tree is this supposed to go?
> >
> > Not mine :)
> >
> > Have fun with it!
> 
> Hehe :)
> 
> But I don't see why this patch 5 should go either to mac80211 or
> wireless-drivers trees as there's no dependency or anything like that,
> AFAIK it's just cleanup. So it would simplest to get this patch 5 to
> staging tree, less conflicts that way.

Sorry, I thought it was dependant on the previous patches, given that
the first time I tried to apply it, it failed.

Omer, can you just resend this single patch to me and I will be glad to
apply it to the staging tree, if it really is stand-alone.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3 5/5] staging: use BIT_ULL for NL80211_STA_INFO_* attribute types

2018-06-18 Thread Omer Efrat
The BIT macro uses unsigned long which some architectures handle as 32 bit
and therefore might cause macro's shift to overflow when used on a value
equals or larger than 32 (NL80211_STA_INFO_RX_DURATION and afterwards).

Since 'filled' member in station_info changed to u64, BIT_ULL macro
should be used with all NL80211_STA_INFO_* attribute types instead of BIT
to prevent future possible bugs when one will use BIT macro for higher
attributes by mistake.

This commit cleans up all usages of BIT macro with the above field
in cfg80211 by changing it to BIT_ULL instead.

Signed-off-by: Omer Efrat 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 +-
 drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 14 +++---
 drivers/staging/wlan-ng/cfg80211.c|  4 ++--
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 02178e2..26b838f 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -1273,16 +1273,16 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy,
goto exit;
}
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
sinfo->signal = 
translate_percentage_to_dbm(padapter->recvpriv.signal_strength);
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
sinfo->txrate.legacy = rtw_get_cur_max_rate(padapter);
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_PACKETS);
sinfo->rx_packets = sta_rx_data_pkts(psta);
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_TX_PACKETS);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS);
sinfo->tx_packets = psta->sta_stats.tx_pkts;
 
}
@@ -3013,7 +3013,7 @@ static intcfg80211_rtw_dump_station(struct wiphy 
*wiphy, struct net_device *nde
goto exit;
}
memcpy(mac, psta->hwaddr, ETH_ALEN);
-   sinfo->filled = BIT(NL80211_STA_INFO_SIGNAL);
+   sinfo->filled = BIT_ULL(NL80211_STA_INFO_SIGNAL);
sinfo->signal = psta->rssi;
 
 exit:
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index e248702..13d3918 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1141,7 +1141,7 @@ static int get_station(struct wiphy *wiphy, struct 
net_device *dev,
return -ENOENT;
}
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_INACTIVE_TIME);
 
wilc_get_inactive_time(vif, mac, &inactive_time);
sinfo->inactive_time = 1000 * inactive_time;
@@ -1150,11 +1150,11 @@ static int get_station(struct wiphy *wiphy, struct 
net_device *dev,
 
wilc_get_statistics(vif, &stats);
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
-BIT(NL80211_STA_INFO_RX_PACKETS) |
-BIT(NL80211_STA_INFO_TX_PACKETS) |
-BIT(NL80211_STA_INFO_TX_FAILED) |
-BIT(NL80211_STA_INFO_TX_BITRATE);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL) |
+BIT_ULL(NL80211_STA_INFO_RX_PACKETS) |
+BIT_ULL(NL80211_STA_INFO_TX_PACKETS) |
+BIT_ULL(NL80211_STA_INFO_TX_FAILED) |
+BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
 
sinfo->signal = stats.rssi;
sinfo->rx_packets = stats.rx_cnt;
@@ -1775,7 +1775,7 @@ static int dump_station(struct wiphy *wiphy, struct 
net_device *dev,
priv = wiphy_priv(wiphy);
vif = netdev_priv(priv->dev);
 
-   sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_SIGNAL);
 
wilc_get_rssi(vif, &sinfo->signal);
 
diff --git a/drivers/staging/wlan-ng/cfg80211.c 
b/drivers/staging/wlan-ng/cfg80211.c
index 4291225..07c52e3 100644
--- a/drivers/staging/wlan-ng/cfg80211.c
+++ b/drivers/staging/wlan-ng/cfg80211.c
@@ -282,9 +282,9 @@ static int prism2_get_station(struct wiphy *wiphy, struct 
net_device *dev,
 
if (result == 0) {
sinfo->txrate.legacy = quality.txrate.data;
-   sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
+   sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE);
sinfo->signal = quality.level.data;
-   sinfo->filled |= 

Credit Suisse Bank London Dringend

2018-06-18 Thread Credit Suisse Bank London,England.
Guten Tag, wie geht es dir heute? Ich habe Ihre E-Mail-Adresse von Ihrem 
Länderverzeichnis erhalten und beschlossen, Sie bezüglich dieses 
Geschäftsvorschlags zu kontaktieren. Ich bin Mr.Chris Williams von der 
Investment Banking Abteilung der Credit Suisse Bank, One Cabot Square, London 
E14 4QJ, Großbritannien. Ich kontaktiere Sie bezüglich eines 
Geschäftsvorschlags, der für uns beide von immensem Nutzen sein wird.

In meiner Abteilung entdeckte ich eine verlassene Summe von £ 17,5 Millionen 
GBP (17 Millionen fünfhunderttausend Britische Pfund Sterling) auf einem Konto, 
das einem unserer ausländischen Kunden, Herrn Brodskii Nikolai, gehörte, einem 
russischen Geschäftsmann, der Opfer von der Malaysia Airlines Flug 370 (MH370 / 
MAS370), der am 8. März 2014 im Süden des Indischen Ozeans auf dem Weg vom 
internationalen Flughafen Kuala Lumpur zum internationalen Flughafen von 
Beijing abgestürzt ist und alle an Bord tötet.

Sehen Sie sich die Website für weitere Informationen an: 
http://www.bbc.com/news/world-asia-26503141


Seit seinem Tod hat unsere Bank darauf gewartet, dass die nächsten Angehörigen 
die Forderung nach seinen Geldern und Nachlässen in Höhe von £ 17,5 Millionen 
GBP geltend machen, aber niemand hat es getan, ich war persönlich bei der Suche 
nach einem seiner Verwandten erfolglos. Ich ersuche Sie, Ihre Einwilligung zu 
erteilen, Sie der Bank als nächsten Angehörigen des Verstorbenen vorzustellen, 
damit Ihnen der Erlös dieses Kontos im Wert von £ 17,5 Millionen GBP 
gutgeschrieben werden kann.

Der Deal wird in diesem Verhältnis geteilt: 55% für mich und 45% für Sie. Ich 
verfüge über alle notwendigen und wichtigen Dokumente, die in diesem Geschäft 
verwendet werden können. Ich brauche Ihre ehrliche Zusammenarbeit, 
Vertraulichkeit und Vertrauen, damit wir diese Transaktion sehen können. Ich 
garantiere Ihnen 100% igen Erfolg in diesem Geschäft, bitte seien Sie 
versichert, dass dieses Geschäft im Rahmen einer legitimen Vereinbarung 
ausgeführt wird, die Sie sowohl im Vereinigten Königreich als auch in Ihrem 
Land vor jeglichen Gesetzesverstößen schützt.

Wenn Sie in der Lage sind, diesen Deal zu bearbeiten, wenden Sie sich bitte mit 
den folgenden Details an mich, damit wir fortfahren können:

1. Dein voller Name:
2. Telefonnummer:
3. Kontaktadresse:
4. Alter:
5. Geschlecht:
6. Beruf:
7. Ihre Nationalität:

Nach einer methodischen Suche habe ich mich entschieden, Sie zu kontaktieren, 
in der Hoffnung, dass Sie diesen Vorschlag interessant finden. Bitte bestätigen 
Sie diese Nachricht und geben Sie Ihr Interesse an. Ich werde Sie mit weiteren 
Informationen versorgen.

Ihre Zustimmung zu diesem E-Mail- und Geschäftsvorschlag wird sehr geschätzt.

Freundliche Grüße,
Herr Chris Williams
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: rtsx: remove rtsx_trace() and related code

2018-06-18 Thread Dan Carpenter
> @@ -117,7 +112,6 @@ static int ms_transfer_data(struct rtsx_chip *chip, u8 
> trans_mode,
>   enum dma_data_direction dir;
>  
>   if (!buf || !buf_len) {
> - rtsx_trace(chip);
>   return STATUS_FAIL;
>   }
>  

You're introducing a bunch of checkpatch.pl warnings.  Normally we would
ask you to not do that...  I don't care too much because someone will
eventually fix it, but still...

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: rtl8723bs: remove get_monotonic_boottime()

2018-06-18 Thread Arnd Bergmann
get_monotonic_boottime() is deprecated because it uses the
old 'timespec' structure. This replaces one of the last callers
with a call to ktime_get_boottime, which also simplifies it
a bit by avoiding a double conversion.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 9 +
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
index 02178e25fbb8..73fc3a742f74 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c
@@ -233,13 +233,6 @@ static int rtw_ieee80211_channel_to_frequency(int chan, 
int band)
return 0; /* not supported */
 }
 
-static u64 rtw_get_systime_us(void)
-{
-   struct timespec ts;
-   get_monotonic_boottime(&ts);
-   return ((u64)ts.tv_sec*100) + ts.tv_nsec / 1000;
-}
-
 #define MAX_BSSINFO_LEN 1000
 struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct 
wlan_network *pnetwork)
 {
@@ -331,7 +324,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter 
*padapter, struct wl
 
notify_channel = ieee80211_get_channel(wiphy, freq);
 
-   notify_timestamp = rtw_get_systime_us();
+   notify_timestamp = ktime_to_us(ktime_get_boottime());
 
notify_interval = le16_to_cpu(*(__le16 
*)rtw_get_beacon_interval_from_ie(pnetwork->network.IEs));
notify_capability = le16_to_cpu(*(__le16 
*)rtw_get_capability_from_ie(pnetwork->network.IEs));
-- 
2.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: android/vsoc: stop using 'timespec'

2018-06-18 Thread Arnd Bergmann
The timespec structure suffers from the y2038 overflow and should not
be used. This changes handle_vsoc_cond_wait() to use ktime_t directly.

Signed-off-by: Arnd Bergmann 
---
 drivers/staging/android/vsoc.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/android/vsoc.c b/drivers/staging/android/vsoc.c
index 806beda1040b..22571abcaa4e 100644
--- a/drivers/staging/android/vsoc.c
+++ b/drivers/staging/android/vsoc.c
@@ -405,7 +405,7 @@ static int handle_vsoc_cond_wait(struct file *filp, struct 
vsoc_cond_wait *arg)
int ret = 0;
struct vsoc_device_region *region_p = vsoc_region_from_filep(filp);
atomic_t *address = NULL;
-   struct timespec ts;
+   ktime_t wake_time;
 
/* Ensure that the offset is aligned */
if (arg->offset & (sizeof(uint32_t) - 1))
@@ -433,14 +433,13 @@ static int handle_vsoc_cond_wait(struct file *filp, 
struct vsoc_cond_wait *arg)
 * We do things this way to flatten differences between 32 bit
 * and 64 bit timespecs.
 */
-   ts.tv_sec = arg->wake_time_sec;
-   ts.tv_nsec = arg->wake_time_nsec;
-
-   if (!timespec_valid(&ts))
+   if (arg->wake_time_nsec >= NSEC_PER_SEC)
return -EINVAL;
+   wake_time = ktime_set(arg->wake_time_sec, arg->wake_time_nsec);
+
hrtimer_init_on_stack(&to->timer, CLOCK_MONOTONIC,
  HRTIMER_MODE_ABS);
-   hrtimer_set_expires_range_ns(&to->timer, timespec_to_ktime(ts),
+   hrtimer_set_expires_range_ns(&to->timer, wake_time,
 current->timer_slack_ns);
 
hrtimer_init_sleeper(to, current);
-- 
2.9.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v3] staging:iio:accel:adis16240: sign extend function replace hard code duplication

2018-06-18 Thread Karim Eshapa
Use sign_extend32 kernel function instead of code duplication,
Safe also for 16 bit. and remove declaration of bits variable not needed.

Signed-off-by: Karim Eshapa 
---
 drivers/staging/iio/accel/adis16240.c | 11 ++-
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/iio/accel/adis16240.c 
b/drivers/staging/iio/accel/adis16240.c
index fff6d99089cc..24e525f1ef25 100644
--- a/drivers/staging/iio/accel/adis16240.c
+++ b/drivers/staging/iio/accel/adis16240.c
@@ -250,7 +250,6 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
 {
struct adis *st = iio_priv(indio_dev);
int ret;
-   int bits;
u8 addr;
s16 val16;
 
@@ -287,24 +286,18 @@ static int adis16240_read_raw(struct iio_dev *indio_dev,
*val = 25000 / 244 - 0x133; /* 25 C = 0x133 */
return IIO_VAL_INT;
case IIO_CHAN_INFO_CALIBBIAS:
-   bits = 10;
addr = adis16240_addresses[chan->scan_index][0];
ret = adis_read_reg_16(st, addr, &val16);
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, 9);
return IIO_VAL_INT;
case IIO_CHAN_INFO_PEAK:
-   bits = 10;
addr = adis16240_addresses[chan->scan_index][1];
ret = adis_read_reg_16(st, addr, &val16);
if (ret)
return ret;
-   val16 &= (1 << bits) - 1;
-   val16 = (s16)(val16 << (16 - bits)) >> (16 - bits);
-   *val = val16;
+   *val = sign_extend32(val16, 9);
return IIO_VAL_INT;
}
return -EINVAL;
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: board: drop refcount in success case

2018-06-18 Thread Nicholas Mc Guire
 The call to of_find_compatible_node() returns irqc_node with refcount
incremented thus it must be explicitly decremented here after it was
checked for non-NULL.

Signed-off-by: Nicholas Mc Guire 
Fixes: commit 72ee8626eeb1 ("staging: board: Add support for translating hwirq 
to virq numbers")
---

Problem located with an experimental coccinelle script

Patch was compile-tested with: x86_64_defconfig + STAGING=y, STAGING_BOARD=y

Patch is against 4.18-rc1 (localversion-next is next-20180618)

 drivers/staging/board/board.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c
index cb6feb3..8ee48e5 100644
--- a/drivers/staging/board/board.c
+++ b/drivers/staging/board/board.c
@@ -64,12 +64,13 @@ int __init board_staging_gic_setup_xlate(const char 
*gic_match,
irqc_node = of_find_compatible_node(NULL, NULL, gic_match);
 
WARN_ON(!irqc_node);
if (!irqc_node)
return -ENOENT;
 
+   of_node_put(irqc_node);
irqc_base = base;
return 0;
 }
 
 static void __init gic_fixup_resource(struct resource *res)
 {
-- 
2.1.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging:iio:adc:ad7816: Backward resources cleanups in probe

2018-06-18 Thread Karim Eshapa
Backward cleanups for all resources allocated in probing
in case of failure at any regestering or allocation step.

Signed-off-by: Karim Eshapa 
---
 drivers/staging/iio/adc/ad7816.c | 22 +-
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c
index bf76a8620bdb..5ff14c830451 100644
--- a/drivers/staging/iio/adc/ad7816.c
+++ b/drivers/staging/iio/adc/ad7816.c
@@ -373,7 +373,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
if (ret) {
dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n",
chip->rdwr_pin);
-   return ret;
+   goto device_free;
}
gpio_direction_input(chip->rdwr_pin);
ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin,
@@ -381,7 +381,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
if (ret) {
dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n",
chip->convert_pin);
-   return ret;
+   goto free_rdwr_pin;
}
gpio_direction_input(chip->convert_pin);
ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin,
@@ -389,7 +389,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
if (ret) {
dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n",
chip->busy_pin);
-   return ret;
+   goto free_convert_pin;
}
gpio_direction_input(chip->busy_pin);
 
@@ -407,17 +407,29 @@ static int ad7816_probe(struct spi_device *spi_dev)
indio_dev->name,
indio_dev);
if (ret)
-   return ret;
+   goto free_busy_pin;
}
 
ret = devm_iio_device_register(&spi_dev->dev, indio_dev);
if (ret)
-   return ret;
+   goto free_dev_irq;
 
dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n",
 indio_dev->name);
 
return 0;
+free_dev_irq:
+   devm_free_irq(&spi_dev->dev, spi_dev->irq, indio_dev);
+free_busy_pin:
+   devm_gpio_free(&spi_dev->dev, chip->busy_pin);
+free_convert_pin:
+   devm_gpio_free(&spi_dev->dev, chip->convert_pin);
+free_rdwr_pin:
+   devm_gpio_free(&spi_dev->dev, chip->rdwr_pin);
+device_free:
+   devm_iio_device_free(&spi_dev->dev, indio_dev);
+
+   return ret;
 }
 
 static const struct spi_device_id ad7816_id[] = {
-- 
2.17.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: Do Qualcomm drivers use DMA buffers for request_firmware_into_buf()?

2018-06-18 Thread Luis R. Rodriguez
On Thu, Jun 07, 2018 at 11:06:11AM -0700, Bjorn Andersson wrote:
> On Thu 07 Jun 09:23 PDT 2018, Ard Biesheuvel wrote:
> 
> > On 7 June 2018 at 18:18, Bjorn Andersson  wrote:
> > > On Wed 06 Jun 13:32 PDT 2018, Luis R. Rodriguez wrote:
> > >
> > >> On Fri, Jun 01, 2018 at 09:23:46PM +0200, Luis R. Rodriguez wrote:
> > >> > On Tue, May 08, 2018 at 03:38:05PM +, Luis R. Rodriguez wrote:
> > >> > > On Fri, May 04, 2018 at 12:44:37PM -0700, Martijn Coenen wrote:
> > >> > > >
> > >> > > > I think the Qualcomm folks owning this (Andy, David, Bjorn, already
> > >> > > > cc'd here) are better suited to answer that question.
> > >> > >
> > >> > > Andy, David, Bjorn?
> > >> >
> > >> > Andy, David, Bjorn?
> > >>
> > >> A month now with no answer...
>
> So it's this memremap() region that we pass to
> request_firmware_into_buf() currently, the previously mentioned
> dma_alloc_coherent() region is used as we invoke the secure world
> operation to set up the firmware authentication.

memremap() is for IO memory, and in that sense it is also not much different
from DMA memory in terms of the concerns Mimi has for LSMs and what guarantees
LSMs can make to users.

Regardless of the device, once you write certain data to the IO memory we cannot
be sure the device will wait for all IO to be written, this will be device 
specific.

As such I would suggest READING_IOMEM for this case have 
request_firmware_into_buf()
use it.

With that said, since we have only one user of this caller, a future rename
to reflect its current actual use would be good. The rename can wait though.

  Luis
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: pi433: fix race condition in pi433_open

2018-06-18 Thread Hugo Lefeuvre
Hi Dan,

> We need to decrement device->users-- on the error paths as well.
> This function was already slightly broken with respect to counting the
> users, but let's not make it worse.
> 
> I think it's still a tiny bit racy because it's not an atomic type.

Oh right, I missed that. I'll fix it in the v2. :)

> I'm not sure the error handling in open() works either.  It's releasing
> device->rx_buffer but there could be another user.

Agree.

> The ->rx_buffer
> should be allocated in probe() instead of open() probably, no?  And then
> freed in pi433_remove().  Then once we put that in the right layer
> it means we can just get rid of ->users...

It would be great to get rid of this counter, indeed. But how to do it
properly without breaking things ? It seems to be useful to me...

For example, how do you handle the case where remove() is called but
some operations are still running on existing fds ?

What if remove frees the rx_buffer while a read() call executes this ?

copy_to_user(buf, device->rx_buffer, bytes_received)

rx_buffer is freed by release() because it's the only buffer from the
device structure used in read/write/ioctl, meaning that we can only
free it when we are sure that it isn't used anywhere anymore.

So, we can't do it in remove() unless remove() is delayed until the
last release() has returned.

> The lines:
>
>   1008  if (!device->spi)
>   1009  kfree(device);
>
> make no sort of sense at all...  Fortunately it's not posssible for
> device->spi to be NULL so it's dead code.

Really ? device->spi is NULL-ed in remove() so that operations on
remaining fds can detect remove() was already called and free remaining
resources:
 
1296 /* make sure ops on existing fds can abort cleanly */
1297 device->spi = NULL;

Thanks for your time !

Regards,
 Hugo

-- 
 Hugo Lefeuvre (hle)|www.owl.eu.com
4096/ 9C4F C8BF A4B0 8FC5 48EB 56B8 1962 765B B9A8 BACA
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging:iio:adc:ad7816: Backward resources cleanups in probe

2018-06-18 Thread Lars-Peter Clausen
On 06/19/2018 01:38 AM, Karim Eshapa wrote:
> Backward cleanups for all resources allocated in probing
> in case of failure at any regestering or allocation step.

Hi,

Thanks for the patch.

Resources that are allocated with devm_ are freed automatically in case of
an error, so this patch should not be necessary.

> 
> Signed-off-by: Karim Eshapa 
> ---
>  drivers/staging/iio/adc/ad7816.c | 22 +-
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/iio/adc/ad7816.c 
> b/drivers/staging/iio/adc/ad7816.c
> index bf76a8620bdb..5ff14c830451 100644
> --- a/drivers/staging/iio/adc/ad7816.c
> +++ b/drivers/staging/iio/adc/ad7816.c
> @@ -373,7 +373,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
>   if (ret) {
>   dev_err(&spi_dev->dev, "Fail to request rdwr gpio PIN %d.\n",
>   chip->rdwr_pin);
> - return ret;
> + goto device_free;
>   }
>   gpio_direction_input(chip->rdwr_pin);
>   ret = devm_gpio_request(&spi_dev->dev, chip->convert_pin,
> @@ -381,7 +381,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
>   if (ret) {
>   dev_err(&spi_dev->dev, "Fail to request convert gpio PIN %d.\n",
>   chip->convert_pin);
> - return ret;
> + goto free_rdwr_pin;
>   }
>   gpio_direction_input(chip->convert_pin);
>   ret = devm_gpio_request(&spi_dev->dev, chip->busy_pin,
> @@ -389,7 +389,7 @@ static int ad7816_probe(struct spi_device *spi_dev)
>   if (ret) {
>   dev_err(&spi_dev->dev, "Fail to request busy gpio PIN %d.\n",
>   chip->busy_pin);
> - return ret;
> + goto free_convert_pin;
>   }
>   gpio_direction_input(chip->busy_pin);
>  
> @@ -407,17 +407,29 @@ static int ad7816_probe(struct spi_device *spi_dev)
>   indio_dev->name,
>   indio_dev);
>   if (ret)
> - return ret;
> + goto free_busy_pin;
>   }
>  
>   ret = devm_iio_device_register(&spi_dev->dev, indio_dev);
>   if (ret)
> - return ret;
> + goto free_dev_irq;
>  
>   dev_info(&spi_dev->dev, "%s temperature sensor and ADC registered.\n",
>indio_dev->name);
>  
>   return 0;
> +free_dev_irq:
> + devm_free_irq(&spi_dev->dev, spi_dev->irq, indio_dev);
> +free_busy_pin:
> + devm_gpio_free(&spi_dev->dev, chip->busy_pin);
> +free_convert_pin:
> + devm_gpio_free(&spi_dev->dev, chip->convert_pin);
> +free_rdwr_pin:
> + devm_gpio_free(&spi_dev->dev, chip->rdwr_pin);
> +device_free:
> + devm_iio_device_free(&spi_dev->dev, indio_dev);
> +
> + return ret;
>  }
>  
>  static const struct spi_device_id ad7816_id[] = {
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel