4 /* this is needed, separate from the main nx-842.c driver, because that main
5 * driver loads the platform drivers during its init(), and it expects one
6 * (or none) of the platform drivers to set this pointer to its driver.
7 * That means this pointer can't be in the main nx-842 driver, because it
8 * wouldn't be accessible until after the main driver loaded, which wouldn't
9 * be possible as it's waiting for the platform driver to load. So place it
12 static struct nx842_driver
*driver
;
13 static DEFINE_SPINLOCK(driver_lock
);
15 struct nx842_driver
*nx842_platform_driver(void)
19 EXPORT_SYMBOL_GPL(nx842_platform_driver
);
21 bool nx842_platform_driver_set(struct nx842_driver
*_driver
)
25 spin_lock(&driver_lock
);
31 WARN(1, "can't set platform driver, already set to %s\n",
34 spin_unlock(&driver_lock
);
37 EXPORT_SYMBOL_GPL(nx842_platform_driver_set
);
39 /* only call this from the platform driver exit function */
40 void nx842_platform_driver_unset(struct nx842_driver
*_driver
)
42 spin_lock(&driver_lock
);
44 if (driver
== _driver
)
47 WARN(1, "can't unset platform driver %s, currently set to %s\n",
48 _driver
->name
, driver
->name
);
50 WARN(1, "can't unset platform driver, already unset\n");
52 spin_unlock(&driver_lock
);
54 EXPORT_SYMBOL_GPL(nx842_platform_driver_unset
);
56 bool nx842_platform_driver_get(void)
60 spin_lock(&driver_lock
);
63 ret
= try_module_get(driver
->owner
);
65 spin_unlock(&driver_lock
);
69 EXPORT_SYMBOL_GPL(nx842_platform_driver_get
);
71 void nx842_platform_driver_put(void)
73 spin_lock(&driver_lock
);
76 module_put(driver
->owner
);
78 spin_unlock(&driver_lock
);
80 EXPORT_SYMBOL_GPL(nx842_platform_driver_put
);
82 MODULE_LICENSE("GPL");
83 MODULE_AUTHOR("Dan Streetman <ddstreet@ieee.org>");
84 MODULE_DESCRIPTION("842 H/W Compression platform driver");