RE: [PATCH v14 net-next 1/1] hv_sock: introduce Hyper-V Sockets

2016-07-08 Thread Dexuan Cui
> From: Olaf Hering [mailto:o...@aepfle.de]
> Sent: Friday, July 8, 2016 0:02
> On Thu, Jun 30, Dexuan Cui wrote:
> 
> > +/* The MTU is 16KB per the host side's design. */
> > +struct hvsock_recv_buf {
> > +   unsigned int data_len;
> > +   unsigned int data_offset;
> > +
> > +   struct vmpipe_proto_header hdr;
> > +   u8 buf[PAGE_SIZE * 4];
> 
> Please use some macro related to the protocol rather than a Linux
> compiletime macro.
OK. I'll fix this.
 
> > +/* We send at most 4KB payload per VMBus packet. */
> > +struct hvsock_send_buf {
> > +   struct vmpipe_proto_header hdr;
> > +   u8 buf[PAGE_SIZE];
> 
> Same here.
OK. I'll fix this.

> > + * Copyright(c) 2016, Microsoft Corporation. All rights reserved.
> 
> Here the BSD license follows. I think its required/desired to also
> include a GPL blurb like it is done in many other files:
> ...
>  * Alternatively, this software may be distributed under the terms of
>  * the GNU General Public License ("GPL") version 2 as published by the
>  * Free Software Foundation.
> 
> 
> Otherwise the MODULE_LICENSE string might be incorrect.
I'll add the GPL blurb.
 
> > +   /* Hyper-V Sockets requires at least VMBus 4.0 */
> > +   if ((vmbus_proto_version >> 16) < 4) {
> > +   pr_err("failed to load: VMBus 4 or later is required\n");
> 
> I guess this mens WS 2016+, and loading in earlier host versions will
> trigger this path? I think a silent ENODEV is enough.
Yes. 
OK, I'll remove the pr_err().

> 
> > +   return -ENODEV;
> 
> Olaf

I'll post v15 shortly, which will address all the comments from Joe and Olaf.

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


[PATCH v15 net-next 0/1] introduce Hyper-V VM Sockets(hv_sock)

2016-07-08 Thread Dexuan Cui
Hyper-V Sockets (hv_sock) supplies a byte-stream based communication
mechanism between the host and the guest. It's somewhat like TCP over
VMBus, but the transportation layer (VMBus) is much simpler than IP.

With Hyper-V Sockets, applications between the host and the guest can talk
to each other directly by the traditional BSD-style socket APIs.

Hyper-V Sockets is only available on new Windows hosts, like Windows Server
2016. More info is in this article "Make your own integration services":
https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service

The patch implements the necessary support in the guest side by
introducing a new socket address family AF_HYPERV.

You can also get the patch by:
https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160708_v15

Note: the VMBus driver side's supporting patches have been in the mainline
tree.

I know the kernel has already had a VM Sockets driver (AF_VSOCK) based
on VMware VMCI (net/vmw_vsock/, drivers/misc/vmw_vmci), and KVM is
proposing AF_VSOCK of virtio version:
http://marc.info/?l=linux-netdev&m=145952064004765&w=2

However, though Hyper-V Sockets may seem conceptually similar to
AF_VOSCK, there are differences in the transportation layer, and IMO these
make the direct code reusing impractical:

1. In AF_VSOCK, the endpoint type is: , but in
AF_HYPERV, the endpoint type is: . Here GUID
is 128-bit.

2. AF_VSOCK supports SOCK_DGRAM, while AF_HYPERV doesn't.

3. AF_VSOCK supports some special sock opts, like SO_VM_SOCKETS_BUFFER_SIZE,
SO_VM_SOCKETS_BUFFER_MIN/MAX_SIZE and SO_VM_SOCKETS_CONNECT_TIMEOUT.
These are meaningless to AF_HYPERV.

4. Some AF_VSOCK's VMCI transportation ops are meanless to AF_HYPERV/VMBus,
like .notify_recv_init
.notify_recv_pre_block
.notify_recv_pre_dequeue
.notify_recv_post_dequeue
.notify_send_init
.notify_send_pre_block
.notify_send_pre_enqueue
.notify_send_post_enqueue
etc.

So I think we'd better introduce a new address family: AF_HYPERV.

Please review the patch.

Looking forward to your comments, especially comments from David. :-)

Changes since v1:
- updated "[PATCH 6/7] hvsock: introduce Hyper-V VM Sockets feature"
- added __init and __exit for the module init/exit functions
- net/hv_sock/Kconfig: "default m" -> "default m if HYPERV"
- MODULE_LICENSE: "Dual MIT/GPL" -> "Dual BSD/GPL"

Changes since v2:
- fixed various coding issue pointed out by David Miller
- fixed indentation issues
- removed pr_debug in net/hv_sock/af_hvsock.c
- used reverse-Chrismas-tree style for local variables.
- EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL

Changes since v3:
- fixed a few coding issue pointed by Vitaly Kuznetsov and Dan Carpenter
- fixed the ret value in vmbus_recvpacket_hvsock on error
- fixed the style of multi-line comment: vmbus_get_hvsock_rw_status()

Changes since v4 (https://lkml.org/lkml/2015/7/28/404):
- addressed all the comments about V4.
- treat the hvsock offers/channels as special VMBus devices
- add a mechanism to pass hvsock events to the hvsock driver
- fixed some corner cases with proper locking when a connection is closed
- rebased to the latest Greg's tree

Changes since v5 (https://lkml.org/lkml/2015/12/24/103):
- addressed the coding style issues (Vitaly Kuznetsov & David Miller, thanks!)
- used a better coding for the per-channel rescind callback (Thank Vitaly!)
- avoided the introduction of new VMBUS driver APIs vmbus_sendpacket_hvsock()
and vmbus_recvpacket_hvsock() and used vmbus_sendpacket()/vmbus_recvpacket()
in the higher level (i.e., the vmsock driver). Thank Vitaly!

Changes since v6 (http://lkml.iu.edu/hypermail/linux/kernel/1601.3/01813.html)
- only a few minor changes of coding style and comments

Changes since v7
- a few minor changes of coding style: thanks, Joe Perches!
- added some lines of comments about GUID/UUID before the struct sockaddr_hv.

Changes since v8
- removed the unnecessary __packed for some definitions: thanks, David!
- hvsock_open_connection:  use offer.u.pipe.user_def[0] to know the connection
and reorganized the function
direction 
- reorganized the code according to suggestions from Cathy Avery: split big
functions into small ones, set .setsockopt and getsockopt to
sock_no_setsockopt/sock_no_getsockopt
- inline'd some small list helper functions

Changes since v9
- minimized struct hvsock_sock by making the send/recv buffers pointers.
   the buffers are allocated by kmalloc() in __hvsock_create() now.
- minimized the sizes of the send/recv buffers and the vmbus ringbuffers.

Changes since v10

1) add module params: send_ring_page, recv_ring_page. They can be used to
enlarge the ringbuffer size to get better performance, e.g.,
# modprobe hv_sock  recv_ring_page=16 send_ring_page=16
By default, recv_ring_page is 3 and send_ring_page is 2.

2) add module param max_socket_number (the default is 1024).
A user can enlarge the number to create more than 1024 hv_sock sockets.
By default, 1024 sockets take about 1024 * (3+2+1+1) * 4KB = 28M bytes.
(H

[PATCH v15 net-next 1/1] hv_sock: introduce Hyper-V Sockets

2016-07-08 Thread Dexuan Cui
Hyper-V Sockets (hv_sock) supplies a byte-stream based communication
mechanism between the host and the guest. It's somewhat like TCP over
VMBus, but the transportation layer (VMBus) is much simpler than IP.

With Hyper-V Sockets, applications between the host and the guest can talk
to each other directly by the traditional BSD-style socket APIs.

Hyper-V Sockets is only available on new Windows hosts, like Windows Server
2016. More info is in this article "Make your own integration services":
https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service

The patch implements the necessary support in the guest side by introducing
a new socket address family AF_HYPERV.

Signed-off-by: Dexuan Cui 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Vitaly Kuznetsov 
Cc: Cathy Avery 
---

You can also get the patch here (2764221d):
https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160708_v15

For the change log before v12, please see https://lkml.org/lkml/2016/5/15/31

In v12, the changes are mainly the following:

1) remove the module params as David suggested.

2) use 5 exact pages for VMBus send/recv rings, respectively.
The host side's design of the feature requires 5 exact pages for recv/send
rings respectively -- this is suboptimal considering memory consumption,
however unluckily we have to live with it, before the host comes up with
a new design in the future. :-(

3) remove the per-connection static send/recv buffers
Instead, we allocate and free the buffers dynamically only when we recv/send
data. This means: when a connection is idle, no memory is consumed as
recv/send buffers at all.

In v13:
I return ENOMEM on buffer alllocation failure

   Actually "man read/write" says "Other errors may occur, depending on the
object connected to fd". "man send/recv" indeed lists ENOMEM.
   Considering AF_HYPERV is a new socket type, ENOMEM seems OK here.
   In the long run, I think we should add a new API in the VMBus driver,
allowing data copy from VMBus ringbuffer into user mode buffer directly.
This way, we can even eliminate this temporary buffer.

In v14:
fix some coding style issues pointed out by David.

In v15:
Just some stylistic changes addressing comments from Joe Perches and
Olaf Hering -- thank you!
- add a GPL blurb.
- define a new macro PAGE_SIZE_4K and use it to replace PAGE_SIZE
- change sk_to_hvsock/hvsock_to_sk() from macros to inline functions
- remove a not-very-useful pr_err()
- fix some typos in comment and coding style issues.

Looking forward to your comments!

 MAINTAINERS |2 +
 include/linux/hyperv.h  |   13 +
 include/linux/socket.h  |4 +-
 include/net/af_hvsock.h |   78 +++
 include/uapi/linux/hyperv.h |   24 +
 net/Kconfig |1 +
 net/Makefile|1 +
 net/hv_sock/Kconfig |   10 +
 net/hv_sock/Makefile|3 +
 net/hv_sock/af_hvsock.c | 1523 +++
 10 files changed, 1658 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50f69ba..6eaa26f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5514,7 +5514,9 @@ F:drivers/pci/host/pci-hyperv.c
 F: drivers/net/hyperv/
 F: drivers/scsi/storvsc_drv.c
 F: drivers/video/fbdev/hyperv_fb.c
+F: net/hv_sock/
 F: include/linux/hyperv.h
+F: include/net/af_hvsock.h
 F: tools/hv/
 F: Documentation/ABI/stable/sysfs-bus-vmbus
 
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
index 50f493e..1cda6ea5 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1508,5 +1508,18 @@ static inline void commit_rd_index(struct vmbus_channel 
*channel)
vmbus_set_event(channel);
 }
 
+struct vmpipe_proto_header {
+   u32 pkt_type;
+   u32 data_size;
+};
+
+#define HVSOCK_HEADER_LEN  (sizeof(struct vmpacket_descriptor) + \
+sizeof(struct vmpipe_proto_header))
+
+/* See 'prev_indices' in hv_ringbuffer_read(), hv_ringbuffer_write() */
+#define PREV_INDICES_LEN   (sizeof(u64))
 
