]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - drivers/macintosh/smu.c
[POWERPC] powermac: Constify & voidify get_property()
[mirror_ubuntu-jammy-kernel.git] / drivers / macintosh / smu.c
index db2ae71d07ef08511f480c5f6b7978b68772daaa..6f358600536e6e10f830e7fe702bb5f3e32dd035 100644 (file)
@@ -19,7 +19,6 @@
  *    the userland interface
  */
 
-#include <linux/config.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
 #include <linux/device.h>
@@ -35,6 +34,7 @@
 #include <linux/delay.h>
 #include <linux/sysdev.h>
 #include <linux/poll.h>
+#include <linux/mutex.h>
 
 #include <asm/byteorder.h>
 #include <asm/io.h>
@@ -92,7 +92,7 @@ struct smu_device {
  * 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);
 
@@ -447,7 +447,7 @@ EXPORT_SYMBOL(smu_present);
 int __init smu_init (void)
 {
        struct device_node *np;
-       u32 *data;
+       const u32 *data;
 
         np = of_find_node_by_type(NULL, "smu");
         if (np == NULL)
@@ -483,7 +483,7 @@ int __init smu_init (void)
                printk(KERN_ERR "SMU: Can't find doorbell GPIO !\n");
                goto fail;
        }
-       data = (u32 *)get_property(np, "reg", NULL);
+       data = get_property(np, "reg", NULL);
        if (data == NULL) {
                of_node_put(np);
                printk(KERN_ERR "SMU: Can't find doorbell GPIO address !\n");
@@ -497,8 +497,7 @@ int __init smu_init (void)
        smu->doorbell = *data;
        if (smu->doorbell < 0x50)
                smu->doorbell += 0x50;
-       if (np->n_intrs > 0)
-               smu->db_irq = np->intrs[0].line;
+       smu->db_irq = irq_of_parse_and_map(np, 0);
 
        of_node_put(np);
 
@@ -507,7 +506,7 @@ int __init smu_init (void)
                np = of_find_node_by_name(NULL, "smu-interrupt");
                if (np == NULL)
                        break;
-               data = (u32 *)get_property(np, "reg", NULL);
+               data = get_property(np, "reg", NULL);
                if (data == NULL) {
                        of_node_put(np);
                        break;
@@ -515,8 +514,7 @@ int __init smu_init (void)
                smu->msg = *data;
                if (smu->msg < 0x50)
                        smu->msg += 0x50;
-               if (np->n_intrs > 0)
-                       smu->msg_irq = np->intrs[0].line;
+               smu->msg_irq = irq_of_parse_and_map(np, 0);
                of_node_put(np);
        } while(0);
 
@@ -555,7 +553,7 @@ static int smu_late_init(void)
 
        if (smu->db_irq != NO_IRQ) {
                if (request_irq(smu->db_irq, smu_db_intr,
-                               SA_SHIRQ, "SMU doorbell", smu) < 0) {
+                               IRQF_SHARED, "SMU doorbell", smu) < 0) {
                        printk(KERN_WARNING "SMU: can't "
                               "request interrupt %d\n",
                               smu->db_irq);
@@ -565,7 +563,7 @@ static int smu_late_init(void)
 
        if (smu->msg_irq != NO_IRQ) {
                if (request_irq(smu->msg_irq, smu_msg_intr,
-                               SA_SHIRQ, "SMU message", smu) < 0) {
+                               IRQF_SHARED, "SMU message", smu) < 0) {
                        printk(KERN_WARNING "SMU: can't "
                               "request interrupt %d\n",
                               smu->msg_irq);
@@ -629,8 +627,6 @@ static struct of_platform_driver smu_of_platform_driver =
 
 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
@@ -639,7 +635,7 @@ static int __init smu_init_sysfs(void)
         * 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;
 }
 
@@ -963,11 +959,11 @@ static struct smu_sdbp_header *smu_create_sdb_partition(int id)
 /* Note: Only allowed to return error code in pointers (using ERR_PTR)
  * when interruptible is 1
  */
-struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
-                                               int interruptible)
+const struct smu_sdbp_header *__smu_get_sdb_partition(int id,
+               unsigned int *size, int interruptible)
 {
        char pname[32];
-       struct smu_sdbp_header *part;
+       const struct smu_sdbp_header *part;
 
        if (!smu)
                return NULL;
@@ -978,25 +974,24 @@ struct smu_sdbp_header *__smu_get_sdb_partition(int id, unsigned int *size,
 
        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);
+       part = get_property(smu->of_node, pname, size);
        if (part == NULL) {
                DPRINTK("trying to extract from SMU ...\n");
                part = smu_create_sdb_partition(id);
                if (part != NULL && size)
                        *size = part->len << 2;
        }
-       up(&smu_part_access);
+       mutex_unlock(&smu_part_access);
        return part;
 }
 
-struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size)
+const struct smu_sdbp_header *smu_get_sdb_partition(int id, unsigned int *size)
 {
        return __smu_get_sdb_partition(id, size, 0);
 }
@@ -1075,7 +1070,7 @@ static ssize_t smu_write(struct file *file, const char __user *buf,
                pp->mode = smu_file_events;
                return 0;
        } else if (hdr.cmdtype == SMU_CMDTYPE_GET_PARTITION) {
-               struct smu_sdbp_header *part;
+               const struct smu_sdbp_header *part;
                part = __smu_get_sdb_partition(hdr.cmd, NULL, 1);
                if (part == NULL)
                        return -EINVAL;