char: xillybus: Fix internal data structure initialization
authorEli Billauer <eli.billauer@gmail.com>
Wed, 24 Feb 2016 08:40:51 +0000 (10:40 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 5 Mar 2016 20:19:39 +0000 (12:19 -0800)
A couple of fields in a data structure, which is used by the driver only,
were not initialized properly during the driver's setup.

The primary issue with this bug was that channel->wr_buf_size remained zero,
so calls to dma_sync_single_for_cpu() took place with zero size, and
consequently did nothing.

This had a rather minimal practical impact, because

(a) these calls are NOPs on Intel/AMD platforms, as well as other platforms
    with coherent cache, and
(b) it's extremely rare that any cache line would survive between two reads
    from a given DMA buffer

Hence no significant practical difference is expected with this patch.

Signed-off-by: Eli Billauer <eli.billauer@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/xillybus/xillybus_core.c

index 77d6c127e691a4a8a6417bd4cd0760fed0d513e8..dcd19f3f182e569e4e8e991653afdfb3b5af14be 100644 (file)
@@ -509,7 +509,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
                        channel->log2_element_size = ((format > 2) ?
                                                      2 : format);
 
-                       bytebufsize = channel->rd_buf_size = bufsize *
+                       bytebufsize = bufsize *
                                (1 << channel->log2_element_size);
 
                        buffers = devm_kcalloc(dev, bufnum,
@@ -523,6 +523,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
 
                if (!is_writebuf) {
                        channel->num_rd_buffers = bufnum;
+                       channel->rd_buf_size = bytebufsize;
                        channel->rd_allow_partial = allowpartial;
                        channel->rd_synchronous = synchronous;
                        channel->rd_exclusive_open = exclusive_open;
@@ -533,6 +534,7 @@ static int xilly_setupchannels(struct xilly_endpoint *ep,
                                                   bufnum, bytebufsize);
                } else if (channelnum > 0) {
                        channel->num_wr_buffers = bufnum;
+                       channel->wr_buf_size = bytebufsize;
 
                        channel->seekable = seekable;
                        channel->wr_supports_nonempty = supports_nonempty;