C and other Super I/O cosmetic fixes.
[coreboot.git] / src / superio / smsc / fdc37m60x / superio.c
index 33d8587b59637b69d7960f838cd3392af1abc102..d074c648deed9439a9bcfd758098e8f9cc65c0ee 100644 (file)
 #include <device/pnp.h>
 #include <uart8250.h>
 #include <pc80/keyboard.h>
+#include <stdlib.h>
 #include "chip.h"
 #include "fdc37m60x.h"
 
 static void init(device_t dev)
 {
-       struct superio_smsc_fdc37m60x_config *conf;
-       struct resource *res0, *res1;
+       struct superio_smsc_fdc37m60x_config *conf = dev->chip_info;
+       struct resource *res0;
 
-       if (!dev->enabled) {
+       if (!dev->enabled)
                return;
-       }
-
-       conf = dev->chip_info;
 
-       switch (dev->path.u.pnp.device) {
+       switch (dev->path.pnp.device) {
        case FDC37M60X_FDC: /* TODO. */
                break;
        case FDC37M60X_PP: /* TODO. */
@@ -50,9 +48,7 @@ static void init(device_t dev)
                init_uart8250(res0->base, &conf->com2);
                break;
        case FDC37M60X_KBCK:
-               res0 = find_resource(dev, PNP_IDX_IO0);
-               res1 = find_resource(dev, PNP_IDX_IO1);
-               init_pc_keyboard(res0->base, res1->base, &conf->keyboard);
+               pc_keyboard_init(&conf->keyboard);
                break;
        case FDC37M60X_AUX: /* TODO. */
                break;
@@ -69,19 +65,18 @@ static struct device_operations ops = {
 
 /* TODO: FDC, PP, AUX. */
 static struct pnp_info pnp_dev_info[] = {
{ &ops, FDC37M60X_SP1,  PNP_IO0 | PNP_IRQ0, { 0x7f8, 0 }, },
{ &ops, FDC37M60X_SP2,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, { 0x7f8, 0 }, },
{ &ops, FDC37M60X_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, { 0x7f8, 0 }, { 0x7f8, 0x4}, },
      { &ops, FDC37M60X_SP1,  PNP_IO0 | PNP_IRQ0, {0x07f8, 0}, },
      { &ops, FDC37M60X_SP2,  PNP_IO0 | PNP_IRQ0 | PNP_DRQ0 | PNP_DRQ1, {0x07f8, 0}, },
      { &ops, FDC37M60X_KBCK, PNP_IO0 | PNP_IO1 | PNP_IRQ0, {0x07f8, 0}, {0x07f8, 4}, },
 };
 
 static void enable_dev(struct device *dev)
 {
        pnp_enable_devices(dev, &pnp_ops,
-               sizeof(pnp_dev_info)/sizeof(pnp_dev_info[0]), pnp_dev_info);
+               ARRAY_SIZE(pnp_dev_info), pnp_dev_info);
 }
 
 struct chip_operations superio_smsc_fdc37m60x_ops = {
        CHIP_NAME("SMSC FDC37M60X Super I/O")
        .enable_dev = enable_dev,
 };
-