mirror of
https://github.com/torvalds/linux.git
synced 2024-11-19 10:31:48 +00:00
PCI: rcar-gen2: Add local struct device pointers
Use a local "struct device *dev" for brevity and consistency with other drivers. No functional change intended. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Simon Horman <horms+renesas@verge.net.au>
This commit is contained in:
parent
3ff8e4ac3a
commit
de9e6bc84b
@ -154,10 +154,11 @@ static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
|
|||||||
static irqreturn_t rcar_pci_err_irq(int irq, void *pw)
|
static irqreturn_t rcar_pci_err_irq(int irq, void *pw)
|
||||||
{
|
{
|
||||||
struct rcar_pci_priv *priv = pw;
|
struct rcar_pci_priv *priv = pw;
|
||||||
|
struct device *dev = priv->dev;
|
||||||
u32 status = ioread32(priv->reg + RCAR_PCI_INT_STATUS_REG);
|
u32 status = ioread32(priv->reg + RCAR_PCI_INT_STATUS_REG);
|
||||||
|
|
||||||
if (status & RCAR_PCI_INT_ALLERRORS) {
|
if (status & RCAR_PCI_INT_ALLERRORS) {
|
||||||
dev_err(priv->dev, "error irq: status %08x\n", status);
|
dev_err(dev, "error irq: status %08x\n", status);
|
||||||
|
|
||||||
/* clear the error(s) */
|
/* clear the error(s) */
|
||||||
iowrite32(status & RCAR_PCI_INT_ALLERRORS,
|
iowrite32(status & RCAR_PCI_INT_ALLERRORS,
|
||||||
@ -170,13 +171,14 @@ static irqreturn_t rcar_pci_err_irq(int irq, void *pw)
|
|||||||
|
|
||||||
static void rcar_pci_setup_errirq(struct rcar_pci_priv *priv)
|
static void rcar_pci_setup_errirq(struct rcar_pci_priv *priv)
|
||||||
{
|
{
|
||||||
|
struct device *dev = priv->dev;
|
||||||
int ret;
|
int ret;
|
||||||
u32 val;
|
u32 val;
|
||||||
|
|
||||||
ret = devm_request_irq(priv->dev, priv->irq, rcar_pci_err_irq,
|
ret = devm_request_irq(dev, priv->irq, rcar_pci_err_irq,
|
||||||
IRQF_SHARED, "error irq", priv);
|
IRQF_SHARED, "error irq", priv);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(priv->dev, "cannot claim IRQ for error handling\n");
|
dev_err(dev, "cannot claim IRQ for error handling\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,15 +194,16 @@ static inline void rcar_pci_setup_errirq(struct rcar_pci_priv *priv) { }
|
|||||||
static int rcar_pci_setup(int nr, struct pci_sys_data *sys)
|
static int rcar_pci_setup(int nr, struct pci_sys_data *sys)
|
||||||
{
|
{
|
||||||
struct rcar_pci_priv *priv = sys->private_data;
|
struct rcar_pci_priv *priv = sys->private_data;
|
||||||
|
struct device *dev = priv->dev;
|
||||||
void __iomem *reg = priv->reg;
|
void __iomem *reg = priv->reg;
|
||||||
u32 val;
|
u32 val;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pm_runtime_enable(priv->dev);
|
pm_runtime_enable(dev);
|
||||||
pm_runtime_get_sync(priv->dev);
|
pm_runtime_get_sync(dev);
|
||||||
|
|
||||||
val = ioread32(reg + RCAR_PCI_UNIT_REV_REG);
|
val = ioread32(reg + RCAR_PCI_UNIT_REV_REG);
|
||||||
dev_info(priv->dev, "PCI: bus%u revision %x\n", sys->busnr, val);
|
dev_info(dev, "PCI: bus%u revision %x\n", sys->busnr, val);
|
||||||
|
|
||||||
/* Disable Direct Power Down State and assert reset */
|
/* Disable Direct Power Down State and assert reset */
|
||||||
val = ioread32(reg + RCAR_USBCTR_REG) & ~RCAR_USBCTR_DIRPD;
|
val = ioread32(reg + RCAR_USBCTR_REG) & ~RCAR_USBCTR_DIRPD;
|
||||||
@ -275,7 +278,7 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)
|
|||||||
|
|
||||||
/* Add PCI resources */
|
/* Add PCI resources */
|
||||||
pci_add_resource(&sys->resources, &priv->mem_res);
|
pci_add_resource(&sys->resources, &priv->mem_res);
|
||||||
ret = devm_request_pci_bus_resources(priv->dev, &sys->resources);
|
ret = devm_request_pci_bus_resources(dev, &sys->resources);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -311,6 +314,7 @@ static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
|
|||||||
static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
|
static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
|
||||||
struct device_node *np)
|
struct device_node *np)
|
||||||
{
|
{
|
||||||
|
struct device *dev = pci->dev;
|
||||||
struct of_pci_range range;
|
struct of_pci_range range;
|
||||||
struct of_pci_range_parser parser;
|
struct of_pci_range_parser parser;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -331,14 +335,14 @@ static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
|
|||||||
|
|
||||||
/* Catch HW limitations */
|
/* Catch HW limitations */
|
||||||
if (!(range.flags & IORESOURCE_PREFETCH)) {
|
if (!(range.flags & IORESOURCE_PREFETCH)) {
|
||||||
dev_err(pci->dev, "window must be prefetchable\n");
|
dev_err(dev, "window must be prefetchable\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
if (pci->window_addr) {
|
if (pci->window_addr) {
|
||||||
u32 lowaddr = 1 << (ffs(pci->window_addr) - 1);
|
u32 lowaddr = 1 << (ffs(pci->window_addr) - 1);
|
||||||
|
|
||||||
if (lowaddr < pci->window_size) {
|
if (lowaddr < pci->window_size) {
|
||||||
dev_err(pci->dev, "invalid window size/addr\n");
|
dev_err(dev, "invalid window size/addr\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,6 +354,7 @@ static int rcar_pci_parse_map_dma_ranges(struct rcar_pci_priv *pci,
|
|||||||
|
|
||||||
static int rcar_pci_probe(struct platform_device *pdev)
|
static int rcar_pci_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
|
struct device *dev = &pdev->dev;
|
||||||
struct resource *cfg_res, *mem_res;
|
struct resource *cfg_res, *mem_res;
|
||||||
struct rcar_pci_priv *priv;
|
struct rcar_pci_priv *priv;
|
||||||
void __iomem *reg;
|
void __iomem *reg;
|
||||||
@ -357,7 +362,7 @@ static int rcar_pci_probe(struct platform_device *pdev)
|
|||||||
void *hw_private[1];
|
void *hw_private[1];
|
||||||
|
|
||||||
cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
cfg_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||||
reg = devm_ioremap_resource(&pdev->dev, cfg_res);
|
reg = devm_ioremap_resource(dev, cfg_res);
|
||||||
if (IS_ERR(reg))
|
if (IS_ERR(reg))
|
||||||
return PTR_ERR(reg);
|
return PTR_ERR(reg);
|
||||||
|
|
||||||
@ -368,8 +373,7 @@ static int rcar_pci_probe(struct platform_device *pdev)
|
|||||||
if (mem_res->start & 0xFFFF)
|
if (mem_res->start & 0xFFFF)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
priv = devm_kzalloc(&pdev->dev,
|
priv = devm_kzalloc(dev, sizeof(struct rcar_pci_priv), GFP_KERNEL);
|
||||||
sizeof(struct rcar_pci_priv), GFP_KERNEL);
|
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -378,10 +382,10 @@ static int rcar_pci_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
priv->irq = platform_get_irq(pdev, 0);
|
priv->irq = platform_get_irq(pdev, 0);
|
||||||
priv->reg = reg;
|
priv->reg = reg;
|
||||||
priv->dev = &pdev->dev;
|
priv->dev = dev;
|
||||||
|
|
||||||
if (priv->irq < 0) {
|
if (priv->irq < 0) {
|
||||||
dev_err(&pdev->dev, "no valid irq found\n");
|
dev_err(dev, "no valid irq found\n");
|
||||||
return priv->irq;
|
return priv->irq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,23 +394,23 @@ static int rcar_pci_probe(struct platform_device *pdev)
|
|||||||
priv->window_pci = 0x40000000;
|
priv->window_pci = 0x40000000;
|
||||||
priv->window_size = SZ_1G;
|
priv->window_size = SZ_1G;
|
||||||
|
|
||||||
if (pdev->dev.of_node) {
|
if (dev->of_node) {
|
||||||
struct resource busnr;
|
struct resource busnr;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = of_pci_parse_bus_range(pdev->dev.of_node, &busnr);
|
ret = of_pci_parse_bus_range(dev->of_node, &busnr);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "failed to parse bus-range\n");
|
dev_err(dev, "failed to parse bus-range\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->busnr = busnr.start;
|
priv->busnr = busnr.start;
|
||||||
if (busnr.end != busnr.start)
|
if (busnr.end != busnr.start)
|
||||||
dev_warn(&pdev->dev, "only one bus number supported\n");
|
dev_warn(dev, "only one bus number supported\n");
|
||||||
|
|
||||||
ret = rcar_pci_parse_map_dma_ranges(priv, pdev->dev.of_node);
|
ret = rcar_pci_parse_map_dma_ranges(priv, dev->of_node);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "failed to parse dma-range\n");
|
dev_err(dev, "failed to parse dma-range\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -421,7 +425,7 @@ static int rcar_pci_probe(struct platform_device *pdev)
|
|||||||
hw.map_irq = rcar_pci_map_irq;
|
hw.map_irq = rcar_pci_map_irq;
|
||||||
hw.ops = &rcar_pci_ops;
|
hw.ops = &rcar_pci_ops;
|
||||||
hw.setup = rcar_pci_setup;
|
hw.setup = rcar_pci_setup;
|
||||||
pci_common_init_dev(&pdev->dev, &hw);
|
pci_common_init_dev(dev, &hw);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user