On Thu, 11 Oct 2018, Christoph Hellwig wrote:

> 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: Christoph Hellwig <h...@lst.de>
> ---
>  drivers/scsi/esp_scsi.h |  2 +-
>  drivers/scsi/mac_esp.c  |  5 ++---
>  drivers/scsi/sun_esp.c  | 37 +++++++++++++------------------------
>  3 files changed, 16 insertions(+), 28 deletions(-)
> 
> diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
> index 8163dca2071b..f98abd0ead57 100644
> --- a/drivers/scsi/esp_scsi.h
> +++ b/drivers/scsi/esp_scsi.h
> @@ -435,7 +435,7 @@ struct esp {
>       const struct esp_driver_ops *ops;
>  
>       struct Scsi_Host        *host;
> -     void                    *dev;
> +     struct device           *dev;
>  
>       struct esp_cmd_entry    *active_cmd;
>  
> diff --git a/drivers/scsi/mac_esp.c b/drivers/scsi/mac_esp.c
> index eb551f3cc471..85d067889a9b 100644
> --- a/drivers/scsi/mac_esp.c
> +++ b/drivers/scsi/mac_esp.c
> @@ -58,8 +58,7 @@ static struct esp *esp_chips[2];
>  static DEFINE_SPINLOCK(esp_chips_lock);
>  
>  #define MAC_ESP_GET_PRIV(esp) ((struct mac_esp_priv *) \
> -                            platform_get_drvdata((struct platform_device *) \
> -                                                 (esp->dev)))
> +                            dev_get_drvdata((esp)->dev))
>  
>  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)
>       esp = shost_priv(host);
>  
>       esp->host = host;
> -     esp->dev = dev;
> +     esp->dev = &dev->dev;
>  
>       esp->command_block = kzalloc(16, GFP_KERNEL);
>       if (!esp->command_block)


Isn't this missing the corresponding dev_set_drvdata() in esp_mac_probe()? 
Also conversion to dev_get_drvdata() in esp_mac_remove()?

-- 

> diff --git a/drivers/scsi/sun_esp.c b/drivers/scsi/sun_esp.c
> index c7b60ed61c38..91577ceb4cba 100644
> --- a/drivers/scsi/sun_esp.c
> +++ b/drivers/scsi/sun_esp.c
> @@ -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)
>  {
> -     struct platform_device *op = esp->dev;
> +     struct platform_device *op = to_platform_device(esp->dev);
>       struct resource *res;
>  
>       /* On HME, two reg sets exist, first is DVMA,
> @@ -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)
>  {
> -     struct platform_device *op = esp->dev;
> -
> -     esp->command_block = dma_alloc_coherent(&op->dev, 16,
> +     esp->command_block = dma_alloc_coherent(esp->dev, 16,
>                                               &esp->command_block_dma,
>                                               GFP_KERNEL);
>       if (!esp->command_block)
> @@ -113,7 +111,7 @@ static int esp_sbus_map_command_block(struct esp *esp)
>  static int esp_sbus_register_irq(struct esp *esp)
>  {
>       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];
>       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)
>  
>  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;
>  
>       dp = op->dev.of_node;
> @@ -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)
>  {
> -     struct platform_device *op = esp->dev;
> +     struct platform_device *op = to_platform_device(esp->dev);
>       struct device_node *dp;
>  
>       dp = op->dev.of_node;
> @@ -155,7 +153,7 @@ static void esp_get_differential(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;
>       int fmhz;
>  
> @@ -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)
>  {
>       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;
>       u8 bursts, val;
>  
> @@ -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,
>                                     size_t sz, int dir)
>  {
> -     struct platform_device *op = esp->dev;
> -
> -     return dma_map_single(&op->dev, buf, sz, dir);
> +     return dma_map_single(esp->dev, buf, sz, dir);
>  }
>  
>  static int sbus_esp_map_sg(struct esp *esp, struct scatterlist *sg,
>                                 int num_sg, int dir)
>  {
> -     struct platform_device *op = esp->dev;
> -
> -     return dma_map_sg(&op->dev, sg, num_sg, dir);
> +     return dma_map_sg(esp->dev, sg, num_sg, dir);
>  }
>  
>  static void sbus_esp_unmap_single(struct esp *esp, dma_addr_t addr,
>                                 size_t sz, int dir)
>  {
> -     struct platform_device *op = esp->dev;
> -
> -     dma_unmap_single(&op->dev, addr, sz, dir);
> +     dma_unmap_single(esp->dev, addr, sz, dir);
>  }
>  
>  static void sbus_esp_unmap_sg(struct esp *esp, struct scatterlist *sg,
>                             int num_sg, int dir)
>  {
> -     struct platform_device *op = esp->dev;
> -
> -     dma_unmap_sg(&op->dev, sg, num_sg, dir);
> +     dma_unmap_sg(esp->dev, sg, num_sg, dir);
>  }
>  
>  static int sbus_esp_irq_pending(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_sbus64, lim;
> -     struct platform_device *op;
> +     struct platform_device *op = to_platform_device(esp->dev);
>       u32 val;
>  
>       can_do_burst16 = (esp->bursts & DMA_BURST16) != 0;
>       can_do_burst32 = (esp->bursts & DMA_BURST32) != 0;
>       can_do_burst64 = 0;
>       can_do_sbus64 = 0;
> -     op = esp->dev;
>       if (sbus_can_dma_64bit())
>               can_do_sbus64 = 1;
>       if (sbus_can_burst64())
> @@ -504,7 +493,7 @@ static int esp_sbus_probe_one(struct platform_device *op,
>       esp = shost_priv(host);
>  
>       esp->host = host;
> -     esp->dev = op;
> +     esp->dev = &op->dev;
>       esp->ops = &sbus_esp_ops;
>  
>       if (hme)
> 

Reply via email to