+#define HVSOCK_PKT_LEN(payload_len)(HVSOCK_HEADER_LEN + \
+   ALIGN((payload_len), 8) + \
+   PREV_INDICES_LEN)
 #endif /* _HYPERV_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
index b5cc5a6..0b68b58 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -202,8 +202,9 @@ struct ucred {
 #define AF_VSOCK   40  /* vSockets */
 #define AF_KCM 41  /* Kernel Connection Multiplexor*/
 #define AF_QIPCRTR 42  /* Qualcomm IPC Router  */
+#define AF_HYPERV  43  /* Hyper-V Sockets  */
 
-#define AF_MAX 43  /* For now.. */
+#define AF_MAX 44  /* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC  AF_UNSPEC
@@ -251,6 +252,7 @@ struct ucred {
 #define PF_VS

RE: [PATCH v15 net-next 1/1] hv_sock: introduce Hyper-V Sockets

2016-07-08 Thread Dexuan Cui
> From: Dexuan Cui
> Sent: Friday, July 8, 2016 15:47
> 
> You can also get the patch here (2764221d):
> https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160708_v15
> 
> In v14:
> fix some coding style issues pointed out by David.
> 
> In v15:
> Just some stylistic changes addressing comments from Joe Perches and
> Olaf Hering -- thank you!
> - add a GPL blurb.
> - define a new macro PAGE_SIZE_4K and use it to replace PAGE_SIZE
> - change sk_to_hvsock/hvsock_to_sk() from macros to inline functions
> - remove a not-very-useful pr_err()
> - fix some typos in comment and coding style issues.

FYI: the diff between v14 and v15 is attached: the diff is generated by 
git-diff-ing the 2 branches decui/hv_sock/net-next/20160629_v14 and 
decui/hv_sock/net-next/20160708_v15 in the above github repo.
 
Thanks,
-- Dexuan


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


Partnership INVESTMENT

2016-07-08 Thread GLOBAL PARTNERSHIP & INVESTMENTS
The Chief Executive Officer,
Managing Director 
Chief Financial Director,

A CALL FOR BUSINESS & PROJECT FACILITATORS

WE ARE A BUSINESS DEVELOPMENT INVESTOR working on expanding its portfolio 
globally in Financing and Developing Projects. We are active Investors and 
Financiers in sectors and geographies that hold potential and tangible returns, 
working in partnership with a number of world-class organizations with a 
combined International pool of nearly Half a Trillion in available Liquidity.

We have a confirmed Cash Backed Financial Facility ready to be invested only in 
your country as part of a Scheme; Social Investment Funds (SIFs) to provide 
loans to our companies and individuals, to help sustain and grow already proven 
solutions to poverty. Our fund providers and investors include foundations 
aiming to align assets with mission, religious pension funds striving for 
community impact, development banks seeking catalytic impact investment 
opportunities and accredited individual investors. This is a 100% Project and 
Business Development Investment facility and is absolutely “FLEXIBLE PROCEDURE” 
for delivery via Bank-to-Bank only and facility is up to 30 years. We would be 
happy to partner with you if you have any viable business or project and our 
areas of interest are any viable project such as Real Estate Projects, Business 
Start-up and Expansion Projects, Oil/Gas Projects, Mining Projects, 
Government/Municipal Projects, Motion Picture/Entertainment Projects, and many 
other types of projects, to name a few.

Do contact me with your Serious Inquiries Only for further details and 
information at your earliest convenience. We look forward to receiving your 
reply to my personal email address: i...@hk-financial.com 

HK FINANCIAL FIDUCIARY
Suite 811 Tsimshatsui Centre, 
East Wing, 66 Mody Road,
Tsimshatsui East, Kowloon, Hong Kong
Email: i...@hk-financial.com  
Hong Kong Office: +85 281 929 504
Skype: benjamin.jones10010




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


Partnership INVESTMENT

2016-07-08 Thread GLOBAL PARTNERSHIP & INVESTMENTS
The Chief Executive Officer,
Managing Director 
Chief Financial Director,

A CALL FOR BUSINESS & PROJECT FACILITATORS

WE ARE A BUSINESS DEVELOPMENT INVESTOR working on expanding its portfolio 
globally in Financing and Developing Projects. We are active Investors and 
Financiers in sectors and geographies that hold potential and tangible returns, 
working in partnership with a number of world-class organizations with a 
combined International pool of nearly Half a Trillion in available Liquidity.

We have a confirmed Cash Backed Financial Facility ready to be invested only in 
your country as part of a Scheme; Social Investment Funds (SIFs) to provide 
loans to our companies and individuals, to help sustain and grow already proven 
solutions to poverty. Our fund providers and investors include foundations 
aiming to align assets with mission, religious pension funds striving for 
community impact, development banks seeking catalytic impact investment 
opportunities and accredited individual investors. This is a 100% Project and 
Business Development Investment facility and is absolutely “FLEXIBLE PROCEDURE” 
for delivery via Bank-to-Bank only and facility is up to 30 years. We would be 
happy to partner with you if you have any viable business or project and our 
areas of interest are any viable project such as Real Estate Projects, Business 
Start-up and Expansion Projects, Oil/Gas Projects, Mining Projects, 
Government/Municipal Projects, Motion Picture/Entertainment Projects, and many 
other types of projects, to name a few.

Do contact me with your Serious Inquiries Only for further details and 
information at your earliest convenience. We look forward to receiving your 
reply to my personal email address: i...@hk-financial.com 

HK FINANCIAL FIDUCIARY
Suite 811 Tsimshatsui Centre, 
East Wing, 66 Mody Road,
Tsimshatsui East, Kowloon, Hong Kong
Email: i...@hk-financial.com  
Hong Kong Office: +85 281 929 504
Skype: benjamin.jones10010




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


Re: [PATCH v15 net-next 1/1] hv_sock: introduce Hyper-V Sockets

2016-07-08 Thread Cathy Avery
It's too bad about having to allocate the send/receive rings on a per 
socket basis. Hopefully this will change in the future.


I have built kernel 4.7.0-rc6 with this patch and did a quick test on 
the driver using rhel7 over hyperv Windows Server 2016 TP5. These were 
basic send and receive tests ( host to vm and vm to host ) using apps 
provided by Dexuan.


Reviewed-by: Cathy Avery 
Tested-by: Cathy Avery 

On 07/08/2016 03:47 AM, Dexuan Cui wrote:

Hyper-V Sockets (hv_sock) supplies a byte-stream based communication
mechanism between the host and the guest. It's somewhat like TCP over
VMBus, but the transportation layer (VMBus) is much simpler than IP.

With Hyper-V Sockets, applications between the host and the guest can talk
to each other directly by the traditional BSD-style socket APIs.

Hyper-V Sockets is only available on new Windows hosts, like Windows Server
2016. More info is in this article "Make your own integration services":
https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service

The patch implements the necessary support in the guest side by introducing
a new socket address family AF_HYPERV.

Signed-off-by: Dexuan Cui 
Cc: "K. Y. Srinivasan" 
Cc: Haiyang Zhang 
Cc: Vitaly Kuznetsov 
Cc: Cathy Avery 
---

You can also get the patch here (2764221d):
https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160708_v15

For the change log before v12, please see https://lkml.org/lkml/2016/5/15/31

In v12, the changes are mainly the following:

1) remove the module params as David suggested.

2) use 5 exact pages for VMBus send/recv rings, respectively.
The host side's design of the feature requires 5 exact pages for recv/send
rings respectively -- this is suboptimal considering memory consumption,
however unluckily we have to live with it, before the host comes up with
a new design in the future. :-(

3) remove the per-connection static send/recv buffers
Instead, we allocate and free the buffers dynamically only when we recv/send
data. This means: when a connection is idle, no memory is consumed as
recv/send buffers at all.

