Commit 5f1ab70a authored by Federico Vaga's avatar Federico Vaga

drv: fix pointer to FMC fru.h

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 08f01f24
......@@ -11,6 +11,7 @@ ccflags-y = -DVERSION=\"$(VERSION)\"
ccflags-y += -I$(src)
ccflags-y += -I$(ZIO_ABS)/include
ccflags-y += -I$(FMC_ABS)/include
ccflags-y += -I$(FMC_ABS)/include/uapi
ccflags-$(CONFIG_FMC_TDC_DEBUG) += -DDEBUG
......
......@@ -14,7 +14,7 @@
#include <linux/jhash.h>
#include <linux/slab.h>
#include <linux/fmc.h>
#include <linux/ipmi-fru.h>
#include <linux/ipmi/fru.h>
#include <linux/zio.h>
#include "fmc-tdc.h"
......
......@@ -285,52 +285,9 @@ static int ft_zio_block_nr_pages(struct zio_block *block)
return nr_pages;
}
static int sg_alloc_table_from_block_vmalloc(struct sg_table *sgt,
struct zio_block *block)
{
struct scatterlist *sg;
unsigned int nr_pages;
int bytesleft = 0;
void *bufp = NULL;
int mapbytes;
int i;
int err;
nr_pages = ft_zio_block_nr_pages(block);
err = sg_alloc_table(sgt, nr_pages, GFP_KERNEL);
if (err)
return err;
bytesleft = block->datalen;
bufp = block->data;
for_each_sg(sgt->sgl, sg, sgt->nents, i) {
/*
* If there are less bytes left than what fits
* in the current page (plus page alignment offset)
* we just feed in this, else we stuff in as much
* as we can.
*/
if (bytesleft < (PAGE_SIZE - offset_in_page(bufp)))
mapbytes = bytesleft;
else
mapbytes = PAGE_SIZE - offset_in_page(bufp);
sg_set_page(sg, vmalloc_to_page(bufp), mapbytes,
offset_in_page(bufp));
/* Configure next values */
bufp += mapbytes;
bytesleft -= mapbytes;
pr_debug("sg item (%p(+0x%lx), len:%d, left:%d)\n",
virt_to_page(bufp), offset_in_page(bufp),
mapbytes, bytesleft);
}
return 0;
}
static int sg_alloc_table_from_block_kmalloc(struct device *dev,
struct sg_table *sgt,
struct zio_block *block)
static int sg_alloc_table_from_block(struct device *dev,
struct sg_table *sgt,
struct zio_block *block)
{
struct page **pages;
unsigned int nr_pages;
......@@ -348,8 +305,14 @@ static int sg_alloc_table_from_block_kmalloc(struct device *dev,
return -ENOMEM;
data = (void *) block->data;
for (i = 0; i < nr_pages; ++i)
pages[i] = virt_to_page(data + PAGE_SIZE * i);
if (is_vmalloc_addr(data)) {
for (i = 0; i < nr_pages; ++i) {
pages[i] = vmalloc_to_page(data + PAGE_SIZE * i);
}
} else {
for (i = 0; i < nr_pages; ++i)
pages[i] = virt_to_page(data + PAGE_SIZE * i);
}
max_segment_size = dma_get_max_seg_size(dev);
max_segment_size &= PAGE_MASK; /* to make alloc_table happy */
......@@ -362,15 +325,6 @@ static int sg_alloc_table_from_block_kmalloc(struct device *dev,
kfree(pages);
return err;
}
static int sg_alloc_table_from_block(struct device *dev,
struct sg_table *sgt,
struct zio_block *block)
{
if (is_vmalloc_addr(block->data))
return sg_alloc_table_from_block_vmalloc(sgt, block);
else
return sg_alloc_table_from_block_kmalloc(dev, sgt, block);
}
static int ft_zio_block_dma_map_sg(struct fmctdc_dev *ft, unsigned int ch,
struct zio_block *block,
......
......@@ -20,7 +20,7 @@
#include <linux/list.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/ipmi-fru.h>
#include <linux/ipmi/fru.h>
#include <linux/fmc.h>
#include <linux/zio.h>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment