RE: [PATCH char-misc 1/1] Drivers: hv: vmbus: Make synic_initialized flag per-cpu

2018-07-31 Thread Michael Kelley (EOSG)
From: Vitaly Kuznetsov  Sent: Tuesday, July 31, 2018 4:20 
AM
> 
> Reviewed-by: Vitaly Kuznetsov 

Thanks for the review

> 
> Alternatively, we can get rid of synic_initialized flag altogether:
> hv_synic_init() never fails in the first place but we can always
> implement something like:
> 
> int hv_synic_is_initialized(void) {
>   union hv_synic_scontrol sctrl;
> 
>   hv_get_synic_state(sctrl.as_uint64);
> 
>   return sctrl.enable;
> }
> 
> as it doesn't seem that we need to check synic state on _other_ CPUs.
> 
> --
>   Vitaly

I was trying to decide if there are any arguments in favor of one
approach vs. the other:  a per-cpu flag in memory or checking
the synic_control "enable" bit.   Seems like a wash to me, in which
case I have a slight preference for the per-cpu flag in memory vs.
creating another function to return sctrl.enable.  But I'm completely
open to reasons why checking sctrl.enable is better.

Michael

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


Re: [PATCH 05/23] staging: wilc1000: rename goto to avoid leading '_' in label name

2018-07-31 Thread Ajay Singh
Hi Dan,

On Mon, 30 Jul 2018 14:32:31 +0300
Dan Carpenter  wrote:

> On Mon, Jul 30, 2018 at 03:40:24PM +0530, Ajay Singh wrote:
> > Hi Dan,
> > 
> > On Mon, 30 Jul 2018 11:41:13 +0300
> > Dan Carpenter  wrote:
> >   
> > > On Fri, Jul 20, 2018 at 04:35:24AM +0530, Ajay Singh wrote:  
> > > > Hi Dan,
> > > > 
> > > > On Thu, 19 Jul 2018 12:27:44 +0300
> > > > Dan Carpenter  wrote:
> > > > 
> > > > > On Thu, Jul 19, 2018 at 04:15:01AM +0530, Ajay Singh
> > > > > wrote:
> > > > > > diff --git a/drivers/staging/wilc1000/wilc_wlan.c
> > > > > > b/drivers/staging/wilc1000/wilc_wlan.c index
> > > > > > 85af365..8e71c28 100644 ---
> > > > > > a/drivers/staging/wilc1000/wilc_wlan.c +++
> > > > > > b/drivers/staging/wilc1000/wilc_wlan.c @@ -850,13 +850,13
> > > > > > @@ static void wilc_wlan_handle_isr_ext(struct wilc *wilc,
> > > > > > u32 int_status) if (wilc->rx_buffer) buffer =
> > > > > > >rx_buffer[offset]; else
> > > > > > -   goto _end_;
> > > > > > +   goto end;  
> > > > > 
> > > > > This isn't related to your patch but this goto doesn't appear
> > > > > to make any sort of sense.  I have no idea what was intended.
> > > > > 
> > > > 
> > > > Thanks for pointing it out. I will include these changes in
> > > > separate patchset.
> > > > 
> > > > Yes, the position of goto label can be moved just before
> > > > wilc_wlan_handle_rxq(wilc), as 'ret' will always be '0' when
> > > > goto statement is executed.
> > > > 
> > > > Actually earlier there were few more goto statement in this
> > > > function and single label 'end' was used to handle for
> > > > different cases. But in previous cleanup patches those cases
> > > > were removed. Now this function can be further refactor by
> > > > either moving goto label before wilc_wlan_handle_rxq(wilc) or
> > > > avoid goto use by adding the rx_buffer validation along with
> > > > size check.
> > > > 
> > > > i.e 
> > > > 
> > > > end:
> > > > wilc_wlan_handle_rxq(wilc)
> > > > 
> > > > 
> > > > OR
> > > > 
> > > > if (size > 0 && wilc->rx_buffer) {
> > > > 
> > > > 
> > > > }
> > > > wilc_wlan_handle_rxq(wilc)
> > > > 
> > > 
> > > Actually looking at it now, you could probably just remove the if
> > > statement.  Hopefully wilc->rx_buffer is non-NULL at this point?
> > > Is there really any need to call wilc_wlan_handle_rxq() when we
> > > haven't called wilc_wlan_rxq_add()?
> > >   
> > 
> > Yes, wilc->rx_buffer would be non NULL value as its only one time
> > allocated buffer. wilc_wlan_handle_rxq() was called without
> > wilc_wlan_rxq_add() just as a fail safe to ensure there are no
> > pending packets in the queue.  
> 
> The only thing is wilc->quit can be set.  Otherwise if ->rx_buffer is
> NULL it would just result in a NULL dereference.  (We are deep into
> hypotheticals here because we're discussing impossible code).
> 

I have prepared a patch based on the feedback. The patch is submitted
in https://patchwork.kernel.org/patch/10551703/.

Regards,
Ajay

> 
> ___
> 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 v7 00/15] staging: mt7621-pci: avoid custom pci config read and writes

2018-07-31 Thread Sergio Paracuellos
On Wed, Aug 01, 2018 at 07:56:38AM +1000, NeilBrown wrote:
> On Tue, Jul 31 2018, Sergio Paracuellos wrote:
> 
> > This patch series include an attempt to avoid the use of custom
> > read and writes in driver code and use PCI subsystem common ones.
> >
> > In order to do this 'map_bus' callback is implemented and also
> > data structures for driver are included. The regs base address
> > ranges and data is being readed from device tree and the driver
> > gets clean a lot of code.
> >
> > This patchet also removes all legacy PCI code using now PCI_DRIVERS_GENERIC
> > kernel api.
> >
> > Changes in v7:
> > - PATCH 1: Store resources in mt7621_pci data structure.
> > - PATCH 1: Change completely function 
> > mt7621_pci_parse_request_of_pci_ranges
> >   to parse resources from ranges manually instead of use the function 
> >   devm_of_pci_get_host_bridge_resources. This is closer to the mips pci 
> > legacy
> >   code.
> > - PATCH 1: Create 'mt7621_pcie_request_resources' function to request 
> > resources
> >   parsed from ranges property in the DT. Use pci_add_resource_offset 
> > and set them
> >   manually like the mips pci-legacy code do.
> > - PATCH 1: don't delete function setup_cm_memory_region and call it 
> > with memory
> >   resource.
> > - Other patches rebased and adapted to this changes.
> >
> 
> No good, sorry.
> 
> mt7621_pci_parse_request_of_pci_ranges()
> calls of_pci_range_to_resource() which, for IO resources,
> calls
>   port = pci_address_to_pio(range->cpu_addr);
> ->cpu_addr is 1e16
> and pci_address_to_pci sees that this is larger that IO_SPACE_LIMIT
> (0x) and returns -1.
> So the pci probe failed.
> 
> Maybe mips should have a arch-specific pci_address_to_pio, which does
> the setp_cm_memory_region() thing just a random guess really.
> 
> Though if I hack pci_address_to_pio() to succeed, I get:
> 
> [1.99] mt7621-pci 1e14.pcie: resource collision: [io  
> 0x1e16-0x1e16] conflicts with PCI IO [io  0x-0x]
> 
> which looks a little weird ... why do those conflict?  Maybe because
> everything has to fit into "PCI IO"..
> I'm getting lost...

Mmmm, So that seems to be the reason about why the result of 
of_pci_range_to_resource is
not checked in the legacy code:

See arch/mips/pci/pci-legacy.c +137 (pci_load_of_ranges function). We can try 
if no checking
it change the things and call in the same places the legacy code does change 
things. Just apply this (diff is against PATCH 1):

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 4e8958b..a7f31cd 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -545,9 +545,7 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct 
mt7621_pcie *pcie)
}

for_each_of_pci_range(, ) {
-   err = of_pci_range_to_resource(, node, );
-   if (err < 0)
-   return err;
+   of_pci_range_to_resource(, node, );

switch (res.flags & IORESOURCE_TYPE_BITS) {
case IORESOURCE_IO:
@@ -569,7 +567,6 @@ static int mt7621_pci_parse_request_of_pci_ranges(struct 
mt7621_pcie *pcie)

memcpy(>mem, , sizeof(res));
pcie->mem.name = "non-prefetchable";
-   setup_cm_memory_region(>mem);
break;
}
}
@@ -610,9 +607,6 @@ static int mt7621_pcie_parse_dt(struct mt7621_pcie *pcie)
if (IS_ERR(pcie->base))
return PTR_ERR(pcie->base);

-   err = mt7621_pci_parse_request_of_pci_ranges(pcie);
-   if (err)
-   return err;

return 0;
 }
@@ -876,6 +870,12 @@ pcie(2/1/0) link statuspcie2_num   pcie1_num   
pcie0_num
write_config(0, 0, 0, 0x70c, val);
}

+   err = mt7621_pci_parse_request_of_pci_ranges(pcie);
+   if (err)
+   return err;
+
+   setup_cm_memory_region(>mem);
+
err = mt7621_pcie_request_resources(pcie);
if (err) {
dev_err(dev, "Error requesting resources\n");

> 
> Thanks,
> NeilBrown

If this does not work I get completely lost :-(.

Thanks for your time and effort in this.

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


[PATCH] staging:mt29f_spinand: MT29F2G failing as only 16-bit arguments and variables used for addressing.

2018-07-31 Thread Jheng-Jhong Wu
For NAND flash chips with more than 1Gbit (e.g. MT29F2G) more than 16 bits
are necessary to address the correct page. The driver sets the address for
more than 16 bits, but it uses 16-bit arguments and variables (these are
page_id, block_id, row) to do address operations. Obviously, these
arguments and variables cannot deal with more than 16-bit address.

Signed-off-by: Jheng-Jhong Wu 
---
 drivers/staging/mt29f_spinand/mt29f_spinand.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/mt29f_spinand/mt29f_spinand.c 
b/drivers/staging/mt29f_spinand/mt29f_spinand.c
index 4484784..a0f4cbcb 100644
--- a/drivers/staging/mt29f_spinand/mt29f_spinand.c
+++ b/drivers/staging/mt29f_spinand/mt29f_spinand.c
@@ -308,10 +308,10 @@ static int spinand_write_enable(struct spi_device 
*spi_nand)
return spinand_cmd(spi_nand, );
 }
 
-static int spinand_read_page_to_cache(struct spi_device *spi_nand, u16 page_id)
+static int spinand_read_page_to_cache(struct spi_device *spi_nand, u32 page_id)
 {
struct spinand_cmd cmd = {0};
-   u16 row;
+   u32 row;
 
row = page_id;
cmd.cmd = CMD_READ;
@@ -331,7 +331,7 @@ static int spinand_read_page_to_cache(struct spi_device 
*spi_nand, u16 page_id)
  *   locations.
  *   No tRd delay.
  */
-static int spinand_read_from_cache(struct spi_device *spi_nand, u16 page_id,
+static int spinand_read_from_cache(struct spi_device *spi_nand, u32 page_id,
   u16 byte_id, u16 len, u8 *rbuf)
 {
struct spinand_cmd cmd = {0};
@@ -362,7 +362,7 @@ static int spinand_read_from_cache(struct spi_device 
*spi_nand, u16 page_id,
  *   The read includes two commands to the Nand - 0x13 and 0x03 commands
  *   Poll to read status to wait for tRD time.
  */
-static int spinand_read_page(struct spi_device *spi_nand, u16 page_id,
+static int spinand_read_page(struct spi_device *spi_nand, u32 page_id,
 u16 offset, u16 len, u8 *rbuf)
 {
int ret;
@@ -430,7 +430,7 @@ static int spinand_read_page(struct spi_device *spi_nand, 
u16 page_id,
  *   Since it is writing the data to cache, there is no tPROG time.
  */
 static int spinand_program_data_to_cache(struct spi_device *spi_nand,
-u16 page_id, u16 byte_id,
+u32 page_id, u16 byte_id,
 u16 len, u8 *wbuf)
 {
struct spinand_cmd cmd = {0};
@@ -457,10 +457,10 @@ static int spinand_program_data_to_cache(struct 
spi_device *spi_nand,
  *   the Nand array.
  *   Need to wait for tPROG time to finish the transaction.
  */
-static int spinand_program_execute(struct spi_device *spi_nand, u16 page_id)
+static int spinand_program_execute(struct spi_device *spi_nand, u32 page_id)
 {
struct spinand_cmd cmd = {0};
-   u16 row;
+   u32 row;
 
row = page_id;
cmd.cmd = CMD_PROG_PAGE_EXC;
@@ -486,7 +486,7 @@ static int spinand_program_execute(struct spi_device 
*spi_nand, u16 page_id)
  *   Poll to wait for the tPROG time to finish the transaction.
  */
 static int spinand_program_page(struct spi_device *spi_nand,
-   u16 page_id, u16 offset, u16 len, u8 *buf)
+   u32 page_id, u16 offset, u16 len, u8 *buf)
 {
int retval;
u8 status = 0;
@@ -573,10 +573,10 @@ static int spinand_program_page(struct spi_device 
*spi_nand,
  *   one block--64 pages
  *   Need to wait for tERS.
  */
-static int spinand_erase_block_erase(struct spi_device *spi_nand, u16 block_id)
+static int spinand_erase_block_erase(struct spi_device *spi_nand, u32 block_id)
 {
struct spinand_cmd cmd = {0};
-   u16 row;
+   u32 row;
 
row = block_id;
cmd.cmd = CMD_ERASE_BLK;
@@ -599,7 +599,7 @@ static int spinand_erase_block_erase(struct spi_device 
*spi_nand, u16 block_id)
  *   and then send the 0xd8 erase command
  *   Poll to wait for the tERS time to complete the tranaction.
  */
-static int spinand_erase_block(struct spi_device *spi_nand, u16 block_id)
+static int spinand_erase_block(struct spi_device *spi_nand, u32 block_id)
 {
int retval;
u8 status = 0;
-- 
2.7.4

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


Re: [PATCH v7 00/15] staging: mt7621-pci: avoid custom pci config read and writes

2018-07-31 Thread NeilBrown
On Tue, Jul 31 2018, Sergio Paracuellos wrote:

> This patch series include an attempt to avoid the use of custom
> read and writes in driver code and use PCI subsystem common ones.
>
> In order to do this 'map_bus' callback is implemented and also
> data structures for driver are included. The regs base address
> ranges and data is being readed from device tree and the driver
> gets clean a lot of code.
>
> This patchet also removes all legacy PCI code using now PCI_DRIVERS_GENERIC
> kernel api.
>
> Changes in v7:
> - PATCH 1: Store resources in mt7621_pci data structure.
> - PATCH 1: Change completely function 
> mt7621_pci_parse_request_of_pci_ranges
>   to parse resources from ranges manually instead of use the function 
>   devm_of_pci_get_host_bridge_resources. This is closer to the mips pci 
> legacy
>   code.
> - PATCH 1: Create 'mt7621_pcie_request_resources' function to request 
> resources
>   parsed from ranges property in the DT. Use pci_add_resource_offset and 
> set them
>   manually like the mips pci-legacy code do.
> - PATCH 1: don't delete function setup_cm_memory_region and call it with 
> memory
>   resource.
> - Other patches rebased and adapted to this changes.
>

No good, sorry.

mt7621_pci_parse_request_of_pci_ranges()
calls of_pci_range_to_resource() which, for IO resources,
calls
port = pci_address_to_pio(range->cpu_addr);
->cpu_addr is 1e16
and pci_address_to_pci sees that this is larger that IO_SPACE_LIMIT
(0x) and returns -1.
So the pci probe failed.

Maybe mips should have a arch-specific pci_address_to_pio, which does
the setp_cm_memory_region() thing just a random guess really.

Though if I hack pci_address_to_pio() to succeed, I get:

[1.99] mt7621-pci 1e14.pcie: resource collision: [io  
0x1e16-0x1e16] conflicts with PCI IO [io  0x-0x]

which looks a little weird ... why do those conflict?  Maybe because
everything has to fit into "PCI IO"..
I'm getting lost...

Thanks,
NeilBrown


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


[PATCH 14/14] staging:rtl8192u: Change clock comment - Style

2018-07-31 Thread John Whitmore
A number of block comments have been changed to comply with the coding
standard. These are coding style changes which should have no impact
on runtime code execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 77f0e26f5d2d..3052f53d2e7e 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -14,10 +14,10 @@ struct aci_aifsn {
u8:1;
 };
 
-//
-// Direction Field Values.
-// Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
-//
+/*
+ * Direction Field Values.
+ * Ref: WMM spec 2.2.11: WME TSPEC Element, p.18.
+ */
 enum direction_value {
DIR_UP  = 0,// 0x00 // UpLink
DIR_DOWN= 1,// 0x01 // DownLink
@@ -69,9 +69,9 @@ struct tspec_body {
u16 medium_time;
 };
 
-//
-//  802.11 Management frame Status Code field
-//
+/*
+ *  802.11 Management frame Status Code field
+ */
 struct octet_string {
u8  *octet;
u16 length;
-- 
2.18.0

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


[PATCH 13/14] staging:rtl8192u: Rename IsACValid and add parenthesis - Style

2018-07-31 Thread John Whitmore
The macro IsACValid is renamed to resolve the checkpatch issue with
CamelCase naming. In addition the parameter has parenthesis added to
clear the checkpatch issue with precedence issues.

These changes are coding style changes and as such should have not
impact on runtime code execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h| 2 +-
 drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 59a60f86607c..77f0e26f5d2d 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -77,6 +77,6 @@ struct octet_string {
u16 length;
 };
 
-#define IsACValid(ac)  ((ac <= 7) ? true : false)
+#define is_ac_valid(ac)(((ac) <= 7) ? true : false)
 
 #endif // #ifndef __INC_QOS_TYPE_H
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index e0ccabadec22..de06cd11ab65 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -309,7 +309,7 @@ bool GetTs(
UP = 0;
} else {
// In WMM case: we use 4 TID only
-   if (!IsACValid(TID)) {
+   if (!is_ac_valid(TID)) {
IEEE80211_DEBUG(IEEE80211_DL_ERR, " in %s(), TID(%d) is 
not valid\n", __func__, TID);
return false;
}
-- 
2.18.0

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


[PATCH 09/14] staging:rtl8192u: Move QOS_TCLAS to rtl819x_TS.h - Style

2018-07-31 Thread John Whitmore
Move the union QOS_TCLAS from the header file rtl819x_Qos.h to header
file rtl819x_TS.h, where the structure is actually used, as the member
of another structure.

This is a coding style change, which should have no impact on runtime
code execution.

Signed-off-by: John Whitmore 
---
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 51 ---
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   | 51 +++
 2 files changed, 51 insertions(+), 51 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index a4b8b577cf79..fb055a848d59 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -69,57 +69,6 @@ struct tspec_body {
u16 medium_time;
 };
 
-typedef union _QOS_TCLAS {
-
-   struct _TYPE_GENERAL {
-   u8  Priority;
-   u8  ClassifierType;
-   u8  Mask;
-   } TYPE_GENERAL;
-
-   struct _TYPE0_ETH {
-   u8  Priority;
-   u8  ClassifierType;
-   u8  Mask;
-   u8  SrcAddr[6];
-   u8  DstAddr[6];
-   u16 Type;
-   } TYPE0_ETH;
-
-   struct _TYPE1_IPV4 {
-   u8  Priority;
-   u8  ClassifierType;
-   u8  Mask;
-   u8  Version;
-   u8  SrcIP[4];
-   u8  DstIP[4];
-   u16 SrcPort;
-   u16 DstPort;
-   u8  DSCP;
-   u8  Protocol;
-   u8  Reserved;
-   } TYPE1_IPV4;
-
-   struct _TYPE1_IPV6 {
-   u8  Priority;
-   u8  ClassifierType;
-   u8  Mask;
-   u8  Version;
-   u8  SrcIP[16];
-   u8  DstIP[16];
-   u16 SrcPort;
-   u16 DstPort;
-   u8  FlowLabel[3];
-   } TYPE1_IPV6;
-
-   struct _TYPE2_8021Q {
-   u8  Priority;
-   u8  ClassifierType;
-   u8  Mask;
-   u16 TagType;
-   } TYPE2_8021Q;
-} QOS_TCLAS, *PQOS_TCLAS;
-
 //
 //  802.11 Management frame Status Code field
 //
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
index a9f865f810ce..5cf00a2e08ae 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
@@ -14,6 +14,57 @@ enum tr_select {
RX_DIR = 1,
 };
 
+typedef union _QOS_TCLAS {
+
+   struct _TYPE_GENERAL {
+   u8  Priority;
+   u8  ClassifierType;
+   u8  Mask;
+   } TYPE_GENERAL;
+
+   struct _TYPE0_ETH {
+   u8  Priority;
+   u8  ClassifierType;
+   u8  Mask;
+   u8  SrcAddr[6];
+   u8  DstAddr[6];
+   u16 Type;
+   } TYPE0_ETH;
+
+   struct _TYPE1_IPV4 {
+   u8  Priority;
+   u8  ClassifierType;
+   u8  Mask;
+   u8  Version;
+   u8  SrcIP[4];
+   u8  DstIP[4];
+   u16 SrcPort;
+   u16 DstPort;
+   u8  DSCP;
+   u8  Protocol;
+   u8  Reserved;
+   } TYPE1_IPV4;
+
+   struct _TYPE1_IPV6 {
+   u8  Priority;
+   u8  ClassifierType;
+   u8  Mask;
+   u8  Version;
+   u8  SrcIP[16];
+   u8  DstIP[16];
+   u16 SrcPort;
+   u16 DstPort;
+   u8  FlowLabel[3];
+   } TYPE1_IPV6;
+
+   struct _TYPE2_8021Q {
+   u8  Priority;
+   u8  ClassifierType;
+   u8  Mask;
+   u16 TagType;
+   } TYPE2_8021Q;
+} QOS_TCLAS, *PQOS_TCLAS;
+
 struct ts_common_info {
struct list_headlist;
struct timer_list   setup_timer;
-- 
2.18.0

___
devel mailing list

[PATCH 06/14] staging:rtl8192u: Rename TSInfo - Style

2018-07-31 Thread John Whitmore
Rename TSInfo, the memeber variable of struct tspec_body to ts_info.
This change clears the checkpatch issue with CamelCase naming.

This is a coding style change which should not impact runtime code
execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 2 +-
 drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h| 2 +-
 drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 8 
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index d35f10c695e4..01b631c2a180 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -626,7 +626,7 @@ TsInitAddBA(
pBA->DialogToken++; // 
DialogToken: Only keep the latest dialog token
pBA->BaParamSet.field.AMSDU_Support = 0;// Do not support 
A-MSDU with A-MPDU now!!
pBA->BaParamSet.field.BAPolicy = Policy;// Policy: Delayed or 
Immediate
-   pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.TSInfo.uc_tsid;  
// TID
+   pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.ts_info.uc_tsid; 
// TID
// BufferSize: This need to be set according to A-MPDU vector
pBA->BaParamSet.field.BufferSize = 32;  // BufferSize: This 
need to be set according to A-MPDU vector
pBA->BaTimeoutValue = 0;// 
Timeout value: Set 0 to disable Timer
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index a4cecf4cc756..db0392cfd6d4 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -52,7 +52,7 @@ struct qos_tsinfo {
  * Note: sizeof 55 bytes
  */
 struct tspec_body {
-   struct qos_tsinfo   TSInfo; //u8TSInfo[3];
+   struct qos_tsinfo   ts_info;//u8TSInfo[3];
u16 NominalMSDUsize;
u16 MaxMSDUsize;
u32 MinServiceItv;
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index bd2b4e5dfa60..e0ccabadec22 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -246,10 +246,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct 
ieee80211_device *ieee,
if (!search_dir[dir])
continue;
list_for_each_entry(pRet, psearch_list, list){
-   //  IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, 
dir:%d\n", pRet->Addr, pRet->TSpec.TSInfo.ucTSID, 
pRet->TSpec.TSInfo.ucDirection);
+   //  IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, 
dir:%d\n", pRet->Addr, pRet->TSpec.ts_info.ucTSID, 
pRet->TSpec.ts_info.ucDirection);
if (memcmp(pRet->addr, Addr, 6) == 0)
-   if (pRet->t_spec.TSInfo.uc_tsid == TID)
-   if(pRet->t_spec.TSInfo.uc_direction == 
dir) {
+   if (pRet->t_spec.ts_info.uc_tsid == TID)
+   if(pRet->t_spec.ts_info.uc_direction == 
dir) {
//  printk("Bingo! got it\n");
break;
}
@@ -355,7 +355,7 @@ bool GetTs(
// For HCCA or WMMSA, TS cannot be addmit without 
negotiation.
//
struct tspec_body   TSpec;
-   struct qos_tsinfo   *pTSInfo = 
+   struct qos_tsinfo   *pTSInfo = _info;
struct list_head*pUnusedList =
(TxRxSelect == 
TX_DIR)?

(>Tx_TS_Unused_List):
-- 
2.18.0

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


[PATCH 02/14] staging:rtl8192u: Remove union from aci_aifsn - Style

2018-07-31 Thread John Whitmore
The union aci_aifsn is not used as a union, but only as a struct.
The union seems to have been used to ensure that the size of the
structure was only a single byte. That size is set by the bitfield
structure, adding a union with an unused byte adds nothing.

The union has been removed. This is a coding style change and
should not impact runtime code execution.

Signed-off-by: John Whitmore 
---
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 23 ---
 drivers/staging/rtl8192u/r8192U_dm.c  |  4 ++--
 2 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 810d81addcf6..1f16d1692c03 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -2,19 +2,16 @@
 #ifndef __INC_QOS_TYPE_H
 #define __INC_QOS_TYPE_H
 
-//
-// ACI/AIFSN Field.
-// Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
-//
-union aci_aifsn {
-   u8  char_data;
-
-   struct {
-   u8  aifsn:4;
-   u8  acm:1;
-   u8  aci:2;
-   u8  reserved:1;
-   } f;// Field
+/*
+ * ACI/AIFSN Field.
+ * Ref: WMM spec 2.2.2: WME Parameter Element, p.12.
+ * Note: 1 Byte Length
+ */
+struct aci_aifsn {
+   u8  aifsn:4;
+   u8  acm:1;
+   u8  aci:2;
+   u8:1;
 };
 
 //
diff --git a/drivers/staging/rtl8192u/r8192U_dm.c 
b/drivers/staging/rtl8192u/r8192U_dm.c
index 92ba1fdd9831..0ba1b1e2bc6e 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -2242,12 +2242,12 @@ static void dm_check_edca_turbo(
{
/*  TODO:  Modified this part and try to set 
acm control in only 1 IO processing!! */
 
-   union aci_aifsn *pAciAifsn = (union aci_aifsn 
*)&(qos_parameters->aifs[0]);
+   struct aci_aifsn *pAciAifsn = (struct aci_aifsn 
*)&(qos_parameters->aifs[0]);
u8  AcmCtrl;
 
read_nic_byte(dev, AcmHwCtrl, );
 
-   if (pAciAifsn->f.acm) { /*  acm bit is 1. */
+   if (pAciAifsn->acm) { /*  acm bit is 1. */
AcmCtrl |= AcmHw_BeqEn;
} else {/* ACM bit is 0. */
AcmCtrl &= (~AcmHw_BeqEn);
-- 
2.18.0

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


[PATCH 12/14] staging:rtl8192u: Remove unused UP2AC - Style

2018-07-31 Thread John Whitmore
The macro UP2AC is commented out of the header file so the macro and its
associated comment are removed.

This is a coding style change which should have no impact on runtime
code execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 50b05ee52210..59a60f86607c 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -77,9 +77,6 @@ struct octet_string {
u16 length;
 };
 
-//Added by joseph
-//UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
-//#define UP2AC(up)((up<3)?((up==0)?1:0):(up>>1))
 #define IsACValid(ac)  ((ac <= 7) ? true : false)
 
 #endif // #ifndef __INC_QOS_TYPE_H
-- 
2.18.0

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


[PATCH 03/14] staging:rtl8192u: Remove union from qos_tsinfo - Style

2018-07-31 Thread John Whitmore
The union is never used as a union but only as a bitfield struct.
One side of the union (u8 charData[3];) Only seems to be present to
ensure that the structures size is 3 bytes in length. That length, of
the structure is dictated by the largest element of the union, so the
byte array only dictates size if it's the largest element of the union.
The byte array and union add nothing.

The union has therefore been removed and the structure and access to
the structure simplified.

Additionally since one of the bitfield variables (ucAccessPolicy)
spans a byte boundary the base type of the bitfield has been changed
from u8 to u16. Compilers have probably moved on from having an issue
with this, call it OCD.

The changes are coding style in nature and should not impact runtime
code execution.

Signed-off-by: John Whitmore 
---
 .../rtl8192u/ieee80211/rtl819x_BAProc.c   |  2 +-
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 40 +--
 .../rtl8192u/ieee80211/rtl819x_TSProc.c   | 26 ++--
 3 files changed, 33 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index e296813203aa..4e8bcc25ad2c 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -626,7 +626,7 @@ TsInitAddBA(
pBA->DialogToken++; // 
DialogToken: Only keep the latest dialog token
pBA->BaParamSet.field.AMSDU_Support = 0;// Do not support 
A-MSDU with A-MPDU now!!
pBA->BaParamSet.field.BAPolicy = Policy;// Policy: Delayed or 
Immediate
-   pBA->BaParamSet.field.TID = 
pTS->ts_common_info.t_spec.f.TSInfo.field.ucTSID;   // TID
+   pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.ucTSID; 
// TID
// BufferSize: This need to be set according to A-MPDU vector
pBA->BaParamSet.field.BufferSize = 32;  // BufferSize: This 
need to be set according to A-MPDU vector
pBA->BaTimeoutValue = 0;// 
Timeout value: Set 0 to disable Timer
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 1f16d1692c03..4faa89db8355 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -26,26 +26,24 @@ enum direction_value {
 };
 
 
-//
-// TS Info field in WMM TSPEC Element.
-// Ref:
-// 1. WMM spec 2.2.11: WME TSPEC Element, p.18.
-// 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
-//
-union qos_tsinfo {
-   u8  charData[3];
-   struct {
-   u8  ucTrafficType:1;//WMM 
is reserved
-   u8  ucTSID:4;
-   u8  ucDirection:2;
-   u8  ucAccessPolicy:2;   //WMM: bit8=0, bit7=1
-   u8  ucAggregation:1;//WMM is 
reserved
-   u8  ucPSB:1;//WMMSA 
is APSD
-   u8  ucUP:3;
-   u8  ucTSInfoAckPolicy:2;//WMM is 
reserved
-   u8  ucSchedule:1;   //WMM is 
reserved
-   u8  ucReserved:7;
-   } field;
+/*
+ * TS Info field in WMM TSPEC Element.
+ * Ref:
+ * 1. WMM spec 2.2.11: WME TSPEC Element, p.18.
+ * 2. 8185 QoS code: QOS_TSINFO [def. in QoS_mp.h]
+ * Note: sizeof 3 Bytes
+ */
+struct qos_tsinfo {
+   u16 ucTrafficType:1;//WMM is reserved
+   u16 ucTSID:4;
+   u16 ucDirection:2;
+   u16 ucAccessPolicy:2;   //WMM: bit8=0, bit7=1
+   u16 ucAggregation:1;//WMM is reserved
+   u16 ucPSB:1;//WMMSA is APSD
+   u16 ucUP:3;
+   u16 ucTSInfoAckPolicy:2;//WMM is reserved
+   u8  ucSchedule:1;   //WMM is reserved
+   u8  ucReserved:7;
 };
 
 //
@@ -56,7 +54,7 @@ typedef union _TSPEC_BODY {
u8  charData[55];
 
struct {
-   union qos_tsinfoTSInfo; //u8TSInfo[3];
+   struct qos_tsinfo   TSInfo; //u8TSInfo[3];
u16 NominalMSDUsize;
u16 MaxMSDUsize;
u32 MinServiceItv;
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index c21bf3d3b242..39a074621b3b 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -246,10 +246,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct 
ieee80211_device *ieee,
if (!search_dir[dir])

[PATCH 10/14] staging:rtl8192u: rename OCTET_STRING - Style

2018-07-31 Thread John Whitmore
Rename the structure OCTET_STRING to octet_string. This is to comply
with the coding style of using lowercase for types. In addition the
typedef directive is removed to clear the checkpatch issue with
defining new types.

These are coding style changes which should have no impact on runtime
code execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 ++--
 drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 6 +++---
 drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h   | 4 ++--
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 326a1e47bade..3cfeac0d7214 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -1543,14 +1543,14 @@ typedef struct _RT_POWER_SAVE_CONTROL {
boolbTmpFilterHiddenAP;
boolbTmpUpdateParms;
u8  tmpSsidBuf[33];
-   OCTET_STRINGtmpSsid2Scan;
+   struct octet_string tmpSsid2Scan;
boolbTmpSsid2Scan;
u8  tmpNetworkType;
u8  tmpChannelNumber;
u16 tmpBcnPeriod;
u8  tmpDtimPeriod;
u16 tmpmCap;
-   OCTET_STRINGtmpSuppRateSet;
+   struct octet_string tmpSuppRateSet;
u8  tmpSuppRateBuf[MAX_NUM_RATES];
boolbTmpSuppRate;
IbssParms   tmpIbpm;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index ca3a35b8ac07..706b4419e643 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -1063,7 +1063,7 @@ ieee80211_association_req(struct ieee80211_network 
*beacon,
if (beacon->bCkipSupported) {
static u8   AironetIeOui[] = {0x00, 0x01, 0x66}; // 
"4500-client"
u8  CcxAironetBuf[30];
-   OCTET_STRINGosCcxAironetIE;
+   struct octet_string osCcxAironetIE;
 
memset(CcxAironetBuf, 0, 30);
osCcxAironetIE.Octet = CcxAironetBuf;
@@ -1087,7 +1087,7 @@ ieee80211_association_req(struct ieee80211_network 
*beacon,
 
if (beacon->bCcxRmEnable) {
static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
-   OCTET_STRING osCcxRmCap;
+   struct octet_string osCcxRmCap;
 
osCcxRmCap.Octet = CcxRmCapBuf;
osCcxRmCap.Length = sizeof(CcxRmCapBuf);
@@ -1100,7 +1100,7 @@ ieee80211_association_req(struct ieee80211_network 
*beacon,
 
if (beacon->BssCcxVerNumber >= 2) {
u8  CcxVerNumBuf[] = {0x00, 0x40, 0x96, 
0x03, 0x00};
-   OCTET_STRINGosCcxVerNum;
+   struct octet_string osCcxVerNum;
CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
osCcxVerNum.Octet = CcxVerNumBuf;
osCcxVerNum.Length = sizeof(CcxVerNumBuf);
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index fb055a848d59..531a3e22e799 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -72,10 +72,10 @@ struct tspec_body {
 //
 //  802.11 Management frame Status Code field
 //
-typedef struct _OCTET_STRING {
+struct octet_string {
u8  *Octet;
u16 Length;
-} OCTET_STRING, *POCTET_STRING;
+};
 
 //Added by joseph
 //UP Mapping to AC, using in MgntQuery_SequenceNumber() and maybe for DSCP
-- 
2.18.0

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


[PATCH 11/14] staging:rtl8192u: Rename octet_string members - Style

2018-07-31 Thread John Whitmore
Rename the structure octet_string's member variables Octet to octet and
Length to length. This change clears the checkpatch issue with CamelCase
naming of variables.

This is purely a coding style change which should have no impact on
runtime code execution.

Signed-off-by: John Whitmore 
---
 .../rtl8192u/ieee80211/ieee80211_softmac.c| 34 +--
 .../rtl8192u/ieee80211/rtl819x_HTProc.c   |  4 +--
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  |  4 +--
 3 files changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c 
b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index 706b4419e643..51cb5e4658b0 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -1066,49 +1066,49 @@ ieee80211_association_req(struct ieee80211_network 
*beacon,
struct octet_string osCcxAironetIE;
 
memset(CcxAironetBuf, 0, 30);
-   osCcxAironetIE.Octet = CcxAironetBuf;
-   osCcxAironetIE.Length = sizeof(CcxAironetBuf);
+   osCcxAironetIE.octet = CcxAironetBuf;
+   osCcxAironetIE.length = sizeof(CcxAironetBuf);
//
// Ref. CCX test plan v3.61, 3.2.3.1 step 13.
// We want to make the device type as "4500-client". 060926, by 
CCW.
//
-   memcpy(osCcxAironetIE.Octet, AironetIeOui, 
sizeof(AironetIeOui));
+   memcpy(osCcxAironetIE.octet, AironetIeOui, 
sizeof(AironetIeOui));
 
// CCX1 spec V1.13, A01.1 CKIP Negotiation (page23):
// "The CKIP negotiation is started with the associate request 
from the client to the access point,
//  containing an Aironet element with both the MIC and KP bits 
set."
-   osCcxAironetIE.Octet[IE_CISCO_FLAG_POSITION] |= 
(SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC);
+   osCcxAironetIE.octet[IE_CISCO_FLAG_POSITION] |= 
(SUPPORT_CKIP_PK | SUPPORT_CKIP_MIC);
tag = skb_put(skb, ckip_ie_len);
*tag++ = MFIE_TYPE_AIRONET;
-   *tag++ = osCcxAironetIE.Length;
-   memcpy(tag, osCcxAironetIE.Octet, osCcxAironetIE.Length);
-   tag += osCcxAironetIE.Length;
+   *tag++ = osCcxAironetIE.length;
+   memcpy(tag, osCcxAironetIE.octet, osCcxAironetIE.length);
+   tag += osCcxAironetIE.length;
}
 
if (beacon->bCcxRmEnable) {
static u8 CcxRmCapBuf[] = {0x00, 0x40, 0x96, 0x01, 0x01, 0x00};
struct octet_string osCcxRmCap;
 
-   osCcxRmCap.Octet = CcxRmCapBuf;
-   osCcxRmCap.Length = sizeof(CcxRmCapBuf);
+   osCcxRmCap.octet = CcxRmCapBuf;
+   osCcxRmCap.length = sizeof(CcxRmCapBuf);
tag = skb_put(skb, ccxrm_ie_len);
*tag++ = MFIE_TYPE_GENERIC;
-   *tag++ = osCcxRmCap.Length;
-   memcpy(tag, osCcxRmCap.Octet, osCcxRmCap.Length);
-   tag += osCcxRmCap.Length;
+   *tag++ = osCcxRmCap.length;
+   memcpy(tag, osCcxRmCap.octet, osCcxRmCap.length);
+   tag += osCcxRmCap.length;
}
 
if (beacon->BssCcxVerNumber >= 2) {
u8  CcxVerNumBuf[] = {0x00, 0x40, 0x96, 
0x03, 0x00};
struct octet_string osCcxVerNum;
CcxVerNumBuf[4] = beacon->BssCcxVerNumber;
-   osCcxVerNum.Octet = CcxVerNumBuf;
-   osCcxVerNum.Length = sizeof(CcxVerNumBuf);
+   osCcxVerNum.octet = CcxVerNumBuf;
+   osCcxVerNum.length = sizeof(CcxVerNumBuf);
tag = skb_put(skb, cxvernum_ie_len);
*tag++ = MFIE_TYPE_GENERIC;
-   *tag++ = osCcxVerNum.Length;
-   memcpy(tag, osCcxVerNum.Octet, osCcxVerNum.Length);
-   tag += osCcxVerNum.Length;
+   *tag++ = osCcxVerNum.length;
+   memcpy(tag, osCcxVerNum.octet, osCcxVerNum.length);
+   tag += osCcxVerNum.length;
}
//HT cap element
if (ieee->pHTInfo->bCurrentHTSupport && ieee->pHTInfo->bEnableHT) {
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
index 264d15fbcc6b..b948eae5909d 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c
@@ -738,10 +738,10 @@ void HTConstructRT2RTAggElement(struct ieee80211_device 
*ieee, u8 *posRT2RTAgg,
   section of code.
if(IS_UNDER_11N_AES_MODE(Adapter))
{
-   posRT2RTAgg->Octet[5] |= RT_HT_CAP_USE_AMPDU;
+   posRT2RTAgg->octet[5] |= RT_HT_CAP_USE_AMPDU;
}else
{
-   posRT2RTAgg->Octet[5] &= 0xfb;
+   posRT2RTAgg->octet[5] &= 0xfb;
}
 

[PATCH 04/14] staging:rtl8192u: Rename members of struct qos_tsinfo - Style

2018-07-31 Thread John Whitmore
The member variables of struct qos_tsinfo all cause checkpatch issues
with CamelCase naming. As the variables are used in so few places the
changes are combined into this single patch.

Additionally the member variable usReserved is never used in code so
has been removed.

These are all coding style changes which should have no impact on
runtime code execution.

Signed-off-by: John Whitmore 
---
 .../rtl8192u/ieee80211/rtl819x_BAProc.c   |  2 +-
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 20 -
 .../rtl8192u/ieee80211/rtl819x_TSProc.c   | 22 +--
 3 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 4e8bcc25ad2c..96fab43c1cfe 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -626,7 +626,7 @@ TsInitAddBA(
pBA->DialogToken++; // 
DialogToken: Only keep the latest dialog token
pBA->BaParamSet.field.AMSDU_Support = 0;// Do not support 
A-MSDU with A-MPDU now!!
pBA->BaParamSet.field.BAPolicy = Policy;// Policy: Delayed or 
Immediate
-   pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.f.TSInfo.ucTSID; 
// TID
+   pBA->BaParamSet.field.TID = 
pTS->ts_common_info.t_spec.f.TSInfo.uc_tsid;// TID
// BufferSize: This need to be set according to A-MPDU vector
pBA->BaParamSet.field.BufferSize = 32;  // BufferSize: This 
need to be set according to A-MPDU vector
pBA->BaTimeoutValue = 0;// 
Timeout value: Set 0 to disable Timer
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 4faa89db8355..d36a14197b4c 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -34,16 +34,16 @@ enum direction_value {
  * Note: sizeof 3 Bytes
  */
 struct qos_tsinfo {
-   u16 ucTrafficType:1;//WMM is reserved
-   u16 ucTSID:4;
-   u16 ucDirection:2;
-   u16 ucAccessPolicy:2;   //WMM: bit8=0, bit7=1
-   u16 ucAggregation:1;//WMM is reserved
-   u16 ucPSB:1;//WMMSA is APSD
-   u16 ucUP:3;
-   u16 ucTSInfoAckPolicy:2;//WMM is reserved
-   u8  ucSchedule:1;   //WMM is reserved
-   u8  ucReserved:7;
+   u16 uc_traffic_type:1;  //WMM is reserved
+   u16 uc_tsid:4;
+   u16 uc_direction:2;
+   u16 uc_access_policy:2; //WMM: bit8=0, bit7=1
+   u16 uc_aggregation:1;   //WMM is reserved
+   u16 uc_psb:1;   //WMMSA is APSD
+   u16 uc_up:3;
+   u16 uc_ts_info_ack_policy:2;//WMM is reserved
+   u8  uc_schedule:1;  //WMM is reserved
+   u8:7;
 };
 
 //
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 39a074621b3b..076278dae321 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -248,8 +248,8 @@ static struct ts_common_info *SearchAdmitTRStream(struct 
ieee80211_device *ieee,
list_for_each_entry(pRet, psearch_list, list){
//  IEEE80211_DEBUG(IEEE80211_DL_TS, "ADD:%pM, TID:%d, 
dir:%d\n", pRet->Addr, pRet->TSpec.f.TSInfo.ucTSID, 
pRet->TSpec.f.TSInfo.ucDirection);
if (memcmp(pRet->addr, Addr, 6) == 0)
-   if (pRet->t_spec.f.TSInfo.ucTSID == TID)
-   if(pRet->t_spec.f.TSInfo.ucDirection == 
dir) {
+   if (pRet->t_spec.f.TSInfo.uc_tsid == TID)
+   if(pRet->t_spec.f.TSInfo.uc_direction 
== dir) {
//  printk("Bingo! got it\n");
break;
}
@@ -383,15 +383,15 @@ bool GetTs(
 
IEEE80211_DEBUG(IEEE80211_DL_TS, "to init 
current TS, UP:%d, Dir:%d, addr:%pM\n", UP, Dir, Addr);
// Prepare TS Info releated field
-   pTSInfo->ucTrafficType = 0; // 
Traffic type: WMM is reserved in this field
-   pTSInfo->ucTSID = UP;   // TSID
-   pTSInfo->ucDirection = Dir; // 
Direction: if there is DirectLink, this need additional consideration.
- 

[PATCH 07/14] staging:rtl8192u: Rename tspec_body members - Style

2018-07-31 Thread John Whitmore
The member variables of the tspec_body have been renamed to clear the
checkpatch issue with CamelCase naming. As these member variables are
never used in the code the changes are combined into this single
patch.

These changes are coding style changes which should have no impact on
runtime code execution.

Signed-off-by: John Whitmore 
---
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 30 +--
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index db0392cfd6d4..025810c93160 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -53,21 +53,21 @@ struct qos_tsinfo {
  */
 struct tspec_body {
struct qos_tsinfo   ts_info;//u8TSInfo[3];
-   u16 NominalMSDUsize;
-   u16 MaxMSDUsize;
-   u32 MinServiceItv;
-   u32 MaxServiceItv;
-   u32 InactivityItv;
-   u32 SuspenItv;
-   u32 ServiceStartTime;
-   u32 MinDataRate;
-   u32 MeanDataRate;
-   u32 PeakDataRate;
-   u32 MaxBurstSize;
-   u32 DelayBound;
-   u32 MinPhyRate;
-   u16 SurplusBandwidthAllowance;
-   u16 MediumTime;
+   u16 nominal_msd_usize;
+   u16 max_msd_usize;
+   u32 min_service_itv;
+   u32 max_service_itv;
+   u32 inactivity_itv;
+   u32 suspen_itv;
+   u32 service_start_time;
+   u32 min_data_rate;
+   u32 mean_data_rate;
+   u32 peak_data_rate;
+   u32 max_burst_size;
+   u32 delay_bound;
+   u32 min_phy_rate;
+   u16 surplus_bandwidth_allowance;
+   u16 medium_time;
 };
 
 //typedef struct _TCLASS{
-- 
2.18.0

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


[PATCH 01/14] staging:rtl8192u: Clean cmpk_counttxstatistic() comments - Style

2018-07-31 Thread John Whitmore
The only useful piece of information in the header comment of this
static function was the name of the function and parameters. That
is not useful information, given that they are in the C Source of
the function declaration, a few lines below the comment. The block
comment has been removed.

This is a coding style change, there should be no impact on runtime
code execution.

Signed-off-by: John Whitmore 
---
 drivers/staging/rtl8192u/r819xU_cmdpkt.c | 18 --
 1 file changed, 18 deletions(-)

diff --git a/drivers/staging/rtl8192u/r819xU_cmdpkt.c 
b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
index d2293a335ed1..900f7866d381 100644
--- a/drivers/staging/rtl8192u/r819xU_cmdpkt.c
+++ b/drivers/staging/rtl8192u/r819xU_cmdpkt.c
@@ -60,24 +60,6 @@ rt_status SendTxCommandPacket(struct net_device *dev, void 
*pData, u32 DataLen)
return RT_STATUS_SUCCESS;
 }
 
-/*-
- * Function:cmpk_counttxstatistic()
- *
- * Overview:
- *
- * Input:   PADAPTER   pAdapter
- *  STRUCT CMD_PKT_TX_FEEDBACK *psTx_FB
- *
- * Output:  NONE
- *
- * Return:  NONE
- *
- * Revised History:
- *  When   Who Remark
- *  05/12/2008 amy Create Version 0 porting from windows code.
- *
- *---
- */
 static void cmpk_count_txstatistic(struct net_device *dev, struct 
cmd_pkt_tx_feedback *pstx_fb)
 {
struct r8192_priv *priv = ieee80211_priv(dev);
-- 
2.18.0

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


[PATCH 08/14] staging:rtl8192u: Remove commented out code - Style

2018-07-31 Thread John Whitmore
A number of structures have been commented out of code. Obviously they
are not used and as a result have been removed from the code.

This is a coding style change which should have no impact on runtime
code execution.

Signed-off-by: John Whitmore 
---
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index 025810c93160..a4b8b577cf79 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -25,7 +25,6 @@ enum direction_value {
DIR_BI_DIR  = 3,// 0x11 // Bi-Direction
 };
 
-
 /*
  * TS Info field in WMM TSPEC Element.
  * Ref:
@@ -70,9 +69,6 @@ struct tspec_body {
u16 medium_time;
 };
 
-//typedef struct _TCLASS{
-// TODO
-//} TCLASS, *PTCLASS;
 typedef union _QOS_TCLAS {
 
struct _TYPE_GENERAL {
@@ -124,21 +120,6 @@ typedef union _QOS_TCLAS {
} TYPE2_8021Q;
 } QOS_TCLAS, *PQOS_TCLAS;
 
-//typedef struct _U_APSD{
-//- TriggerEnable [4]
-//- MaxSPLength
-//- HighestAcBuffered
-//} U_APSD, *PU_APSD;
-
-//joseph TODO:
-// UAPSD function should be implemented by 2 data structure
-// "Qos control field" and "Qos info field"
-//typedef struct _QOS_UAPSD{
-// u8  bTriggerEnable[4];
-// u8  MaxSPLength;
-// u8  HighestBufAC;
-//} QOS_UAPSD, *PQOS_APSD;
-
 //
 //  802.11 Management frame Status Code field
 //
-- 
2.18.0

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


[PATCH 00/14] staging:rtl8192u: rtl819x_Qos.h style changes

2018-07-31 Thread John Whitmore
The first patch is a change to the block comment on the function
cmpk_counttxstatistic(). The function is a static to the file so the
block comment could be trimmed. Unfortunately I could find no useful
information in the block comment, apart from function name and list
of parameter types, which is included in the declaration. As a result
I totally cut the block comment.

All the remaining 13 patches fix coding style and checkpatch issues
with the file rtl819x_Qos.h. Possibly the major change is the
truncation of a number of unions to the structure which is actually
being used.

John Whitmore (14):
  staging:rtl8192u: Clean cmpk_counttxstatistic() comments - Style
  staging:rtl8192u: Remove union from aci_aifsn - Style
  staging:rtl8192u: Remove union from qos_tsinfo - Style
  staging:rtl8192u: Rename members of struct qos_tsinfo - Style
  staging:rtl8192u: Refactor union TSPEC_BODY - Style
  staging:rtl8192u: Rename TSInfo - Style
  staging:rtl8192u: Rename tspec_body members - Style
  staging:rtl8192u: Remove commented out code - Style
  staging:rtl8192u: Move QOS_TCLAS to rtl819x_TS.h - Style
  staging:rtl8192u: rename OCTET_STRING - Style
  staging:rtl8192u: Rename octet_string members - Style
  staging:rtl8192u: Remove unused UP2AC - Style
  staging:rtl8192u: Rename IsACValid and add parenthesis - Style
  staging:rtl8192u: Change clock comment - Style

 .../staging/rtl8192u/ieee80211/ieee80211.h|   4 +-
 .../rtl8192u/ieee80211/ieee80211_softmac.c|  40 ++--
 .../rtl8192u/ieee80211/rtl819x_BAProc.c   |   2 +-
 .../rtl8192u/ieee80211/rtl819x_HTProc.c   |   4 +-
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 207 ++
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   |  53 -
 .../rtl8192u/ieee80211/rtl819x_TSProc.c   |  36 +--
 drivers/staging/rtl8192u/r8192U_dm.c  |   4 +-
 drivers/staging/rtl8192u/r819xU_cmdpkt.c  |  18 --
 9 files changed, 160 insertions(+), 208 deletions(-)

-- 
2.18.0

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


[PATCH 05/14] staging:rtl8192u: Refactor union TSPEC_BODY - Style

2018-07-31 Thread John Whitmore
The union TSPEC_BODY is never used as a union. The union comprises an
array of bytes and a bitfield structure, both of which are 55 bytes in
length, but the byte array is never used. As a result the union has
been truncated to the bitfield struct, which is actually used.

Additionally the typedef has been removed from the structure to clear
the checkpatch issue with defining new types. Additionally the name has
been changed to lowercase to comply with coding style.

These changes are all coding style changes which should have no impact
on runtime code execution.

Signed-off-by: John Whitmore 
---
 .../rtl8192u/ieee80211/rtl819x_BAProc.c   |  2 +-
 .../staging/rtl8192u/ieee80211/rtl819x_Qos.h  | 49 +--
 .../staging/rtl8192u/ieee80211/rtl819x_TS.h   |  2 +-
 .../rtl8192u/ieee80211/rtl819x_TSProc.c   | 16 +++---
 4 files changed, 33 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 96fab43c1cfe..d35f10c695e4 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -626,7 +626,7 @@ TsInitAddBA(
pBA->DialogToken++; // 
DialogToken: Only keep the latest dialog token
pBA->BaParamSet.field.AMSDU_Support = 0;// Do not support 
A-MSDU with A-MPDU now!!
pBA->BaParamSet.field.BAPolicy = Policy;// Policy: Delayed or 
Immediate
-   pBA->BaParamSet.field.TID = 
pTS->ts_common_info.t_spec.f.TSInfo.uc_tsid;// TID
+   pBA->BaParamSet.field.TID = pTS->ts_common_info.t_spec.TSInfo.uc_tsid;  
// TID
// BufferSize: This need to be set according to A-MPDU vector
pBA->BaParamSet.field.BufferSize = 32;  // BufferSize: This 
need to be set according to A-MPDU vector
pBA->BaTimeoutValue = 0;// 
Timeout value: Set 0 to disable Timer
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
index d36a14197b4c..a4cecf4cc756 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h
@@ -46,32 +46,29 @@ struct qos_tsinfo {
u8:7;
 };
 
-//
-// WMM TSPEC Body.
-// Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
-//
-typedef union _TSPEC_BODY {
-   u8  charData[55];
-
-   struct {
-   struct qos_tsinfo   TSInfo; //u8TSInfo[3];
-   u16 NominalMSDUsize;
-   u16 MaxMSDUsize;
-   u32 MinServiceItv;
-   u32 MaxServiceItv;
-   u32 InactivityItv;
-   u32 SuspenItv;
-   u32 ServiceStartTime;
-   u32 MinDataRate;
-   u32 MeanDataRate;
-   u32 PeakDataRate;
-   u32 MaxBurstSize;
-   u32 DelayBound;
-   u32 MinPhyRate;
-   u16 SurplusBandwidthAllowance;
-   u16 MediumTime;
-   } f;// Field
-} TSPEC_BODY, *PTSPEC_BODY;
+/*
+ * WMM TSPEC Body.
+ * Ref: WMM spec 2.2.11: WME TSPEC Element, p.16.
+ * Note: sizeof 55 bytes
+ */
+struct tspec_body {
+   struct qos_tsinfo   TSInfo; //u8TSInfo[3];
+   u16 NominalMSDUsize;
+   u16 MaxMSDUsize;
+   u32 MinServiceItv;
+   u32 MaxServiceItv;
+   u32 InactivityItv;
+   u32 SuspenItv;
+   u32 ServiceStartTime;
+   u32 MinDataRate;
+   u32 MeanDataRate;
+   u32 PeakDataRate;
+   u32 MaxBurstSize;
+   u32 DelayBound;
+   u32 MinPhyRate;
+   u16 SurplusBandwidthAllowance;
+   u16 MediumTime;
+};
 
 //typedef struct _TCLASS{
 // TODO
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
index f5e79853fe9c..a9f865f810ce 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TS.h
@@ -19,7 +19,7 @@ struct ts_common_info {
struct timer_list   setup_timer;
struct timer_list   inact_timer;
u8  addr[6];
-   TSPEC_BODY  t_spec;
+   struct tspec_body   t_spec;
QOS_TCLAS   t_class[TCLAS_NUM];
u8  t_clas_proc;
u8  t_clas_num;
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c 
b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
index 076278dae321..bd2b4e5dfa60 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c
@@ -104,7 +104,7 @@ static void TsAddBaProcess(struct timer_list *t)
 static void ResetTsCommonInfo(struct 

[PATCH 07/15] staging: gasket: ioctl: fix function param line continuation style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Fix multi-line alignment formatting to look like:
  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
   VARIABLE3, VARIABLE4);

Many of these TODO items were previously cleaned up during the conversion
to standard logging functions.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_ioctl.c | 60 +--
 1 file changed, 30 insertions(+), 30 deletions(-)

diff --git a/drivers/staging/gasket/gasket_ioctl.c 
b/drivers/staging/gasket/gasket_ioctl.c
index 134d45a281ac..d3397cc74e69 100644
--- a/drivers/staging/gasket/gasket_ioctl.c
+++ b/drivers/staging/gasket/gasket_ioctl.c
@@ -79,12 +79,12 @@ static int gasket_read_simple_page_table_size(
if (ibuf.page_table_index >= gasket_dev->num_page_tables)
return -EFAULT;
 
-   ibuf.size = gasket_page_table_num_simple_entries(
-   gasket_dev->page_table[ibuf.page_table_index]);
+   ibuf.size =
+   
gasket_page_table_num_simple_entries(gasket_dev->page_table[ibuf.page_table_index]);
 
-   trace_gasket_ioctl_page_table_data(
-   ibuf.page_table_index, ibuf.size, ibuf.host_address,
-   ibuf.device_address);
+   trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
+  ibuf.host_address,
+  ibuf.device_address);
 
if (copy_to_user(argp, , sizeof(ibuf)))
return -EFAULT;
@@ -138,21 +138,21 @@ static int gasket_map_buffers(struct gasket_dev 
*gasket_dev,
if (copy_from_user(, argp, sizeof(struct gasket_page_table_ioctl)))
return -EFAULT;
 
-   trace_gasket_ioctl_page_table_data(
-   ibuf.page_table_index, ibuf.size, ibuf.host_address,
-   ibuf.device_address);
+   trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
+  ibuf.host_address,
+  ibuf.device_address);
 
if (ibuf.page_table_index >= gasket_dev->num_page_tables)
return -EFAULT;
 
-   if (gasket_page_table_are_addrs_bad(
-   gasket_dev->page_table[ibuf.page_table_index],
-   ibuf.host_address, ibuf.device_address, ibuf.size))
+   if 
(gasket_page_table_are_addrs_bad(gasket_dev->page_table[ibuf.page_table_index],
+   ibuf.host_address,
+   ibuf.device_address, ibuf.size))
return -EINVAL;
 
-   return gasket_page_table_map(
-   gasket_dev->page_table[ibuf.page_table_index],
-   ibuf.host_address, ibuf.device_address, ibuf.size / PAGE_SIZE);
+   return 
gasket_page_table_map(gasket_dev->page_table[ibuf.page_table_index],
+ibuf.host_address, ibuf.device_address,
+ibuf.size / PAGE_SIZE);
 }
 
 /* Unmap a userspace buffer from a device virtual address. */
@@ -164,16 +164,15 @@ static int gasket_unmap_buffers(struct gasket_dev 
*gasket_dev,
if (copy_from_user(, argp, sizeof(struct gasket_page_table_ioctl)))
return -EFAULT;
 
-   trace_gasket_ioctl_page_table_data(
-   ibuf.page_table_index, ibuf.size, ibuf.host_address,
-   ibuf.device_address);
+   trace_gasket_ioctl_page_table_data(ibuf.page_table_index, ibuf.size,
+  ibuf.host_address,
+  ibuf.device_address);
 
if (ibuf.page_table_index >= gasket_dev->num_page_tables)
return -EFAULT;
 
-   if (gasket_page_table_is_dev_addr_bad(
-   gasket_dev->page_table[ibuf.page_table_index],
-   ibuf.device_address, ibuf.size))
+   if 
(gasket_page_table_is_dev_addr_bad(gasket_dev->page_table[ibuf.page_table_index],
+ ibuf.device_address, ibuf.size))
return -EINVAL;
 
gasket_page_table_unmap(gasket_dev->page_table[ibuf.page_table_index],
@@ -197,8 +196,8 @@ static int gasket_config_coherent_allocator(
   sizeof(struct gasket_coherent_alloc_config_ioctl)))
return -EFAULT;
 
-   trace_gasket_ioctl_config_coherent_allocator(
-   ibuf.enable, ibuf.size, ibuf.dma_address);
+   trace_gasket_ioctl_config_coherent_allocator(ibuf.enable, ibuf.size,
+ibuf.dma_address);
 
if (ibuf.page_table_index >= gasket_dev->num_page_tables)
return -EFAULT;
@@ -207,13 +206,13 @@ static int gasket_config_coherent_allocator(
return -ENOMEM;
 
if (ibuf.enable == 0) {
-   ret = gasket_free_coherent_memory(
-   gasket_dev, ibuf.size, ibuf.dma_address,
-

[PATCH 08/15] staging: gasket: page table: fix function param line continuation style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Fix multi-line alignment formatting to look like:
  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
   VARIABLE3, VARIABLE4);

Many of these TODO items were previously cleaned up during the conversion
to standard logging functions.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 206 +++--
 drivers/staging/gasket/gasket_page_table.h |  33 ++--
 2 files changed, 120 insertions(+), 119 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index aa036b2e8193..13e1d0952a47 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -215,11 +215,10 @@ struct gasket_page_table {
 };
 
 /* See gasket_page_table.h for description. */
-int gasket_page_table_init(
-   struct gasket_page_table **ppg_tbl,
-   const struct gasket_bar_data *bar_data,
-   const struct gasket_page_table_config *page_table_config,
-   struct device *device, struct pci_dev *pci_dev)
+int gasket_page_table_init(struct gasket_page_table **ppg_tbl,
+  const struct gasket_bar_data *bar_data,
+  const struct gasket_page_table_config 
*page_table_config,
+  struct device *device, struct pci_dev *pci_dev)
 {
ulong bytes;
struct gasket_page_table *pg_tbl;
@@ -276,10 +275,10 @@ int gasket_page_table_init(
pg_tbl->extended_flag = 0;
}
pg_tbl->num_active_pages = 0;
-   pg_tbl->base_slot = (u64 __iomem *)&(
-   bar_data->virt_base[page_table_config->base_reg]);
-   pg_tbl->extended_offset_reg = (u64 __iomem *)&(
-   bar_data->virt_base[page_table_config->extended_reg]);
+   pg_tbl->base_slot =
+   (u64 __iomem 
*)_data->virt_base[page_table_config->base_reg];
+   pg_tbl->extended_offset_reg =
+   (u64 __iomem 
*)_data->virt_base[page_table_config->extended_reg];
pg_tbl->device = get_device(device);
pg_tbl->pci_dev = pci_dev_get(pci_dev);
 
@@ -292,8 +291,8 @@ int gasket_page_table_init(
  * Check if a range of PTEs is free.
  * The page table mutex must be held by the caller.
  */
-static bool gasket_is_pte_range_free(
-   struct gasket_page_table_entry *ptes, uint num_entries)
+static bool gasket_is_pte_range_free(struct gasket_page_table_entry *ptes,
+uint num_entries)
 {
int i;
 
@@ -309,9 +308,9 @@ static bool gasket_is_pte_range_free(
  * Free a second level page [sub]table.
  * The page table mutex must be held before this call.
  */
-static void gasket_free_extended_subtable(
-   struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte,
-   u64 __iomem *slot)
+static void gasket_free_extended_subtable(struct gasket_page_table *pg_tbl,
+ struct gasket_page_table_entry *pte,
+ u64 __iomem *slot)
 {
/* Release the page table from the driver */
pte->status = PTE_FREE;
@@ -337,8 +336,8 @@ static void gasket_free_extended_subtable(
  * Actually perform collection.
  * The page table mutex must be held by the caller.
  */
-static void gasket_page_table_garbage_collect_nolock(
-   struct gasket_page_table *pg_tbl)
+static void
+gasket_page_table_garbage_collect_nolock(struct gasket_page_table *pg_tbl)
 {
struct gasket_page_table_entry *pte;
u64 __iomem *slot;
@@ -351,10 +350,10 @@ static void gasket_page_table_garbage_collect_nolock(
 pte < pg_tbl->entries + pg_tbl->config.total_entries;
 pte++, slot++) {
if (pte->status == PTE_INUSE) {
-   if (gasket_is_pte_range_free(
-   pte->sublevel, GASKET_PAGES_PER_SUBTABLE))
-   gasket_free_extended_subtable(
-   pg_tbl, pte, slot);
+   if (gasket_is_pte_range_free(pte->sublevel,
+GASKET_PAGES_PER_SUBTABLE))
+   gasket_free_extended_subtable(pg_tbl, pte,
+ slot);
}
}
 }
@@ -384,8 +383,8 @@ void gasket_page_table_cleanup(struct gasket_page_table 
*pg_tbl)
 }
 
 /* See gasket_page_table.h for description. */
-int gasket_page_table_partition(
-   struct gasket_page_table *pg_tbl, uint num_simple_entries)
+int gasket_page_table_partition(struct gasket_page_table *pg_tbl,
+   uint num_simple_entries)
 {
int i, start;
 
@@ -445,10 +444,10 @@ static int is_coherent(struct gasket_page_table *pg_tbl, 
ulong host_addr)
  * an extended mapping, these will be within a second-level page table
  * allocated by the host and so must have 

[PATCH 04/15] staging: gasket: pg tbl: remove static function forward declarations

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Remove forward declarations of static functions, move code to avoid
forward references, for kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 1433 ++--
 1 file changed, 684 insertions(+), 749 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index b42f6637b909..aa036b2e8193 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -214,71 +214,6 @@ struct gasket_page_table {
struct gasket_coherent_page_entry *coherent_pages;
 };
 
-/* Mapping declarations */
-static int gasket_map_simple_pages(
-   struct gasket_page_table *pg_tbl, ulong host_addr,
-   ulong dev_addr, uint num_pages);
-static int gasket_map_extended_pages(
-   struct gasket_page_table *pg_tbl, ulong host_addr,
-   ulong dev_addr, uint num_pages);
-static int gasket_perform_mapping(
-   struct gasket_page_table *pg_tbl,
-   struct gasket_page_table_entry *pte_base, u64 __iomem *att_base,
-   ulong host_addr, uint num_pages, int is_simple_mapping);
-
-static int gasket_alloc_simple_entries(
-   struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages);
-static int gasket_alloc_extended_entries(
-   struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_entries);
-static int gasket_alloc_extended_subtable(
-   struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte,
-   u64 __iomem *att_reg);
-
-/* Unmapping declarations */
-static void gasket_page_table_unmap_nolock(
-   struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages);
-static void gasket_page_table_unmap_all_nolock(
-   struct gasket_page_table *pg_tbl);
-static void gasket_unmap_simple_pages(
-   struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages);
-static void gasket_unmap_extended_pages(
-   struct gasket_page_table *pg_tbl, ulong start_addr, uint num_pages);
-static void gasket_perform_unmapping(
-   struct gasket_page_table *pg_tbl,
-   struct gasket_page_table_entry *pte_base, u64 __iomem *att_base,
-   uint num_pages, int is_simple_mapping);
-
-static void gasket_free_extended_subtable(
-   struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte,
-   u64 __iomem *att_reg);
-static bool gasket_release_page(struct page *page);
-
-/* Other/utility declarations */
-static inline bool gasket_addr_is_simple(
-   struct gasket_page_table *pg_tbl, ulong addr);
-static bool gasket_is_simple_dev_addr_bad(
-   struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages);
-static bool gasket_is_extended_dev_addr_bad(
-   struct gasket_page_table *pg_tbl, ulong dev_addr, uint num_pages);
-static bool gasket_is_pte_range_free(
-   struct gasket_page_table_entry *pte, uint num_entries);
-static void gasket_page_table_garbage_collect_nolock(
-   struct gasket_page_table *pg_tbl);
-
-/* Address format declarations */
-static ulong gasket_components_to_dev_address(
-   struct gasket_page_table *pg_tbl, int is_simple, uint page_index,
-   uint offset);
-static int gasket_simple_page_idx(
-   struct gasket_page_table *pg_tbl, ulong dev_addr);
-static ulong gasket_extended_lvl0_page_idx(
-   struct gasket_page_table *pg_tbl, ulong dev_addr);
-static ulong gasket_extended_lvl1_page_idx(
-   struct gasket_page_table *pg_tbl, ulong dev_addr);
-
-static int is_coherent(struct gasket_page_table *pg_tbl, ulong host_addr);
-
-/* Public/exported functions */
 /* See gasket_page_table.h for description. */
 int gasket_page_table_init(
struct gasket_page_table **ppg_tbl,
@@ -353,6 +288,85 @@ int gasket_page_table_init(
return 0;
 }
 
+/*
+ * Check if a range of PTEs is free.
+ * The page table mutex must be held by the caller.
+ */
+static bool gasket_is_pte_range_free(
+   struct gasket_page_table_entry *ptes, uint num_entries)
+{
+   int i;
+
+   for (i = 0; i < num_entries; i++) {
+   if (ptes[i].status != PTE_FREE)
+   return false;
+   }
+
+   return true;
+}
+
+/*
+ * Free a second level page [sub]table.
+ * The page table mutex must be held before this call.
+ */
+static void gasket_free_extended_subtable(
+   struct gasket_page_table *pg_tbl, struct gasket_page_table_entry *pte,
+   u64 __iomem *slot)
+{
+   /* Release the page table from the driver */
+   pte->status = PTE_FREE;
+
+   /* Release the page table from the device */
+   writeq(0, slot);
+   /* Force sync around the address release. */
+   mb();
+
+   if (pte->dma_addr)
+   dma_unmap_page(pg_tbl->device, pte->dma_addr, PAGE_SIZE,
+  DMA_BIDIRECTIONAL);
+
+   vfree(pte->sublevel);
+
+   if (pte->page)
+   free_page((ulong)page_address(pte->page));
+
+   memset(pte, 0, sizeof(struct 

[PATCH 11/15] staging: gasket: TODO: remove entry for multi-line alignment style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Multi-line alignment formatting issues fixed, remove the TODO entry for
this.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/TODO | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO
index 6aa2a7f6bc4b..6ff8e01b04cc 100644
--- a/drivers/staging/gasket/TODO
+++ b/drivers/staging/gasket/TODO
@@ -4,9 +4,6 @@ staging directory.
 - Use misc interface instead of major number for driver version description.
 - Add descriptions of module_param's
 - apex_get_status() should actually check status.
-- Fix multi-line alignment formatting to look like:
-  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
-   VARIABLE3, VARIABLE4);
 - "drivers" should never be dealing with "raw" sysfs calls or mess around with
   kobjects at all. The driver core should handle all of this for you
   automaically. There should not be a need for raw attribute macros.
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 09/15] staging: gasket: sysfs: fix function param line continuation style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Fix multi-line alignment formatting to look like:
  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
   VARIABLE3, VARIABLE4);

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_sysfs.c | 26 +++---
 drivers/staging/gasket/gasket_sysfs.h | 32 +--
 2 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/drivers/staging/gasket/gasket_sysfs.c 
b/drivers/staging/gasket/gasket_sysfs.c
index ef4eca02afa6..a4bfca43cd03 100644
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ b/drivers/staging/gasket/gasket_sysfs.c
@@ -145,8 +145,8 @@ void gasket_sysfs_init(void)
}
 }
 
-int gasket_sysfs_create_mapping(
-   struct device *device, struct gasket_dev *gasket_dev)
+int gasket_sysfs_create_mapping(struct device *device,
+   struct gasket_dev *gasket_dev)
 {
struct gasket_sysfs_mapping *mapping;
int map_idx = -1;
@@ -210,8 +210,8 @@ int gasket_sysfs_create_mapping(
return 0;
 }
 
-int gasket_sysfs_create_entries(
-   struct device *device, const struct gasket_sysfs_attribute *attrs)
+int gasket_sysfs_create_entries(struct device *device,
+   const struct gasket_sysfs_attribute *attrs)
 {
int i;
int ret;
@@ -293,8 +293,8 @@ void gasket_sysfs_put_device_data(struct device *device, 
struct gasket_dev *dev)
 }
 EXPORT_SYMBOL(gasket_sysfs_put_device_data);
 
-struct gasket_sysfs_attribute *gasket_sysfs_get_attr(
-   struct device *device, struct device_attribute *attr)
+struct gasket_sysfs_attribute *
+gasket_sysfs_get_attr(struct device *device, struct device_attribute *attr)
 {
int i;
int num_attrs;
@@ -317,8 +317,8 @@ struct gasket_sysfs_attribute *gasket_sysfs_get_attr(
 }
 EXPORT_SYMBOL(gasket_sysfs_get_attr);
 
-void gasket_sysfs_put_attr(
-   struct device *device, struct gasket_sysfs_attribute *attr)
+void gasket_sysfs_put_attr(struct device *device,
+  struct gasket_sysfs_attribute *attr)
 {
int i;
int num_attrs;
@@ -342,9 +342,9 @@ void gasket_sysfs_put_attr(
 }
 EXPORT_SYMBOL(gasket_sysfs_put_attr);
 
-ssize_t gasket_sysfs_register_store(
-   struct device *device, struct device_attribute *attr, const char *buf,
-   size_t count)
+ssize_t gasket_sysfs_register_store(struct device *device,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
ulong parsed_value = 0;
struct gasket_sysfs_mapping *mapping;
@@ -386,8 +386,8 @@ ssize_t gasket_sysfs_register_store(
gasket_attr->data.bar_address.offset);
 
if (gasket_attr->write_callback)
-   gasket_attr->write_callback(
-   gasket_dev, gasket_attr, parsed_value);
+   gasket_attr->write_callback(gasket_dev, gasket_attr,
+   parsed_value);
 
gasket_sysfs_put_attr(device, gasket_attr);
put_mapping(mapping);
diff --git a/drivers/staging/gasket/gasket_sysfs.h 
b/drivers/staging/gasket/gasket_sysfs.h
index e9f4fad80461..f32eaf89e056 100644
--- a/drivers/staging/gasket/gasket_sysfs.h
+++ b/drivers/staging/gasket/gasket_sysfs.h
@@ -68,9 +68,9 @@ struct gasket_sysfs_attribute {
 * The callback should perform any logging necessary, as errors cannot
 * be returned from the callback.
 */
-   void (*write_callback)(
-   struct gasket_dev *dev, struct gasket_sysfs_attribute *attr,
-   ulong value);
+   void (*write_callback)(struct gasket_dev *dev,
+  struct gasket_sysfs_attribute *attr,
+  ulong value);
 };
 
 #define GASKET_SYSFS_RO(_name, _show_function, _attr_type) 
\
@@ -98,8 +98,8 @@ void gasket_sysfs_init(void);
  * If this function is not called before gasket_sysfs_create_entries, a warning
  * will be logged.
  */
-int gasket_sysfs_create_mapping(
-   struct device *device, struct gasket_dev *gasket_dev);
+int gasket_sysfs_create_mapping(struct device *device,
+   struct gasket_dev *gasket_dev);
 
 /*
  * Creates bulk entries in sysfs.
@@ -111,8 +111,8 @@ int gasket_sysfs_create_mapping(
  * gasket_sysfs_create_mapping had a legacy device, the entries will be created
  * for it, as well.
  */
-int gasket_sysfs_create_entries(
-   struct device *device, const struct gasket_sysfs_attribute *attrs);
+int gasket_sysfs_create_entries(struct device *device,
+   const struct gasket_sysfs_attribute *attrs);
 
 /*
  * Removes a device mapping from the global table.
@@ -141,8 +141,8 @@ struct gasket_dev *gasket_sysfs_get_device_data(struct 
device *device);
  * @device: Kernel device structure.
  * @dev: Gasket device descriptor (returned by 

[PATCH 12/15] staging: gasket: apex: move driver-private defines out of apex.h

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

apex.h is supposed to contain kernel-userspace interface definitions,
but has a number of defines that are only used by apex_driver.c or are
not used at all.  Move driver implementation defines not shared with
userspace to the driver source.  Remove unused defines.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/apex.h| 62 +---
 drivers/staging/gasket/apex_driver.c | 29 +
 2 files changed, 31 insertions(+), 60 deletions(-)

diff --git a/drivers/staging/gasket/apex.h b/drivers/staging/gasket/apex.h
index d89cc2387b7d..3bbce5e4 100644
--- a/drivers/staging/gasket/apex.h
+++ b/drivers/staging/gasket/apex.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Apex kernel-userspace interface definition(s).
+ * Apex kernel-userspace interface definitions.
  *
  * Copyright (C) 2018 Google, Inc.
  */
@@ -8,66 +8,8 @@
 #define __APEX_H__
 
 #include 
-#include 
 
-#include "gasket.h"
-
-/* Structural definitions/macros. */
-/* The number of PCI BARs. */
-#define APEX_NUM_BARS 3
-
-/* Size of a memory page in bytes, and the related number of bits to shift. */
-#define APEX_PAGE_SHIFT 12
-#define APEX_PAGE_SIZE BIT(APEX_PAGE_SHIFT)
-
-#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */
-
-/*
- * Addresses are 2^3=8 bytes each. Page in second level page table holds
- * APEX_PAGE_SIZE/8 addresses.
- */
-#define APEX_ADDR_SHIFT 3
-#define APEX_LEVEL_SHIFT (APEX_PAGE_SHIFT - APEX_ADDR_SHIFT)
-#define APEX_LEVEL_SIZE BIT(APEX_LEVEL_SHIFT)
-
-#define APEX_PAGE_TABLE_MAX 65536
-#define APEX_SIMPLE_PAGE_MAX APEX_PAGE_TABLE_MAX
-#define APEX_EXTENDED_PAGE_MAX (APEX_PAGE_TABLE_MAX << APEX_LEVEL_SHIFT)
-
-/* Check reset 120 times */
-#define APEX_RESET_RETRY 120
-/* Wait 100 ms between checks. Total 12 sec wait maximum. */
-#define APEX_RESET_DELAY 100
-
-#define APEX_CHIP_INIT_DONE 2
-#define APEX_RESET_ACCEPTED 0
-
-enum apex_reset_types {
-   APEX_CHIP_REINIT_RESET = 3,
-};
-
-/* Interrupt defines */
-/* Gasket device interrupts enums must be dense (i.e., no empty slots). */
-enum apex_interrupt {
-   APEX_INTERRUPT_INSTR_QUEUE = 0,
-   APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1,
-   APEX_INTERRUPT_PARAM_QUEUE = 2,
-   APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3,
-   APEX_INTERRUPT_SC_HOST_0 = 4,
-   APEX_INTERRUPT_SC_HOST_1 = 5,
-   APEX_INTERRUPT_SC_HOST_2 = 6,
-   APEX_INTERRUPT_SC_HOST_3 = 7,
-   APEX_INTERRUPT_TOP_LEVEL_0 = 8,
-   APEX_INTERRUPT_TOP_LEVEL_1 = 9,
-   APEX_INTERRUPT_TOP_LEVEL_2 = 10,
-   APEX_INTERRUPT_TOP_LEVEL_3 = 11,
-   APEX_INTERRUPT_FATAL_ERR = 12,
-   APEX_INTERRUPT_COUNT = 13,
-};
-
-/*
- * Clock Gating ioctl.
- */
+/* Clock Gating ioctl. */
 struct apex_gate_clock_ioctl {
/* Enter or leave clock gated state. */
u64 enable;
diff --git a/drivers/staging/gasket/apex_driver.c 
b/drivers/staging/gasket/apex_driver.c
index c0d3922e1d7c..dfbff47b4608 100644
--- a/drivers/staging/gasket/apex_driver.c
+++ b/drivers/staging/gasket/apex_driver.c
@@ -54,6 +54,17 @@
  */
 #define APEX_PAGE_TABLE_TOTAL_ENTRIES 8192
 
+#define APEX_EXTENDED_SHIFT 63 /* Extended address bit position. */
+
+enum apex_reset_types {
+   APEX_CHIP_REINIT_RESET = 3,
+};
+
+/* Check reset 120 times */
+#define APEX_RESET_RETRY 120
+/* Wait 100 ms between checks. Total 12 sec wait maximum. */
+#define APEX_RESET_DELAY 100
+
 /* Enumeration of the supported sysfs entries. */
 enum sysfs_attribute_type {
ATTR_KERNEL_HIB_PAGE_TABLE_SIZE,
@@ -133,6 +144,24 @@ static const struct gasket_mappable_region 
mappable_regions[NUM_REGIONS] = {
 static const struct gasket_mappable_region cm_mappable_regions[1] = { { 0x0,
APEX_CH_MEM_BYTES } };
 
+/* Gasket device interrupts enums must be dense (i.e., no empty slots). */
+enum apex_interrupt {
+   APEX_INTERRUPT_INSTR_QUEUE = 0,
+   APEX_INTERRUPT_INPUT_ACTV_QUEUE = 1,
+   APEX_INTERRUPT_PARAM_QUEUE = 2,
+   APEX_INTERRUPT_OUTPUT_ACTV_QUEUE = 3,
+   APEX_INTERRUPT_SC_HOST_0 = 4,
+   APEX_INTERRUPT_SC_HOST_1 = 5,
+   APEX_INTERRUPT_SC_HOST_2 = 6,
+   APEX_INTERRUPT_SC_HOST_3 = 7,
+   APEX_INTERRUPT_TOP_LEVEL_0 = 8,
+   APEX_INTERRUPT_TOP_LEVEL_1 = 9,
+   APEX_INTERRUPT_TOP_LEVEL_2 = 10,
+   APEX_INTERRUPT_TOP_LEVEL_3 = 11,
+   APEX_INTERRUPT_FATAL_ERR = 12,
+   APEX_INTERRUPT_COUNT = 13,
+};
+
 /* Interrupt descriptors for Apex */
 static struct gasket_interrupt_desc apex_interrupts[] = {
{
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 15/15] staging: gasket: page table: fix header file include guard symbol

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

The include guard symbol for gasket_page_table.h is out-of-date.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.h 
b/drivers/staging/gasket/gasket_page_table.h
index 00c06f050eb9..7b01b73ea3e7 100644
--- a/drivers/staging/gasket/gasket_page_table.h
+++ b/drivers/staging/gasket/gasket_page_table.h
@@ -9,8 +9,8 @@
  * Copyright (C) 2018 Google, Inc.
  */
 
-#ifndef __GASKET_ADDR_TRNSL_H__
-#define __GASKET_ADDR_TRNSL_H__
+#ifndef __GASKET_PAGE_TABLE_H__
+#define __GASKET_PAGE_TABLE_H__
 
 #include 
 #include 
@@ -246,4 +246,4 @@ void gasket_free_coherent_memory_all(struct gasket_dev 
*gasket_dev,
 int gasket_set_user_virt(struct gasket_dev *gasket_dev, uint64_t size,
 dma_addr_t dma_address, ulong vma);
 
-#endif
+#endif  /* __GASKET_PAGE_TABLE_H__ */
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 14/15] Revert "staging: gasket: page table: hold references to device and pci_dev"

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

gasket_free_dev() is called only from driver PCI probe and remove
function. It is guaranteed that that pci_dev structure is not going
anywhere during that time; there is no need to take this additional
reference.

This reverts commit dd9d1502feea3c23d412f289aad79e1d4e86d45d.

Reported-by: Dmitry Torokhov 
Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_page_table.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_page_table.c 
b/drivers/staging/gasket/gasket_page_table.c
index 13e1d0952a47..ed6ab3c5f038 100644
--- a/drivers/staging/gasket/gasket_page_table.c
+++ b/drivers/staging/gasket/gasket_page_table.c
@@ -280,7 +280,7 @@ int gasket_page_table_init(struct gasket_page_table 
**ppg_tbl,
pg_tbl->extended_offset_reg =
(u64 __iomem 
*)_data->virt_base[page_table_config->extended_reg];
pg_tbl->device = get_device(device);
-   pg_tbl->pci_dev = pci_dev_get(pci_dev);
+   pg_tbl->pci_dev = pci_dev;
 
dev_dbg(device, "Page table initialized successfully\n");
 
@@ -378,7 +378,6 @@ void gasket_page_table_cleanup(struct gasket_page_table 
*pg_tbl)
pg_tbl->entries = NULL;
 
put_device(pg_tbl->device);
-   pci_dev_put(pg_tbl->pci_dev);
kfree(pg_tbl);
 }
 
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 06/15] staging: gasket: core: fix function param line continuation style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Fix multi-line alignment formatting to look like:
  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
   VARIABLE3, VARIABLE4);

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 294 +--
 drivers/staging/gasket/gasket_core.h |  68 +++
 2 files changed, 179 insertions(+), 183 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index b5a7254fbfb3..44344528cd88 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -103,8 +103,9 @@ enum gasket_sysfs_attribute_type {
 };
 
 /* Perform a standard Gasket callback. */
-static inline int check_and_invoke_callback(
-   struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *))
+static inline int
+check_and_invoke_callback(struct gasket_dev *gasket_dev,
+ int (*cb_function)(struct gasket_dev *))
 {
int ret = 0;
 
@@ -119,8 +120,9 @@ static inline int check_and_invoke_callback(
 }
 
 /* Perform a standard Gasket callback without grabbing gasket_dev->mutex. */
-static inline int gasket_check_and_invoke_callback_nolock(
-   struct gasket_dev *gasket_dev, int (*cb_function)(struct gasket_dev *))
+static inline int
+gasket_check_and_invoke_callback_nolock(struct gasket_dev *gasket_dev,
+   int (*cb_function)(struct gasket_dev *))
 {
int ret = 0;
 
@@ -147,8 +149,8 @@ static int gasket_owned_by_current_tgid(struct 
gasket_cdev_info *info)
  *
  * Returns the located slot number on success or a negative number on failure.
  */
-static int gasket_find_dev_slot(
-   struct gasket_internal_desc *internal_desc, const char *kobj_name)
+static int gasket_find_dev_slot(struct gasket_internal_desc *internal_desc,
+   const char *kobj_name)
 {
int i;
 
@@ -186,9 +188,9 @@ static int gasket_find_dev_slot(
  *
  * Returns 0 if successful, a negative error code otherwise.
  */
-static int gasket_alloc_dev(
-   struct gasket_internal_desc *internal_desc, struct device *parent,
-   struct gasket_dev **pdev, const char *kobj_name)
+static int gasket_alloc_dev(struct gasket_internal_desc *internal_desc,
+   struct device *parent, struct gasket_dev **pdev,
+   const char *kobj_name)
 {
int dev_idx;
const struct gasket_driver_desc *driver_desc =
@@ -228,7 +230,7 @@ static int gasket_alloc_dev(
 gasket_dev->dev_idx);
dev_info->devt =
MKDEV(driver_desc->major, driver_desc->minor +
-   gasket_dev->dev_idx);
+ gasket_dev->dev_idx);
dev_info->device = device_create(internal_desc->class, parent,
dev_info->devt, gasket_dev, dev_info->name);
 
@@ -371,8 +373,8 @@ static void gasket_unmap_pci_bar(struct gasket_dev *dev, 
int bar_num)
  *
  * Returns 0 on success and a negative value otherwise.
  */
-static int gasket_setup_pci(
-   struct pci_dev *pci_dev, struct gasket_dev *gasket_dev)
+static int gasket_setup_pci(struct pci_dev *pci_dev,
+   struct gasket_dev *gasket_dev)
 {
int i, mapped_bars, ret;
 
@@ -421,8 +423,8 @@ static int gasket_get_hw_status(struct gasket_dev 
*gasket_dev)
const struct gasket_driver_desc *driver_desc =
gasket_dev->internal_desc->driver_desc;
 
-   status = gasket_check_and_invoke_callback_nolock(
-   gasket_dev, driver_desc->device_status_cb);
+   status = gasket_check_and_invoke_callback_nolock(gasket_dev,
+
driver_desc->device_status_cb);
if (status != GASKET_STATUS_ALIVE) {
dev_dbg(gasket_dev->dev, "Hardware reported status %d.\n",
status);
@@ -437,8 +439,7 @@ static int gasket_get_hw_status(struct gasket_dev 
*gasket_dev)
}
 
for (i = 0; i < driver_desc->num_page_tables; ++i) {
-   status = gasket_page_table_system_status(
-   gasket_dev->page_table[i]);
+   status = 
gasket_page_table_system_status(gasket_dev->page_table[i]);
if (status != GASKET_STATUS_ALIVE) {
dev_dbg(gasket_dev->dev,
"Page table %d reported status %d.\n",
@@ -450,8 +451,10 @@ static int gasket_get_hw_status(struct gasket_dev 
*gasket_dev)
return GASKET_STATUS_ALIVE;
 }
 
-static ssize_t gasket_write_mappable_regions(
-   char *buf, const struct gasket_driver_desc *driver_desc, int bar_index)
+static ssize_t
+gasket_write_mappable_regions(char *buf,
+ const struct gasket_driver_desc *driver_desc,
+ int bar_index)
 {
int i;
ssize_t written;
@@ -478,8 +481,8 @@ static ssize_t 

[PATCH 13/15] staging: gasket: core: use bool type for ns_capable result

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

When gasket core was converted from using capable() to use ns_capable()
instead, the type of the variable holding the result should have been
converted from int to bool.

Reported-by: Dmitry Torokhov 
Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index 44344528cd88..f76f4a0ecbac 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -1191,7 +1191,7 @@ static int gasket_open(struct inode *inode, struct file 
*filp)
struct gasket_cdev_info *dev_info =
container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
struct pid_namespace *pid_ns = task_active_pid_ns(current);
-   int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
+   bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
 
gasket_dev = dev_info->gasket_dev_ptr;
driver_desc = gasket_dev->internal_desc->driver_desc;
@@ -1270,7 +1270,7 @@ static int gasket_release(struct inode *inode, struct 
file *file)
struct gasket_cdev_info *dev_info =
container_of(inode->i_cdev, struct gasket_cdev_info, cdev);
struct pid_namespace *pid_ns = task_active_pid_ns(current);
-   int is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
+   bool is_root = ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN);
 
gasket_dev = dev_info->gasket_dev_ptr;
driver_desc = gasket_dev->internal_desc->driver_desc;
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 10/15] staging: gasket: interrupt: fix function param line continuation style

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Fix multi-line alignment formatting to look like:
  int ret = long_function_name(device, VARIABLE1, VARIABLE2,
   VARIABLE3, VARIABLE4);

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_interrupt.c | 73 +++
 drivers/staging/gasket/gasket_interrupt.h | 19 +++---
 2 files changed, 43 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index 3079b59b122b..09c3d0747af6 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -144,11 +144,10 @@ static void gasket_interrupt_setup(struct gasket_dev 
*gasket_dev)
}
 
mask = ~(0x << pack_shift);
-   value = gasket_dev_read_64(
-   gasket_dev,
-   interrupt_data->interrupt_bar_index,
-   interrupt_data->interrupts[i].reg) &
-   mask;
+   value = gasket_dev_read_64(gasket_dev,
+  
interrupt_data->interrupt_bar_index,
+  
interrupt_data->interrupts[i].reg);
+   value &= mask;
value |= interrupt_data->interrupts[i].index
 << pack_shift;
}
@@ -187,8 +186,8 @@ static irqreturn_t gasket_msix_interrupt_handler(int irq, 
void *dev_id)
return IRQ_HANDLED;
 }
 
-static int gasket_interrupt_msix_init(
-   struct gasket_interrupt_data *interrupt_data)
+static int
+gasket_interrupt_msix_init(struct gasket_interrupt_data *interrupt_data)
 {
int ret = 1;
int i;
@@ -210,10 +209,9 @@ static int gasket_interrupt_msix_init(
interrupt_data->msix_configured = 1;
 
for (i = 0; i < interrupt_data->num_interrupts; i++) {
-   ret = request_irq(
-   interrupt_data->msix_entries[i].vector,
-   gasket_msix_interrupt_handler, 0, interrupt_data->name,
-   interrupt_data);
+   ret = request_irq(interrupt_data->msix_entries[i].vector,
+ gasket_msix_interrupt_handler, 0,
+ interrupt_data->name, interrupt_data);
 
if (ret) {
dev_err(_data->pci_dev->dev,
@@ -250,25 +248,23 @@ static void force_msix_interrupt_unmasking(struct 
gasket_dev *gasket_dev)
ulong location = APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE +
 MSIX_MASK_BIT_OFFSET + i * MSIX_VECTOR_SIZE;
u32 mask =
-   gasket_dev_read_32(
-   gasket_dev,
-   gasket_dev->interrupt_data->interrupt_bar_index,
-   location);
+   gasket_dev_read_32(gasket_dev,
+  
gasket_dev->interrupt_data->interrupt_bar_index,
+  location);
if (!(mask & 1))
continue;
/* Unmask the msix vector (clear 32 bits) */
-   gasket_dev_write_32(
-   gasket_dev, 0,
-   gasket_dev->interrupt_data->interrupt_bar_index,
-   location);
+   gasket_dev_write_32(gasket_dev, 0,
+   
gasket_dev->interrupt_data->interrupt_bar_index,
+   location);
}
 #undef MSIX_VECTOR_SIZE
 #undef MSIX_MASK_BIT_OFFSET
 #undef APEX_BAR2_REG_KERNEL_HIB_MSIX_TABLE
 }
 
-static ssize_t interrupt_sysfs_show(
-   struct device *device, struct device_attribute *attr, char *buf)
+static ssize_t interrupt_sysfs_show(struct device *device,
+   struct device_attribute *attr, char *buf)
 {
int i, ret;
ssize_t written = 0, total_written = 0;
@@ -318,22 +314,22 @@ static ssize_t interrupt_sysfs_show(
 }
 
 static struct gasket_sysfs_attribute interrupt_sysfs_attrs[] = {
-   GASKET_SYSFS_RO(
-   interrupt_counts, interrupt_sysfs_show, ATTR_INTERRUPT_COUNTS),
+   GASKET_SYSFS_RO(interrupt_counts, interrupt_sysfs_show,
+   ATTR_INTERRUPT_COUNTS),
GASKET_END_OF_ATTR_ARRAY,
 };
 
-int gasket_interrupt_init(
-   struct gasket_dev *gasket_dev, const char *name, int type,
-   const struct gasket_interrupt_desc *interrupts,
-   int num_interrupts, int pack_width, int bar_index,
-   const struct gasket_wire_interrupt_offsets *wire_int_offsets)
+int gasket_interrupt_init(struct gasket_dev *gasket_dev, const char *name,
+ int type,
+ const struct 

[PATCH 01/15] staging: gasket: core: remove static function forward declarations

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Remove forward declarations of static functions, move code to avoid
forward references, for kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_core.c | 1900 +-
 1 file changed, 922 insertions(+), 978 deletions(-)

diff --git a/drivers/staging/gasket/gasket_core.c 
b/drivers/staging/gasket/gasket_core.c
index c00774059f9e..b5a7254fbfb3 100644
--- a/drivers/staging/gasket/gasket_core.c
+++ b/drivers/staging/gasket/gasket_core.c
@@ -67,61 +67,6 @@ enum do_map_region_status {
DO_MAP_REGION_INVALID,
 };
 
-/* Function declarations; comments are with definitions. */
-static int __init gasket_init(void);
-static void __exit gasket_exit(void);
-
-static int gasket_pci_probe(
-   struct pci_dev *pci_dev, const struct pci_device_id *id);
-static void gasket_pci_remove(struct pci_dev *pci_dev);
-
-static int gasket_setup_pci(struct pci_dev *pci_dev, struct gasket_dev *dev);
-static void gasket_cleanup_pci(struct gasket_dev *dev);
-
-static int gasket_map_pci_bar(struct gasket_dev *dev, int bar_num);
-static void gasket_unmap_pci_bar(struct gasket_dev *dev, int bar_num);
-
-static int gasket_alloc_dev(
-   struct gasket_internal_desc *internal_desc, struct device *dev,
-   struct gasket_dev **pdev, const char *kobj_name);
-static void gasket_free_dev(struct gasket_dev *dev);
-
-static int gasket_find_dev_slot(
-   struct gasket_internal_desc *internal_desc, const char *kobj_name);
-
-static int gasket_add_cdev(
-   struct gasket_cdev_info *dev_info,
-   const struct file_operations *file_ops, struct module *owner);
-
-static int gasket_enable_dev(
-   struct gasket_internal_desc *internal_desc,
-   struct gasket_dev *gasket_dev);
-static void gasket_disable_dev(struct gasket_dev *gasket_dev);
-
-static struct gasket_internal_desc *lookup_internal_desc(
-   struct pci_dev *pci_dev);
-
-static ssize_t gasket_sysfs_data_show(
-   struct device *device, struct device_attribute *attr, char *buf);
-
-static int gasket_mmap(struct file *filp, struct vm_area_struct *vma);
-static int gasket_open(struct inode *inode, struct file *file);
-static int gasket_release(struct inode *inode, struct file *file);
-static long gasket_ioctl(struct file *filp, uint cmd, ulong arg);
-
-static int gasket_mm_vma_bar_offset(
-   const struct gasket_dev *gasket_dev, const struct vm_area_struct *vma,
-   ulong *bar_offset);
-static bool gasket_mm_get_mapping_addrs(
-   const struct gasket_mappable_region *region, ulong bar_offset,
-   ulong requested_length, struct gasket_mappable_region *mappable_region,
-   ulong *virt_offset);
-static enum do_map_region_status do_map_region(
-   const struct gasket_dev *gasket_dev, struct vm_area_struct *vma,
-   struct gasket_mappable_region *map_region);
-
-static int gasket_get_hw_status(struct gasket_dev *gasket_dev);
-
 /* Global data definitions. */
 /* Mutex - only for framework-wide data. Other data should be protected by
  * finer-grained locks.
@@ -157,48 +102,6 @@ enum gasket_sysfs_attribute_type {
ATTR_USER_MEM_RANGES
 };
 
-/* File operations for all Gasket devices. */
-static const struct file_operations gasket_file_ops = {
-   .owner = THIS_MODULE,
-   .llseek = no_llseek,
-   .mmap = gasket_mmap,
-   .open = gasket_open,
-   .release = gasket_release,
-   .unlocked_ioctl = gasket_ioctl,
-};
-
-/* These attributes apply to all Gasket driver instances. */
-static const struct gasket_sysfs_attribute gasket_sysfs_generic_attrs[] = {
-   GASKET_SYSFS_RO(bar_offsets, gasket_sysfs_data_show, ATTR_BAR_OFFSETS),
-   GASKET_SYSFS_RO(bar_sizes, gasket_sysfs_data_show, ATTR_BAR_SIZES),
-   GASKET_SYSFS_RO(driver_version, gasket_sysfs_data_show,
-   ATTR_DRIVER_VERSION),
-   GASKET_SYSFS_RO(framework_version, gasket_sysfs_data_show,
-   ATTR_FRAMEWORK_VERSION),
-   GASKET_SYSFS_RO(device_type, gasket_sysfs_data_show, ATTR_DEVICE_TYPE),
-   GASKET_SYSFS_RO(revision, gasket_sysfs_data_show,
-   ATTR_HARDWARE_REVISION),
-   GASKET_SYSFS_RO(pci_address, gasket_sysfs_data_show, ATTR_PCI_ADDRESS),
-   GASKET_SYSFS_RO(status, gasket_sysfs_data_show, ATTR_STATUS),
-   GASKET_SYSFS_RO(is_device_owned, gasket_sysfs_data_show,
-   ATTR_IS_DEVICE_OWNED),
-   GASKET_SYSFS_RO(device_owner, gasket_sysfs_data_show,
-   ATTR_DEVICE_OWNER),
-   GASKET_SYSFS_RO(write_open_count, gasket_sysfs_data_show,
-   ATTR_WRITE_OPEN_COUNT),
-   GASKET_SYSFS_RO(reset_count, gasket_sysfs_data_show, ATTR_RESET_COUNT),
-   GASKET_SYSFS_RO(user_mem_ranges, gasket_sysfs_data_show,
-   ATTR_USER_MEM_RANGES),
-   GASKET_END_OF_ATTR_ARRAY
-};
-
-MODULE_DESCRIPTION("Google Gasket driver framework");
-MODULE_VERSION(GASKET_FRAMEWORK_VERSION);
-MODULE_LICENSE("GPL v2");

[PATCH 05/15] staging: gasket: TODO: remove entry for static function declarations

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

The static function declarations are removed, remove the TODO file entry
for this.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/TODO | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/gasket/TODO b/drivers/staging/gasket/TODO
index 7f4c13ce021b..6aa2a7f6bc4b 100644
--- a/drivers/staging/gasket/TODO
+++ b/drivers/staging/gasket/TODO
@@ -1,6 +1,5 @@
 This is a list of things that need to be done to get this driver out of the
 staging directory.
-- Remove static function declarations.
 - Document sysfs files with Documentation/ABI/ entries.
 - Use misc interface instead of major number for driver version description.
 - Add descriptions of module_param's
-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 03/15] staging: gasket: interrupt: remove static function forward declarations

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Remove forward declarations of static functions, move code to avoid
forward references, for kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_interrupt.c | 499 +++---
 1 file changed, 242 insertions(+), 257 deletions(-)

diff --git a/drivers/staging/gasket/gasket_interrupt.c 
b/drivers/staging/gasket/gasket_interrupt.c
index 27fde991edc6..3079b59b122b 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -70,32 +70,259 @@ struct gasket_interrupt_data {
int irq;
 };
 
-/* Function definitions. */
-static ssize_t interrupt_sysfs_show(
-   struct device *device, struct device_attribute *attr, char *buf);
-
-static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id);
-
 /* Structures to display interrupt counts in sysfs. */
 enum interrupt_sysfs_attribute_type {
ATTR_INTERRUPT_COUNTS,
 };
 
+/* Set up device registers for interrupt handling. */
+static void gasket_interrupt_setup(struct gasket_dev *gasket_dev)
+{
+   int i;
+   int pack_shift;
+   ulong mask;
+   ulong value;
+   struct gasket_interrupt_data *interrupt_data =
+   gasket_dev->interrupt_data;
+
+   if (!interrupt_data) {
+   dev_dbg(gasket_dev->dev, "Interrupt data is not initialized\n");
+   return;
+   }
+
+   dev_dbg(gasket_dev->dev, "Running interrupt setup\n");
+
+   if (interrupt_data->type == PLATFORM_WIRE ||
+   interrupt_data->type == PCI_MSI) {
+   /* Nothing needs to be done for platform or PCI devices. */
+   return;
+   }
+
+   if (interrupt_data->type != PCI_MSIX) {
+   dev_dbg(gasket_dev->dev,
+   "Cannot handle unsupported interrupt type %d\n",
+   interrupt_data->type);
+   return;
+   }
+
+   /* Setup the MSIX table. */
+
+   for (i = 0; i < interrupt_data->num_interrupts; i++) {
+   /*
+* If the interrupt is not packed, we can write the index into
+* the register directly. If not, we need to deal with a read-
+* modify-write and shift based on the packing index.
+*/
+   dev_dbg(gasket_dev->dev,
+   "Setting up interrupt index %d with index 0x%llx and "
+   "packing %d\n",
+   interrupt_data->interrupts[i].index,
+   interrupt_data->interrupts[i].reg,
+   interrupt_data->interrupts[i].packing);
+   if (interrupt_data->interrupts[i].packing == UNPACKED) {
+   value = interrupt_data->interrupts[i].index;
+   } else {
+   switch (interrupt_data->interrupts[i].packing) {
+   case PACK_0:
+   pack_shift = 0;
+   break;
+   case PACK_1:
+   pack_shift = interrupt_data->pack_width;
+   break;
+   case PACK_2:
+   pack_shift = 2 * interrupt_data->pack_width;
+   break;
+   case PACK_3:
+   pack_shift = 3 * interrupt_data->pack_width;
+   break;
+   default:
+   dev_dbg(gasket_dev->dev,
+   "Found interrupt description with "
+   "unknown enum %d\n",
+   interrupt_data->interrupts[i].packing);
+   return;
+   }
+
+   mask = ~(0x << pack_shift);
+   value = gasket_dev_read_64(
+   gasket_dev,
+   interrupt_data->interrupt_bar_index,
+   interrupt_data->interrupts[i].reg) &
+   mask;
+   value |= interrupt_data->interrupts[i].index
+<< pack_shift;
+   }
+   gasket_dev_write_64(gasket_dev, value,
+   interrupt_data->interrupt_bar_index,
+   interrupt_data->interrupts[i].reg);
+   }
+}
+
+static irqreturn_t gasket_msix_interrupt_handler(int irq, void *dev_id)
+{
+   struct eventfd_ctx *ctx;
+   struct gasket_interrupt_data *interrupt_data = dev_id;
+   int interrupt = -1;
+   int i;
+
+   /* If this linear lookup is a problem, we can maintain a map/hash. */
+   for (i = 0; i < interrupt_data->num_interrupts; i++) {
+   if (interrupt_data->msix_entries[i].vector == irq) {
+   interrupt = 

[PATCH 02/15] staging: gasket: ioctl: remove static function forward declarations

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

Remove forward declarations of static functions, move code to avoid
forward references, for kernel style.

Signed-off-by: Todd Poynor 
---
 drivers/staging/gasket/gasket_ioctl.c | 356 --
 1 file changed, 168 insertions(+), 188 deletions(-)

diff --git a/drivers/staging/gasket/gasket_ioctl.c 
b/drivers/staging/gasket/gasket_ioctl.c
index 55bdd7bfac86..134d45a281ac 100644
--- a/drivers/staging/gasket/gasket_ioctl.c
+++ b/drivers/staging/gasket/gasket_ioctl.c
@@ -23,194 +23,6 @@
 #define trace_gasket_ioctl_config_coherent_allocator(x, ...)
 #endif
 
-static bool gasket_ioctl_check_permissions(struct file *filp, uint cmd);
-static int gasket_set_event_fd(struct gasket_dev *dev,
-  struct gasket_interrupt_eventfd __user *argp);
-static int gasket_read_page_table_size(
-   struct gasket_dev *gasket_dev,
-   struct gasket_page_table_ioctl __user *argp);
-static int gasket_read_simple_page_table_size(
-   struct gasket_dev *gasket_dev,
-   struct gasket_page_table_ioctl __user *argp);
-static int gasket_partition_page_table(
-   struct gasket_dev *gasket_dev,
-   struct gasket_page_table_ioctl __user *argp);
-static int gasket_map_buffers(struct gasket_dev *gasket_dev,
- struct gasket_page_table_ioctl __user *argp);
-static int gasket_unmap_buffers(struct gasket_dev *gasket_dev,
-   struct gasket_page_table_ioctl __user *argp);
-static int gasket_config_coherent_allocator(
-   struct gasket_dev *gasket_dev,
-   struct gasket_coherent_alloc_config_ioctl __user *argp);
-
-/*
- * standard ioctl dispatch function.
- * @filp: File structure pointer describing this node usage session.
- * @cmd: ioctl number to handle.
- * @argp: ioctl-specific data pointer.
- *
- * Standard ioctl dispatcher; forwards operations to individual handlers.
- */
-long gasket_handle_ioctl(struct file *filp, uint cmd, void __user *argp)
-{
-   struct gasket_dev *gasket_dev;
-   unsigned long arg = (unsigned long)argp;
-   gasket_ioctl_permissions_cb_t ioctl_permissions_cb;
-   int retval;
-
-   gasket_dev = (struct gasket_dev *)filp->private_data;
-   trace_gasket_ioctl_entry(gasket_dev->dev_info.name, cmd);
-
-   ioctl_permissions_cb = gasket_get_ioctl_permissions_cb(gasket_dev);
-   if (ioctl_permissions_cb) {
-   retval = ioctl_permissions_cb(filp, cmd, argp);
-   if (retval < 0) {
-   trace_gasket_ioctl_exit(retval);
-   return retval;
-   } else if (retval == 0) {
-   trace_gasket_ioctl_exit(-EPERM);
-   return -EPERM;
-   }
-   } else if (!gasket_ioctl_check_permissions(filp, cmd)) {
-   trace_gasket_ioctl_exit(-EPERM);
-   dev_dbg(gasket_dev->dev, "ioctl cmd=%x noperm\n", cmd);
-   return -EPERM;
-   }
-
-   /* Tracing happens in this switch statement for all ioctls with
-* an integer argrument, but ioctls with a struct argument
-* that needs copying and decoding, that tracing is done within
-* the handler call.
-*/
-   switch (cmd) {
-   case GASKET_IOCTL_RESET:
-   trace_gasket_ioctl_integer_data(arg);
-   retval = gasket_reset(gasket_dev, arg);
-   break;
-   case GASKET_IOCTL_SET_EVENTFD:
-   retval = gasket_set_event_fd(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_CLEAR_EVENTFD:
-   trace_gasket_ioctl_integer_data(arg);
-   retval = gasket_interrupt_clear_eventfd(
-   gasket_dev->interrupt_data, (int)arg);
-   break;
-   case GASKET_IOCTL_PARTITION_PAGE_TABLE:
-   trace_gasket_ioctl_integer_data(arg);
-   retval = gasket_partition_page_table(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_NUMBER_PAGE_TABLES:
-   trace_gasket_ioctl_integer_data(gasket_dev->num_page_tables);
-   if (copy_to_user(argp, _dev->num_page_tables,
-sizeof(uint64_t)))
-   retval = -EFAULT;
-   else
-   retval = 0;
-   break;
-   case GASKET_IOCTL_PAGE_TABLE_SIZE:
-   retval = gasket_read_page_table_size(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_SIMPLE_PAGE_TABLE_SIZE:
-   retval = gasket_read_simple_page_table_size(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_MAP_BUFFER:
-   retval = gasket_map_buffers(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_CONFIG_COHERENT_ALLOCATOR:
-   retval = gasket_config_coherent_allocator(gasket_dev, argp);
-   break;
-   case GASKET_IOCTL_UNMAP_BUFFER:
-   retval = 

[PATCH 00/15] staging: gasket: cleanups continue

2018-07-31 Thread Todd Poynor
From: Todd Poynor 

More cleanups for the gasket and apex drivers: finish up TODO items
for static function forward declarations and multi-line alignment
style, a couple of fixups for recent patch feedback, and a couple
other issues found in the meantime.

Todd Poynor (15):
  staging: gasket: core: remove static function forward declarations
  staging: gasket: ioctl: remove static function forward declarations
  staging: gasket: interrupt: remove static function forward
declarations
  staging: gasket: pg tbl: remove static function forward declarations
  staging: gasket: TODO: remove entry for static function declarations
  staging: gasket: core: fix function param line continuation style
  staging: gasket: ioctl: fix function param line continuation style
  staging: gasket: page table: fix function param line continuation
style
  staging: gasket: sysfs: fix function param line continuation style
  staging: gasket: interrupt: fix function param line continuation style
  staging: gasket: TODO: remove entry for multi-line alignment style
  staging: gasket: apex: move driver-private defines out of apex.h
  staging: gasket: core: use bool type for ns_capable result
  Revert "staging: gasket: page table: hold references to device and
pci_dev"
  staging: gasket: page table: fix header file include guard symbol

 drivers/staging/gasket/TODO|4 -
 drivers/staging/gasket/apex.h  |   62 +-
 drivers/staging/gasket/apex_driver.c   |   29 +
 drivers/staging/gasket/gasket_core.c   | 2040 ++--
 drivers/staging/gasket/gasket_core.h   |   68 +-
 drivers/staging/gasket/gasket_interrupt.c  |  530 +++--
 drivers/staging/gasket/gasket_interrupt.h  |   19 +-
 drivers/staging/gasket/gasket_ioctl.c  |  412 ++--
 drivers/staging/gasket/gasket_page_table.c | 1434 +++---
 drivers/staging/gasket/gasket_page_table.h |   39 +-
 drivers/staging/gasket/gasket_sysfs.c  |   26 +-
 drivers/staging/gasket/gasket_sysfs.h  |   32 +-
 12 files changed, 2248 insertions(+), 2447 deletions(-)

-- 
2.18.0.345.g5c9ce644c3-goog

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


[PATCH 1/2] staging: fsl-dpaa2/eth: convert documentation to .rst format

2018-07-31 Thread Ioana Ciornei
Convert the DPAA2 Ethernet driver documentation to .rst format
and rename the file accordingly.
Also add a SPDX tag to the new rst file.

Signed-off-by: Ioana Ciornei 
---
 .../ethernet/{README => ethernet-driver.rst}   | 39 +++---
 1 file changed, 19 insertions(+), 20 deletions(-)
 rename drivers/staging/fsl-dpaa2/ethernet/{README => ethernet-driver.rst} (94%)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/README 
b/drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst
similarity index 94%
rename from drivers/staging/fsl-dpaa2/ethernet/README
rename to drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst
index e3b5c90..90ec940 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/README
+++ b/drivers/staging/fsl-dpaa2/ethernet/ethernet-driver.rst
@@ -1,16 +1,13 @@
-Freescale DPAA2 Ethernet driver
-===
-
-This file provides documentation for the Freescale DPAA2 Ethernet driver.
+.. SPDX-License-Identifier: GPL-2.0
+.. include:: 
 
+===
+DPAA2 Ethernet driver
+===
 
-Contents
-
-   Supported Platforms
-   Architecture Overview
-   Creating a Network Interface
-   Features & Offloads
+:Copyright: |copy| 2017-2018 NXP
 
+This file provides documentation for the Freescale DPAA2 Ethernet driver.
 
 Supported Platforms
 ===
@@ -23,10 +20,11 @@ Architecture Overview
 Unlike regular NICs, in the DPAA2 architecture there is no single hardware 
block
 representing network interfaces; instead, several separate hardware resources
 concur to provide the networking functionality:
-- network interfaces
-- queues, channels
-- buffer pools
-- MAC/PHY
+
+- network interfaces
+- queues, channels
+- buffer pools
+- MAC/PHY
 
 All hardware resources are allocated and configured through the Management
 Complex (MC) portals. MC abstracts most of these resources as DPAA2 objects
@@ -35,14 +33,13 @@ hardware resources, like queues, do not have a 
corresponding MC object and
 are treated as internal resources of other objects.
 
 For a more detailed description of the DPAA2 architecture and its object
-abstractions see:
-   Documentation/networking/dpaa2/overview.rst
+abstractions see *Documentation/networking/dpaa2/overview.rst*.
 
 Each Linux net device is built on top of a Datapath Network Interface (DPNI)
 object and uses Buffer Pools (DPBPs), I/O Portals (DPIOs) and Concentrators
 (DPCONs).
 
-Configuration interface:
+Configuration interface::
 
  ---
 | DPAA2 Ethernet Driver |
@@ -56,7 +53,7 @@ Configuration interface:
 | DPBP API |   | DPNI API || DPCON API |
  -- --  ---
  .  .. software
-===  .  ==  .    .  ===
+===  .  ==  .    .  ===
  .  .. hardware
  --
 |MC hardware portals   |
@@ -72,11 +69,11 @@ DPBPs represent hardware buffer pools. Packet I/O is 
performed in the context
 of DPCON objects, using DPIO portals for managing and communicating with the
 hardware resources.
 
-Datapath (I/O) interface:
+Datapath (I/O) interface::
 
  ---
 |   DPAA2 Ethernet Driver   |
-  ---
+ ---
   |  ^^ ||
   |  || ||
enqueue|   dequeue|   data |  dequeue|   seed |
@@ -132,6 +129,8 @@ DPNIs are decoupled from PHYs; a DPNI can be connected to a 
PHY through a DPMAC
 object or to another DPNI through an internal link, but the connection is
 managed by MC and completely transparent to the Ethernet driver.
 
+::
+
  - - -
 | eth if1 |   | eth if2 |   | eth ifn |
  - - -
-- 
1.9.1

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


[PATCH 2/2] staging: fsl-dpaa2/eth: add SPDX license identifiers

2018-07-31 Thread Ioana Ciornei
The DPAA2 Ethernet driver files use a GPL-2.0+ OR BSD-3-Clause
license. Add SPDX tags and delete the full license text,
keeping the existing licenses for each file.
Add a GPL-2.0 tag for the Makefile.

Signed-off-by: Ioana Ciornei 
---
 drivers/staging/fsl-dpaa2/ethernet/Makefile|  1 +
 .../staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h   | 29 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 29 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 29 +
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 29 +
 drivers/staging/fsl-dpaa2/ethernet/dpkg.h  | 30 +-
 drivers/staging/fsl-dpaa2/ethernet/dpni-cmd.h  | 30 +-
 drivers/staging/fsl-dpaa2/ethernet/dpni.c  | 30 +-
 drivers/staging/fsl-dpaa2/ethernet/dpni.h  | 30 +-
 drivers/staging/fsl-dpaa2/ethernet/net.h   | 30 +-
 10 files changed, 10 insertions(+), 257 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/Makefile 
b/drivers/staging/fsl-dpaa2/ethernet/Makefile
index 77b0b74..9315ecd 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/Makefile
+++ b/drivers/staging/fsl-dpaa2/ethernet/Makefile
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 #
 # Makefile for the Freescale DPAA2 Ethernet controller
 #
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h
index 3b040e8..9801528 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth-trace.h
@@ -1,32 +1,5 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
 /* Copyright 2014-2015 Freescale Semiconductor Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- *  notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- *  names of its contributors may be used to endorse or promote products
- *  derived from this software without specific prior written permission.
- *
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") as published by the Free Software
- * Foundation, either version 2 of that License or (at your option) any
- * later version.
- *
- * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #undef TRACE_SYSTEM
diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c 
b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
index 41dd6d88..e2dac44 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c
@@ -1,33 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause)
 /* Copyright 2014-2016 Freescale Semiconductor Inc.
  * Copyright 2016-2017 NXP
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- *  notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *  notice, this list of conditions and the following disclaimer in the
- *  documentation and/or other materials provided with the distribution.
- * * Neither the name of Freescale Semiconductor nor the
- *  names of its contributors may be used to endorse or promote products
- *  derived from this software without specific prior written permission.
- *
- *
- * ALTERNATIVELY, this software may be distributed under the terms of the
- * GNU General Public License ("GPL") as published by the Free Software
- * Foundation, either version 2 of that License or (at your option) any
- * 

Re: [PATCH v1] media: staging: tegra-vde: Replace debug messages with trace points

2018-07-31 Thread Dmitry Osipenko
On Wednesday, 25 July 2018 04:20:29 MSK Dmitry Osipenko wrote:
> On Wednesday, 25 July 2018 03:37:33 MSK Mauro Carvalho Chehab wrote:
> > Em Wed, 25 Jul 2018 01:38:37 +0300
> > 
> > Dmitry Osipenko  escreveu:
> > > On Wednesday, 25 July 2018 01:06:52 MSK Mauro Carvalho Chehab wrote:
> > > > Em Sat,  7 Jul 2018 19:20:49 +0300
> > > > 
> > > > Dmitry Osipenko  escreveu:
> > > > > Trace points are much more efficient than debug messages for
> > > > > extensive
> > > > > tracing and could be conveniently enabled / disabled dynamically,
> > > > > hence
> > > > > let's replace debug messages with the trace points.
> > > > 
> > > > This patch require some work:
> > > > 
> > > > $ make ARCH=i386  CF=-D__CHECK_ENDIAN__
> > > > CONFIG_DEBUG_SECTION_MISMATCH=y
> > > > C=1
> > > > W=1 CHECK='compile_checks' M=drivers/staging/media
> > > > 
> > > > ./include/linux/slab.h:631:13: error: undefined identifier
> > > > '__builtin_mul_overflow' ./include/linux/slab.h:631:13: warning: call
> > > > with
> > > > no type!
> > > > fixdep: error opening file: drivers/staging/media/tegra-vde/trace.h:
> > > > No
> > > > such file or directory
> > > > 
> > >   CHECK   drivers/staging/media/tegra-vde/tegra-vde.c
> > > 
> > > /bin/sh: compile_checks: command not found
> > > 
> > > Upstream kernel doesn't have "compile_checks" script and I can't find it
> > > anywhere else.
> > 
> > This is just a call for smatch/sparse:
> > 
> > #!/bin/bash
> > /devel/smatch/smatch -p=kernel $@
> > # This is too pedantic and produce lots of false-positives
> > #/devel/smatch/smatch --two-passes -- -p=kernel $@
> > /devel/sparse/sparse $@
> > 
> > However, the problem here is that you're doing a 64 bits division.
> > That causes compilation to break with 32 bits. you need to use
> > do_div & friends.
> 
> The tegra-vde driver code is fine, it is a known issue with the kernels
> checker [0]. Unfortunately the patch for the checker haven't been applied
> yet.
> 
> [0] https://www.spinics.net/lists/kernel/msg2824058.html

Mauro, are you going to un-reject patch [0] and apply it or there is some 
action needed from my side now?

[0] https://patchwork.linuxtv.org/patch/51002/


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


[PATCH] staging: gasket: sysfs: fix potential null dereference

2018-07-31 Thread Ivan Bornyakov
Add handling of possible allocation failure.

Reported by smatch:

  drivers/staging/gasket/gasket_sysfs.c:105 put_mapping() error: potential null 
dereference 'files_to_remove'. (kcalloc returns null)

Signed-off-by: Ivan Bornyakov 
---
 drivers/staging/gasket/gasket_sysfs.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/gasket/gasket_sysfs.c 
b/drivers/staging/gasket/gasket_sysfs.c
index ef4eca02afa6..682e5c21f203 100644
--- a/drivers/staging/gasket/gasket_sysfs.c
+++ b/drivers/staging/gasket/gasket_sysfs.c
@@ -101,6 +101,12 @@ static void put_mapping(struct gasket_sysfs_mapping 
*mapping)
files_to_remove = kcalloc(num_files_to_remove,
  sizeof(*files_to_remove),
  GFP_KERNEL);
+   if (!files_to_remove) {
+   pr_err("%s: can't allocate memory\n", __func__);
+   mutex_unlock(>mutex);
+   return;
+   }
+
for (i = 0; i < num_files_to_remove; i++)
files_to_remove[i] = mapping->attributes[i].attr;
 
-- 
2.16.4

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


[PATCH v7 05/15] staging: mt7621-pci: simplify read_config function

2018-07-31 Thread Sergio Paracuellos
read_config function is always called with bus and func
being 0. Avoid those params and just use 0 inside the
function. Return readed value instead pass a reference
parameter.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 01b2944..d26adf3 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -241,15 +241,13 @@ struct pci_ops mt7621_pci_ops = {
.write  = pci_generic_config_write,
 };
 
-static void
-read_config(struct mt7621_pcie *pcie,
-   unsigned long bus, unsigned long dev,
-   unsigned long func, unsigned long reg, unsigned long *val)
+static u32
+read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg)
 {
-   u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+   u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
 
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
-   *val = pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
+   return pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
 }
 
 static void
@@ -273,7 +271,7 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 
if (dev->bus->number == 0) {
write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned 
long *));
+   val = read_config(pcie, slot, PCI_BASE_ADDRESS_0);
printk("BAR0 at slot %d = %x\n", slot, val);
}
 
@@ -552,7 +550,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
struct mt7621_pcie *pcie;
struct pci_host_bridge *bridge;
int err;
-   unsigned long val = 0;
+   u32 val = 0;
 
if (!dev->of_node)
return -ENODEV;
@@ -597,13 +595,13 @@ static int mt7621_pci_probe(struct platform_device *pdev)
bypass_pipe_rst();
set_phy_for_ssc();
 
-   read_config(pcie, 0, 0, 0, 0x70c, );
+   val = read_config(pcie, 0, 0x70c);
printk("Port 0 N_FTS = %x\n", (unsigned int)val);
 
-   read_config(pcie, 0, 1, 0, 0x70c, );
+   val = read_config(pcie, 1, 0x70c);
printk("Port 1 N_FTS = %x\n", (unsigned int)val);
 
-   read_config(pcie, 0, 2, 0, 0x70c, );
+   val = read_config(pcie, 2, 0x70c);
printk("Port 2 N_FTS = %x\n", (unsigned int)val);
 
rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL);
@@ -724,25 +722,25 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 
switch (pcie_link_status) {
case 7:
-   read_config(pcie, 0, 2, 0, 0x4, );
+   val = read_config(pcie, 2, 0x4);
write_config(pcie, 0, 2, 0, 0x4, val|0x4);
-   read_config(pcie, 0, 2, 0, 0x70c, );
+   val = read_config(pcie, 2, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
write_config(pcie, 0, 2, 0, 0x70c, val);
case 3:
case 5:
case 6:
-   read_config(pcie, 0, 1, 0, 0x4, );
+   val = read_config(pcie, 1, 0x4);
write_config(pcie, 0, 1, 0, 0x4, val|0x4);
-   read_config(pcie, 0, 1, 0, 0x70c, );
+   val = read_config(pcie, 1, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
write_config(pcie, 0, 1, 0, 0x70c, val);
default:
-   read_config(pcie, 0, 0, 0, 0x4, );
+   val = read_config(pcie, 0, 0x4);
write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable
-   read_config(pcie, 0, 0, 0, 0x70c, );
+   val = read_config(pcie, 0, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
write_config(pcie, 0, 0, 0, 0x70c, val);
-- 
2.7.4

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


[PATCH v7 11/15] staging: mt7621-pci: remove RALINK_PCI_BASE from remaining definitions

2018-07-31 Thread Sergio Paracuellos
RALINK_PCI_BASE has no sense and this driver has base address readed
and mapped from device tree. Remove remaining uses of it and
change code to use pcie_read and pcie_write functions in places
where this was being used.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 131 
 1 file changed, 67 insertions(+), 64 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 73cfb4f..20f7d58 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -76,7 +76,6 @@
 
 #define RALINK_PCI_PCICFG_ADDR 0x
 #define RALINK_PCI_PCIMSK_ADDR 0x000C
-#define RALINK_PCI_BASE0xBE14
 
 #define RT6855_PCIE0_OFFSET0x2000
 #define RT6855_PCIE1_OFFSET0x3000
@@ -89,8 +88,8 @@
 #define RALINK_PCI_SUBID   0x0038
 #define RALINK_PCI_STATUS  0x0050
 
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
-#define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
+#define RALINK_PCIEPHY_P0P1_CTL_OFFSET 0x9000
+#define RALINK_PCIEPHY_P2_CTL_OFFSET   0xA000
 
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
@@ -244,105 +243,109 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 
pin)
 }
 
 void
-set_pcie_phy(u32 *addr, int start_b, int bits, int val)
+set_pcie_phy(struct mt7621_pcie *pcie, u32 offset,
+int start_b, int bits, int val)
 {
-   *(unsigned int *)(addr) &= ~(((1<> 6) & 0x7;
/* Set PCIe Port0 & Port1 PHY to disable SSC */
/* Debug Xtal Type */
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  8, 1, 
0x01); // rg_pe1_frc_h_xtal_type
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  9, 2, 
0x00); // rg_pe1_h_xtal_type
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  4, 1, 
0x01); // rg_pe1_frc_phy_en//Force Port 0 enable control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  4, 1, 
0x01); // rg_pe1_frc_phy_en//Force Port 1 enable control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  5, 1, 
0x00); // rg_pe1_phy_en//Port 0 disable
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  5, 1, 
0x00); // rg_pe1_phy_en//Port 1 disable
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  8, 1, 
0x01);  // rg_pe1_frc_h_xtal_type
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x400),  9, 2, 
0x00);  // rg_pe1_h_xtal_type
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  4, 1, 
0x01);  // rg_pe1_frc_phy_en//Force Port 0 enable control
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  4, 1, 
0x01);  // rg_pe1_frc_phy_en//Force Port 1 enable control
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x000),  5, 1, 
0x00);  // rg_pe1_phy_en//Port 0 disable
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x100),  5, 1, 
0x00);  // rg_pe1_phy_en//Port 1 disable
if (reg <= 5 && reg >= 3) { // 40MHz Xtal
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x01); // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x01);  // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
printk("* Xtal 40MHz *\n");
} else {// 25MHz | 20MHz Xtal
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x00); // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
+   set_pcie_phy(pcie, (RALINK_PCIEPHY_P0P1_CTL_OFFSET + 0x490),  
6, 2, 0x00);  // RG_PE1_H_PLL_PREDIV  //Pre-divider ratio (for host mode)
if (reg >= 6) {
printk("* Xtal 25MHz *\n");
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4bc),  4, 2, 0x01); // RG_PE1_H_PLL_FBKSEL  //Feedback clock select
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x49c),  0, 31, 0x1800);  // RG_PE1_H_LCDDS_PCW_NCPO  //DDS NCPO 
PCW (for host mode)
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a4),  0, 16, 0x18d);   // RG_PE1_H_LCDDS_SSC_PRD   //DDS SSC dither 
period control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a8),  0, 12, 0x4a);// RG_PE1_H_LCDDS_SSC_DELTA //DDS SSC dither 
amplitude control
-   set_pcie_phy((u32 *)(RALINK_PCIEPHY_P0P1_CTL_OFFSET + 
0x4a8), 16, 12, 0x4a);// RG_PE1_H_LCDDS_SSC_DELTA1//DDS SSC dither 
amplitude control for initial
+  

[PATCH v7 13/15] staging: mt7621-pci: rename RALINK_PCI_CONFIG_DATA_VIRTUAL_REG definition

2018-07-31 Thread Sergio Paracuellos
RALINK_PCI_CONFIG_DATA_VIRTUAL_REG is a very long name. Make it a bit
shorter renaming it to RALINK_PCI_CONFIG_DATA.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 56d23df..d93df3a 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -67,7 +67,7 @@
 #define RALINK_PCIE2_CLK_ENBIT(26)
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
-#define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
+#define RALINK_PCI_CONFIG_DATA 0x24
 #define RALINK_PCI_MEMBASE 0x28
 #define RALINK_PCI_IOBASE  0x2C
 #define RALINK_PCIE0_RST   BIT(24)
@@ -189,7 +189,7 @@ static void __iomem *mt7621_pcie_map_bus(struct pci_bus 
*bus,
 
writel(address, pcie->base + RALINK_PCI_CONFIG_ADDR);
 
-   return pcie->base + RALINK_PCI_CONFIG_DATA_VIRTUAL_REG + (where & 3);
+   return pcie->base + RALINK_PCI_CONFIG_DATA + (where & 3);
 }
 
 struct pci_ops mt7621_pci_ops = {
@@ -204,7 +204,7 @@ read_config(struct mt7621_pcie *pcie, unsigned int dev, u32 
reg)
u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
 
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
-   return pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
+   return pcie_read(pcie, RALINK_PCI_CONFIG_DATA);
 }
 
 static void
@@ -213,7 +213,7 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, 
u32 reg, u32 val)
u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
 
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
-   pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
+   pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA);
 }
 
 int
-- 
2.7.4

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


[PATCH v7 15/15] staging: mt7621-dts: add pcie controller port registers

2018-07-31 Thread Sergio Paracuellos
The pcie node of the device tree only contains registers
for the host-bridge and pcie port 0. Add the pcie port 1
and pcie port 2 also.

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

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index 4610403..2e837e6 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -394,8 +394,10 @@
 
pcie: pcie@1e14 {
compatible = "mediatek,mt7621-pci";
-   reg = <0x1e14 0x100
-   0x1e142000 0x100>;
+   reg = <0x1e14 0x100 /* host-pci bridge registers */
+   0x1e142000 0x100/* pcie port 0 RC control registers 
*/
+   0x1e143000 0x100/* pcie port 1 RC control registers 
*/
+   0x1e144000 0x100>;  /* pcie port 2 RC control registers 
*/
 
#address-cells = <3>;
#size-cells = <2>;
-- 
2.7.4

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


[PATCH v7 06/15] staging: mt7621-pci: simplify write_config function

2018-07-31 Thread Sergio Paracuellos
write_config function is always called with bus and func
being 0. Avoid those params and just use 0 inside the
function. Review parameter types changing for more proper
ones.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index d26adf3..c87ab9c 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -251,11 +251,9 @@ read_config(struct mt7621_pcie *pcie, unsigned int dev, 
u32 reg)
 }
 
 static void
-write_config(struct mt7621_pcie *pcie,
-unsigned long bus, unsigned long dev,
-unsigned long func, unsigned long reg, unsigned long val)
+write_config(struct mt7621_pcie *pcie, unsigned int dev, u32 reg, u32 val)
 {
-   u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+   u32 address = mt7621_pci_get_cfgaddr(0, dev, 0, reg);
 
pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
@@ -270,7 +268,7 @@ pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
int irq;
 
if (dev->bus->number == 0) {
-   write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
+   write_config(pcie, slot, PCI_BASE_ADDRESS_0, MEMORY_BASE);
val = read_config(pcie, slot, PCI_BASE_ADDRESS_0);
printk("BAR0 at slot %d = %x\n", slot, val);
}
@@ -723,27 +721,27 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
switch (pcie_link_status) {
case 7:
val = read_config(pcie, 2, 0x4);
-   write_config(pcie, 0, 2, 0, 0x4, val|0x4);
+   write_config(pcie, 2, 0x4, val|0x4);
val = read_config(pcie, 2, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(pcie, 0, 2, 0, 0x70c, val);
+   write_config(pcie, 2, 0x70c, val);
case 3:
case 5:
case 6:
val = read_config(pcie, 1, 0x4);
-   write_config(pcie, 0, 1, 0, 0x4, val|0x4);
+   write_config(pcie, 1, 0x4, val|0x4);
val = read_config(pcie, 1, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(pcie, 0, 1, 0, 0x70c, val);
+   write_config(pcie, 1, 0x70c, val);
default:
val = read_config(pcie, 0, 0x4);
-   write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable
+   write_config(pcie, 0, 0x4, val|0x4); //bus master enable
val = read_config(pcie, 0, 0x70c);
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(pcie, 0, 0, 0, 0x70c, val);
+   write_config(pcie, 0, 0x70c, val);
}
 
err = mt7621_pcie_request_resources(pcie);
-- 
2.7.4

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


[PATCH v7 08/15] staging: mt7621-pci: avoid register duplication per controller using pcie_[read|write]

2018-07-31 Thread Sergio Paracuellos
Use pcie_[read|write] fucntions to read and write controller registers.
Define those only by offset and pass controller offset + register offset
relative to base address to functions.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 70 -
 1 file changed, 34 insertions(+), 36 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 171907b..491481f 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -74,8 +74,8 @@
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
-#define RALINK_PCI_MEMBASE *(volatile u32 *)(RALINK_PCI_BASE + 
0x0028)
-#define RALINK_PCI_IOBASE  *(volatile u32 *)(RALINK_PCI_BASE + 
0x002C)
+#define RALINK_PCI_MEMBASE 0x28
+#define RALINK_PCI_IOBASE  0x2C
 #define RALINK_PCIE0_RST   (1<<24)
 #define RALINK_PCIE1_RST   (1<<25)
 #define RALINK_PCIE2_RST   (1<<26)
@@ -88,26 +88,12 @@
 #define RT6855_PCIE1_OFFSET0x3000
 #define RT6855_PCIE2_OFFSET0x4000
 
-#define RALINK_PCI0_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0010)
-#define RALINK_PCI0_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0018)
-#define RALINK_PCI0_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0030)
-#define RALINK_PCI0_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0034)
-#define RALINK_PCI0_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0038)
-#define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0050)
-
-#define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0010)
-#define RALINK_PCI1_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0018)
-#define RALINK_PCI1_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0030)
-#define RALINK_PCI1_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0034)
-#define RALINK_PCI1_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0038)
-#define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0050)
-
-#define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0010)
-#define RALINK_PCI2_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0018)
-#define RALINK_PCI2_ID *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0030)
-#define RALINK_PCI2_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0034)
-#define RALINK_PCI2_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0038)
-#define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0050)
+#define RALINK_PCI_BAR0SETUP_ADDR  0x0010
+#define RALINK_PCI_IMBASEBAR0_ADDR 0x0018
+#define RALINK_PCI_ID  0x0030
+#define RALINK_PCI_CLASS   0x0034
+#define RALINK_PCI_SUBID   0x0038
+#define RALINK_PCI_STATUS  0x0050
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
@@ -594,7 +580,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
*(unsigned int *)(0xbe000620) |= 0x1<<19 | 0x1<<8 | 0x1<<7; 
// set DATA
mdelay(1000);
 
-   if ((RALINK_PCI0_STATUS & 0x1) == 0) {
+   if ((pcie_read(pcie, RT6855_PCIE0_OFFSET + RALINK_PCI_STATUS) & 0x1) == 
0) {
printk("PCIE0 no card, disable it(RST)\n");
ASSERT_SYSRST_PCIE(RALINK_PCIE0_RST);
rt_sysc_m32(RALINK_PCIE0_CLK_EN, 0, RALINK_CLKCFG1);
@@ -604,7 +590,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt
}
 
-   if ((RALINK_PCI1_STATUS & 0x1) == 0) {
+   if ((pcie_read(pcie, RT6855_PCIE1_OFFSET + RALINK_PCI_STATUS) & 0x1) == 
0) {
printk("PCIE1 no card, disable it(RST)\n");
ASSERT_SYSRST_PCIE(RALINK_PCIE1_RST);
rt_sysc_m32(RALINK_PCIE1_CLK_EN, 0, RALINK_CLKCFG1);
@@ -614,7 +600,7 @@ static int mt7621_pci_probe(struct platform_device *pdev)
RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt
}
 
-   if ((RALINK_PCI2_STATUS & 0x1) == 0) {
+   if ((pcie_read(pcie, RT6855_PCIE2_OFFSET + RALINK_PCI_STATUS) & 0x1) == 
0) {
printk("PCIE2 no card, disable it(RST)\n");
ASSERT_SYSRST_PCIE(RALINK_PCIE2_RST);

[PATCH v7 12/15] staging: mt7621-pci: use BIT macro in preprocessor definitions

2018-07-31 Thread Sergio Paracuellos
Some preprocessor definitions are using a custom implementation of
BIT macro. Just use linux kernel BIT macro instead.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 20f7d58..56d23df 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -62,17 +62,17 @@
  * devices.
  */
 
-#define RALINK_PCIE0_CLK_EN(1<<24)
-#define RALINK_PCIE1_CLK_EN(1<<25)
-#define RALINK_PCIE2_CLK_EN(1<<26)
+#define RALINK_PCIE0_CLK_ENBIT(24)
+#define RALINK_PCIE1_CLK_ENBIT(25)
+#define RALINK_PCIE2_CLK_ENBIT(26)
 
 #define RALINK_PCI_CONFIG_ADDR 0x20
 #define RALINK_PCI_CONFIG_DATA_VIRTUAL_REG 0x24
 #define RALINK_PCI_MEMBASE 0x28
 #define RALINK_PCI_IOBASE  0x2C
-#define RALINK_PCIE0_RST   (1<<24)
-#define RALINK_PCIE1_RST   (1<<25)
-#define RALINK_PCIE2_RST   (1<<26)
+#define RALINK_PCIE0_RST   BIT(24)
+#define RALINK_PCIE1_RST   BIT(25)
+#define RALINK_PCIE2_RST   BIT(26)
 
 #define RALINK_PCI_PCICFG_ADDR 0x
 #define RALINK_PCI_PCIMSK_ADDR 0x000C
@@ -115,11 +115,11 @@
 #define RALINK_PCIE_CLK_GEN0x7c
 #define RALINK_PCIE_CLK_GEN1   0x80
 //RALINK_RSTCTRL bit
-#define RALINK_PCIE_RST(1<<23)
-#define RALINK_PCI_RST (1<<24)
+#define RALINK_PCIE_RSTBIT(23)
+#define RALINK_PCI_RST BIT(24)
 //RALINK_CLKCFG1 bit
-#define RALINK_PCI_CLK_EN  (1<<19)
-#define RALINK_PCIE_CLK_EN (1<<21)
+#define RALINK_PCI_CLK_EN  BIT(19)
+#define RALINK_PCIE_CLK_EN BIT(21)
 
 #define MEMORY_BASE 0x0
 static int pcie_link_status = 0;
-- 
2.7.4

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


[PATCH v7 14/15] staging: mt7621-pci: remove remaining pci_legacy dependant code

2018-07-31 Thread Sergio Paracuellos
pcibios_* remaining code is not neccessary at all. We can use
map_irq set to of_irq_parse_and_map_pci driver 'probe' function.
Remove this code.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 33 +
 1 file changed, 1 insertion(+), 32 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index d93df3a..7d013c5 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -216,32 +216,6 @@ write_config(struct mt7621_pcie *pcie, unsigned int dev, 
u32 reg, u32 val)
pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA);
 }
 
-int
-pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
-{
-   struct mt7621_pcie *pcie = dev->bus->sysdata;
-   u16 cmd;
-   u32 val;
-   int irq;
-
-   if (dev->bus->number == 0) {
-   write_config(pcie, slot, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   val = read_config(pcie, slot, PCI_BASE_ADDRESS_0);
-   printk("BAR0 at slot %d = %x\n", slot, val);
-   }
-
-   pci_write_config_byte(dev, PCI_CACHE_LINE_SIZE, 0x14);  //configure 
cache line size 0x14
-   pci_write_config_byte(dev, PCI_LATENCY_TIMER, 0xFF);  //configure 
latency timer 0x10
-   pci_read_config_word(dev, PCI_COMMAND, );
-   cmd = cmd | PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
-   pci_write_config_word(dev, PCI_COMMAND, cmd);
-
-   irq = of_irq_parse_and_map_pci(dev, slot, pin);
-
-   pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
-   return irq;
-}
-
 void
 set_pcie_phy(struct mt7621_pcie *pcie, u32 offset,
 int start_b, int bits, int val)
@@ -482,7 +456,7 @@ static int mt7621_pcie_register_host(struct pci_host_bridge 
*host)
host->busnr = pcie->busn.start;
host->dev.parent = pcie->dev;
host->ops = _pci_ops;
-   host->map_irq = pcibios_map_irq;
+   host->map_irq = of_irq_parse_and_map_pci;
host->swizzle_irq = pci_common_swizzle;
host->sysdata = pcie;
 
@@ -746,11 +720,6 @@ pcie(2/1/0) link statuspcie2_num   pcie1_num   
pcie0_num
return 0;
 }
 
-int pcibios_plat_dev_init(struct pci_dev *dev)
-{
-   return 0;
-}
-
 static const struct of_device_id mt7621_pci_ids[] = {
{ .compatible = "mediatek,mt7621-pci" },
{},
-- 
2.7.4

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


[PATCH v7 07/15] staging: mt7621-pci: remove unused macros

2018-07-31 Thread Sergio Paracuellos
There some macros that are not being used. Remove them.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 24 +---
 1 file changed, 1 insertion(+), 23 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index c87ab9c..171907b 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -84,7 +84,6 @@
 #define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
0x000C)
 #define RALINK_PCI_BASE0xBE14
 
-#define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 #define RT6855_PCIE0_OFFSET0x2000
 #define RT6855_PCIE1_OFFSET0x3000
 #define RT6855_PCIE2_OFFSET0x4000
@@ -95,8 +94,6 @@
 #define RALINK_PCI0_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0034)
 #define RALINK_PCI0_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0038)
 #define RALINK_PCI0_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0050)
-#define RALINK_PCI0_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0060)
-#define RALINK_PCI0_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE0_OFFSET + 0x0064)
 
 #define RALINK_PCI1_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0010)
 #define RALINK_PCI1_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0018)
@@ -104,8 +101,6 @@
 #define RALINK_PCI1_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0034)
 #define RALINK_PCI1_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0038)
 #define RALINK_PCI1_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0050)
-#define RALINK_PCI1_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0060)
-#define RALINK_PCI1_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE1_OFFSET + 0x0064)
 
 #define RALINK_PCI2_BAR0SETUP_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0010)
 #define RALINK_PCI2_IMBASEBAR0_ADDR*(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0018)
@@ -113,17 +108,10 @@
 #define RALINK_PCI2_CLASS  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0034)
 #define RALINK_PCI2_SUBID  *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0038)
 #define RALINK_PCI2_STATUS *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0050)
-#define RALINK_PCI2_DERR   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0060)
-#define RALINK_PCI2_ECRC   *(volatile u32 *)(RALINK_PCI_BASE + 
RT6855_PCIE2_OFFSET + 0x0064)
 
 #define RALINK_PCIEPHY_P0P1_CTL_OFFSET (RALINK_PCI_BASE + 0x9000)
 #define RALINK_PCIEPHY_P2_CTL_OFFSET   (RALINK_PCI_BASE + 0xA000)
 
-#define MV_WRITE(ofs, data)\
-   *(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
-#define MV_READ(ofs, data) \
-   *(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
 
@@ -141,28 +129,18 @@
else\
rt_sysc_m32(0, val, RALINK_RSTCTRL);\
} while (0)
+
 #define RALINK_CLKCFG1 0x30
 #define RALINK_RSTCTRL 0x34
 #define RALINK_GPIOMODE0x60
 #define RALINK_PCIE_CLK_GEN0x7c
 #define RALINK_PCIE_CLK_GEN1   0x80
-#define PPLL_CFG1  0x9c
-#define PPLL_DRV   0xa0
-/* SYSC_REG_SYSTEM_CONFIG1 bits */
-#define RALINK_PCI_HOST_MODE_EN(1<<7)
-#define RALINK_PCIE_RC_MODE_EN (1<<8)
 //RALINK_RSTCTRL bit
 #define RALINK_PCIE_RST(1<<23)
 #define RALINK_PCI_RST (1<<24)
 //RALINK_CLKCFG1 bit
 #define RALINK_PCI_CLK_EN  (1<<19)
 #define RALINK_PCIE_CLK_EN (1<<21)
-//RALINK_GPIOMODE bit
-#define PCI_SLOTx2 (1<<11)
-#define PCI_SLOTx1 (2<<11)
-//MTK PCIE PLL bit
-#define PDRV_SW_SET(1<<31)
-#define LC_CKDRVPD_(1<<19)
 
 #define MEMORY_BASE 0x0
 static int pcie_link_status = 0;
-- 
2.7.4

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


[PATCH v7 10/15] staging: mt7621-pci: use pcie_[read|write] in RALINK_PCI_PCICFG_ADDR and RALINK_PCI_PCIMSK_ADDR

2018-07-31 Thread Sergio Paracuellos
RALINK_PCI_PCICFG_ADDR and RALINK_PCI_PCIMSK_ADDR are defined to be directly
referenced for read and write. Use pcie_read and pcie_write instead changing
its definition to a simple relative offset to pcie base address.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index f28e8c2..73cfb4f 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -74,8 +74,8 @@
 #define RALINK_PCIE1_RST   (1<<25)
 #define RALINK_PCIE2_RST   (1<<26)
 
-#define RALINK_PCI_PCICFG_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
0x)
-#define RALINK_PCI_PCIMSK_ADDR *(volatile u32 *)(RALINK_PCI_BASE + 
0x000C)
+#define RALINK_PCI_PCICFG_ADDR 0x
+#define RALINK_PCI_PCIMSK_ADDR 0x000C
 #define RALINK_PCI_BASE0xBE14
 
 #define RT6855_PCIE0_OFFSET0x2000
@@ -581,7 +581,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<0);
} else {
pcie_link_status |= 1<<0;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<20); // enable pcie1 interrupt
+   val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR);
+   val |= (1<<20); // enable pcie1 interrupt
+   pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR);
}
 
if ((pcie_read(pcie, RT6855_PCIE1_OFFSET + RALINK_PCI_STATUS) & 0x1) == 
0) {
@@ -591,7 +593,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<1);
} else {
pcie_link_status |= 1<<1;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<21); // enable pcie1 interrupt
+   val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR);
+   val |= (1<<21); // enable pcie1 interrupt
+   pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR);
}
 
if ((pcie_read(pcie, RT6855_PCIE2_OFFSET + RALINK_PCI_STATUS) & 0x1) == 
0) {
@@ -601,7 +605,9 @@ static int mt7621_pci_probe(struct platform_device *pdev)
pcie_link_status &= ~(1<<2);
} else {
pcie_link_status |= 1<<2;
-   RALINK_PCI_PCIMSK_ADDR |= (1<<22); // enable pcie2 interrupt
+   val = pcie_read(pcie, RALINK_PCI_PCIMSK_ADDR);
+   val |= (1<<22); // enable pcie2 interrupt
+   pcie_write(pcie, val, RALINK_PCI_PCIMSK_ADDR);
}
 
if (pcie_link_status == 0)
@@ -620,27 +626,35 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 */
switch (pcie_link_status) {
case 2:
-   RALINK_PCI_PCICFG_ADDR &= ~0x00ff;
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 20;//port1
+   val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
+   val &= ~0x00ff;
+   val |= 0x1 << 16;   // port 0
+   val |= 0x0 << 20;   // port 1
+   pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);
break;
case 4:
-   RALINK_PCI_PCICFG_ADDR &= ~0x0fff;
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x2 << 20;//port1
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 24;//port2
+   val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
+   val &= ~0x0fff;
+   val |= 0x1 << 16;   //port0
+   val |= 0x2 << 20;   //port1
+   val |= 0x0 << 24;   //port2
+   pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);
break;
case 5:
-   RALINK_PCI_PCICFG_ADDR &= ~0x0fff;
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x2 << 20;//port1
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 24;//port2
+   val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
+   val &= ~0x0fff;
+   val |= 0x0 << 16;   //port0
+   val |= 0x2 << 20;   //port1
+   val |= 0x1 << 24;   //port2
+   pcie_write(pcie, val, RALINK_PCI_PCICFG_ADDR);
break;
case 6:
-   RALINK_PCI_PCICFG_ADDR &= ~0x0fff;
-   RALINK_PCI_PCICFG_ADDR |= 0x2 << 16;//port0
-   RALINK_PCI_PCICFG_ADDR |= 0x0 << 20;//port1
-   RALINK_PCI_PCICFG_ADDR |= 0x1 << 24;//port2
+   val = pcie_read(pcie, RALINK_PCI_PCICFG_ADDR);
+   val &= ~0x0fff;
+   val |= 0x2 << 16;   //port0
+   val |= 0x0 << 20;   //port1
+   val |= 0x1 << 24;   //port2
+   pcie_write(pcie, val, 

[PATCH v7 09/15] staging: mt7621-pci: review includes putting them in alphabethic order

2018-07-31 Thread Sergio Paracuellos
There are some includes that are being used that are not really
needed to correct driver compilation. Remove them and reorder the
rest alphabetically.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 491481f..f28e8c2 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -40,26 +40,20 @@
  **
  */
 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
+#include 
+#include 
 #include 
+#include 
 #include 
-#include 
-#include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
-
-#include 
+#include 
 #include 
+#include 
 
 #include "../../pci/pci.h"
 
-- 
2.7.4

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


[PATCH v7 00/15] staging: mt7621-pci: avoid custom pci config read and writes

2018-07-31 Thread Sergio Paracuellos
This patch series include an attempt to avoid the use of custom
read and writes in driver code and use PCI subsystem common ones.

In order to do this 'map_bus' callback is implemented and also
data structures for driver are included. The regs base address
ranges and data is being readed from device tree and the driver
gets clean a lot of code.

This patchet also removes all legacy PCI code using now PCI_DRIVERS_GENERIC
kernel api.

Changes in v7:
- PATCH 1: Store resources in mt7621_pci data structure.
- PATCH 1: Change completely function mt7621_pci_parse_request_of_pci_ranges
  to parse resources from ranges manually instead of use the function 
  devm_of_pci_get_host_bridge_resources. This is closer to the mips pci 
legacy
  code.
- PATCH 1: Create 'mt7621_pcie_request_resources' function to request 
resources
  parsed from ranges property in the DT. Use pci_add_resource_offset and 
set them
  manually like the mips pci-legacy code do.
- PATCH 1: don't delete function setup_cm_memory_region and call it with 
memory
  resource.
- Other patches rebased and adapted to this changes.

Changes in v6:
- Reorder patches to be each patch correct in itself.
- PATCH 1 adds also Kconfig to do the step from legacy to generic code
- PATCH 1 remaps io space using devm_pci_remap_iospace for io resource in
  a new function called 'mt7621_pci_parse_request_of_pci_ranges'.
- Other patches rebased and adapted with this changes.

Changes in v5:
- Include driver Kconfig file to add compilation depends of 
PCI_DRIVERS_GENERIC.
  The new added configuration option is CONFIG_PCI_MT7621.
- Add list_splice_init(, >windows); in PATCH 1 to set windows
  from resources obtanined from devm_request_pci_bus_resources.
- Move devm_of_pci_get_host_bridge_resources and 
devm_request_pci_bus_resources
  after the ports initialization legacy code.
- Add pcie ports 1 and 2 RC registers to device tree. There was only being 
included
  port RC register for port 0.
- Review includes and order them alphabetically.

Changes in v4:
- Rebased onto staging-next.

Changes in v3:
- Include new patches to delete all RALINK_BASE definition
  dependant code and be able to avoid use of pci_legacy code.
- use devm_of_pci_get_host_bridge_resources,
  devm_request_pci_bus_resources and pci_scan_root_bus_bridge
  and pci_bus_add_devices

Changes in v2:
- squash PATCH 1 and PATCH 2 of previous series in only PATCH 1
- Change name for host structure.
- Create a new port structure (platform has 3 pcie controllers)
- Replace the use of pci_generic_config_[read|write]32 in favour
  of pci_generic_config_[read|write] and change map_bus implemen-
  tation for hopefully the right one.

Best regards,
Sergio Paracuellos

Sergio Paracuellos (15):
  staging: mt7621-pci: use generic kernel pci subsystem read and write
  staging: mt7621-pci: remove dead code derived to not use custom reads
and writes
  staging: mt7621-pci: add pcie_write and pcie_read helpers
  staging: mt7621-pci: use pcie_[read|write] in [write|read]_config
  staging: mt7621-pci: simplify read_config function
  staging: mt7621-pci: simplify write_config function
  staging: mt7621-pci: remove unused macros
  staging: mt7621-pci: avoid register duplication per controller using
pcie_[read|write]
  staging: mt7621-pci: review includes putting them in alphabethic order
  staging: mt7621-pci: use pcie_[read|write] in RALINK_PCI_PCICFG_ADDR
and RALINK_PCI_PCIMSK_ADDR
  staging: mt7621-pci: remove RALINK_PCI_BASE from remaining definitions
  staging: mt7621-pci: use BIT macro in preprocessor definitions
  staging: mt7621-pci: rename RALINK_PCI_CONFIG_DATA_VIRTUAL_REG
definition
  staging: mt7621-pci: remove remaining pci_legacy dependant code
  staging: mt7621-dts: add pcie controller port registers

 drivers/staging/Kconfig |   2 +
 drivers/staging/mt7621-dts/mt7621.dtsi  |   6 +-
 drivers/staging/mt7621-pci/Kconfig  |   7 +
 drivers/staging/mt7621-pci/pci-mt7621.c | 783 +---
 4 files changed, 426 insertions(+), 372 deletions(-)
 create mode 100644 drivers/staging/mt7621-pci/Kconfig

-- 
2.7.4

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


[PATCH v7 04/15] staging: mt7621-pci: use pcie_[read|write] in [write|read]_config

2018-07-31 Thread Sergio Paracuellos
Instead of custom macros use pcie_read and pcie_write functions.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/mt7621-pci/pci-mt7621.c | 67 -
 1 file changed, 32 insertions(+), 35 deletions(-)

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index ac7c118..01b2944 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -242,41 +242,38 @@ struct pci_ops mt7621_pci_ops = {
 };
 
 static void
-read_config(unsigned long bus, unsigned long dev, unsigned long func, unsigned 
long reg, unsigned long *val)
+read_config(struct mt7621_pcie *pcie,
+   unsigned long bus, unsigned long dev,
+   unsigned long func, unsigned long reg, unsigned long *val)
 {
-   u32 address_reg, data_reg, address;
-
-   address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
-   MV_WRITE(address_reg, address);
-   MV_READ(data_reg, val);
-   return;
+   u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+
+   pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
+   *val = pcie_read(pcie, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
 }
 
 static void
-write_config(unsigned long bus, unsigned long dev, unsigned long func, 
unsigned long reg, unsigned long val)
+write_config(struct mt7621_pcie *pcie,
+unsigned long bus, unsigned long dev,
+unsigned long func, unsigned long reg, unsigned long val)
 {
-   u32 address_reg, data_reg, address;
-
-   address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-   address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
-   MV_WRITE(address_reg, address);
-   MV_WRITE(data_reg, val);
-   return;
+   u32 address = mt7621_pci_get_cfgaddr(bus, dev, func, reg);
+
+   pcie_write(pcie, address, RALINK_PCI_CONFIG_ADDR);
+   pcie_write(pcie, val, RALINK_PCI_CONFIG_DATA_VIRTUAL_REG);
 }
 
 int
 pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
+   struct mt7621_pcie *pcie = dev->bus->sysdata;
u16 cmd;
u32 val;
int irq;
 
if (dev->bus->number == 0) {
-   write_config(0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
-   read_config(0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned long 
*));
+   write_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, MEMORY_BASE);
+   read_config(pcie, 0, slot, 0, PCI_BASE_ADDRESS_0, (unsigned 
long *));
printk("BAR0 at slot %d = %x\n", slot, val);
}
 
@@ -600,13 +597,13 @@ static int mt7621_pci_probe(struct platform_device *pdev)
bypass_pipe_rst();
set_phy_for_ssc();
 
-   read_config(0, 0, 0, 0x70c, );
+   read_config(pcie, 0, 0, 0, 0x70c, );
printk("Port 0 N_FTS = %x\n", (unsigned int)val);
 
-   read_config(0, 1, 0, 0x70c, );
+   read_config(pcie, 0, 1, 0, 0x70c, );
printk("Port 1 N_FTS = %x\n", (unsigned int)val);
 
-   read_config(0, 2, 0, 0x70c, );
+   read_config(pcie, 0, 2, 0, 0x70c, );
printk("Port 2 N_FTS = %x\n", (unsigned int)val);
 
rt_sysc_m32(0, RALINK_PCIE_RST, RALINK_RSTCTRL);
@@ -727,28 +724,28 @@ pcie(2/1/0) link status   pcie2_num   pcie1_num   
pcie0_num
 
switch (pcie_link_status) {
case 7:
-   read_config(0, 2, 0, 0x4, );
-   write_config(0, 2, 0, 0x4, val|0x4);
-   read_config(0, 2, 0, 0x70c, );
+   read_config(pcie, 0, 2, 0, 0x4, );
+   write_config(pcie, 0, 2, 0, 0x4, val|0x4);
+   read_config(pcie, 0, 2, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(0, 2, 0, 0x70c, val);
+   write_config(pcie, 0, 2, 0, 0x70c, val);
case 3:
case 5:
case 6:
-   read_config(0, 1, 0, 0x4, );
-   write_config(0, 1, 0, 0x4, val|0x4);
-   read_config(0, 1, 0, 0x70c, );
+   read_config(pcie, 0, 1, 0, 0x4, );
+   write_config(pcie, 0, 1, 0, 0x4, val|0x4);
+   read_config(pcie, 0, 1, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(0, 1, 0, 0x70c, val);
+   write_config(pcie, 0, 1, 0, 0x70c, val);
default:
-   read_config(0, 0, 0, 0x4, );
-   write_config(0, 0, 0, 0x4, val|0x4); //bus master enable
-   read_config(0, 0, 0, 0x70c, );
+   read_config(pcie, 0, 0, 0, 0x4, );
+   write_config(pcie, 0, 0, 0, 0x4, val|0x4); //bus master enable
+   read_config(pcie, 0, 0, 0, 0x70c, );
val &= ~(0xff)<<8;
val |= 0x50<<8;
-   write_config(0, 0, 0, 0x70c, val);
+   

[PATCH v7 02/15] staging: mt7621-pci: remove dead code derived to not use custom reads and writes

2018-07-31 Thread Sergio Paracuellos
Driver is using now pci subsystem generics reads and writes and requesting
bus resources without using legacy code functions. Because of this there is
a lot of dead code that can be removed.

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 4e8958b..1aa8967 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -123,15 +123,6 @@
*(volatile u32 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le32(data)
 #define MV_READ(ofs, data) \
*(data) = le32_to_cpu(*(volatile u32 *)(RALINK_PCI_BASE+(ofs)))
-#define MV_WRITE_16(ofs, data) \
-   *(volatile u16 *)(RALINK_PCI_BASE+(ofs)) = cpu_to_le16(data)
-#define MV_READ_16(ofs, data)  \
-   *(data) = le16_to_cpu(*(volatile u16 *)(RALINK_PCI_BASE+(ofs)))
-
-#define MV_WRITE_8(ofs, data)  \
-   *(volatile u8 *)(RALINK_PCI_BASE+(ofs)) = data
-#define MV_READ_8(ofs, data)   \
-   *(data) = *(volatile u8 *)(RALINK_PCI_BASE+(ofs))
 
 #define RALINK_PCI_MM_MAP_BASE 0x6000
 #define RALINK_PCI_IO_MAP_BASE 0x1e16
@@ -176,13 +167,6 @@
 #define MEMORY_BASE 0x0
 static int pcie_link_status = 0;
 
-#define PCI_ACCESS_READ_1  0
-#define PCI_ACCESS_READ_2  1
-#define PCI_ACCESS_READ_4  2
-#define PCI_ACCESS_WRITE_1 3
-#define PCI_ACCESS_WRITE_2 4
-#define PCI_ACCESS_WRITE_4 5
-
 /**
  * struct mt7621_pcie_port - PCIe port information
  * @base: IO mapped register base
@@ -229,118 +213,6 @@ static inline u32 mt7621_pci_get_cfgaddr(unsigned int 
bus, unsigned int slot,
(func << 8) | (where & 0xfc) | 0x8000;
 }
 
-static int config_access(unsigned char access_type, struct pci_bus *bus,
-   unsigned int devfn, unsigned int where, u32 *data)
-{
-   unsigned int slot = PCI_SLOT(devfn);
-   u8 func = PCI_FUNC(devfn);
-   u32 address_reg, data_reg;
-   unsigned int address;
-
-   address_reg = RALINK_PCI_CONFIG_ADDR;
-   data_reg = RALINK_PCI_CONFIG_DATA_VIRTUAL_REG;
-
-   address = mt7621_pci_get_cfgaddr(bus->number, slot, func, where);
-
-   MV_WRITE(address_reg, address);
-
-   switch (access_type) {
-   case PCI_ACCESS_WRITE_1:
-   MV_WRITE_8(data_reg+(where&0x3), *data);
-   break;
-   case PCI_ACCESS_WRITE_2:
-   MV_WRITE_16(data_reg+(where&0x3), *data);
-   break;
-   case PCI_ACCESS_WRITE_4:
-   MV_WRITE(data_reg, *data);
-   break;
-   case PCI_ACCESS_READ_1:
-   MV_READ_8(data_reg+(where&0x3), data);
-   break;
-   case PCI_ACCESS_READ_2:
-   MV_READ_16(data_reg+(where&0x3), data);
-   break;
-   case PCI_ACCESS_READ_4:
-   MV_READ(data_reg, data);
-   break;
-   default:
-   printk("no specify access type\n");
-   break;
-   }
-   return 0;
-}
-
-static int
-read_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 *val)
-{
-   return config_access(PCI_ACCESS_READ_1, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-read_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 *val)
-{
-   return config_access(PCI_ACCESS_READ_2, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-read_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 *val)
-{
-   return config_access(PCI_ACCESS_READ_4, bus, devfn, (unsigned 
int)where, (u32 *)val);
-}
-
-static int
-write_config_byte(struct pci_bus *bus, unsigned int devfn, int where, u8 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_1, bus, devfn, (unsigned int)where, 
(u32 *)))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-write_config_word(struct pci_bus *bus, unsigned int devfn, int where, u16 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_2, bus, devfn, where, (u32 *)))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-write_config_dword(struct pci_bus *bus, unsigned int devfn, int where, u32 val)
-{
-   if (config_access(PCI_ACCESS_WRITE_4, bus, devfn, where, ))
-   return -1;
-
-   return PCIBIOS_SUCCESSFUL;
-}
-
-static int
-pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, 
u32 *val)
-{
-   switch (size) {
-   case 1:
-   return read_config_byte(bus, devfn, where, (u8 *) val);
-   case 2:
-   return read_config_word(bus, devfn, where, (u16 *) val);
-   default:
-   return read_config_dword(bus, devfn, where, val);
-   }
-}
-
-static int
-pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, 
u32 val)
-{
-   switch (size) {
-   case 1:
-   return 

[PATCH v7 03/15] staging: mt7621-pci: add pcie_write and pcie_read helpers

2018-07-31 Thread Sergio Paracuellos
Introdice this functions to make easier to write/read to/from
an offset relative to base address

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

diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 1aa8967..ac7c118 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -206,6 +206,16 @@ struct mt7621_pcie {
struct list_head ports;
 };
 
+static inline u32 pcie_read(struct mt7621_pcie *pcie, u32 reg)
+{
+   return readl(pcie->base + reg);
+}
+
+static inline void pcie_write(struct mt7621_pcie *pcie, u32 val, u32 reg)
+{
+   writel(val, pcie->base + reg);
+}
+
 static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,
 unsigned int func, unsigned int where)
 {
-- 
2.7.4

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


[PATCH v7 01/15] staging: mt7621-pci: use generic kernel pci subsystem read and write

2018-07-31 Thread Sergio Paracuellos
map_bus callback is called before every .read/.write operation.
Implement it and change custom read write operations for the
pci subsystem generics. Make the probe function to don't use
legacy stuff and request bus resources directly. Get pci register
base and ranges from device tree.
The driver is not using PCI_LEGACY code anymore and shall use the
PCI_DRIVERS_GENERIC option to correct compile it. Add also new
Kconfig file for this controller setting there its correct dependencies.

Signed-off-by: Sergio Paracuellos 
---
 drivers/staging/Kconfig |   2 +
 drivers/staging/mt7621-pci/Kconfig  |   7 +
 drivers/staging/mt7621-pci/pci-mt7621.c | 249 ++--
 3 files changed, 243 insertions(+), 15 deletions(-)
 create mode 100644 drivers/staging/mt7621-pci/Kconfig

diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index 2bce647..732b631 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -110,6 +110,8 @@ source "drivers/staging/vboxvideo/Kconfig"
 
 source "drivers/staging/pi433/Kconfig"
 
+source "drivers/staging/mt7621-pci/Kconfig"
+
 source "drivers/staging/mt7621-pinctrl/Kconfig"
 
 source "drivers/staging/mt7621-spi/Kconfig"
diff --git a/drivers/staging/mt7621-pci/Kconfig 
b/drivers/staging/mt7621-pci/Kconfig
new file mode 100644
index 000..d335338
--- /dev/null
+++ b/drivers/staging/mt7621-pci/Kconfig
@@ -0,0 +1,7 @@
+config PCI_MT7621
+   tristate "MediaTek MT7621 PCI Controller"
+   depends on RALINK
+   select PCI_DRIVERS_GENERIC
+   help
+ This selects a driver for the MediaTek MT7621 PCI Controller.
+
diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c 
b/drivers/staging/mt7621-pci/pci-mt7621.c
index 650e49b..4e8958b 100644
--- a/drivers/staging/mt7621-pci/pci-mt7621.c
+++ b/drivers/staging/mt7621-pci/pci-mt7621.c
@@ -53,11 +53,16 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 
 #include 
 #include 
 
+#include "../../pci/pci.h"
+
 /*
  * These functions and structures provide the BIOS scan and mapping of the PCI
  * devices.
@@ -178,6 +183,45 @@ static int pcie_link_status = 0;
 #define PCI_ACCESS_WRITE_2 4
 #define PCI_ACCESS_WRITE_4 5
 
+/**
+ * struct mt7621_pcie_port - PCIe port information
+ * @base: IO mapped register base
+ * @list: port list
+ * @pcie: pointer to PCIe host info
+ * @reset: pointer to port reset control
+ */
+struct mt7621_pcie_port {
+   void __iomem *base;
+   struct list_head list;
+   struct mt7621_pcie *pcie;
+   struct reset_control *reset;
+};
+
+/**
+ * struct mt7621_pcie - PCIe host information
+ * @base: IO Mapped Register Base
+ * @dev: Pointer to PCIe device
+ * @io: IO resource
+ * @pio: PIO resource
+ * @mem: non-prefetchable memory resource
+ * @busn: bus range
+ * @offset: IO / Memory offset
+ * @ports: pointer to PCIe port information
+ */
+struct mt7621_pcie {
+   void __iomem *base;
+   struct device *dev;
+   struct resource io;
+   struct resource pio;
+   struct resource mem;
+   struct resource busn;
+   struct {
+   resource_size_t mem;
+   resource_size_t io;
+   } offset;
+   struct list_head ports;
+};
+
 static inline u32 mt7621_pci_get_cfgaddr(unsigned int bus, unsigned int slot,
 unsigned int func, unsigned int where)
 {
@@ -297,17 +341,22 @@ pci_config_write(struct pci_bus *bus, unsigned int devfn, 
int where, int size, u
}
 }
 
-struct pci_ops mt7621_pci_ops = {
-   .read   = pci_config_read,
-   .write  = pci_config_write,
-};
+static void __iomem *mt7621_pcie_map_bus(struct pci_bus *bus,
+unsigned int devfn, int where)
+{
+   struct mt7621_pcie *pcie = bus->sysdata;
+   u32 address = mt7621_pci_get_cfgaddr(bus->number, PCI_SLOT(devfn),
+PCI_FUNC(devfn), where);
+
+   writel(address, pcie->base + RALINK_PCI_CONFIG_ADDR);
 
-static struct resource mt7621_res_pci_mem1;
-static struct resource mt7621_res_pci_io1;
-static struct pci_controller mt7621_controller = {
-   .pci_ops= _pci_ops,
-   .mem_resource   = _res_pci_mem1,
-   .io_resource= _res_pci_io1,
+   return pcie->base + RALINK_PCI_CONFIG_DATA_VIRTUAL_REG + (where & 3);
+}
+
+struct pci_ops mt7621_pci_ops = {
+   .map_bus= mt7621_pcie_map_bus,
+   .read   = pci_generic_config_read,
+   .write  = pci_generic_config_write,
 };
 
 static void
@@ -463,9 +512,10 @@ set_phy_for_ssc(void)
set_pcie_phy((u32 *)(RALINK_PCIEPHY_P2_CTL_OFFSET + 0x000),  4, 1, 
0x00);   // rg_pe1_frc_phy_en//Force Port 0 disable control
 }
 
-void setup_cm_memory_region(struct resource *mem_resource)
+static void setup_cm_memory_region(struct resource *mem_resource)
 {
resource_size_t mask;
+
if (mips_cps_numiocu(0)) {
/* FIXME: 

[PATCH 7/7] staging: rtl8188eu: rename odm_RTL8188E - style

2018-07-31 Thread Michael Straube
Rename source and header file to avoid CamelCase.
odm_RTL8188E.c -> odm_rtl8188e.c
odm_RTL8188E.h -> odm_rtl8188e.h

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/Makefile  | 2 +-
 .../staging/rtl8188eu/hal/{odm_RTL8188E.c => odm_rtl8188e.c}| 0
 drivers/staging/rtl8188eu/include/odm_precomp.h | 2 +-
 .../rtl8188eu/include/{odm_RTL8188E.h => odm_rtl8188e.h}| 0
 4 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/staging/rtl8188eu/hal/{odm_RTL8188E.c => odm_rtl8188e.c} (100%)
 rename drivers/staging/rtl8188eu/include/{odm_RTL8188E.h => odm_rtl8188e.h} 
(100%)

diff --git a/drivers/staging/rtl8188eu/Makefile 
b/drivers/staging/rtl8188eu/Makefile
index aa6ea65d05fe..4e606b03ec03 100644
--- a/drivers/staging/rtl8188eu/Makefile
+++ b/drivers/staging/rtl8188eu/Makefile
@@ -29,7 +29,7 @@ r8188eu-y :=  \
hal/hal_com.o   \
hal/odm.o   \
hal/odm_HWConfig.o  \
-   hal/odm_RTL8188E.o  \
+   hal/odm_rtl8188e.o  \
hal/rtl8188e_cmd.o  \
hal/rtl8188e_dm.o   \
hal/rtl8188e_hal_init.o \
diff --git a/drivers/staging/rtl8188eu/hal/odm_RTL8188E.c 
b/drivers/staging/rtl8188eu/hal/odm_rtl8188e.c
similarity index 100%
rename from drivers/staging/rtl8188eu/hal/odm_RTL8188E.c
rename to drivers/staging/rtl8188eu/hal/odm_rtl8188e.c
diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h 
b/drivers/staging/rtl8188eu/include/odm_precomp.h
index f00967fd9599..4d0dd12645bd 100644
--- a/drivers/staging/rtl8188eu/include/odm_precomp.h
+++ b/drivers/staging/rtl8188eu/include/odm_precomp.h
@@ -31,7 +31,7 @@
 
 #include "odm_reg.h"
 
-#include "odm_RTL8188E.h"
+#include "odm_rtl8188e.h"
 
 void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm);
 void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm);
diff --git a/drivers/staging/rtl8188eu/include/odm_RTL8188E.h 
b/drivers/staging/rtl8188eu/include/odm_rtl8188e.h
similarity index 100%
rename from drivers/staging/rtl8188eu/include/odm_RTL8188E.h
rename to drivers/staging/rtl8188eu/include/odm_rtl8188e.h
-- 
2.18.0

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


[PATCH 6/7] staging: rtl8188eu: remove unused rtw_remove_bcn_ie()

2018-07-31 Thread Michael Straube
The function rtw_remove_bcn_ie() is never used, so remove it.
Discovered by cppcheck.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c| 40 --
 drivers/staging/rtl8188eu/include/rtw_ap.h |  2 --
 2 files changed, 42 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 82fb1b028fa0..676d549ef786 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -145,46 +145,6 @@ static void update_BCNTIM(struct adapter *padapter)
set_tx_beacon_cmd(padapter);
 }
 
-void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex 
*pnetwork,
-  u8 index)
-{
-   u8 *p, *dst_ie = NULL, *premainder_ie = NULL;
-   u8 *pbackup_remainder_ie = NULL;
-   uint offset, ielen, ie_offset, remainder_ielen = 0;
-   u8  *pie = pnetwork->ies;
-
-   p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, ,
-  pnetwork->ie_length - _FIXED_IE_LENGTH_);
-   if (p && ielen > 0) {
-   ielen += 2;
-
-   premainder_ie = p + ielen;
-
-   ie_offset = (int)(p - pie);
-
-   remainder_ielen = pnetwork->ie_length - ie_offset - ielen;
-
-   dst_ie = p;
-   }
-
-   if (remainder_ielen > 0) {
-   pbackup_remainder_ie = rtw_malloc(remainder_ielen);
-   if (pbackup_remainder_ie && premainder_ie)
-   memcpy(pbackup_remainder_ie, premainder_ie,
-  remainder_ielen);
-   }
-
-   /* copy remainder IE */
-   if (pbackup_remainder_ie) {
-   memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
-
-   kfree(pbackup_remainder_ie);
-   }
-
-   offset =  (uint)(dst_ie - pie);
-   pnetwork->ie_length = offset + remainder_ielen;
-}
-
 static u8 chk_sta_is_alive(struct sta_info *psta)
 {
u8 ret = false;
diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h 
b/drivers/staging/rtl8188eu/include/rtw_ap.h
index f8f07257976c..7a4203bce473 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ap.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ap.h
@@ -19,8 +19,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter,
 struct sta_info *psta);
 void init_mlme_ap_info(struct adapter *padapter);
 void free_mlme_ap_info(struct adapter *padapter);
-void rtw_remove_bcn_ie(struct adapter *padapter,
-  struct wlan_bssid_ex *pnetwork, u8 index);
 void update_beacon(struct adapter *padapter, u8 ie_id,
   u8 *oui, u8 tx);
 void add_RATid(struct adapter *padapter, struct sta_info *psta,
-- 
2.18.0

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


[PATCH 1/7] staging: rtl8188eu: use is_broadcast_ether_addr

2018-07-31 Thread Michael Straube
Use is_broadcast_ether_addr instead of checking each byte of the
address array for 0xff. Shortens the code and improves readability.

As required by is_broadcast_ether_addr, the address array sta_addr
is properly aligned in all uses. Thanks to Joe Perches.

Signed-off-by: Michael Straube 
---
 .../staging/rtl8188eu/os_dep/ioctl_linux.c| 34 ++-
 1 file changed, 10 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 221fae22bab6..4a8124570e6e 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -361,9 +361,7 @@ static int wpa_set_encryption(struct net_device *dev, 
struct ieee_param *param,
goto exit;
}
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+   if (is_broadcast_ether_addr(param->sta_addr)) {
if (param->u.crypt.idx >= WEP_KEYS) {
ret = -EINVAL;
goto exit;
@@ -2208,9 +2206,7 @@ static int rtw_set_encryption(struct net_device *dev, 
struct ieee_param *param,
ret =  -EINVAL;
goto exit;
}
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) {
+   if (is_broadcast_ether_addr(param->sta_addr)) {
if (param->u.crypt.idx >= WEP_KEYS) {
ret = -EINVAL;
goto exit;
@@ -2471,9 +2467,7 @@ static int rtw_add_sta(struct net_device *dev, struct 
ieee_param *param)
if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)))
return -EINVAL;
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
+   if (is_broadcast_ether_addr(param->sta_addr))
return -EINVAL;
 
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
@@ -2528,9 +2522,7 @@ static int rtw_del_sta(struct net_device *dev, struct 
ieee_param *param)
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
+   if (is_broadcast_ether_addr(param->sta_addr))
return -EINVAL;
 
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
@@ -2566,9 +2558,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, 
struct ieee_param *par
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
 
-   if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff &&
-   param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff &&
-   param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff)
+   if (is_broadcast_ether_addr(param_ex->sta_addr))
return -EINVAL;
 
psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr);
@@ -2622,9 +2612,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, 
struct ieee_param *param)
if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true)
return -EINVAL;
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
+   if (is_broadcast_ether_addr(param->sta_addr))
return -EINVAL;
 
psta = rtw_get_stainfo(pstapriv, param->sta_addr);
@@ -2779,10 +2767,9 @@ static int rtw_ioctl_acl_remove_sta(struct net_device 
*dev, struct ieee_param *p
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-   param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff)
+   if (is_broadcast_ether_addr(param->sta_addr))
return -EINVAL;
+
return rtw_acl_remove_sta(padapter, param->sta_addr);
 }
 
@@ -2794,10 +2781,9 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, 
struct ieee_param *para
if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true)
return -EINVAL;
 
-   if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff &&
-   param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff &&
-

[PATCH 5/7] staging: rtl8188eu: remove unused rtw_add_bcn_ie()

2018-07-31 Thread Michael Straube
The function rtw_add_bcn_ie() is never used, so remove it.
Discovered by cppcheck.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c| 66 --
 drivers/staging/rtl8188eu/include/rtw_ap.h |  2 -
 2 files changed, 68 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index 220b4bbe1f84..82fb1b028fa0 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -145,72 +145,6 @@ static void update_BCNTIM(struct adapter *padapter)
set_tx_beacon_cmd(padapter);
 }
 
-void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
-   u8 index, u8 *data, u8 len)
-{
-   struct ndis_802_11_var_ie *pIE;
-   u8 bmatch = false;
-   u8 *pie = pnetwork->ies;
-   u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL;
-   u8 *pbackup_remainder_ie = NULL;
-   u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0;
-
-   for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->ie_length;) 
{
-   pIE = (struct ndis_802_11_var_ie *)(pnetwork->ies + i);
-
-   if (pIE->ElementID > index) {
-   break;
-   /*  already exist the same IE */
-   } else if (pIE->ElementID == index) {
-   p = (u8 *)pIE;
-   ielen = pIE->Length;
-   bmatch = true;
-   break;
-   }
-   p = (u8 *)pIE;
-   ielen = pIE->Length;
-   i += (pIE->Length + 2);
-   }
-
-   if (p && ielen > 0) {
-   ielen += 2;
-
-   premainder_ie = p + ielen;
-
-   ie_offset = (int)(p - pie);
-
-   remainder_ielen = pnetwork->ie_length - ie_offset - ielen;
-
-   if (bmatch)
-   dst_ie = p;
-   else
-   dst_ie = p + ielen;
-   }
-
-   if (remainder_ielen > 0) {
-   pbackup_remainder_ie = rtw_malloc(remainder_ielen);
-   if (pbackup_remainder_ie && premainder_ie)
-   memcpy(pbackup_remainder_ie, premainder_ie,
-  remainder_ielen);
-   }
-
-   *dst_ie++ = index;
-   *dst_ie++ = len;
-
-   memcpy(dst_ie, data, len);
-   dst_ie += len;
-
-   /* copy remainder IE */
-   if (pbackup_remainder_ie) {
-   memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen);
-
-   kfree(pbackup_remainder_ie);
-   }
-
-   offset =  (uint)(dst_ie - pie);
-   pnetwork->ie_length = offset + remainder_ielen;
-}
-
 void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex 
*pnetwork,
   u8 index)
 {
diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h 
b/drivers/staging/rtl8188eu/include/rtw_ap.h
index bca41d68ce9d..f8f07257976c 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ap.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ap.h
@@ -19,8 +19,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter,
 struct sta_info *psta);
 void init_mlme_ap_info(struct adapter *padapter);
 void free_mlme_ap_info(struct adapter *padapter);
-void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
-   u8 index, u8 *data, u8 len);
 void rtw_remove_bcn_ie(struct adapter *padapter,
   struct wlan_bssid_ex *pnetwork, u8 index);
 void update_beacon(struct adapter *padapter, u8 ie_id,
-- 
2.18.0

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


[PATCH 3/7] staging: rtl8188eu: fix comparsions to NULL - style

2018-07-31 Thread Michael Straube
Use x instead of x != NULL.
Use !x instead of x == NULL.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/os_intfs.c  |  2 +-
 drivers/staging/rtl8188eu/os_dep/usb_intf.c  |  6 +++---
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 10 +-
 drivers/staging/rtl8188eu/os_dep/xmit_linux.c|  2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c 
b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 9b810c76d6de..62294bdc465e 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -311,7 +311,7 @@ struct net_device *rtw_init_netdev(struct adapter 
*old_padapter)
 
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n"));
 
-   if (old_padapter != NULL)
+   if (old_padapter)
pnetdev = rtw_alloc_etherdev_with_old_priv((void 
*)old_padapter);
 
if (!pnetdev)
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c 
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 69f04fa0a189..28cbd6b3d26c 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -325,7 +325,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv 
*dvobj,
int status = _FAIL;
 
padapter = vzalloc(sizeof(*padapter));
-   if (padapter == NULL)
+   if (!padapter)
goto exit;
padapter->dvobj = dvobj;
dvobj->if1 = padapter;
@@ -334,14 +334,14 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv 
*dvobj,
mutex_init(>hw_init_mutex);
 
pnetdev = rtw_init_netdev(padapter);
-   if (pnetdev == NULL)
+   if (!pnetdev)
goto free_adapter;
SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj));
padapter = rtw_netdev_priv(pnetdev);
 
if (padapter->registrypriv.monitor_enable) {
pmondev = rtl88eu_mon_init();
-   if (pmondev == NULL)
+   if (!pmondev)
netdev_warn(pnetdev, "Failed to initialize monitor 
interface");
padapter->pmondev = pmondev;
}
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c 
b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index c69edb7d174c..a59eb017227f 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -58,7 +58,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct 
sk_buff *pskb)
prxstat = (struct recv_stat *)pbuf;
 
precvframe = rtw_alloc_recvframe(pfree_recv_queue);
-   if (precvframe == NULL) {
+   if (!precvframe) {
RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, 
("recvbuf2recvframe: precvframe==NULL\n"));
DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX 
Drop!\n", __func__, __LINE__);
goto _exit_recvbuf2recvframe;
@@ -436,16 +436,16 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, 
struct recv_buf *precvbuf)
return _FAIL;
}
 
-   if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) {
+   if ((!precvbuf->reuse) || (!precvbuf->pskb)) {
precvbuf->pskb = skb_dequeue(>free_recv_skb_queue);
-   if (precvbuf->pskb != NULL)
+   if (precvbuf->pskb)
precvbuf->reuse = true;
}
 
/* re-assign for linux based on skb */
-   if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) {
+   if ((!precvbuf->reuse) || (!precvbuf->pskb)) {
precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, 
MAX_RECVBUF_SZ);
-   if (precvbuf->pskb == NULL) {
+   if (!precvbuf->pskb) {
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, 
("init_recvbuf(): alloc_skb fail!\n"));
DBG_88E(" usb_read_port() alloc_skb fail!#\n");
return _FAIL;
diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c 
b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
index 85cde696d369..d8ef9b5d81a8 100644
--- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c
@@ -19,7 +19,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, 
struct xmit_buf *pxmitb
int i;
 
pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL);
-   if (pxmitbuf->pallocated_buf == NULL)
+   if (!pxmitbuf->pallocated_buf)
return _FAIL;
 
pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ);
-- 
2.18.0

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


[PATCH 4/7] staging: rtl8188eu: remove unnecessary parentheses - style

2018-07-31 Thread Michael Straube
Remove unnecessary parentheses to improve readability.

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c 
b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
index a59eb017227f..5ddfc2ead127 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c
@@ -436,14 +436,14 @@ u32 usb_read_port(struct adapter *adapter, u32 addr, 
struct recv_buf *precvbuf)
return _FAIL;
}
 
-   if ((!precvbuf->reuse) || (!precvbuf->pskb)) {
+   if (!precvbuf->reuse || !precvbuf->pskb) {
precvbuf->pskb = skb_dequeue(>free_recv_skb_queue);
if (precvbuf->pskb)
precvbuf->reuse = true;
}
 
/* re-assign for linux based on skb */
-   if ((!precvbuf->reuse) || (!precvbuf->pskb)) {
+   if (!precvbuf->reuse || !precvbuf->pskb) {
precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, 
MAX_RECVBUF_SZ);
if (!precvbuf->pskb) {
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, 
("init_recvbuf(): alloc_skb fail!\n"));
-- 
2.18.0

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


[PATCH 2/7] staging: rtl8188eu: fix indentation - style

2018-07-31 Thread Michael Straube
Fix indentation to clear checkpatch warnings.
WARNING: suspect code indent for conditional statements

Signed-off-by: Michael Straube 
---
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 4 ++--
 drivers/staging/rtl8188eu/os_dep/usb_intf.c| 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 4a8124570e6e..19387d87185d 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -142,7 +142,7 @@ static char *translate_scan(struct adapter *padapter,
if (ht_cap)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
else
-   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
+   snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
} else if ((rtw_is_cckrates_included((u8 
*)>network.SupportedRates))) {
if (ht_cap)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
@@ -2299,7 +2299,7 @@ static int rtw_set_encryption(struct net_device *dev, 
struct ieee_param *param,
 
psecuritypriv->dot118021XGrpPrivacy = _WEP40_;
if (param->u.crypt.key_len == 13)
-   
psecuritypriv->dot118021XGrpPrivacy = _WEP104_;
+   psecuritypriv->dot118021XGrpPrivacy = 
_WEP104_;
} else if (strcmp(param->u.crypt.alg, "TKIP") == 0) {
DBG_88E("%s, set group_key, TKIP\n", __func__);
psecuritypriv->dot118021XGrpPrivacy = _TKIP_;
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c 
b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index 025cd0f59718..69f04fa0a189 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -380,7 +380,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv 
*dvobj,
/* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto
 * suspend influence */
if (usb_autopm_get_interface(pusb_intf) < 0)
-   pr_debug("can't get autopm:\n");
+   pr_debug("can't get autopm:\n");
 
/*  alloc dev name after read efuse. */
rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname);
-- 
2.18.0

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


Re: [PATCH char-misc 1/1] Drivers: hv: vmbus: Make synic_initialized flag per-cpu

2018-07-31 Thread Vitaly Kuznetsov
mhkelle...@gmail.com writes:

> From: Michael Kelley 
>
> The synic_initialized flag is part of the global hv_context
> structure.  But the Hyper-V synthetic interrupt controller is
> fundamentally a per-cpu device, and other synic related
> fields are in hv_per_cpu_context.  In a multi-CPU system,
> synic_initialized gets set multiple times, making the test in
> hv_synic_cleanup() invalid.  Fix this by moving the flag to
> hv_per_cpu_context and adjusting the references.
>
> Signed-off-by: Michael Kelley 
> ---
>  drivers/hv/hv.c   | 16 +++-
>  drivers/hv/hyperv_vmbus.h |  4 ++--
>  2 files changed, 9 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
> index 312fe5e..8d4fe0e 100644
> --- a/drivers/hv/hv.c
> +++ b/drivers/hv/hv.c
> @@ -33,9 +33,7 @@
>  #include "hyperv_vmbus.h"
>
>  /* The one and only */
> -struct hv_context hv_context = {
> - .synic_initialized  = false,
> -};
> +struct hv_context hv_context;
>
>  /*
>   * If false, we're using the old mechanism for stimer0 interrupts
> @@ -315,7 +313,7 @@ int hv_synic_init(unsigned int cpu)
>
>   hv_set_synic_state(sctrl.as_uint64);
>
> - hv_context.synic_initialized = true;
> + hv_cpu->synic_initialized = true;
>
>   /*
>* Register the per-cpu clockevent source.
> @@ -354,6 +352,8 @@ void hv_synic_clockevents_cleanup(void)
>   */
>  int hv_synic_cleanup(unsigned int cpu)
>  {
> + struct hv_per_cpu_context *hv_cpu
> + = per_cpu_ptr(hv_context.cpu_context, cpu);
>   union hv_synic_sint shared_sint;
>   union hv_synic_simp simp;
>   union hv_synic_siefp siefp;
> @@ -362,7 +362,7 @@ int hv_synic_cleanup(unsigned int cpu)
>   bool channel_found = false;
>   unsigned long flags;
>
> - if (!hv_context.synic_initialized)
> + if (!hv_cpu->synic_initialized)
>   return -EFAULT;
>
>   /*
> @@ -395,12 +395,8 @@ int hv_synic_cleanup(unsigned int cpu)
>
>   /* Turn off clockevent device */
>   if (ms_hyperv.features & HV_MSR_SYNTIMER_AVAILABLE) {
> - struct hv_per_cpu_context *hv_cpu
> - = this_cpu_ptr(hv_context.cpu_context);
> -
>   clockevents_unbind_device(hv_cpu->clk_evt, cpu);
>   hv_ce_shutdown(hv_cpu->clk_evt);
> - put_cpu_ptr(hv_cpu);
>   }
>
>   hv_get_synint_state(VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
> @@ -428,5 +424,7 @@ int hv_synic_cleanup(unsigned int cpu)
>   sctrl.enable = 0;
>   hv_set_synic_state(sctrl.as_uint64);
>
> + hv_cpu->synic_initialized = false;
> +
>   return 0;
>  }
> diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
> index 72eaba3..eadd3df 100644
> --- a/drivers/hv/hyperv_vmbus.h
> +++ b/drivers/hv/hyperv_vmbus.h
> @@ -202,6 +202,8 @@ enum {
>  struct hv_per_cpu_context {
>   void *synic_message_page;
>   void *synic_event_page;
> + bool synic_initialized;
> +
>   /*
>* buffer to post messages to the host.
>*/
> @@ -230,8 +232,6 @@ struct hv_context {
>
>   void *tsc_page;
>
> - bool synic_initialized;
> -
>   struct hv_per_cpu_context __percpu *cpu_context;
>
>   /*

Reviewed-by: Vitaly Kuznetsov 

Alternatively, we can get rid of synic_initialized flag altogether:
hv_synic_init() never fails in the first place but we can always
implement something like:

int hv_synic_is_initialized(void) {
union hv_synic_scontrol sctrl;

hv_get_synic_state(sctrl.as_uint64);

return sctrl.enable;
}

as it doesn't seem that we need to check synic state on _other_ CPUs.

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


Re: [PATCH v6 00/15] staging: mt7621-pci: avoid custom pci config read and writes

2018-07-31 Thread Sergio Paracuellos
On Tue, Jul 31, 2018 at 03:25:43PM +1000, NeilBrown wrote:
> On Tue, Jul 31 2018, Sergio Paracuellos wrote:
> 
> > On Tue, Jul 31, 2018 at 08:55:52AM +1000, NeilBrown wrote:
> >> On Mon, Jul 30 2018, Sergio Paracuellos wrote:
> >> 
> >> > This patch series include an attempt to avoid the use of custom
> >> > read and writes in driver code and use PCI subsystem common ones.
> >> >
> >> > In order to do this 'map_bus' callback is implemented and also
> >> > data structures for driver are included. The regs base address
> >> > is being readed from device tree and the driver gets clean a lot
> >> > of code.
> >> >
> >> > Also the driver get removes all legacy PCI code using now 
> >> > PCI_DRIVERS_GENERIC.
> >> >
> >> > Changes in v6:
> >> > - Reorder patches to be each patch correct in itself.
> >> > - PATCH 1 adds also Kconfig to do the step from legacy to generic 
> >> > code
> >> > - PATCH 1 remaps io space using devm_pci_remap_iospace for io 
> >> > resource in 
> >> >   a new function called 'mt7621_pci_parse_request_of_pci_ranges'.
> >> > - Other patches rebased and adapted with this changes.
> >> 
> >> No noticeable difference.
> >> Still hangs after
> >> [8.63] ahci :01:00.0: enabling device ( -> 0002)
> >> 
> >> the readl() at the start of ahci_enable_ahci() hangs, reading c4017004.
> >> 
> >> I built on a merge of
> >>  Merge: 527838d470e3 b9f13084580c
> >> 
> >> linus' master + staging/staging-testing
> >> 
> >> dmesg below.
> >
> > Thanks for this.
> >
> 
> >> [8.43] bootconsole [early0] disabled
> >> [8.43] bootconsole [early0] disabled
> >> [8.45] cacheinfo: Failed to find cpu0 device node
> >> [8.46] cacheinfo: Unable to detect cache hierarchy for CPU 0
> >> [8.55] loop: module loaded
> >> [8.56] ahci :01:00.0: enabling device ( -> 0002)
> >> 
> >> 
> >
> > So this last dmesg is the new one with last v6, right? Because I can see 
> 
> Right.
> 
> 
> > that at least now the assigned resources are pretty much the same of the 
> > ones in the dmesg of the
> > original code talking in terms of assigned BAR's and bridge windows. No 
> > weird BAR 9 anymore, which I think is 
> > good. We can try to get back the hack which I removed at first and see what 
> > happend. The hack is
> > this function removed in PATCH 2:
> >
> > -void setup_cm_memory_region(struct resource *mem_resource)
> > -{
> > -   resource_size_t mask;
> > -   if (mips_cps_numiocu(0)) {
> > -   /* FIXME: hardware doesn't accept mask values with 1s after
> > -* 0s (e.g. 0xffef), so it would be great to warn if that's
> > -* about to happen */
> > -   mask = ~(mem_resource->end - mem_resource->start);
> > -
> > -   write_gcr_reg1_base(mem_resource->start);
> > -   write_gcr_reg1_mask(mask | CM_GCR_REGn_MASK_CMTGT_IOCU0);
> > -   printk("PCI coherence region base: 0x%08llx, mask/settings: 
> > 0x%08llx\n",
> > -   (unsigned long long)read_gcr_reg1_base(),
> > -   (unsigned long long)read_gcr_reg1_mask());
> > -   }
> > -}
> >
> > We can try to add it again and and call it from 
> > 'mt7621_pci_parse_request_of_pci_ranges'
> > in the label of the case of the case 'IORESOURCE_MEM' (as you can see this 
> > was intentionally
> > without code just to test this if this v6 fails):
> >
> > break;
> > case IORESOURCE_MEM:
> > +   setup_cm_memory_region(res);
> > break;
> 
> I added setup_cm_memory_region() back in and called it from
> mt7621_pci_parse_request_of_pci_ranges()
> as suggested.
> Now we don't hang at the same place, but crash shortly after.
> 
> [8.75] WARNING: CPU: 2 PID: 1 at ../drivers/ata/libahci.c:227 
> ahci_save_initial_config+0x3c/0x3e0
> 
> This is at the end of ahci_enable_ahci(). the HOST_AHCI_EN bit never was
> set.
> 
> 
> >
> > If this also fails we can try to move the call to 
> > 'mt7621_pcie_parse_dt(pcie, );' after the
> > HW initialization code just before the list_splice_init(, 
> > >windows); line:
> >
> > -   err = mt7621_pcie_parse_dt(pcie, );
> > -   if (err) {
> > -   dev_err(dev, "Parsing DT failed\n");
> > -   return err;
> > -   }
> > -
> > -   /*
> > iomem_resource.start = 0;
> > iomem_resource.end = ~0;
> > ...
> >
> > write_config(0, 0, 0, 0x70c, val);
> > }
> >
> > +   err = mt7621_pcie_parse_dt(pcie, );
> > +   if (err) {
> > +   dev_err(dev, "Parsing DT failed\n");
> > +   return err;
> > +   }
> > +
> > list_splice_init(, >windows);
> 
> If I move the call to mt7621_pcie_parse_dt() anywhere after
> the call to set_phy_for_ssc() I get a crash at the start of
> set_pcie_phy() called from set_phy_for_ssc(), presumably because
> pcie->base isn't set.
> 
> Keep trying, I'm sure we'll get there.

Neil, I think you notice it actually, but just in case I think it is better
to confirm it. This series 

Re: [PATCH 01/13] staging: gasket: core: hold reference to pci_dev while used

2018-07-31 Thread Dmitry Torokhov
On Sun, Jul 29, 2018 at 12:37 PM Todd Poynor  wrote:
>
> From: Todd Poynor 
>
> Hold a reference on the struct pci_dev while a pointer to it is held in
> the gasket data structures.
>
> Signed-off-by: Todd Poynor 
> ---
>  drivers/staging/gasket/gasket_core.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/gasket/gasket_core.c 
> b/drivers/staging/gasket/gasket_core.c
> index 2b484d067c38a..b832a4f529f27 100644
> --- a/drivers/staging/gasket/gasket_core.c
> +++ b/drivers/staging/gasket/gasket_core.c
> @@ -488,6 +488,7 @@ static void gasket_free_dev(struct gasket_dev *gasket_dev)
> internal_desc->devs[gasket_dev->dev_idx] = NULL;
> mutex_unlock(_desc->mutex);
> put_device(gasket_dev->dev);
> +   pci_dev_put(gasket_dev->pci_dev);

gasket_free_dev() is called only from driver PCI probe and remove
function. I can assure you that that pci_dev structure is not going
anywhere, there is no need to take this additional reference.

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