ALSA: mpu401: Adjust four checks for null pointers
[platform/kernel/linux-exynos.git] / sound / drivers / mpu401 / mpu401_uart.c
index 3a7c317..b997222 100644 (file)
@@ -136,7 +136,7 @@ irqreturn_t snd_mpu401_uart_interrupt(int irq, void *dev_id)
 {
        struct snd_mpu401 *mpu = dev_id;
        
-       if (mpu == NULL)
+       if (!mpu)
                return IRQ_NONE;
        _snd_mpu401_uart_interrupt(mpu);
        return IRQ_HANDLED;
@@ -157,7 +157,7 @@ irqreturn_t snd_mpu401_uart_interrupt_tx(int irq, void *dev_id)
 {
        struct snd_mpu401 *mpu = dev_id;
        
-       if (mpu == NULL)
+       if (!mpu)
                return IRQ_NONE;
        uart_interrupt_tx(mpu);
        return IRQ_HANDLED;
@@ -544,10 +544,9 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
                                   out_enable, in_enable, &rmidi)) < 0)
                return err;
        mpu = kzalloc(sizeof(*mpu), GFP_KERNEL);
-       if (mpu == NULL) {
-               snd_printk(KERN_ERR "mpu401_uart: cannot allocate\n");
-               snd_device_free(card, rmidi);
-               return -ENOMEM;
+       if (!mpu) {
+               err = -ENOMEM;
+               goto free_device;
        }
        rmidi->private_data = mpu;
        rmidi->private_free = snd_mpu401_uart_free;
@@ -559,12 +558,12 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
        if (! (info_flags & MPU401_INFO_INTEGRATED)) {
                int res_size = hardware == MPU401_HW_PC98II ? 4 : 2;
                mpu->res = request_region(port, res_size, "MPU401 UART");
-               if (mpu->res == NULL) {
+               if (!mpu->res) {
                        snd_printk(KERN_ERR "mpu401_uart: "
                                   "unable to grab port 0x%lx size %d\n",
                                   port, res_size);
-                       snd_device_free(card, rmidi);
-                       return -EBUSY;
+                       err = -EBUSY;
+                       goto free_device;
                }
        }
        if (info_flags & MPU401_INFO_MMIO) {
@@ -584,8 +583,8 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
                                "MPU401 UART", (void *) mpu)) {
                        snd_printk(KERN_ERR "mpu401_uart: "
                                   "unable to grab IRQ %d\n", irq);
-                       snd_device_free(card, rmidi);
-                       return -EBUSY;
+                       err = -EBUSY;
+                       goto free_device;
                }
        }
        if (irq < 0 && !(info_flags & MPU401_INFO_IRQ_HOOK))
@@ -613,6 +612,9 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,
        if (rrawmidi)
                *rrawmidi = rmidi;
        return 0;
+free_device:
+       snd_device_free(card, rmidi);
+       return err;
 }
 
 EXPORT_SYMBOL(snd_mpu401_uart_new);