Commit 98cda6a2 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Martin K. Petersen

scsi: esp_scsi: use strong typing for the dev field

esp->dev is a void pointer that points either to a struct device, or a
struct platform_device.  As we can easily get from the device to the
platform_device if needed change it to always point to a struct device
and properly type the pointer to avoid errors.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Tested-by: default avatarFinn Thain <fthain@telegraphics.com.au>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 10c0cd38
...@@ -435,7 +435,7 @@ struct esp { ...@@ -435,7 +435,7 @@ struct esp {
const struct esp_driver_ops *ops; const struct esp_driver_ops *ops;
struct Scsi_Host *host; struct Scsi_Host *host;
void *dev; struct device *dev;
struct esp_cmd_entry *active_cmd; struct esp_cmd_entry *active_cmd;
......
...@@ -58,8 +58,7 @@ static struct esp *esp_chips[2]; ...@@ -58,8 +58,7 @@ static struct esp *esp_chips[2];
static DEFINE_SPINLOCK(esp_chips_lock); static DEFINE_SPINLOCK(esp_chips_lock);
#define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \ #define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \
platform_get_drvdata((struct platform_device *) \ dev_get_drvdata((esp)->dev))
(esp->dev)))
static inline void mac_esp_write8(struct esp *esp, u8 val, unsigned long reg) static inline void mac_esp_write8(struct esp *esp, u8 val, unsigned long reg)
{ {
...@@ -508,7 +507,7 @@ static int esp_mac_probe(struct platform_device *dev) ...@@ -508,7 +507,7 @@ static int esp_mac_probe(struct platform_device *dev)
esp = shost_priv(host); esp = shost_priv(host);
esp->host = host; esp->host = host;
esp->dev = dev; esp->dev = &dev->dev;
esp->command_block = kzalloc(16, GFP_KERNEL); esp->command_block = kzalloc(16, GFP_KERNEL);
if (!esp->command_block) if (!esp->command_block)
......
...@@ -80,7 +80,7 @@ static int esp_sbus_setup_dma(struct esp *esp, struct platform_device *dma_of) ...@@ -80,7 +80,7 @@ static int esp_sbus_setup_dma(struct esp *esp, struct platform_device *dma_of)
static int esp_sbus_map_regs(struct esp *esp, int hme) static int esp_sbus_map_regs(struct esp *esp, int hme)
{ {
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
struct resource *res; struct resource *res;
/* On HME, two reg sets exist, first is DVMA, /* On HME, two reg sets exist, first is DVMA,
...@@ -100,9 +100,7 @@ static int esp_sbus_map_regs(struct esp *esp, int hme) ...@@ -100,9 +100,7 @@ static int esp_sbus_map_regs(struct esp *esp, int hme)
static int esp_sbus_map_command_block(struct esp *esp) static int esp_sbus_map_command_block(struct esp *esp)
{ {
struct platform_device *op = esp->dev; esp->command_block = dma_alloc_coherent(esp->dev, 16,
esp->command_block = dma_alloc_coherent(&op->dev, 16,
&esp->command_block_dma, &esp->command_block_dma,
GFP_KERNEL); GFP_KERNEL);
if (!esp->command_block) if (!esp->command_block)
...@@ -113,7 +111,7 @@ static int esp_sbus_map_command_block(struct esp *esp) ...@@ -113,7 +111,7 @@ static int esp_sbus_map_command_block(struct esp *esp)
static int esp_sbus_register_irq(struct esp *esp) static int esp_sbus_register_irq(struct esp *esp)
{ {
struct Scsi_Host *host = esp->host; struct Scsi_Host *host = esp->host;
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
host->irq = op->archdata.irqs[0]; host->irq = op->archdata.irqs[0];
return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp); return request_irq(host->irq, scsi_esp_intr, IRQF_SHARED, "ESP", esp);
...@@ -121,7 +119,7 @@ static int esp_sbus_register_irq(struct esp *esp) ...@@ -121,7 +119,7 @@ static int esp_sbus_register_irq(struct esp *esp)
static void esp_get_scsi_id(struct esp *esp, struct platform_device *espdma) static void esp_get_scsi_id(struct esp *esp, struct platform_device *espdma)
{ {
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
struct device_node *dp; struct device_node *dp;
dp = op->dev.of_node; dp = op->dev.of_node;
...@@ -143,7 +141,7 @@ static void esp_get_scsi_id(struct esp *esp, struct platform_device *espdma) ...@@ -143,7 +141,7 @@ static void esp_get_scsi_id(struct esp *esp, struct platform_device *espdma)
static void esp_get_differential(struct esp *esp) static void esp_get_differential(struct esp *esp)
{ {
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
struct device_node *dp; struct device_node *dp;
dp = op->dev.of_node; dp = op->dev.of_node;
...@@ -155,7 +153,7 @@ static void esp_get_differential(struct esp *esp) ...@@ -155,7 +153,7 @@ static void esp_get_differential(struct esp *esp)
static void esp_get_clock_params(struct esp *esp) static void esp_get_clock_params(struct esp *esp)
{ {
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
struct device_node *bus_dp, *dp; struct device_node *bus_dp, *dp;
int fmhz; int fmhz;
...@@ -172,7 +170,7 @@ static void esp_get_clock_params(struct esp *esp) ...@@ -172,7 +170,7 @@ static void esp_get_clock_params(struct esp *esp)
static void esp_get_bursts(struct esp *esp, struct platform_device *dma_of) static void esp_get_bursts(struct esp *esp, struct platform_device *dma_of)
{ {
struct device_node *dma_dp = dma_of->dev.of_node; struct device_node *dma_dp = dma_of->dev.of_node;
struct platform_device *op = esp->dev; struct platform_device *op = to_platform_device(esp->dev);
struct device_node *dp; struct device_node *dp;
u8 bursts, val; u8 bursts, val;
...@@ -215,33 +213,25 @@ static u8 sbus_esp_read8(struct esp *esp, unsigned long reg) ...@@ -215,33 +213,25 @@ static u8 sbus_esp_read8(struct esp *esp, unsigned long reg)
static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf, static dma_addr_t sbus_esp_map_single(struct esp *esp, void *buf,
size_t sz, int dir) size_t sz, int dir)
{ {
struct platform_device *op = esp->dev; return dma_map_single(esp->dev, buf, sz, dir);
return dma_map_single(&op->dev, buf, sz, dir);
} }
static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg, static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg,
int num_sg, int dir) int num_sg, int dir)
{ {
struct platform_device *op = esp->dev; return dma_map_sg(esp->dev, sg, num_sg, dir);
return dma_map_sg(&op->dev, sg, num_sg, dir);
} }
static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr, static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr,
size_t sz, int dir) size_t sz, int dir)
{ {
struct platform_device *op = esp->dev; dma_unmap_single(esp->dev, addr, sz, dir);
dma_unmap_single(&op->dev, addr, sz, dir);
} }
static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg, static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg,
int num_sg, int dir) int num_sg, int dir)
{ {
struct platform_device *op = esp->dev; dma_unmap_sg(esp->dev, sg, num_sg, dir);
dma_unmap_sg(&op->dev, sg, num_sg, dir);
} }
static int sbus_esp_irq_pending(struct esp *esp) static int sbus_esp_irq_pending(struct esp *esp)
...@@ -255,14 +245,13 @@ static void sbus_esp_reset_dma(struct esp *esp) ...@@ -255,14 +245,13 @@ static void sbus_esp_reset_dma(struct esp *esp)
{ {
int can_do_burst16, can_do_burst32, can_do_burst64; int can_do_burst16, can_do_burst32, can_do_burst64;
int can_do_sbus64, lim; int can_do_sbus64, lim;
struct platform_device *op; struct platform_device *op = to_platform_device(esp->dev);
u32 val; u32 val;
can_do_burst16 = (esp->bursts & DMA_BURST16) != 0; can_do_burst16 = (esp->bursts & DMA_BURST16) != 0;
can_do_burst32 = (esp->bursts & DMA_BURST32) != 0; can_do_burst32 = (esp->bursts & DMA_BURST32) != 0;
can_do_burst64 = 0; can_do_burst64 = 0;
can_do_sbus64 = 0; can_do_sbus64 = 0;
op = esp->dev;
if (sbus_can_dma_64bit()) if (sbus_can_dma_64bit())
can_do_sbus64 = 1; can_do_sbus64 = 1;
if (sbus_can_burst64()) if (sbus_can_burst64())
...@@ -504,7 +493,7 @@ static int esp_sbus_probe_one(struct platform_device *op, ...@@ -504,7 +493,7 @@ static int esp_sbus_probe_one(struct platform_device *op,
esp = shost_priv(host); esp = shost_priv(host);
esp->host = host; esp->host = host;
esp->dev = op; esp->dev = &op->dev;
esp->ops = &sbus_esp_ops; esp->ops = &sbus_esp_ops;
if (hme) if (hme)
......
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