[PATCH] rtl8723bs: os_dep: ioctl_linux: fix several braces coding style issues.

2017-08-09 Thread Teo Dacquet
Fix checkpatch issues:
ERROR: that open brace { should be on the previous line.
WARNING: braces {} are not necessary for single statement blocks.

Signed-off-by: Teo Dacquet 
---
 drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 996 -
 1 file changed, 298 insertions(+), 698 deletions(-)

diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c 
b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
index 79d8383d4b9b..c7bad646134e 100644
--- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c
@@ -19,7 +19,7 @@
 #include 
 #include 
 
-#define RTL_IOCTL_WPA_SUPPLICANT   SIOCIWFIRSTPRIV+30
+#define RTL_IOCTL_WPA_SUPPLICANT   (SIOCIWFIRSTPRIV+30)
 
 #define SCAN_ITEM_SIZE 768
 #define MAX_CUSTOM_LEN 64
@@ -44,8 +44,7 @@ extern u8 key_2char2num(u8 hch, u8 lch);
 static u32 rtw_rates[] = {100, 200, 550, 1100,
600, 900, 1200, 1800, 2400, 3600, 4800, 
5400};
 
-static const char * const iw_operation_mode[] =
-{
+static const char * const iw_operation_mode[] = {
"Auto", "Ad-Hoc", "Managed",  "Master", "Repeater", "Secondary", 
"Monitor"
 };
 
@@ -190,16 +189,12 @@ static char *translate_scan(struct adapter *padapter,
start = iwe_stream_add_point(info, start, stop, , 
pnetwork->network.Ssid.Ssid);
 
/* parsing HT_CAP_IE */
-   if (pnetwork->network.Reserved[0] == 2) /*  Probe Request */
-   {
+   if (pnetwork->network.Reserved[0] == 2) { /*  Probe Request */
p = rtw_get_ie(>network.IEs[0], _HT_CAPABILITY_IE_, 
_ielen, pnetwork->network.IELength);
-   }
-   else
-   {
+   } else {
p = rtw_get_ie(>network.IEs[12], _HT_CAPABILITY_IE_, 
_ielen, pnetwork->network.IELength-12);
}
-   if (p && ht_ielen>0)
-   {
+   if (p && ht_ielen>0) {
struct rtw_ieee80211_ht_cap *pht_capie;
ht_cap = true;
pht_capie = (struct rtw_ieee80211_ht_cap *)(p+2);
@@ -210,33 +205,25 @@ static char *translate_scan(struct adapter *padapter,
 
/* Add the protocol name */
iwe.cmd = SIOCGIWNAME;
-   if ((rtw_is_cckratesonly_included((u8 
*)>network.SupportedRates)) == true)
-   {
+   if ((rtw_is_cckratesonly_included((u8 
*)>network.SupportedRates)) == true) {
if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn");
else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b");
-   }
-   else if ((rtw_is_cckrates_included((u8 
*)>network.SupportedRates)) == true)
-   {
+   } else if ((rtw_is_cckrates_included((u8 
*)>network.SupportedRates)) == true) {
if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn");
else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg");
-   }
-   else
-   {
-   if (pnetwork->network.Configuration.DSConfig > 14)
-   {
+   } else {
+   if (pnetwork->network.Configuration.DSConfig > 14) {
if (vht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11AC");
else if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an");
else
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a");
-   }
-   else
-   {
+   } else {
if (ht_cap == true)
snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn");
else
@@ -247,12 +234,9 @@ static char *translate_scan(struct adapter *padapter,
start = iwe_stream_add_event(info, start, stop, , IW_EV_CHAR_LEN);
 
  /* Add mode */
-   if (pnetwork->network.Reserved[0] == 2) /*  Probe Request */
-   {
+   if (pnetwork->network.Reserved[0] == 2) { /*  Probe Request */
cap = 0;
-   }
-   else
-   {
+   } else {
__le16 le_tmp;
 
iwe.cmd = SIOCGIWMODE;
@@ -295,8 +279,7 @@ static char *translate_scan(struct adapter *padapter,
return start;
p = custom;
p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): ");
-   while (pnetwork->network.SupportedRates[i]!= 0)
-   {
+   while (pnetwork->network.SupportedRates[i]!= 0) {
rate = pnetwork->network.SupportedRates[i]&0x7F;
if (rate > max_rate)
max_rate = rate;
@@ -307,20 +290,12 @@ static char *translate_scan(struct adapter *padapter,
 
if (vht_cap == true) {
max_rate = vht_data_rate;
-   }
-   else if (ht_cap == true)
-   {
-   if (mcs_rate&0x8000)/* MCS15 */
-   {

Re: [PATCH] mtd: nand: Rename nand.h into rawnand.h

2017-08-09 Thread Shawn Guo
On Fri, Aug 04, 2017 at 05:29:10PM +0200, Boris Brezillon wrote:
> We are planning to share more code between different NAND based
> devices (SPI NAND, OneNAND and raw NANDs), but before doing that
> we need to move the existing include/linux/mtd/nand.h file into
> include/linux/mtd/rawnand.h so we can later create a nand.h header
> containing all common structure and function prototypes.
> 
> Signed-off-by: Boris Brezillon 
> Signed-off-by: Peter Pan 
...
>  arch/arm/mach-imx/mach-qong.c   | 2 +-

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


[PATCH net-next 05/10] netvsc: no need to allocate send/receive on numa node

2017-08-09 Thread Stephen Hemminger
The send and receive buffers are both per-device (not per-channel).
The associated NUMA node is a property of the CPU which is per-channel
therefore it makes no sense to force the receive/send buffer to be
allocated on a particular node (since it is a shared resource).

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc.c | 19 +--
 1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index c842265d1df9..91b0674cfdb0 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -245,20 +245,13 @@ int netvsc_alloc_recv_comp_ring(struct netvsc_device 
*net_device, u32 q_idx)
 static int netvsc_init_buf(struct hv_device *device,
   struct netvsc_device *net_device)
 {
-   int ret = 0;
-   struct nvsp_message *init_packet;
struct nvsp_1_message_send_receive_buffer_complete *resp;
-   struct net_device *ndev;
+   struct net_device *ndev = hv_get_drvdata(device);
+   struct nvsp_message *init_packet;
size_t map_words;
-   int node;
-
-   ndev = hv_get_drvdata(device);
-
-   node = cpu_to_node(device->channel->target_cpu);
-   net_device->recv_buf = vzalloc_node(net_device->recv_buf_size, node);
-   if (!net_device->recv_buf)
-   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+   int ret = 0;
 
+   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
if (!net_device->recv_buf) {
netdev_err(ndev, "unable to allocate receive "
"buffer of size %d\n", net_device->recv_buf_size);
@@ -339,9 +332,7 @@ static int netvsc_init_buf(struct hv_device *device,
goto cleanup;
 
/* Now setup the send buffer. */
-   net_device->send_buf = vzalloc_node(net_device->send_buf_size, node);
-   if (!net_device->send_buf)
-   net_device->send_buf = vzalloc(net_device->send_buf_size);
+   net_device->send_buf = vzalloc(net_device->send_buf_size);
if (!net_device->send_buf) {
netdev_err(ndev, "unable to allocate send "
   "buffer of size %d\n", net_device->send_buf_size);
-- 
2.11.0

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


[PATCH net-next 02/10] netvsc: don't signal host twice if empty

2017-08-09 Thread Stephen Hemminger
When hv_pkt_iter_next() returns NULL, it has already called
hv_pkt_iter_close(). Calling it twice can lead to extra host signal.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 208f03aa83de..c842265d1df9 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -1190,10 +1190,6 @@ int netvsc_poll(struct napi_struct *napi, int budget)
nvchan->desc = hv_pkt_iter_next(channel, nvchan->desc);
}
 
-   /* if ring is empty, signal host */
-   if (!nvchan->desc)
-   hv_pkt_iter_close(channel);
-
/* If send of pending receive completions suceeded
 *   and did not exhaust NAPI budget this time
 *   and not doing busy poll
-- 
2.11.0

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


[PATCH net-next 10/10] netvsc: keep track of some non-fatal overload conditions

2017-08-09 Thread Stephen Hemminger
Add ethtool statistics for case where send chimmeny buffer is
exhausted and driver has to fall back to doing scatter/gather
send. Also, add statistic for case where ring buffer is full and
receive completions are delayed.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/hyperv_net.h |  2 ++
 drivers/net/hyperv/netvsc.c | 19 +--
 drivers/net/hyperv/netvsc_drv.c |  2 ++
 3 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 4ccfc335a356..345786321879 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -680,6 +680,8 @@ struct netvsc_ethtool_stats {
unsigned long tx_no_space;
unsigned long tx_too_big;
unsigned long tx_busy;
+   unsigned long tx_send_full;
+   unsigned long rx_comp_busy;
 };
 
 struct netvsc_vf_pcpu_stats {
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 5b3a2b8fa77e..938c9f3d2ea6 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -882,7 +882,9 @@ int netvsc_send(struct net_device_context *ndev_ctx,
} else if (pktlen + net_device->pkt_align <
   net_device->send_section_size) {
section_index = netvsc_get_next_send_section(net_device);
-   if (section_index != NETVSC_INVALID_INDEX) {
+   if (unlikely(section_index == NETVSC_INVALID_INDEX)) {
+   ++ndev_ctx->eth_stats.tx_send_full;
+   } else {
move_pkt_msd(_send, _skb, msdp);
msd_len = 0;
}
@@ -948,9 +950,10 @@ int netvsc_send(struct net_device_context *ndev_ctx,
 }
 
 /* Send pending recv completions */
-static int send_recv_completions(struct netvsc_channel *nvchan)
+static int send_recv_completions(struct net_device *ndev,
+struct netvsc_device *nvdev,
+struct netvsc_channel *nvchan)
 {
-   struct netvsc_device *nvdev = nvchan->net_device;
struct multi_recv_comp *mrc = >mrc;
struct recv_comp_msg {
struct nvsp_message_header hdr;
@@ -968,8 +971,12 @@ static int send_recv_completions(struct netvsc_channel 
*nvchan)
msg.status = rcd->status;
ret = vmbus_sendpacket(nvchan->channel, , sizeof(msg),
   rcd->tid, VM_PKT_COMP, 0);
-   if (unlikely(ret))
+   if (unlikely(ret)) {
+   struct net_device_context *ndev_ctx = netdev_priv(ndev);
+
+   ++ndev_ctx->eth_stats.rx_comp_busy;
return ret;
+   }
 
if (++mrc->first == nvdev->recv_completion_cnt)
mrc->first = 0;
@@ -1010,7 +1017,7 @@ static void enq_receive_complete(struct net_device *ndev,
recv_comp_slot_avail(nvdev, mrc, , );
 
if (unlikely(filled > NAPI_POLL_WEIGHT)) {
-   send_recv_completions(nvchan);
+   send_recv_completions(ndev, nvdev, nvchan);
recv_comp_slot_avail(nvdev, mrc, , );
}
 
@@ -1193,7 +1200,7 @@ int netvsc_poll(struct napi_struct *napi, int budget)
 * then re-enable host interrupts
 * and reschedule if ring is not empty.
 */
-   if (send_recv_completions(nvchan) == 0 &&
+   if (send_recv_completions(ndev, net_device, nvchan) == 0 &&
work_done < budget &&
napi_complete_done(napi, work_done) &&
hv_end_read(>inbound)) {
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 873c83a66cc2..b33f0507c373 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1112,6 +1112,8 @@ static const struct {
{ "tx_no_space",  offsetof(struct netvsc_ethtool_stats, tx_no_space) },
{ "tx_too_big",   offsetof(struct netvsc_ethtool_stats, tx_too_big) },
{ "tx_busy",  offsetof(struct netvsc_ethtool_stats, tx_busy) },
+   { "tx_send_full", offsetof(struct netvsc_ethtool_stats, tx_send_full) },
+   { "rx_comp_busy", offsetof(struct netvsc_ethtool_stats, rx_comp_busy) },
 }, vf_stats[] = {
{ "vf_rx_packets", offsetof(struct netvsc_vf_pcpu_stats, rx_packets) },
{ "vf_rx_bytes",   offsetof(struct netvsc_vf_pcpu_stats, rx_bytes) },
-- 
2.11.0

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


[PATCH net-next 07/10] netvsc: remove unnecessary cast of void pointer

2017-08-09 Thread Stephen Hemminger
Assignment to a typed pointer is sufficient in C.
No cast is needed.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 3219d2e8918f..9f89de17b5fa 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -523,9 +523,9 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
 
rndis_msg_size += NDIS_VLAN_PPI_SIZE;
ppi = init_ppi_data(rndis_msg, NDIS_VLAN_PPI_SIZE,
-   IEEE_8021Q_INFO);
-   vlan = (struct ndis_pkt_8021q_info *)((void *)ppi +
-   ppi->ppi_offset);
+   IEEE_8021Q_INFO);
+
+   vlan = (void *)ppi + ppi->ppi_offset;
vlan->vlanid = skb->vlan_tci & VLAN_VID_MASK;
vlan->pri = (skb->vlan_tci & VLAN_PRIO_MASK) >>
VLAN_PRIO_SHIFT;
@@ -538,8 +538,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
ppi = init_ppi_data(rndis_msg, NDIS_LSO_PPI_SIZE,
TCP_LARGESEND_PKTINFO);
 
-   lso_info = (struct ndis_tcp_lso_info *)((void *)ppi +
-   ppi->ppi_offset);
+   lso_info = (void *)ppi + ppi->ppi_offset;
 
lso_info->lso_v2_transmit.type = 
NDIS_TCP_LARGE_SEND_OFFLOAD_V2_TYPE;
if (skb->protocol == htons(ETH_P_IP)) {
-- 
2.11.0

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


[PATCH net-next 01/10] netvsc: delay setup of VF device

2017-08-09 Thread Stephen Hemminger
When VF device is discovered, delay bring it automatically up in
order to allow userspace to some simple changes (like renaming).

Reported-by: Vitaly Kuznetsov 
Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/hyperv_net.h |  2 +-
 drivers/net/hyperv/netvsc_drv.c | 15 ---
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index d1ea99a12cf2..f620c90307ed 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -723,7 +723,7 @@ struct net_device_context {
/* State to manage the associated VF interface. */
struct net_device __rcu *vf_netdev;
struct netvsc_vf_pcpu_stats __percpu *vf_stats;
-   struct work_struct vf_takeover;
+   struct delayed_work vf_takeover;
 
/* 1: allocated, serial number is valid. 0: not allocated */
u32 vf_alloc;
diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index eb0023f55fe1..e059375a6d8c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -47,6 +47,7 @@
 
 #define RING_SIZE_MIN 64
 #define LINKCHANGE_INT (2 * HZ)
+#define VF_TAKEOVER_INT (HZ / 10)
 
 static int ring_size = 128;
 module_param(ring_size, int, S_IRUGO);
@@ -1559,7 +1560,9 @@ static int netvsc_vf_join(struct net_device *vf_netdev,
/* set slave flag before open to prevent IPv6 addrconf */
vf_netdev->flags |= IFF_SLAVE;
 
-   schedule_work(_ctx->vf_takeover);
+   schedule_delayed_work(_ctx->vf_takeover, VF_TAKEOVER_INT);
+
+   call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
 
netdev_info(vf_netdev, "joined to %s\n", ndev->name);
return 0;
@@ -1575,8 +1578,6 @@ static void __netvsc_vf_setup(struct net_device *ndev,
 {
int ret;
 
-   call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
-
/* Align MTU of VF with master */
ret = dev_set_mtu(vf_netdev, ndev->mtu);
if (ret)
@@ -1597,12 +1598,12 @@ static void __netvsc_vf_setup(struct net_device *ndev,
 static void netvsc_vf_setup(struct work_struct *w)
 {
struct net_device_context *ndev_ctx
-   = container_of(w, struct net_device_context, vf_takeover);
+   = container_of(w, struct net_device_context, vf_takeover.work);
struct net_device *ndev = hv_get_drvdata(ndev_ctx->device_ctx);
struct net_device *vf_netdev;
 
if (!rtnl_trylock()) {
-   schedule_work(w);
+   schedule_delayed_work(_ctx->vf_takeover, 0);
return;
}
 
@@ -1706,7 +1707,7 @@ static int netvsc_unregister_vf(struct net_device 
*vf_netdev)
return NOTIFY_DONE;
 
net_device_ctx = netdev_priv(ndev);
-   cancel_work_sync(_device_ctx->vf_takeover);
+   cancel_delayed_work_sync(_device_ctx->vf_takeover);
 
netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
 
@@ -1748,7 +1749,7 @@ static int netvsc_probe(struct hv_device *dev,
 
spin_lock_init(_device_ctx->lock);
INIT_LIST_HEAD(_device_ctx->reconfig_events);
-   INIT_WORK(_device_ctx->vf_takeover, netvsc_vf_setup);
+   INIT_DELAYED_WORK(_device_ctx->vf_takeover, netvsc_vf_setup);
 
net_device_ctx->vf_stats
= netdev_alloc_pcpu_stats(struct netvsc_vf_pcpu_stats);
-- 
2.11.0

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


[PATCH net-next 09/10] netvsc: allow controlling send/recv buffer size

2017-08-09 Thread Stephen Hemminger
Control the size of the buffer areas via ethtool ring settings.
They aren't really traditional hardware rings, but host API breaks
receive and send buffer into chunks. The final size of the chunks are
controlled by the host.

The default value of send and receive buffer area for host DMA
is much larger than it needs to be. Experimentation shows that
4M receive and 1M send is sufficient.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/hyperv_net.h |   9 ++--
 drivers/net/hyperv/netvsc.c |  70 +---
 drivers/net/hyperv/netvsc_drv.c | 117 ++--
 3 files changed, 157 insertions(+), 39 deletions(-)

diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index f620c90307ed..4ccfc335a356 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -148,6 +148,8 @@ struct netvsc_device_info {
unsigned char mac_adr[ETH_ALEN];
int  ring_size;
u32  num_chn;
+   u32  send_sections;
+   u32  recv_sections;
 };
 
 enum rndis_device_state {
@@ -634,12 +636,12 @@ struct nvsp_message {
 #define NETVSC_SEND_BUFFER_SIZE(1024 * 1024 * 15)   /* 
15MB */
 #define NETVSC_INVALID_INDEX   -1
 
+#define NETVSC_SEND_SECTION_SIZE   6144
+#define NETVSC_RECV_SECTION_SIZE   1728
 
 #define NETVSC_RECEIVE_BUFFER_ID   0xcafe
 #define NETVSC_SEND_BUFFER_ID  0
 
-#define NETVSC_PACKET_SIZE  4096
-
 #define VRSS_SEND_TAB_SIZE 16  /* must be power of 2 */
 #define VRSS_CHANNEL_MAX 64
 #define VRSS_CHANNEL_DEFAULT 8
@@ -754,14 +756,13 @@ struct netvsc_device {
 
/* Receive buffer allocated by us but manages by NetVSP */
void *recv_buf;
-   u32 recv_buf_size;
u32 recv_buf_gpadl_handle;
u32 recv_section_cnt;
+   u32 recv_section_size;
u32 recv_completion_cnt;
 
/* Send buffer allocated by us */
void *send_buf;
-   u32 send_buf_size;
u32 send_buf_gpadl_handle;
u32 send_section_cnt;
u32 send_section_size;
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index 91b0674cfdb0..5b3a2b8fa77e 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -75,6 +75,10 @@ static struct netvsc_device *alloc_net_device(void)
atomic_set(_device->open_cnt, 0);
net_device->max_pkt = RNDIS_MAX_PKT_DEFAULT;
net_device->pkt_align = RNDIS_PKT_ALIGN_DEFAULT;
+
+   net_device->recv_section_size = NETVSC_RECV_SECTION_SIZE;
+   net_device->send_section_size = NETVSC_SEND_SECTION_SIZE;
+
init_completion(_device->channel_init_wait);
 
return net_device;
@@ -142,6 +146,7 @@ static void netvsc_destroy_buf(struct hv_device *device)
"revoke receive buffer to netvsp\n");
return;
}
+   net_device->recv_section_cnt = 0;
}
 
/* Teardown the gpadl on the vsp end */
@@ -172,7 +177,7 @@ static void netvsc_destroy_buf(struct hv_device *device)
 * NVSP_MSG1_TYPE_SEND_SEND_BUF msg) therefore, we need
 * to send a revoke msg here
 */
-   if (net_device->send_section_size) {
+   if (net_device->send_section_cnt) {
/* Send the revoke receive buffer */
revoke_packet = _device->revoke_packet;
memset(revoke_packet, 0, sizeof(struct nvsp_message));
@@ -204,6 +209,7 @@ static void netvsc_destroy_buf(struct hv_device *device)
   "revoke send buffer to netvsp\n");
return;
}
+   net_device->send_section_cnt = 0;
}
/* Teardown the gpadl on the vsp end */
if (net_device->send_buf_gpadl_handle) {
@@ -243,18 +249,25 @@ int netvsc_alloc_recv_comp_ring(struct netvsc_device 
*net_device, u32 q_idx)
 }
 
 static int netvsc_init_buf(struct hv_device *device,
-  struct netvsc_device *net_device)
+  struct netvsc_device *net_device,
+  const struct netvsc_device_info *device_info)
 {
struct nvsp_1_message_send_receive_buffer_complete *resp;
struct net_device *ndev = hv_get_drvdata(device);
struct nvsp_message *init_packet;
+   unsigned int buf_size;
size_t map_words;
int ret = 0;
 
-   net_device->recv_buf = vzalloc(net_device->recv_buf_size);
+   /* Get receive buffer area. */
+   buf_size = device_info->recv_sections * net_device->recv_section_size;
+   buf_size = roundup(buf_size, PAGE_SIZE);
+
+   net_device->recv_buf = vzalloc(buf_size);
if (!net_device->recv_buf) {
-   netdev_err(ndev, "unable to allocate receive "
-   "buffer of size %d\n", net_device->recv_buf_size);
+   

[PATCH net-next 06/10] netvsc: whitespace cleanup

2017-08-09 Thread Stephen Hemminger
Fix some minor indentation issues.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index c7391889938b..3219d2e8918f 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -165,7 +165,7 @@ static int netvsc_close(struct net_device *net)
 }
 
 static void *init_ppi_data(struct rndis_message *msg, u32 ppi_size,
-   int pkt_type)
+  int pkt_type)
 {
struct rndis_packet *rndis_pkt;
struct rndis_per_packet_info *ppi;
@@ -286,7 +286,7 @@ static u16 netvsc_select_queue(struct net_device *ndev, 
struct sk_buff *skb,
 }
 
 static u32 fill_pg_buf(struct page *page, u32 offset, u32 len,
-   struct hv_page_buffer *pb)
+  struct hv_page_buffer *pb)
 {
int j = 0;
 
@@ -626,6 +626,7 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct 
net_device *net)
++net_device_ctx->eth_stats.tx_no_memory;
goto drop;
 }
+
 /*
  * netvsc_linkstatus_callback - Link up/down notification
  */
@@ -649,8 +650,8 @@ void netvsc_linkstatus_callback(struct hv_device 
*device_obj,
if (indicate->status == RNDIS_STATUS_LINK_SPEED_CHANGE) {
u32 speed;
 
-   speed = *(u32 *)((void *)indicate + indicate->
-status_buf_offset) / 1;
+   speed = *(u32 *)((void *)indicate
++ indicate->status_buf_offset) / 1;
ndev_ctx->speed = speed;
return;
}
@@ -1018,7 +1019,7 @@ static void netvsc_get_stats64(struct net_device *net,
struct net_device_context *ndev_ctx = netdev_priv(net);
struct netvsc_device *nvdev = rcu_dereference_rtnl(ndev_ctx->nvdev);
struct netvsc_vf_pcpu_stats vf_tot;
-   int i;
+   int i;
 
if (!nvdev)
return;
-- 
2.11.0

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


[PATCH net-next 08/10] netvsc: remove unnecessary check for NULL hdr

2017-08-09 Thread Stephen Hemminger
The function init_page_array is always called with a valid pointer
to RNDIS header. No check for NULL is needed.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 9f89de17b5fa..7b465e40869b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -333,10 +333,9 @@ static u32 init_page_array(void *hdr, u32 len, struct 
sk_buff *skb,
 * 2. skb linear data
 * 3. skb fragment data
 */
-   if (hdr != NULL)
-   slots_used += fill_pg_buf(virt_to_page(hdr),
-   offset_in_page(hdr),
-   len, [slots_used]);
+   slots_used += fill_pg_buf(virt_to_page(hdr),
+ offset_in_page(hdr),
+ len, [slots_used]);
 
packet->rmsg_size = len;
packet->rmsg_pgcnt = slots_used;
-- 
2.11.0

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


[PATCH net-next 00/10] netvsc: minor fixes and improvements

2017-08-09 Thread Stephen Hemminger
These are non-critical bug fixes, related to functionality now in net-next.
 1. delaying the automatic bring up of VF device to allow udev to change name.
 2. performance improvement
 3. handle MAC address change with VF; mostly propogate the error that VF gives.
 4. minor cleanups
 5. allow setting send/receive buffer size with ethtool.

Stephen Hemminger (10):
  netvsc: delay setup of VF device
  netvsc: don't signal host twice if empty
  netvsc: propagate MAC address change to VF slave
  netvsc: check error return when restoring channels and mtu
  netvsc: no need to allocate send/receive on numa node
  netvsc: whitespace cleanup
  netvsc: remove unnecessary cast of void pointer
  netvsc: remove unnecessary check for NULL hdr
  netvsc: allow controlling send/recv buffer size
  netvsc: keep track of some non-fatal overload conditions

 drivers/net/hyperv/hyperv_net.h |  13 ++-
 drivers/net/hyperv/netvsc.c | 106 ++---
 drivers/net/hyperv/netvsc_drv.c | 203 
 3 files changed, 227 insertions(+), 95 deletions(-)

-- 
2.11.0

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


[PATCH net-next 04/10] netvsc: check error return when restoring channels and mtu

2017-08-09 Thread Stephen Hemminger
If setting new values fails, and the attempt to restore original
settings fails. Then log an error and leave device down.
This should never happen, but if it does don't go down in flames.

Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index 07015b1c42c6..c7391889938b 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -845,7 +845,13 @@ static int netvsc_set_channels(struct net_device *net,
} else {
ret = PTR_ERR(nvdev);
device_info.num_chn = orig;
-   rndis_filter_device_add(dev, _info);
+   nvdev = rndis_filter_device_add(dev, _info);
+
+   if (IS_ERR(nvdev)) {
+   netdev_err(net, "restoring channel setting failed: 
%ld\n",
+  PTR_ERR(nvdev));
+   return ret;
+   }
}
 
if (was_opened)
@@ -953,10 +959,16 @@ static int netvsc_change_mtu(struct net_device *ndev, int 
mtu)
 
/* Attempt rollback to original MTU */
ndev->mtu = orig_mtu;
-   rndis_filter_device_add(hdev, _info);
+   nvdev = rndis_filter_device_add(hdev, _info);
 
if (vf_netdev)
dev_set_mtu(vf_netdev, orig_mtu);
+
+   if (IS_ERR(nvdev)) {
+   netdev_err(ndev, "restoring mtu failed: %ld\n",
+  PTR_ERR(nvdev));
+   return ret;
+   }
}
 
if (was_opened)
-- 
2.11.0

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


[PATCH net-next 03/10] netvsc: propagate MAC address change to VF slave

2017-08-09 Thread Stephen Hemminger
If VF is slaved to synthetic device, then any change to netvsc
MAC address should be propagated to the slave device.

If slave device doesn't support MAC address change then it
should also be an error to attempt to change synthetic NIC MAC
address.

It also fixes the error unwind in the original code.
If give a bad address, the old code would change the device
MAC address anyway.

Reviewed-by: Haiyang Zhang 
Signed-off-by: Stephen Hemminger 
---
 drivers/net/hyperv/netvsc_drv.c | 26 +++---
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
index e059375a6d8c..07015b1c42c6 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1053,27 +1053,31 @@ static void netvsc_get_stats64(struct net_device *net,
 static int netvsc_set_mac_addr(struct net_device *ndev, void *p)
 {
struct net_device_context *ndc = netdev_priv(ndev);
+   struct net_device *vf_netdev = rtnl_dereference(ndc->vf_netdev);
struct netvsc_device *nvdev = rtnl_dereference(ndc->nvdev);
struct sockaddr *addr = p;
-   char save_adr[ETH_ALEN];
-   unsigned char save_aatype;
int err;
 
-   memcpy(save_adr, ndev->dev_addr, ETH_ALEN);
-   save_aatype = ndev->addr_assign_type;
-
-   err = eth_mac_addr(ndev, p);
-   if (err != 0)
+   err = eth_prepare_mac_addr_change(ndev, p);
+   if (err)
return err;
 
if (!nvdev)
return -ENODEV;
 
+   if (vf_netdev) {
+   err = dev_set_mac_address(vf_netdev, addr);
+   if (err)
+   return err;
+   }
+
err = rndis_filter_set_device_mac(nvdev, addr->sa_data);
-   if (err != 0) {
-   /* roll back to saved MAC */
-   memcpy(ndev->dev_addr, save_adr, ETH_ALEN);
-   ndev->addr_assign_type = save_aatype;
+   if (!err) {
+   eth_commit_mac_addr_change(ndev, p);
+   } else if (vf_netdev) {
+   /* rollback change on VF */
+   memcpy(addr->sa_data, ndev->dev_addr, ETH_ALEN);
+   dev_set_mac_address(vf_netdev, addr);
}
 
return err;
-- 
2.11.0

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


[PATCH] Fixed brace positions in a series of if statements.

2017-08-09 Thread Seth Kushniryk
My first try at this. I hope it's alright.

Signed-off-by: Seth Kushniryk 
---
 drivers/staging/pi433/pi433_if.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/pi433/pi433_if.c b/drivers/staging/pi433/pi433_if.c
index ed737f4b1e77..55737741e83a 100644
--- a/drivers/staging/pi433/pi433_if.c
+++ b/drivers/staging/pi433/pi433_if.c
@@ -133,19 +133,14 @@ DIO0_irq_handler(unsigned int irq, void *dev_id, struct 
pt_regs *regs)
 {
struct pi433_device *device = dev_id;
 
-   if  (device->irq_state[DIO0] == DIO_PacketSent)
-   {
+   if (device->irq_state[DIO0] == DIO_PacketSent) {
device->free_in_fifo = FIFO_SIZE;
printk("DIO0 irq: Packet sent\n"); // TODO: printk() should 
include KERN_ facility level
wake_up_interruptible(>fifo_wait_queue);
-   }
-   else if (device->irq_state[DIO0] == DIO_Rssi_DIO0)
-   {
+   } else if (device->irq_state[DIO0] == DIO_Rssi_DIO0) {
printk("DIO0 irq: RSSI level over threshold\n");
wake_up_interruptible(>rx_wait_queue);
-   }
-   else if (device->irq_state[DIO0] == DIO_PayloadReady)
-   {
+   } else if (device->irq_state[DIO0] == DIO_PayloadReady) {
printk("DIO0 irq: PayloadReady\n");
device->free_in_fifo = 0;
wake_up_interruptible(>fifo_wait_queue);
-- 
2.11.0

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


[PATCH] staging: wlan-ng: Fix sparse warning: cast to restricted __le16.

2017-08-09 Thread AbdAllah-MEZITI
The same structure is used in both side, so we dont need to cast.
This will fix the following sparse warnings:
drivers/staging/wlan-ng/prism2sta.c:1139:13: warning: cast to restricted __le16
drivers/staging/wlan-ng/prism2sta.c:1150:24: warning: cast to restricted __le16
drivers/staging/wlan-ng/prism2sta.c:1157:37: warning: cast to restricted __le16
drivers/staging/wlan-ng/prism2sta.c:1158:37: warning: cast to restricted __le16
drivers/staging/wlan-ng/prism2sta.c:1159:40: warning: cast to restricted __le16
drivers/staging/wlan-ng/prism2sta.c:1450:31: warning: cast to restricted __le16

Signed-off-by: AbdAllah MEZITI 
---
 drivers/staging/wlan-ng/prism2sta.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c 
b/drivers/staging/wlan-ng/prism2sta.c
index 8c34712..c9df450 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1136,7 +1136,7 @@ static void prism2sta_inf_chinforesults(struct wlandevice 
*wlandev,
unsigned int i, n;
 
hw->channel_info.results.scanchannels =
-   le16_to_cpu(inf->info.chinforesult.scanchannels);
+   inf->info.chinforesult.scanchannels;
 
for (i = 0, n = 0; i < HFA384x_CHINFORESULT_MAX; i++) {
struct hfa384x_ch_info_result_sub *result;
@@ -1147,16 +1147,16 @@ static void prism2sta_inf_chinforesults(struct 
wlandevice *wlandev,
continue;
 
result = >info.chinforesult.result[n];
-   chan = le16_to_cpu(result->chid) - 1;
+   chan = result->chid - 1;
 
if (chan < 0 || chan >= HFA384x_CHINFORESULT_MAX)
continue;
 
chinforesult = >channel_info.results.result[chan];
chinforesult->chid = chan;
-   chinforesult->anl = le16_to_cpu(result->anl);
-   chinforesult->pnl = le16_to_cpu(result->pnl);
-   chinforesult->active = le16_to_cpu(result->active);
+   chinforesult->anl = result->anl;
+   chinforesult->pnl = result->pnl;
+   chinforesult->active = result->active;
 
pr_debug("chinfo: channel %d, %s level (avg/peak)=%d/%d dB, pcf 
%d\n",
 chan + 1,
@@ -1447,7 +1447,7 @@ static void prism2sta_inf_linkstatus(struct wlandevice 
*wlandev,
 {
struct hfa384x *hw = wlandev->priv;
 
-   hw->link_status_new = le16_to_cpu(inf->info.linkstatus.linkstatus);
+   hw->link_status_new = inf->info.linkstatus.linkstatus;
 
schedule_work(>link_bh);
 }
-- 
2.7.4

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


Re: [PATCH] mtd: nand: Rename nand.h into rawnand.h

2017-08-09 Thread Tony Lindgren
* Boris Brezillon  [170804 08:30]:
> We are planning to share more code between different NAND based
> devices (SPI NAND, OneNAND and raw NANDs), but before doing that
> we need to move the existing include/linux/mtd/nand.h file into
> include/linux/mtd/rawnand.h so we can later create a nand.h header
> containing all common structure and function prototypes.

For omap:

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


Re: [PATCH v2 2/3] v4l2-flash-led-class: Create separate sub-devices for indicators

2017-08-09 Thread Rui Miguel Silva
Hi,
On Wed, Aug 09, 2017 at 02:15:54PM +0300, Sakari Ailus wrote:
> The V4L2 flash interface allows controlling multiple LEDs through a single
> sub-devices if, and only if, these LEDs are of different types. This
> approach scales badly for flash controllers that drive multiple flash LEDs
> or for LED specific associations. Essentially, the original assumption of a
> LED driver chip that drives a single flash LED and an indicator LED is no
> longer valid.
> 
> Address the matter by registering one sub-device per LED.
> 
> Signed-off-by: Sakari Ailus 
> Reviewed-by: Jacek Anaszewski 
> Acked-by: Pavel Machek 
> ---
>  drivers/leds/leds-aat1290.c|   4 +-
>  drivers/leds/leds-max77693.c   |   4 +-
>  drivers/media/v4l2-core/v4l2-flash-led-class.c | 113 
> +++--
>  drivers/staging/greybus/light.c|  23 +++--

For greybus/light:
Reviewed-by: Rui Miguel Silva 

---
Cheers,
Rui

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


[PATCH] staging: iio: adc: fix error return code in ad7606_par_probe()

2017-08-09 Thread Gustavo A. R. Silva
platform_get_irq() returns an error code, but the ad7606_par driver
ignores it and always returns -ENODEV. This is not correct and,
prevents -EPROBE_DEFER from being propagated properly.

Print and propagate the return value of platform_get_irq on failure.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva 
---
 drivers/staging/iio/adc/ad7606_par.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/iio/adc/ad7606_par.c 
b/drivers/staging/iio/adc/ad7606_par.c
index cd6c410c..3eb6f8f 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -57,8 +57,8 @@ static int ad7606_par_probe(struct platform_device *pdev)
 
irq = platform_get_irq(pdev, 0);
if (irq < 0) {
-   dev_err(>dev, "no irq\n");
-   return -ENODEV;
+   dev_err(>dev, "no irq: %d\n", irq);
+   return irq;
}
 
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-- 
2.5.0

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


[PATCH RESEND] tools: hv: update buffer handling in hv_fcopy_daemon

2017-08-09 Thread Olaf Hering
Currently this warning is triggered when compiling hv_fcopy_daemon:

hv_fcopy_daemon.c:216:4: warning: dereferencing type-punned pointer will break 
strict-aliasing rules [-Wstrict-aliasing]
kernel_modver = *(__u32 *)buffer;

Convert the send/receive buffer to a union and pass individual members as
needed. This also gives the correct size for the buffer (~6K instead of 64K).

Signed-off-by: Olaf Hering 
---
 tools/hv/hv_fcopy_daemon.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/tools/hv/hv_fcopy_daemon.c b/tools/hv/hv_fcopy_daemon.c
index 26ae609a9448..c273dd34d144 100644
--- a/tools/hv/hv_fcopy_daemon.c
+++ b/tools/hv/hv_fcopy_daemon.c
@@ -138,14 +138,17 @@ void print_usage(char *argv[])
 
 int main(int argc, char *argv[])
 {
-   int fcopy_fd, len;
+   int fcopy_fd;
int error;
int daemonize = 1, long_index = 0, opt;
int version = FCOPY_CURRENT_VERSION;
-   char *buffer[4096 * 2];
-   struct hv_fcopy_hdr *in_msg;
+   union {
+   struct hv_fcopy_hdr hdr;
+   struct hv_start_fcopy start;
+   struct hv_do_fcopy copy;
+   __u32 kernel_modver;
+   } buffer = { };
int in_handshake = 1;
-   __u32 kernel_modver;
 
static struct option long_options[] = {
{"help",no_argument,   0,  'h' },
@@ -195,32 +198,30 @@ int main(int argc, char *argv[])
 * In this loop we process fcopy messages after the
 * handshake is complete.
 */
-   len = pread(fcopy_fd, buffer, (4096 * 2), 0);
+   ssize_t len;
+   len = pread(fcopy_fd, , sizeof(buffer), 0);
if (len < 0) {
syslog(LOG_ERR, "pread failed: %s", strerror(errno));
exit(EXIT_FAILURE);
}
 
if (in_handshake) {
-   if (len != sizeof(kernel_modver)) {
+   if (len != sizeof(buffer.kernel_modver)) {
syslog(LOG_ERR, "invalid version negotiation");
exit(EXIT_FAILURE);
}
-   kernel_modver = *(__u32 *)buffer;
in_handshake = 0;
-   syslog(LOG_INFO, "kernel module version: %d",
-  kernel_modver);
+   syslog(LOG_INFO, "kernel module version: %u",
+  buffer.kernel_modver);
continue;
}
 
-   in_msg = (struct hv_fcopy_hdr *)buffer;
-
-   switch (in_msg->operation) {
+   switch (buffer.hdr.operation) {
case START_FILE_COPY:
-   error = hv_start_fcopy((struct hv_start_fcopy *)in_msg);
+   error = hv_start_fcopy();
break;
case WRITE_TO_FILE:
-   error = hv_copy_data((struct hv_do_fcopy *)in_msg);
+   error = hv_copy_data();
break;
case COMPLETE_FCOPY:
error = hv_copy_finished();
@@ -231,7 +232,7 @@ int main(int argc, char *argv[])
 
default:
syslog(LOG_ERR, "Unknown operation: %d",
-   in_msg->operation);
+   buffer.hdr.operation);
 
}
 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/3] staging: greybus: light: fix memory leak in v4l2 register

2017-08-09 Thread Sakari Ailus
Hi Rui,

On Wed, Aug 09, 2017 at 02:20:02PM +0100, Rui Miguel Silva wrote:
> Hi Sakari,
> On Wed, Aug 09, 2017 at 02:15:53PM +0300, Sakari Ailus wrote:
> > From: Rui Miguel Silva 
> > 
> > We are allocating memory for the v4l2 flash configuration structure and
> > leak it in the normal path. Just use the stack for this as we do not
> > use it outside of this function.
> > 
> > Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
> > Reported-by: Sakari Ailus 
> > Signed-off-by: Rui Miguel Silva 
> > Reviewed-by: Viresh Kumar 
> > ---
> 
> This patch is *not* the patch that I have send, here are the code
> differences from my patch to the one in this series:
> 
> < struct led_classdev_flash *iled = NULL;
> ---
> > struct led_classdev *iled = NULL;
> 51c57
> < iled = _ind->fled;
> ---
> > iled = _ind->fled.led_cdev;
> 89c95
> 
> So, this do not apply at all.
> Maybe you change something in your side.

It's been rebased on linux-next and in particular, patch 85f7ff9702bc
("media: v4l2-flash: Use led_classdev instead of led_classdev_flash for
indicator").

-- 
Sakari Ailus
e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Tools: hv: fix snprintf warning in kvp_daemon

2017-08-09 Thread Olaf Hering
Increase buffer size so that "_{-INT_MAX}" will fit.
Spotted by the gcc7 snprintf checker.

Signed-off-by: Olaf Hering 
---
 tools/hv/hv_kvp_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 88b20e007c05..eaa3bec273c8 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -1136,7 +1136,7 @@ static int process_ip_string(FILE *f, char *ip_string, 
int type)
int i = 0;
int j = 0;
char str[256];
-   char sub_str[10];
+   char sub_str[13];
int offset = 0;
 
memset(addr, 0, sizeof(addr));
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [RESEND PATCH] staging: vboxvideo: remove dead gamma lut code

2017-08-09 Thread Daniel Vetter
On Tue, Aug 08, 2017 at 01:54:52PM +0200, Peter Rosin wrote:
> On 2017-08-07 11:21, Daniel Vetter wrote:
> > On Fri, Aug 04, 2017 at 12:45:06PM +0200, Peter Rosin wrote:
> >> The redundant fb helpers .load_lut, .gamma_set and .gamma_get are
> >> no longer used. Remove the dead code that was not doing anything
> >> sensible anyway.
> >>
> >> Signed-off-by: Peter Rosin 
> >> ---
> >>  drivers/staging/vboxvideo/vbox_fb.c   | 15 ---
> >>  drivers/staging/vboxvideo/vbox_mode.c |  5 -
> >>  2 files changed, 20 deletions(-)
> >>
> >> [This time with an improved Cc list, sorry for the noise. For new
> >>  people, please refer to https://lkml.org/lkml/2017/7/13/593 for
> >>  context]
> >>
> >> Hi Daniel,
> >>
> >> Here it goes, but do you really need me to resend v5 14/14?
> > 
> > Well it's not yet on dri-devel, but our pre-merge CI bots can't read such
> > instructions. They expect a clean new series that applies cleanly, as a
> > top-post, when resending stuff.
> 
> Ok, noted for the next time. These things seem to vary from subsystem to
> subsystem, so it's not trivial to get it right w/o investing serious time
> looking things up. Anyway, sorry about the trouble.

Yes I know, the kernel is absolutely terrible with minor differences in
process between subsystems. And then getting sternly reprimanded if you
don't know them all :-(

Unfortunately our CI has the same problem, it can't parse all the
different flavours of how people re-submit patches, so we just had to
standardize on something.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next 0/1] netvsc: another VF datapath fix

2017-08-09 Thread Stephen Hemminger
On Wed, 09 Aug 2017 11:03:05 +0200
Vitaly Kuznetsov  wrote:

> Stephen Hemminger  writes:
> 
> > The following would allow udev a chance at the device.
> >  
> 
> This would of course work but the approach is a bit hackish and can
> still fail on a loaded system. Raising the pause interval would be an
> option, but again, probably not the best one.
> 
> Let me try to send an RFC removing the check it dev_change_name() and if
> it turns out that it can't be removed we can go back to your patch. But
> in case it can we can leave without it.
> 
> Thanks,

I don't want to require change of semantics of core networking code
for one driver. Changing name of up device has been blocked for so
long that allowing it might break existing userspace apps. It might
be ok in the future, but netvsc needs to work without that change.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 1/3] staging: greybus: light: fix memory leak in v4l2 register

2017-08-09 Thread Rui Miguel Silva
Hi Sakari,
On Wed, Aug 09, 2017 at 02:15:53PM +0300, Sakari Ailus wrote:
> From: Rui Miguel Silva 
> 
> We are allocating memory for the v4l2 flash configuration structure and
> leak it in the normal path. Just use the stack for this as we do not
> use it outside of this function.
> 
> Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
> Reported-by: Sakari Ailus 
> Signed-off-by: Rui Miguel Silva 
> Reviewed-by: Viresh Kumar 
> ---

This patch is *not* the patch that I have send, here are the code
differences from my patch to the one in this series:

<   struct led_classdev_flash *iled = NULL;
---
>   struct led_classdev *iled = NULL;
51c57
<   iled = _ind->fled;
---
>   iled = _ind->fled.led_cdev;
89c95

So, this do not apply at all.
Maybe you change something in your side.

---
Cheers,
Rui


>  drivers/staging/greybus/light.c | 29 +
>  1 file changed, 9 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
> index 129ceed39829..0771db418f84 100644
> --- a/drivers/staging/greybus/light.c
> +++ b/drivers/staging/greybus/light.c
> @@ -534,25 +534,20 @@ static int gb_lights_light_v4l2_register(struct 
> gb_light *light)
>  {
>   struct gb_connection *connection = get_conn_from_light(light);
>   struct device *dev = >bundle->dev;
> - struct v4l2_flash_config *sd_cfg;
> + struct v4l2_flash_config sd_cfg = { {0} };
>   struct led_classdev_flash *fled;
>   struct led_classdev *iled = NULL;
>   struct gb_channel *channel_torch, *channel_ind, *channel_flash;
> - int ret = 0;
> -
> - sd_cfg = kcalloc(1, sizeof(*sd_cfg), GFP_KERNEL);
> - if (!sd_cfg)
> - return -ENOMEM;
>  
>   channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH);
>   if (channel_torch)
>   __gb_lights_channel_v4l2_config(_torch->intensity_uA,
> - _cfg->torch_intensity);
> + _cfg.torch_intensity);
>  
>   channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR);
>   if (channel_ind) {
>   __gb_lights_channel_v4l2_config(_ind->intensity_uA,
> - _cfg->indicator_intensity);
> + _cfg.indicator_intensity);
>   iled = _ind->fled.led_cdev;
>   }
>  
> @@ -561,27 +556,21 @@ static int gb_lights_light_v4l2_register(struct 
> gb_light *light)
>  
>   fled = _flash->fled;
>  
> - snprintf(sd_cfg->dev_name, sizeof(sd_cfg->dev_name), "%s", light->name);
> + snprintf(sd_cfg.dev_name, sizeof(sd_cfg.dev_name), "%s", light->name);
>  
>   /* Set the possible values to faults, in our case all faults */
> - sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
> + sd_cfg.flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
>   LED_FAULT_OVER_TEMPERATURE | LED_FAULT_SHORT_CIRCUIT |
>   LED_FAULT_OVER_CURRENT | LED_FAULT_INDICATOR |
>   LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE |
>   LED_FAULT_LED_OVER_TEMPERATURE;
>  
>   light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled,
> - _flash_ops, sd_cfg);
> - if (IS_ERR_OR_NULL(light->v4l2_flash)) {
> - ret = PTR_ERR(light->v4l2_flash);
> - goto out_free;
> - }
> + _flash_ops, _cfg);
> + if (IS_ERR_OR_NULL(light->v4l2_flash))
> + return PTR_ERR(light->v4l2_flash);
>  
> - return ret;
> -
> -out_free:
> - kfree(sd_cfg);
> - return ret;
> + return 0;
>  }
>  
>  static void gb_lights_light_v4l2_unregister(struct gb_light *light)
> -- 
> 2.11.0
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/3] Create sub-device per LED

2017-08-09 Thread Sakari Ailus
Hi folks,

The original design decision in the V4L2 flash API allows controlling a two
LEDs (an indicator and a flash) through a single sub-device. This covered
virtually all flash driver chips back then but this no longer holds as
there are many LED driver chips with multiple flash LED outputs. This
necessitates creating as many sub-devices as there are flash LEDs.

Additionally the flash LEDs can be associated to different sensors. This is
not unconceivable although not very probable.

This patchset splits the indicator and flash LEDs exposed by the V4L2 flash
class framework into multiple sub-devices. This way the driver creates the
sub-devices individually for each LED which will also facilitate fwnode
matching (e.g. will you refer to LED or a LED driver chip with a phandle?).

since v1:

- Drop patch "staging: greybus: light: Don't leak memory for no gain" in
  favour of Rui's "staging: greybus: light: fix memory leak in v4l2
  register".

- Rebase "staging: greybus: light: fix memory leak in v4l2 register" on
  "media: v4l2-flash: Use led_classdev instead of led_classdev_flash for
  indicator" already in mediatree.

- Add "v4l2-flash-led-class: Document v4l2_flash_init() references" to the
  set.

Rui Miguel Silva (1):
  staging: greybus: light: fix memory leak in v4l2 register

Sakari Ailus (2):
  v4l2-flash-led-class: Create separate sub-devices for indicators
  v4l2-flash-led-class: Document v4l2_flash_init() references

 drivers/leds/leds-aat1290.c|   4 +-
 drivers/leds/leds-max77693.c   |   4 +-
 drivers/media/v4l2-core/v4l2-flash-led-class.c | 113 +++--
 drivers/staging/greybus/light.c|  42 -
 include/media/v4l2-flash-led-class.h   |  47 +++---
 5 files changed, 127 insertions(+), 83 deletions(-)

-- 
2.11.0

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


[PATCH v2 1/3] staging: greybus: light: fix memory leak in v4l2 register

2017-08-09 Thread Sakari Ailus
From: Rui Miguel Silva 

We are allocating memory for the v4l2 flash configuration structure and
leak it in the normal path. Just use the stack for this as we do not
use it outside of this function.

Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
Reported-by: Sakari Ailus 
Signed-off-by: Rui Miguel Silva 
Reviewed-by: Viresh Kumar 
---
 drivers/staging/greybus/light.c | 29 +
 1 file changed, 9 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/greybus/light.c b/drivers/staging/greybus/light.c
index 129ceed39829..0771db418f84 100644
--- a/drivers/staging/greybus/light.c
+++ b/drivers/staging/greybus/light.c
@@ -534,25 +534,20 @@ static int gb_lights_light_v4l2_register(struct gb_light 
*light)
 {
struct gb_connection *connection = get_conn_from_light(light);
struct device *dev = >bundle->dev;
-   struct v4l2_flash_config *sd_cfg;
+   struct v4l2_flash_config sd_cfg = { {0} };
struct led_classdev_flash *fled;
struct led_classdev *iled = NULL;
struct gb_channel *channel_torch, *channel_ind, *channel_flash;
-   int ret = 0;
-
-   sd_cfg = kcalloc(1, sizeof(*sd_cfg), GFP_KERNEL);
-   if (!sd_cfg)
-   return -ENOMEM;
 
channel_torch = get_channel_from_mode(light, GB_CHANNEL_MODE_TORCH);
if (channel_torch)
__gb_lights_channel_v4l2_config(_torch->intensity_uA,
-   _cfg->torch_intensity);
+   _cfg.torch_intensity);
 
channel_ind = get_channel_from_mode(light, GB_CHANNEL_MODE_INDICATOR);
if (channel_ind) {
__gb_lights_channel_v4l2_config(_ind->intensity_uA,
-   _cfg->indicator_intensity);
+   _cfg.indicator_intensity);
iled = _ind->fled.led_cdev;
}
 
@@ -561,27 +556,21 @@ static int gb_lights_light_v4l2_register(struct gb_light 
*light)
 
fled = _flash->fled;
 
-   snprintf(sd_cfg->dev_name, sizeof(sd_cfg->dev_name), "%s", light->name);
+   snprintf(sd_cfg.dev_name, sizeof(sd_cfg.dev_name), "%s", light->name);
 
/* Set the possible values to faults, in our case all faults */
-   sd_cfg->flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
+   sd_cfg.flash_faults = LED_FAULT_OVER_VOLTAGE | LED_FAULT_TIMEOUT |
LED_FAULT_OVER_TEMPERATURE | LED_FAULT_SHORT_CIRCUIT |
LED_FAULT_OVER_CURRENT | LED_FAULT_INDICATOR |
LED_FAULT_UNDER_VOLTAGE | LED_FAULT_INPUT_VOLTAGE |
LED_FAULT_LED_OVER_TEMPERATURE;
 
light->v4l2_flash = v4l2_flash_init(dev, NULL, fled, iled,
-   _flash_ops, sd_cfg);
-   if (IS_ERR_OR_NULL(light->v4l2_flash)) {
-   ret = PTR_ERR(light->v4l2_flash);
-   goto out_free;
-   }
+   _flash_ops, _cfg);
+   if (IS_ERR_OR_NULL(light->v4l2_flash))
+   return PTR_ERR(light->v4l2_flash);
 
-   return ret;
-
-out_free:
-   kfree(sd_cfg);
-   return ret;
+   return 0;
 }
 
 static void gb_lights_light_v4l2_unregister(struct gb_light *light)
-- 
2.11.0

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


[PATCH v2 3/3] v4l2-flash-led-class: Document v4l2_flash_init() references

2017-08-09 Thread Sakari Ailus
The v4l2_flash_init() keeps a reference to the ops struct but not to the
config struct (nor anything it contains). Document this.

Signed-off-by: Sakari Ailus 
Acked-by: Pavel Machek 
---
 include/media/v4l2-flash-led-class.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/media/v4l2-flash-led-class.h 
b/include/media/v4l2-flash-led-class.h
index c3f39992f3fa..6f4825b6a352 100644
--- a/include/media/v4l2-flash-led-class.h
+++ b/include/media/v4l2-flash-led-class.h
@@ -112,6 +112,9 @@ static inline struct v4l2_flash 
*v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)
  * @config:initialization data for V4L2 Flash sub-device
  *
  * Create V4L2 Flash sub-device wrapping given LED subsystem device.
+ * The ops pointer is stored by the V4L2 flash framework. No
+ * references are held to config nor its contents once this function
+ * has returned.
  *
  * Returns: A valid pointer, or, when an error occurs, the return
  * value is encoded using ERR_PTR(). Use IS_ERR() to check and
@@ -130,6 +133,9 @@ struct v4l2_flash *v4l2_flash_init(
  * @config:initialization data for V4L2 Flash sub-device
  *
  * Create V4L2 Flash sub-device wrapping given LED subsystem device.
+ * The ops pointer is stored by the V4L2 flash framework. No
+ * references are held to config nor its contents once this function
+ * has returned.
  *
  * Returns: A valid pointer, or, when an error occurs, the return
  * value is encoded using ERR_PTR(). Use IS_ERR() to check and
-- 
2.11.0

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


Re: [PATCH] staging: greybus: light: fix memory leak in v4l2 register

2017-08-09 Thread Sakari Ailus
Hi Rui and Johan,

On 08/02/17 19:52, Rui Miguel Silva wrote:
> We are allocating memory for the v4l2 flash configuration structure and
> leak it in the normal path. Just use the stack for this as we do not
> use it outside of this function.
> 
> Fixes: 2870b52bae4c ("greybus: lights: add lights implementation")
> Reported-by: Sakari Ailus 
> Signed-off-by: Rui Miguel Silva 

My apologies for missing sending the original patch to the appropriate
recipients the first time.

Could I take this through the mediatree? The second patch in the
original set now depends on this one. I'll cc you the second patch as
well, it will need updates.

-- 
Kind regards,

Sakari Ailus
sakari.ai...@linux.intel.com
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: bcm2835-audio: constify snd_pcm_ops structures

2017-08-09 Thread Arvind Yadav
snd_pcm_ops are not supposed to change at runtime. All functions
working with snd_pcm_ops provided by  work with
const snd_pcm_ops. So mark the non-const structs as const.

Signed-off-by: Arvind Yadav 
---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c 
b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
index 3637ddf..1bf34ce 100644
--- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c
@@ -438,7 +438,7 @@ static int snd_bcm2835_pcm_lib_ioctl(struct 
snd_pcm_substream *substream,
 }
 
 /* operators */
-static struct snd_pcm_ops snd_bcm2835_playback_ops = {
+static const struct snd_pcm_ops snd_bcm2835_playback_ops = {
.open = snd_bcm2835_playback_open,
.close = snd_bcm2835_playback_close,
.ioctl = snd_bcm2835_pcm_lib_ioctl,
@@ -450,7 +450,7 @@ static int snd_bcm2835_pcm_lib_ioctl(struct 
snd_pcm_substream *substream,
.ack = snd_bcm2835_pcm_ack,
 };
 
-static struct snd_pcm_ops snd_bcm2835_playback_spdif_ops = {
+static const struct snd_pcm_ops snd_bcm2835_playback_spdif_ops = {
.open = snd_bcm2835_playback_spdif_open,
.close = snd_bcm2835_playback_close,
.ioctl = snd_bcm2835_pcm_lib_ioctl,
-- 
1.9.1

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