提交 13575e81 编写于 作者: B Bjorn Helgaas 提交者: Len Brown

PNP: convert resource accessors to use pnp_get_resource(), not pnp_resource_table

This removes more direct references to pnp_resource_table.
Signed-off-by: NBjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 53052feb
...@@ -27,46 +27,111 @@ struct pnp_dev; ...@@ -27,46 +27,111 @@ struct pnp_dev;
*/ */
struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int); struct resource *pnp_get_resource(struct pnp_dev *, unsigned int, unsigned int);
/* Use these instead of directly reading pnp_dev to get resource information */ static inline int pnp_resource_valid(struct resource *res)
#define pnp_port_start(dev,bar) ((dev)->res.port_resource[(bar)].start) {
#define pnp_port_end(dev,bar) ((dev)->res.port_resource[(bar)].end) if (res && !(res->flags & IORESOURCE_UNSET))
#define pnp_port_flags(dev,bar) ((dev)->res.port_resource[(bar)].flags) return 1;
#define pnp_port_valid(dev,bar) \ return 0;
((pnp_port_flags((dev),(bar)) & (IORESOURCE_IO | IORESOURCE_UNSET)) \ }
== IORESOURCE_IO)
#define pnp_port_len(dev,bar) \ static inline resource_size_t pnp_resource_len(struct resource *res)
((pnp_port_start((dev),(bar)) == 0 && \ {
pnp_port_end((dev),(bar)) == \ if (res->start == 0 && res->end == 0)
pnp_port_start((dev),(bar))) ? 0 : \ return 0;
\ return res->end - res->start + 1;
(pnp_port_end((dev),(bar)) - \ }
pnp_port_start((dev),(bar)) + 1))
#define pnp_mem_start(dev,bar) ((dev)->res.mem_resource[(bar)].start) static inline resource_size_t pnp_port_start(struct pnp_dev *dev,
#define pnp_mem_end(dev,bar) ((dev)->res.mem_resource[(bar)].end) unsigned int bar)
#define pnp_mem_flags(dev,bar) ((dev)->res.mem_resource[(bar)].flags) {
#define pnp_mem_valid(dev,bar) \ return pnp_get_resource(dev, IORESOURCE_IO, bar)->start;
((pnp_mem_flags((dev),(bar)) & (IORESOURCE_MEM | IORESOURCE_UNSET)) \ }
== IORESOURCE_MEM)
#define pnp_mem_len(dev,bar) \ static inline resource_size_t pnp_port_end(struct pnp_dev *dev,
((pnp_mem_start((dev),(bar)) == 0 && \ unsigned int bar)
pnp_mem_end((dev),(bar)) == \ {
pnp_mem_start((dev),(bar))) ? 0 : \ return pnp_get_resource(dev, IORESOURCE_IO, bar)->end;
\ }
(pnp_mem_end((dev),(bar)) - \
pnp_mem_start((dev),(bar)) + 1)) static inline unsigned long pnp_port_flags(struct pnp_dev *dev,
unsigned int bar)
#define pnp_irq(dev,bar) ((dev)->res.irq_resource[(bar)].start) {
#define pnp_irq_flags(dev,bar) ((dev)->res.irq_resource[(bar)].flags) return pnp_get_resource(dev, IORESOURCE_IO, bar)->flags;
#define pnp_irq_valid(dev,bar) \ }
((pnp_irq_flags((dev),(bar)) & (IORESOURCE_IRQ | IORESOURCE_UNSET)) \
== IORESOURCE_IRQ) static inline int pnp_port_valid(struct pnp_dev *dev, unsigned int bar)
{
#define pnp_dma(dev,bar) ((dev)->res.dma_resource[(bar)].start) return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IO, bar));
#define pnp_dma_flags(dev,bar) ((dev)->res.dma_resource[(bar)].flags) }
#define pnp_dma_valid(dev,bar) \
((pnp_dma_flags((dev),(bar)) & (IORESOURCE_DMA | IORESOURCE_UNSET)) \ static inline resource_size_t pnp_port_len(struct pnp_dev *dev,
== IORESOURCE_DMA) unsigned int bar)
{
return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_IO, bar));
}
static inline resource_size_t pnp_mem_start(struct pnp_dev *dev,
unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_MEM, bar)->start;
}
static inline resource_size_t pnp_mem_end(struct pnp_dev *dev,
unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_MEM, bar)->end;
}
static inline unsigned long pnp_mem_flags(struct pnp_dev *dev, unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_MEM, bar)->flags;
}
static inline int pnp_mem_valid(struct pnp_dev *dev, unsigned int bar)
{
return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_MEM, bar));
}
static inline resource_size_t pnp_mem_len(struct pnp_dev *dev,
unsigned int bar)
{
return pnp_resource_len(pnp_get_resource(dev, IORESOURCE_MEM, bar));
}
static inline resource_size_t pnp_irq(struct pnp_dev *dev, unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->start;
}
static inline unsigned long pnp_irq_flags(struct pnp_dev *dev, unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_IRQ, bar)->flags;
}
static inline int pnp_irq_valid(struct pnp_dev *dev, unsigned int bar)
{
return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_IRQ, bar));
}
static inline resource_size_t pnp_dma(struct pnp_dev *dev, unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_DMA, bar)->start;
}
static inline unsigned long pnp_dma_flags(struct pnp_dev *dev, unsigned int bar)
{
return pnp_get_resource(dev, IORESOURCE_DMA, bar)->flags;
}
static inline int pnp_dma_valid(struct pnp_dev *dev, unsigned int bar)
{
return pnp_resource_valid(pnp_get_resource(dev, IORESOURCE_DMA, bar));
}
#define PNP_PORT_FLAG_16BITADDR (1<<0) #define PNP_PORT_FLAG_16BITADDR (1<<0)
#define PNP_PORT_FLAG_FIXED (1<<1) #define PNP_PORT_FLAG_FIXED (1<<1)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册