In v13:
I return ENOMEM on buffer alllocation failure

Actually "man read/write" says "Other errors may occur, depending on the
object connected to fd". "man send/recv" indeed lists ENOMEM.
Considering AF_HYPERV is a new socket type, ENOMEM seems OK here.
In the long run, I think we should add a new API in the VMBus driver,
allowing data copy from VMBus ringbuffer into user mode buffer directly.
This way, we can even eliminate this temporary buffer.

In v14:
fix some coding style issues pointed out by David.

In v15:
Just some stylistic changes addressing comments from Joe Perches and
Olaf Hering -- thank you!
- add a GPL blurb.
- define a new macro PAGE_SIZE_4K and use it to replace PAGE_SIZE
- change sk_to_hvsock/hvsock_to_sk() from macros to inline functions
- remove a not-very-useful pr_err()
- fix some typos in comment and coding style issues.

Looking forward to your comments!

  MAINTAINERS |2 +
  include/linux/hyperv.h  |   13 +
  include/linux/socket.h  |4 +-
  include/net/af_hvsock.h |   78 +++
  include/uapi/linux/hyperv.h |   24 +
  net/Kconfig |1 +
  net/Makefile|1 +
  net/hv_sock/Kconfig |   10 +
  net/hv_sock/Makefile|3 +
  net/hv_sock/af_hvsock.c | 1523 +++
  10 files changed, 1658 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 50f69ba..6eaa26f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5514,7 +5514,9 @@ F:drivers/pci/host/pci-hyperv.c
  F:drivers/net/hyperv/
  F:drivers/scsi/storvsc_drv.c
  F:drivers/video/fbdev/hyperv_fb.c
