diff options
author | Muhammad Falak R Wani <falakreyaz@gmail.com> | 2016-05-19 07:09:28 -0400 |
---|---|---|
committer | Sebastian Reichel <sre@kernel.org> | 2016-05-29 14:38:02 -0400 |
commit | b32bd7e7d5c1c04bb351420c09217f38dad8b8f1 (patch) | |
tree | 1b3d68ffa8d660d97ed89bf19e3c4b0c50541829 /drivers/hsi | |
parent | f6004b7bc651c11591d544ce3fd60d7bf7d71ccd (diff) |
hsi: use kmemdup
Use kmemdup when some other buffer is immediately copied into allocated
region. It replaces call to allocation followed by memcpy, by a single
call to kmemdup.
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/hsi')
-rw-r--r-- | drivers/hsi/hsi.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/hsi/hsi.c b/drivers/hsi/hsi.c index df380d55c58f..d7ce07ad67f3 100644 --- a/drivers/hsi/hsi.c +++ b/drivers/hsi/hsi.c | |||
@@ -90,19 +90,19 @@ struct hsi_client *hsi_new_client(struct hsi_port *port, | |||
90 | cl->tx_cfg = info->tx_cfg; | 90 | cl->tx_cfg = info->tx_cfg; |
91 | if (cl->tx_cfg.channels) { | 91 | if (cl->tx_cfg.channels) { |
92 | size = cl->tx_cfg.num_channels * sizeof(*cl->tx_cfg.channels); | 92 | size = cl->tx_cfg.num_channels * sizeof(*cl->tx_cfg.channels); |
93 | cl->tx_cfg.channels = kzalloc(size , GFP_KERNEL); | 93 | cl->tx_cfg.channels = kmemdup(info->tx_cfg.channels, size, |
94 | GFP_KERNEL); | ||
94 | if (!cl->tx_cfg.channels) | 95 | if (!cl->tx_cfg.channels) |
95 | goto err_tx; | 96 | goto err_tx; |
96 | memcpy(cl->tx_cfg.channels, info->tx_cfg.channels, size); | ||
97 | } | 97 | } |
98 | 98 | ||
99 | cl->rx_cfg = info->rx_cfg; | 99 | cl->rx_cfg = info->rx_cfg; |
100 | if (cl->rx_cfg.channels) { | 100 | if (cl->rx_cfg.channels) { |
101 | size = cl->rx_cfg.num_channels * sizeof(*cl->rx_cfg.channels); | 101 | size = cl->rx_cfg.num_channels * sizeof(*cl->rx_cfg.channels); |
102 | cl->rx_cfg.channels = kzalloc(size , GFP_KERNEL); | 102 | cl->rx_cfg.channels = kmemdup(info->rx_cfg.channels, size, |
103 | GFP_KERNEL); | ||
103 | if (!cl->rx_cfg.channels) | 104 | if (!cl->rx_cfg.channels) |
104 | goto err_rx; | 105 | goto err_rx; |
105 | memcpy(cl->rx_cfg.channels, info->rx_cfg.channels, size); | ||
106 | } | 106 | } |
107 | 107 | ||
108 | cl->device.bus = &hsi_bus_type; | 108 | cl->device.bus = &hsi_bus_type; |