Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio: move rio_pw_enable into core code

Make rio_pw_enable() routine available to other RapidIO drivers.

Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Cc: Aurelien Jacquiot <a-jacquiot@ti.com>
Cc: Andre van Herk <andre.van.herk@prodrive-technologies.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alexandre Bounine and committed by
Linus Torvalds
b6cb95e8 5024622f

+22 -11
-11
drivers/rapidio/rio-scan.c
··· 974 974 } 975 975 976 976 /** 977 - * rio_pw_enable - Enables/disables port-write handling by a master port 978 - * @port: Master port associated with port-write handling 979 - * @enable: 1=enable, 0=disable 980 - */ 981 - static void rio_pw_enable(struct rio_mport *port, int enable) 982 - { 983 - if (port->ops->pwenable) 984 - port->ops->pwenable(port, enable); 985 - } 986 - 987 - /** 988 977 * rio_enum_mport- Start enumeration through a master port 989 978 * @mport: Master port to send transactions 990 979 * @flags: Enumeration control flags
+19
drivers/rapidio/rio.c
··· 560 560 EXPORT_SYMBOL_GPL(rio_release_inb_pwrite); 561 561 562 562 /** 563 + * rio_pw_enable - Enables/disables port-write handling by a master port 564 + * @mport: Master port associated with port-write handling 565 + * @enable: 1=enable, 0=disable 566 + */ 567 + void rio_pw_enable(struct rio_mport *mport, int enable) 568 + { 569 + if (mport->ops->pwenable) { 570 + mutex_lock(&mport->lock); 571 + 572 + if ((enable && ++mport->pwe_refcnt == 1) || 573 + (!enable && mport->pwe_refcnt && --mport->pwe_refcnt == 0)) 574 + mport->ops->pwenable(mport, enable); 575 + mutex_unlock(&mport->lock); 576 + } 577 + } 578 + EXPORT_SYMBOL_GPL(rio_pw_enable); 579 + 580 + /** 563 581 * rio_map_inb_region -- Map inbound memory region. 564 582 * @mport: Master port. 565 583 * @local: physical address of memory region to be mapped ··· 2059 2041 mport->host_deviceid = rio_get_hdid(mport->id); 2060 2042 mport->nscan = NULL; 2061 2043 mutex_init(&mport->lock); 2044 + mport->pwe_refcnt = 0; 2062 2045 2063 2046 return 0; 2064 2047 }
+2
include/linux/rio.h
··· 266 266 * @dma: DMA device associated with mport 267 267 * @nscan: RapidIO network enumeration/discovery operations 268 268 * @state: mport device state 269 + * @pwe_refcnt: port-write enable ref counter to track enable/disable requests 269 270 */ 270 271 struct rio_mport { 271 272 struct list_head dbells; /* list of doorbell events */ ··· 297 296 #endif 298 297 struct rio_scan *nscan; 299 298 atomic_t state; 299 + unsigned int pwe_refcnt; 300 300 }; 301 301 302 302 static inline int rio_mport_is_running(struct rio_mport *mport)
+1
include/linux/rio_drv.h
··· 375 375 int (*)(struct rio_dev *, union rio_pw_msg*, int)); 376 376 extern int rio_release_inb_pwrite(struct rio_dev *); 377 377 extern int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg); 378 + extern void rio_pw_enable(struct rio_mport *mport, int enable); 378 379 379 380 /* LDM support */ 380 381 int rio_register_driver(struct rio_driver *);