+F: net/hv_sock/
  F:include/linux/hyperv.h
+F: include/net/af_hvsock.h
  F:tools/hv/
  F:Documentation/ABI/stable/sysfs-bus-vmbus
  
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h

index 50f493e..1cda6ea5 100644
--- a/include/linux/hyperv.h
+++ b/include/linux/hyperv.h
@@ -1508,5 +1508,18 @@ static inline void commit_rd_index(struct vmbus_channel 
*channel)
vmbus_set_event(channel);
  }
  
+struct vmpipe_proto_header {

+   u32 pkt_type;
+   u32 data_size;
+};
+
+#define HVSOCK_HEADER_LEN  (sizeof(struct vmpacket_descriptor) + \
+sizeof(struct vmpipe_proto_header))
+
+/* See 'prev_indices' in hv_ringbuffer_read(), hv_ringbuffer_write() */
+#define PREV_INDICES_LEN   (sizeof(u64))
  
+#define HVSOCK_PKT_LEN(payload_len)	(HVSOCK_HEADER_LEN + \

+   ALIGN((payload_len), 8) + \
+   PREV_INDICES_LEN)
  #endif /* _HYPERV_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
index b5cc5a6..0b68b58 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -202,8 +202,9 @@ struct ucred {
  #define AF_VSOCK  4

Re: [v3,01/10] rtlwifi: Create common routine to get hardware info

2016-07-08 Thread Kalle Valo
Larry Finger  wrote:
> All of the rtlwifi family of drivers have a similar routine that acquires
> the hardware info from efuse and initializes a number of variables in the
> driver's private area. A common routine is created for all drivers to use.
> 
> Reported-by: Arnd Bergmann 
> Signed-off-by: Larry Finger 
> Cc: Arnd Bergmann 

Thanks, 10 patches applied to wireless-drivers-next.git:

edb45b67a09d rtlwifi: Create common routine to get hardware info
df5cbc697d9b rtlwifi: rtl8192ce: Convert driver to use common hardware info 
routine
c2d9a411456c rtlwifi: rtl8192cu: Convert driver to use common hardware info 
routine
9468792743a5 rtlwifi: rtl8188ee: Convert driver to use common hardware info 
routine
5c392654ee81 rtlwifi: rtl8192ee: Convert driver to use common hardware info 
routine
8aaf6916de68 rtlwifi: rtl8723ae: Convert driver to use common hardware info 
routine
9e9c9c247c21 rtlwifi: rtl8723be: Convert driver to use common hardware info 
routine
2f7b4b895365 rtlwifi: rtl8821ae: Convert driver to use common hardware info 
routine
a8c9fb2b82ab rtlwifi: rtl8192de: Convert driver to use common hardware info 
routine
238ad2ddf34b rtlwifi: rtl8723ae: Clean up the hardware info routine

-- 
Sent by pwcli
https://patchwork.kernel.org/patch/9214551/

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


Re: [PATCH v15 net-next 1/1] hv_sock: introduce Hyper-V Sockets

2016-07-08 Thread Vitaly Kuznetsov
Dexuan Cui  writes:

> Hyper-V Sockets (hv_sock) supplies a byte-stream based communication
> mechanism between the host and the guest. It's somewhat like TCP over
> VMBus, but the transportation layer (VMBus) is much simpler than IP.
>
> With Hyper-V Sockets, applications between the host and the guest can talk
> to each other directly by the traditional BSD-style socket APIs.
>
> Hyper-V Sockets is only available on new Windows hosts, like Windows Server
> 2016. More info is in this article "Make your own integration services":
> https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/develop/make_mgmt_service
>
> The patch implements the necessary support in the guest side by introducing
> a new socket address family AF_HYPERV.
>
> Signed-off-by: Dexuan Cui 
> Cc: "K. Y. Srinivasan" 
> Cc: Haiyang Zhang 
> Cc: Vitaly Kuznetsov 

Some comments below. The vast majority of them are really minor, the
only thing which bothers me a little bit is WARN() in hvsock_sendmsg()
which I think shouldn't be there. But I may have missed something.

I didn't do any tests for the code.

> Cc: Cathy Avery 
> ---
>
> You can also get the patch here (2764221d):
> https://github.com/dcui/linux/commits/decui/hv_sock/net-next/20160708_v15
>
> For the change log before v12, please see https://lkml.org/lkml/2016/5/15/31
>
> In v12, the changes are mainly the following:
>
> 1) remove the module params as David suggested.
>
> 2) use 5 exact pages for VMBus send/recv rings, respectively.
> The host side's design of the feature requires 5 exact pages for recv/send
> rings respectively -- this is suboptimal considering memory consumption,
> however unluckily we have to live with it, before the host comes up with
> a new design in the future. :-(
>
> 3) remove the per-connection static send/recv buffers
> Instead, we allocate and free the buffers dynamically only when we recv/send
> data. This means: when a connection is idle, no memory is consumed as
> recv/send buffers at all.
>
> In v13:
> I return ENOMEM on buffer alllocation failure
>
>Actually "man read/write" says "Other errors may occur, depending on the
> object connected to fd". "man send/recv" indeed lists ENOMEM.
>Considering AF_HYPERV is a new socket type, ENOMEM seems OK here.
>In the long run, I think we should add a new API in the VMBus driver,
> allowing data copy from VMBus ringbuffer into user mode buffer directly.
> This way, we can even eliminate this temporary buffer.
>
> In v14:
> fix some coding style issues pointed out by David.
>
> In v15:
> Just some stylistic changes addressing comments from Joe Perches and
> Olaf Hering -- thank you!
> - add a GPL blurb.
> - define a new macro PAGE_SIZE_4K and use it to replace PAGE_SIZE
> - change sk_to_hvsock/hvsock_to_sk() from macros to inline functions
> - remove a not-very-useful pr_err()
> - fix some typos in comment and coding style issues.
>
> Looking forward to your comments!
>
>  MAINTAINERS |2 +
>  include/linux/hyperv.h  |   13 +
>  include/linux/socket.h  |4 +-
>  include/net/af_hvsock.h |   78 +++
>  include/uapi/linux/hyperv.h |   24 +
>  net/Kconfig |1 +
>  net/Makefile|1 +
>  net/hv_sock/Kconfig |   10 +
>  net/hv_sock/Makefile|3 +
>  net/hv_sock/af_hvsock.c | 1523 
> +++
>  10 files changed, 1658 insertions(+), 1 deletion(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 50f69ba..6eaa26f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -5514,7 +5514,9 @@ F:  drivers/pci/host/pci-hyperv.c
>  F:   drivers/net/hyperv/
>  F:   drivers/scsi/storvsc_drv.c
>  F:   drivers/video/fbdev/hyperv_fb.c
> +F:   net/hv_sock/
>  F:   include/linux/hyperv.h
> +F:   include/net/af_hvsock.h
>  F:   tools/hv/
>  F:   Documentation/ABI/stable/sysfs-bus-vmbus
>
> diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h
> index 50f493e..1cda6ea5 100644
> --- a/include/linux/hyperv.h
> +++ b/include/linux/hyperv.h
> @@ -1508,5 +1508,18 @@ static inline void commit_rd_index(struct 
> vmbus_channel *channel)
>   vmbus_set_event(channel);
>  }
>
> +struct vmpipe_proto_header {
> + u32 pkt_type;
> + u32 data_size;
> +};
> +
> +#define HVSOCK_HEADER_LEN(sizeof(struct vmpacket_descriptor) + \
> +  sizeof(struct vmpipe_proto_header))
> +
> +/* See 'prev_indices' in hv_ringbuffer_read(), hv_ringbuffer_write() */
> +#define PREV_INDICES_LEN (sizeof(u64))
>
> +#define HVSOCK_PKT_LEN(payload_len)  (HVSOCK_HEADER_LEN + \
> + ALIGN((payload_len), 8) + \
> + PREV_INDICES_LEN)
>  #endif /* _HYPERV_H */
> diff --git a/include/linux/socket.h b/include/linux/socket.h
> index b5cc5a6..0b68b58 100644
> --- a/include/linux/socket.h
> +++ b/include/linux/socket.h
> @@ -202,8 +202,9 @@ struct ucred {
>  #define AF_VSOCK 40  /* vSockets 

Re: [PATCH 01/15 RESEND] staging: dgnc: remove redundant NULL checks in

2016-07-08 Thread Luis de Bethencourt
On 04/07/16 12:36, Daeseok Youn wrote:
> The dgnc_block_til_ready() is only used in dgnc_tty_open().
> The unit data(struct un_t) was stored into tty->driver_data in 
> dgnc_tty_open().
> And also tty and un were tested about NULL so these variables doesn't
> need to check for NULL in dgnc_block_til_ready().
> 
> Signed-off-by: Daeseok Youn 
> ---
> This patch seems to be missed for a long time.
> I resend this patch without any updates.
> 
>  drivers/staging/dgnc/dgnc_tty.c | 9 ++---
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
> index 4eeecc9..6758859 100644
> --- a/drivers/staging/dgnc/dgnc_tty.c
> +++ b/drivers/staging/dgnc/dgnc_tty.c
> @@ -1172,17 +1172,12 @@ static int dgnc_block_til_ready(struct tty_struct 
> *tty,
>   struct channel_t *ch)
>  {
>   int retval = 0;
> - struct un_t *un = NULL;
> + struct un_t *un = tty->driver_data;
>   unsigned long flags;
>   uintold_flags = 0;
>   int sleep_on_un_flags = 0;
>  
> - if (!tty || tty->magic != TTY_MAGIC || !file || !ch ||
> - ch->magic != DGNC_CHANNEL_MAGIC)
> - return -ENXIO;
> -
> - un = tty->driver_data;
> - if (!un || un->magic != DGNC_UNIT_MAGIC)
> + if (!file)
>   return -ENXIO;
>  
>   spin_lock_irqsave(&ch->ch_lock, flags);
> 

Hi,

Just curious. Are you confident of removing the tty->magic != TTY_MAGIC check?

>From what I've seen that one can catch potential errors. I might be wrong.

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


Re: [PATCH v2 1/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
On 7 July 2016 at 17:19, Rasmus Villemoes  wrote:
> On Tue, Jul 05 2016, Markus Mayer  wrote:
>
>> +/**
>> + * strncpytoupper - Copy a length-limited string and convert to uppercase.
>> + * @dst: The buffer to store the result.
>> + * @src: The string to convert to uppercase.
>> + * @len: Maximum string length. May be 0 to set no limit.
>> + *
>> + * Returns pointer to terminating '\0' in @dst.
>> + */
>> +char *strncpytoupper(char *dst, const char *src, size_t len)
>> +{
>> + size_t i;
>> +
>> + for (i = 0; src[i] != '\0' && (i < len || !len); i++)
>> + dst[i] = toupper(src[i]);
>> + if (i < len || !len)
>> + dst[i] = '\0';
>> +
>> + return dst + i;
>> +}
>
> Hm, this seems to copy the insane semantics from strncpy of not
> guaranteeing '\0'-termination.

Yeah. I've been tossing that one around a bit. The reason I did it
this way in the end is due to the use cases I found. strncpy() is
being used there and I was a little wary to make too many changes all
at once.

But I understand your point. I'll look at it again and see what
changes might be required in the code that used strncpy() before.

> Why use 0 as a sentinel, when (size_t)-1 == SIZE_MAX would work just as
> well and require a little less code (no || !len)?

I'll change that.

> I regret suggesting this return semantics and now agree that void would
> be better, especially since there doesn't seem to be anyone who can
> use this (or any other) return value. How about
>
> if (!len)
>return;
>
> for (i = 0; i < len && src[i]; ++i)
>   dst[i] = toupper(src[i]);
> dst[i < len ? i : i-1] = '\0';

This makes sense.

> (I think you must do i < len before testing src[i], since the len
> parameter should be an upper bound on the number of bytes to access in
> both src and dst).
>
> Rasmus

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


Re: [PATCH] Staging: gdm724x: gdm_tty: Fixed a checkpatch check issue.

2016-07-08 Thread Luis de Bethencourt
On 05/07/16 12:33, Samuele Baisi wrote:
> Removed a blankline after an opening bracket.
> 
> Signed-off-by: Samuele Baisi 
> ---
>  drivers/staging/gdm724x/gdm_tty.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c 
> b/drivers/staging/gdm724x/gdm_tty.c
> index eb7e252..ae39663 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -225,7 +225,6 @@ int register_lte_tty_device(struct tty_dev *tty_dev, 
> struct device *device)
>   int j;
>  
>   for (i = 0; i < TTY_MAX_COUNT; i++) {
> -
>   gdm = kmalloc(sizeof(*gdm), GFP_KERNEL);
>   if (!gdm)
>   return -ENOMEM;
> 

Patch applies cleanly and removes the checkpath issue.

Acked-by: Luis de Bethencourt 

Samuele,

It is a good idea to include the issue you are solving in the commit
message, in this case it would be:

Removed a blankline after an opening bracket.

CHECK: Blank lines aren't necessary after an open brace '{'
#228: FILE: drivers/staging/gdm724x/gdm_tty.c:228:
+   for (i = 0; i < TTY_MAX_COUNT; i++) {
+

Signed-off-by:
---

Thanks :)
Luis

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


Re: [PATCH] Staging: rtl8712: Fixed brace and comment style issue

2016-07-08 Thread Luis de Bethencourt
On 03/07/16 04:54, Anuradha Weeraman wrote:
> Fixed issues with coding style.
> 
> Signed-off-by: Anuradha Weeraman 
> ---
>  drivers/staging/rtl8712/xmit_linux.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/staging/rtl8712/xmit_linux.c 
> b/drivers/staging/rtl8712/xmit_linux.c
> index 695f9b9..1e86133 100644
> --- a/drivers/staging/rtl8712/xmit_linux.c
> +++ b/drivers/staging/rtl8712/xmit_linux.c
> @@ -91,7 +91,8 @@ void r8712_set_qos(struct pkt_file *ppktfile, struct 
> pkt_attrib *pattrib)
>   } else {
>   /* "When priority processing of data frames is supported,
>* a STA's SME should send EAPOL-Key frames at the highest
> -  * priority." */
> +  * priority."
> +  */
>  
>   if (pattrib->ether_type == 0x888e)
>   UserPriority = 7;
> @@ -162,16 +163,16 @@ int r8712_xmit_entry(_pkt *pkt, struct  net_device 
> *pnetdev)
>   struct _adapter *padapter = netdev_priv(pnetdev);
>   struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
>  
> - if (!r8712_if_up(padapter)) {
> + if (!r8712_if_up(padapter))
>   goto _xmit_entry_drop;
> - }
> +
>   pxmitframe = r8712_alloc_xmitframe(pxmitpriv);
> - if (!pxmitframe) {
> + if (!pxmitframe)
>   goto _xmit_entry_drop;
> - }
> - if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib))) {
> +
> + if ((!r8712_update_attrib(padapter, pkt, &pxmitframe->attrib)))
>   goto _xmit_entry_drop;
> - }
> +
>   padapter->ledpriv.LedControlHandler(padapter, LED_CTL_TX);
>   pxmitframe->pkt = pkt;
>   if (r8712_pre_xmit(padapter, pxmitframe)) {
> 

Patch applies cleanly and removes the checkpatch issues related to
unnecessary braces and trailing */ in a different line.

Hi Anuradha,

It is a good idea to include the checkpatch issue you are solving in
the commit message, in this case it would be:

Fixed issues with coding style

WARNING: Block comments use a trailing */ on a separate line
#94: FILE: drivers/staging/rtl8712/xmit_linux.c:94:
+* priority." */

WARNING: braces {} are not necessary for single statement blocks
#165: FILE: drivers/staging/rtl8712/xmit_linux.c:165:
+   if (!r8712_if_up(padapter)) {
+   goto _xmit_entry_drop;
+   }
---

You can send each type of checkpatch issue in an separate patch. If
you do this, please fix the other issues as well :) There are some
CamelCase problems and the GPL header needs fixing.

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


Re: [PATCH] Staging: gdm724x: gdm_tty: Fixed a checkpatch check issue.

2016-07-08 Thread Samuele Baisi



Il giorno ven 8 lug 2016 alle 20:17, Luis de Bethencourt 
 ha scritto:

On 05/07/16 12:33, Samuele Baisi wrote:

 Removed a blankline after an opening bracket.

 Signed-off-by: Samuele Baisi 
 ---
  drivers/staging/gdm724x/gdm_tty.c | 1 -
  1 file changed, 1 deletion(-)

 diff --git a/drivers/staging/gdm724x/gdm_tty.c 
b/drivers/staging/gdm724x/gdm_tty.c

 index eb7e252..ae39663 100644
 --- a/drivers/staging/gdm724x/gdm_tty.c
 +++ b/drivers/staging/gdm724x/gdm_tty.c
 @@ -225,7 +225,6 @@ int register_lte_tty_device(struct tty_dev 
*tty_dev, struct device *device)

int j;

for (i = 0; i < TTY_MAX_COUNT; i++) {
 -
gdm = kmalloc(sizeof(*gdm), GFP_KERNEL);
if (!gdm)
return -ENOMEM;



Patch applies cleanly and removes the checkpath issue.

Acked-by: Luis de Bethencourt 

Samuele,

It is a good idea to include the issue you are solving in the commit
message, in this case it would be:

Removed a blankline after an opening bracket.

CHECK: Blank lines aren't necessary after an open brace '{'
#228: FILE: drivers/staging/gdm724x/gdm_tty.c:228:
+   for (i = 0; i < TTY_MAX_COUNT; i++) {
+

Signed-off-by:
---

Thanks :)
Luis


Ok, next time I'll try to be more clear.

Thank you very much and best regards.

Samuele

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


Re: [PATCH] Staging: gdm724x: gdm_tty: Fixed a checkpatch check issue.

2016-07-08 Thread Luis de Bethencourt
On 08/07/16 20:32, Samuele Baisi wrote:
> 
> 
> Il giorno ven 8 lug 2016 alle 20:17, Luis de Bethencourt 
>  ha scritto:
>> On 05/07/16 12:33, Samuele Baisi wrote:
>>>  Removed a blankline after an opening bracket.
>>>
>>>  Signed-off-by: Samuele Baisi 
>>>  ---
>>>   drivers/staging/gdm724x/gdm_tty.c | 1 -
>>>   1 file changed, 1 deletion(-)
>>>
>>>  diff --git a/drivers/staging/gdm724x/gdm_tty.c 
>>> b/drivers/staging/gdm724x/gdm_tty.c
>>>  index eb7e252..ae39663 100644
>>>  --- a/drivers/staging/gdm724x/gdm_tty.c
>>>  +++ b/drivers/staging/gdm724x/gdm_tty.c
>>>  @@ -225,7 +225,6 @@ int register_lte_tty_device(struct tty_dev *tty_dev, 
>>> struct device *device)
>>>   int j;
>>>
>>>   for (i = 0; i < TTY_MAX_COUNT; i++) {
>>>  -
>>>   gdm = kmalloc(sizeof(*gdm), GFP_KERNEL);
>>>   if (!gdm)
>>>   return -ENOMEM;
>>>
>>
>> Patch applies cleanly and removes the checkpath issue.
>>
>> Acked-by: Luis de Bethencourt 
>>
>> Samuele,
>>
>> It is a good idea to include the issue you are solving in the commit
>> message, in this case it would be:
>>
>> Removed a blankline after an opening bracket.
>>
>> CHECK: Blank lines aren't necessary after an open brace '{'
>> #228: FILE: drivers/staging/gdm724x/gdm_tty.c:228:
>> +   for (i = 0; i < TTY_MAX_COUNT; i++) {
>> +
>>
>> Signed-off-by:
>> ---
>>
>> Thanks :)
>> Luis
> 
> Ok, next time I'll try to be more clear.
> 
> Thank you very much and best regards.
> 
> Samuele
> 

No problem Samuele.

Looking forward to more patches from you soon :)
Feel free to CC me in them.

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


[PATCH v3 0/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
This series introduces a family of generic string case conversion
functions. This kind of functionality is needed in several places in
the kernel. Right now, everybody seems to be implementing their own
copy of this functionality.

Based on the discussion of the previous version of this series[1] and
the use cases found in the kernel, it does look like having several
flavours of case conversion functions is beneficial. The use cases fall
into three categories:
- copying a string and converting the case while specifying a
  maximum length to mimic strlcpy()
- copying a string and converting the case without specifying a
  length to mimic strcpy()
- converting the case of a string in-place (i.e. modifying the
  string that was passed in)

Consequently, I am proposing these new functions:
void strlcpytoupper(char *dst, const char *src, size_t len);
void strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

Several drivers are being modified to make use of the functions above.
Another driver that also makes use of this functionality will be
submitted upstream shortly, which prompted this whole exercise.

The changes made here have been compile-tested, but not tried out, due
to lack of required hardware.

Changes since v2:
  - use strlcpy() semantics not strncpy() semantics, i.e. guarantee
NULL termination
  - as a result strncpyto are now called
strlcpyto
  - make functions void
  - use len == -1 (SIZE_MAX) as no-limit indicator rather then len == 0
  - change PATCH 2/7 to match strlcpy() semantics
  - change PATCH 4/7 to match strlcpy() semantics

Changes since v1:
  - expanded strtolower() into a family of functions that cover use
cases when a length argument is or isn't required and that support
copying the string into a new buffer or changing it in-place 
  - changed the function semantics to return a pointer to the
terminating '\0' character of the modified string
  - added strtoupper() functionality mirroring the above
  - dropped the ACPICA patch, since that code is OS independent and
can't rely on a Linux library function (see [2])
  - Added two new patches replacing strtoupper() implementations

[1] https://lkml.org/lkml/2016/6/30/727
[2] https://lkml.org/lkml/2016/7/1/9



Markus Mayer (7):
  lib: string: add functions to case-convert strings
  drm/nouveau/core: make use of new strlcpytolower() function
  ACPI / device_sysfs: make use of new strtolower() function
  staging: speakup: replace spk_strlwr() with strlcpytolower()
  iscsi-target: replace iscsi_initiatorname_tolower() with strtolower()
  drm/nouveau/fifo/gk104: make use of new strcpytoupper() function
  power_supply: make use of new strcpytoupper() function

 drivers/acpi/device_sysfs.c  |  4 +--
 drivers/gpu/drm/nouveau/nvkm/core/firmware.c |  9 +-
 drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c |  5 +--
 drivers/power/power_supply_sysfs.c   | 13 +++-
 drivers/staging/speakup/kobjects.c   |  3 +-
 drivers/staging/speakup/main.c   |  3 +-
 drivers/staging/speakup/speakup.h|  1 -
 drivers/staging/speakup/varhandlers.c| 12 ---
 drivers/target/iscsi/iscsi_target_nego.c | 17 +-
 include/linux/string.h   | 40 
 lib/string.c | 38 ++
 11 files changed, 90 insertions(+), 55 deletions(-)

-- 
2.7.4

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


[PATCH v3 1/7] lib: string: add functions to case-convert strings

2016-07-08 Thread Markus Mayer
Add a collection of generic functions to convert strings to lowercase
or uppercase.

Changing the case of a string (with or without copying it first) seems
to be a recurring requirement in the kernel that is currently being
solved by several duplicated implementations doing the same thing. This
change aims at reducing this code duplication.

The new functions are
void strlcpytoupper(char *dst, const char *src, size_t len);
void strlcpytolower(char *dst, const char *src, size_t len);
void strcpytoupper(char *dst, const char *src);
void strcpytolower(char *dst, const char *src);
void strtoupper(char *s);
void strtolower(char *s);

The "str[l]cpyto*" versions of the function take a destination string
and a source string as arguments. The "strlcpyto*" versions additionally
take a length argument like strlcpy() itself. Lastly, the strto*
functions take a single string argument and modify the passed-in string.

Like strlcpy(), and unlike strncpy(), the functions guarantee NULL
termination of the destination string.

Signed-off-by: Markus Mayer 
---
 include/linux/string.h | 40 
 lib/string.c   | 38 ++
 2 files changed, 78 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 26b6f6a..36c9d14 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -116,6 +116,8 @@ extern void * memchr(const void *,int,__kernel_size_t);
 #endif
 void *memchr_inv(const void *s, int c, size_t n);
 char *strreplace(char *s, char old, char new);
+extern void strlcpytoupper(char *dst, const char *src, size_t len);
+extern void strlcpytolower(char *dst, const char *src, size_t len);
 
 extern void kfree_const(const void *x);
 
@@ -169,4 +171,42 @@ static inline const char *kbasename(const char *path)
return tail ? tail + 1 : path;
 }
 
+/**
+ * strcpytoupper - Copy string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ */
+static inline void strcpytoupper(char *dst, const char *src)
+{
+   strlcpytoupper(dst, src, -1);
+}
+
+/**
+ * strcpytolower - Copy string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ */
+static inline void strcpytolower(char *dst, const char *src)
+{
+   strlcpytolower(dst, src, -1);
+}
+
+/**
+ * strtoupper - Convert string to uppercase.
+ * @s: The string to operate on.
+ */
+static inline void strtoupper(char *s)
+{
+   strlcpytoupper(s, s, -1);
+}
+
+/**
+ * strtolower - Convert string to lowercase.
+ * @s: The string to operate on.
+ */
+static inline void strtolower(char *s)
+{
+   strlcpytolower(s, s, -1);
+}
+
 #endif /* _LINUX_STRING_H_ */
diff --git a/lib/string.c b/lib/string.c
index ed83562..fd8c427 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -952,3 +952,41 @@ char *strreplace(char *s, char old, char new)
return s;
 }
 EXPORT_SYMBOL(strreplace);
+
+/**
+ * strlcpytoupper - Copy a length-limited string and convert to uppercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to uppercase.
+ * @len: Maximum string length. May be SIZE_MAX (-1) to set no limit.
+ */
+void strlcpytoupper(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = toupper(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+}
+EXPORT_SYMBOL(strlcpytoupper);
+
+/**
+ * strlcpytolower - Copy a length-limited string and convert to lowercase.
+ * @dst: The buffer to store the result.
+ * @src: The string to convert to lowercase.
+ * @len: Maximum string length. May be SIZE_MAX (-1) to set no limit.
+ */
+void strlcpytolower(char *dst, const char *src, size_t len)
+{
+   size_t i;
+
+   if (!len)
+   return;
+
+   for (i = 0; i < len && src[i]; ++i)
+   dst[i] = tolower(src[i]);
+   dst[i < len ? i : i - 1] = '\0';
+}
+EXPORT_SYMBOL(strlcpytolower);
-- 
2.7.4

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


[PATCH v3 4/7] staging: speakup: replace spk_strlwr() with strlcpytolower()

2016-07-08 Thread Markus Mayer
After introducing generic strltolower() and strtolower(), spk_strlwr()
is no longer needed.

Signed-off-by: Markus Mayer 
---

Samuel, I left off your ACK, since the implementation of my function
changed in v2 and again in v3. This patch has been updated to match the
new strlcpy() semantics. Here, this means we want the length argument
to be sizeof(new_synth_name).

See https://patchwork.kernel.org/patch/9215217/ for the previous version.


 drivers/staging/speakup/kobjects.c|  3 +--
 drivers/staging/speakup/main.c|  3 ++-
 drivers/staging/speakup/speakup.h |  1 -
 drivers/staging/speakup/varhandlers.c | 12 
 4 files changed, 3 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/speakup/kobjects.c 
b/drivers/staging/speakup/kobjects.c
index 528cbdc..c6e0c2d 100644
--- a/drivers/staging/speakup/kobjects.c
+++ b/drivers/staging/speakup/kobjects.c
@@ -387,11 +387,10 @@ static ssize_t synth_store(struct kobject *kobj, struct 
kobj_attribute *attr,
len = strlen(buf);
if (len < 2 || len > 9)
return -EINVAL;
-   strncpy(new_synth_name, buf, len);
+   strlcpytolower(new_synth_name, buf, sizeof(new_synth_name));
if (new_synth_name[len - 1] == '\n')
len--;
new_synth_name[len] = '\0';
-   spk_strlwr(new_synth_name);
if ((synth != NULL) && (!strcmp(new_synth_name, synth->name))) {
pr_warn("%s already in use\n", new_synth_name);
} else if (synth_init(new_synth_name) != 0) {
diff --git a/drivers/staging/speakup/main.c b/drivers/staging/speakup/main.c
index 97ca4ec..970f568 100644
--- a/drivers/staging/speakup/main.c
+++ b/drivers/staging/speakup/main.c
@@ -2314,7 +2314,8 @@ static int __init speakup_init(void)
spk_initialize_msgs();  /* Initialize arrays for i18n. */
spk_reset_default_chars();
spk_reset_default_chartab();
-   spk_strlwr(synth_name);
+   if (synth_name)
+   strtolower(synth_name);
spk_vars[0].u.n.high = vc->vc_cols;
for (var = spk_vars; var->var_id != MAXVARS; var++)
speakup_register_var(var);
diff --git a/drivers/staging/speakup/speakup.h 
b/drivers/staging/speakup/speakup.h
index df74c91..4725785 100644
--- a/drivers/staging/speakup/speakup.h
+++ b/drivers/staging/speakup/speakup.h
@@ -50,7 +50,6 @@ void synth_insert_next_index(int sent_num);
 void spk_reset_index_count(int sc);
 void spk_get_index_count(int *linecount, int *sentcount);
 int spk_set_key_info(const u_char *key_info, u_char *k_buffer);
-char *spk_strlwr(char *s);
 char *spk_s2uchar(char *start, char *dest);
 int speakup_kobj_init(void);
 void speakup_kobj_exit(void);
diff --git a/drivers/staging/speakup/varhandlers.c 
b/drivers/staging/speakup/varhandlers.c
index e1393d2..a1af222 100644
--- a/drivers/staging/speakup/varhandlers.c
+++ b/drivers/staging/speakup/varhandlers.c
@@ -309,18 +309,6 @@ int spk_set_mask_bits(const char *input, const int which, 
const int how)
return 0;
 }
 
-char *spk_strlwr(char *s)
-{
-   char *p;
-
-   if (!s)
-   return NULL;
-
-   for (p = s; *p; p++)
-   *p = tolower(*p);
-   return s;
-}
-
 char *spk_s2uchar(char *start, char *dest)
 {
int val;
-- 
2.7.4

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


Re: [PATCH RESEND net-next] netvsc: Use the new in-place consumption APIs in the rx path

2016-07-08 Thread David Miller
From: k...@exchange.microsoft.com
Date: Tue,  5 Jul 2016 16:52:46 -0700

> From: K. Y. Srinivasan 
> 
> Use the new APIs for eliminating a copy on the receive path. These new APIs 
> also
> help in minimizing the number of memory barriers we end up issuing (in the
> ringbuffer code) since we can better control when we want to expose the ring
> state to the host.
> 
> The patch is being resent to address earlier email issues.
> 
> Signed-off-by: K. Y. Srinivasan 

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