#include <linux/delay.h>
#include <linux/sysdev.h>
#include <linux/poll.h>
+#include <linux/mutex.h>
#include <asm/byteorder.h>
#include <asm/io.h>
* for now, just hard code that
*/
static struct smu_device *smu;
-static DECLARE_MUTEX(smu_part_access);
+static DEFINE_MUTEX(smu_part_access);
static void smu_i2c_retry(unsigned long data);
* sysfs visibility
*/
-static void smu_create_i2c(struct device_node *np)
-{
- char name[32];
- u32 *reg = (u32 *)get_property(np, "reg", NULL);
-
- if (reg != NULL) {
- sprintf(name, "smu-i2c-%02x", *reg);
- of_platform_device_create(np, name, &smu->of_dev->dev);
- }
-}
-
static void smu_expose_childs(void *unused)
{
- struct device_node *np, *gp;
-
- for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;) {
- if (device_is_compatible(np, "smu-i2c-control")) {
- gp = NULL;
- while ((gp = of_get_next_child(np, gp)) != NULL)
- if (device_is_compatible(gp, "i2c-bus"))
- smu_create_i2c(gp);
- } else if (device_is_compatible(np, "smu-i2c"))
- smu_create_i2c(np);
+ struct device_node *np;
+
+ for (np = NULL; (np = of_get_next_child(smu->of_node, np)) != NULL;)
if (device_is_compatible(np, "smu-sensors"))
of_platform_device_create(np, "smu-sensors",
&smu->of_dev->dev);
- }
-
}
static DECLARE_WORK(smu_expose_childs_work, smu_expose_childs, NULL);
static int __init smu_init_sysfs(void)
{
- int rc;
-
/*
* Due to sysfs bogosity, a sysdev is not a real device, so
* we should in fact create both if we want sysdev semantics
* I'm a bit too far from figuring out how that works with those
* new chipsets, but that will come back and bite us
*/
- rc = of_register_driver(&smu_of_platform_driver);
+ of_register_driver(&smu_of_platform_driver);
return 0;
}
if (interruptible) {
int rc;
- rc = down_interruptible(&smu_part_access);
+ rc = mutex_lock_interruptible(&smu_part_access);
if (rc)
return ERR_PTR(rc);
} else
- down(&smu_part_access);
+ mutex_lock(&smu_part_access);
part = (struct smu_sdbp_header *)get_property(smu->of_node,
pname, size);
if (part != NULL && size)
*size = part->len << 2;
}
- up(&smu_part_access);
+ mutex_unlock(&smu_part_access);
return part;
}