11 #include <linux/device.h>
12 #include <linux/list.h>
13 #include <linux/errno.h>
16 #define PNP_NAME_LEN 50
29 unsigned long type,
unsigned int num)
35 static inline int pnp_resource_valid(
struct resource *
res)
42 static inline int pnp_resource_enabled(
struct resource *res)
51 if (res->
start == 0 && res->
end == 0)
53 return resource_size(res);
62 if (pnp_resource_valid(res))
72 if (pnp_resource_valid(res))
77 static inline unsigned long pnp_port_flags(
struct pnp_dev *dev,
82 if (pnp_resource_valid(res))
87 static inline int pnp_port_valid(
struct pnp_dev *dev,
unsigned int bar)
97 if (pnp_resource_valid(res))
98 return pnp_resource_len(res);
108 if (pnp_resource_valid(res))
118 if (pnp_resource_valid(res))
123 static inline unsigned long pnp_mem_flags(
struct pnp_dev *dev,
unsigned int bar)
127 if (pnp_resource_valid(res))
132 static inline int pnp_mem_valid(
struct pnp_dev *dev,
unsigned int bar)
142 if (pnp_resource_valid(res))
143 return pnp_resource_len(res);
152 if (pnp_resource_valid(res))
157 static inline unsigned long pnp_irq_flags(
struct pnp_dev *dev,
unsigned int bar)
161 if (pnp_resource_valid(res))
166 static inline int pnp_irq_valid(
struct pnp_dev *dev,
unsigned int bar)
176 if (pnp_resource_valid(res))
181 static inline unsigned long pnp_dma_flags(
struct pnp_dev *dev,
unsigned int bar)
185 if (pnp_resource_valid(res))
190 static inline int pnp_dma_valid(
struct pnp_dev *dev,
unsigned int bar)
218 #define global_to_pnp_card(n) list_entry(n, struct pnp_card, global_list)
219 #define protocol_to_pnp_card(n) list_entry(n, struct pnp_card, protocol_list)
220 #define to_pnp_card(n) container_of(n, struct pnp_card, dev)
221 #define pnp_for_each_card(card) \
222 for((card) = global_to_pnp_card(pnp_cards.next); \
223 (card) != global_to_pnp_card(&pnp_cards); \
224 (card) = global_to_pnp_card((card)->global_list.next))
233 static inline void *pnp_get_card_drvdata(
struct pnp_card_link *pcard)
273 #define global_to_pnp_dev(n) list_entry(n, struct pnp_dev, global_list)
274 #define card_to_pnp_dev(n) list_entry(n, struct pnp_dev, card_list)
275 #define protocol_to_pnp_dev(n) list_entry(n, struct pnp_dev, protocol_list)
276 #define to_pnp_dev(n) container_of(n, struct pnp_dev, dev)
277 #define pnp_for_each_dev(dev) \
278 for((dev) = global_to_pnp_dev(pnp_global.next); \
279 (dev) != global_to_pnp_dev(&pnp_global); \
280 (dev) = global_to_pnp_dev((dev)->global_list.next))
281 #define card_for_each_dev(card,dev) \
282 for((dev) = card_to_pnp_dev((card)->devices.next); \
283 (dev) != card_to_pnp_dev(&(card)->devices); \
284 (dev) = card_to_pnp_dev((dev)->card_list.next))
285 #define pnp_dev_name(dev) (dev)->name
287 static inline void *pnp_get_drvdata(
struct pnp_dev *pdev)
292 static inline void pnp_set_drvdata(
struct pnp_dev *pdev,
void *
data)
303 #define PNP_CONFIG_NORMAL 0x0001
304 #define PNP_CONFIG_FORCE 0x0002
307 #define PNP_READ 0x0001
308 #define PNP_WRITE 0x0002
309 #define PNP_DISABLE 0x0004
310 #define PNP_CONFIGURABLE 0x0008
311 #define PNP_REMOVABLE 0x0010
313 #define pnp_can_read(dev) (((dev)->protocol->get) && \
314 ((dev)->capabilities & PNP_READ))
315 #define pnp_can_write(dev) (((dev)->protocol->set) && \
316 ((dev)->capabilities & PNP_WRITE))
317 #define pnp_can_disable(dev) (((dev)->protocol->disable) && \
318 ((dev)->capabilities & PNP_DISABLE))
319 #define pnp_can_configure(dev) ((!(dev)->active) && \
320 ((dev)->capabilities & PNP_CONFIGURABLE))
324 #define pnp_device_is_isapnp(dev) ((dev)->protocol == (&isapnp_protocol))
326 #define pnp_device_is_isapnp(dev) 0
330 #ifdef CONFIG_PNPBIOS
332 #define pnp_device_is_pnpbios(dev) ((dev)->protocol == (&pnpbios_protocol))
334 #define pnp_device_is_pnpbios(dev) 0
337 #ifdef CONFIG_PNPACPI
347 #define pnp_acpi_device(dev) 0
351 #define PNP_READY 0x0000
352 #define PNP_ATTACHED 0x0001
353 #define PNP_BUSY 0x0002
354 #define PNP_FAULTY 0x0004
358 #define isapnp_card_number(dev) ((dev)->card ? (dev)->card->number : -1)
359 #define isapnp_csn_number(dev) ((dev)->number)
382 #define to_pnp_driver(drv) container_of(drv, struct pnp_driver, driver)
397 #define to_pnp_card_driver(drv) container_of(drv, struct pnp_card_driver, link)
400 #define PNP_DRIVER_RES_DO_NOT_CHANGE 0x0001
401 #define PNP_DRIVER_RES_DISABLE 0x0003
428 #define to_pnp_protocol(n) list_entry(n, struct pnp_protocol, protocol_list)
429 #define protocol_for_each_card(protocol,card) \
430 for((card) = protocol_to_pnp_card((protocol)->cards.next); \
431 (card) != protocol_to_pnp_card(&(protocol)->cards); \
432 (card) = protocol_to_pnp_card((card)->protocol_list.next))
433 #define protocol_for_each_dev(protocol,dev) \
434 for((dev) = protocol_to_pnp_dev((protocol)->devices.next); \
435 (dev) != protocol_to_pnp_dev(&(protocol)->devices); \
436 (dev) = protocol_to_pnp_dev((dev)->protocol_list.next))
440 #if defined(CONFIG_PNP)
478 #define pnp_platform_devices 0