Merge branch 'devel' of master.kernel.org:/home/rmk/linux-2.6-arm
[pandora-kernel.git] / fs / udf / misc.c
index a7f5727..15297de 100644 (file)
@@ -54,15 +54,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
        int i;
 
        ea = UDF_I_DATA(inode);
-       if (UDF_I_LENEATTR(inode))
+       if (UDF_I_LENEATTR(inode)) {
                ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
-       else {
+       else {
                ad = ea;
                size += sizeof(struct extendedAttrHeaderDesc);
        }
 
        offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
-           UDF_I_LENALLOC(inode);
+               UDF_I_LENALLOC(inode);
 
        /* TODO - Check for FreeEASpace */
 
@@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
 
                if (UDF_I_LENEATTR(inode)) {
                        /* check checksum/crc */
-                       if (le16_to_cpu(eahd->descTag.tagIdent) !=
-                           TAG_IDENT_EAHD
-                           || le32_to_cpu(eahd->descTag.tagLocation) !=
-                           UDF_I_LOCATION(inode).logicalBlockNum) {
+                       if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
+                           le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
                                return NULL;
                        }
                } else {
                        size -= sizeof(struct extendedAttrHeaderDesc);
-                       UDF_I_LENEATTR(inode) +=
-                           sizeof(struct extendedAttrHeaderDesc);
+                       UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
                        eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
                        if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
                                eahd->descTag.descVersion = cpu_to_le16(3);
                        else
                                eahd->descTag.descVersion = cpu_to_le16(2);
-                       eahd->descTag.tagSerialNum =
-                           cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
-                       eahd->descTag.tagLocation =
-                           cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
+                       eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
+                       eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
                        eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
                        eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
                }
 
                offset = UDF_I_LENEATTR(inode);
                if (type < 2048) {
-                       if (le32_to_cpu(eahd->appAttrLocation) <
-                           UDF_I_LENEATTR(inode)) {
-                               uint32_t aal =
-                                   le32_to_cpu(eahd->appAttrLocation);
-                               memmove(&ea[offset - aal + size], &ea[aal],
-                                       offset - aal);
+                       if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
+                               uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
+                               memmove(&ea[offset - aal + size],
+                                       &ea[aal], offset - aal);
                                offset -= aal;
                                eahd->appAttrLocation = cpu_to_le32(aal + size);
                        }
-                       if (le32_to_cpu(eahd->impAttrLocation) <
-                           UDF_I_LENEATTR(inode)) {
-                               uint32_t ial =
-                                   le32_to_cpu(eahd->impAttrLocation);
-                               memmove(&ea[offset - ial + size], &ea[ial],
-                                       offset - ial);
+                       if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) {
+                               uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
+                               memmove(&ea[offset - ial + size],
+                                       &ea[ial], offset - ial);
                                offset -= ial;
                                eahd->impAttrLocation = cpu_to_le32(ial + size);
                        }
                } else if (type < 65536) {
-                       if (le32_to_cpu(eahd->appAttrLocation) <
-                           UDF_I_LENEATTR(inode)) {
-                               uint32_t aal =
-                                   le32_to_cpu(eahd->appAttrLocation);
-                               memmove(&ea[offset - aal + size], &ea[aal],
-                                       offset - aal);
+                       if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
+                               uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
+                               memmove(&ea[offset - aal + size],
+                                       &ea[aal], offset - aal);
                                offset -= aal;
                                eahd->appAttrLocation = cpu_to_le32(aal + size);
                        }
@@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
                /* rewrite CRC + checksum of eahd */
                crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
                eahd->descTag.descCRCLength = cpu_to_le16(crclen);
-               eahd->descTag.descCRC =
-                   cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0));
+               eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
+                                                           sizeof(tag), crclen, 0));
                eahd->descTag.tagChecksum = 0;
                for (i = 0; i < 16; i++)
                        if (i != 4)
-                               eahd->descTag.tagChecksum +=
-                                   ((uint8_t *) & (eahd->descTag))[i];
+                               eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
                UDF_I_LENEATTR(inode) += size;
                return (struct genericFormat *)&ea[offset];
        }
        if (loc & 0x02) {
        }
+
        return NULL;
 }
 
@@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
 
                /* check checksum/crc */
                if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
-                   le32_to_cpu(eahd->descTag.tagLocation) !=
-                   UDF_I_LOCATION(inode).logicalBlockNum) {
+                   le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
                        return NULL;
                }
 
@@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
 
                while (offset < UDF_I_LENEATTR(inode)) {
                        gaf = (struct genericFormat *)&ea[offset];
-                       if (le32_to_cpu(gaf->attrType) == type
-                           && gaf->attrSubtype == subtype)
+                       if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
                                return gaf;
                        else
                                offset += le32_to_cpu(gaf->attrLength);
                }
        }
+
        return NULL;
 }
 
@@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
                return NULL;
        }
 
-       tag_p = (tag *) (bh->b_data);
+       tag_p = (tag *)(bh->b_data);
 
        *ident = le16_to_cpu(tag_p->tagIdent);
 
        if (location != le32_to_cpu(tag_p->tagLocation)) {
                udf_debug("location mismatch block %u, tag %u != %u\n",
-                         block + UDF_SB_SESSION(sb),
-                         le32_to_cpu(tag_p->tagLocation), location);
+                         block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
                goto error_out;
        }
 
        /* Verify the tag checksum */
        checksum = 0U;
        for (i = 0; i < 4; i++)
-               checksum += (uint8_t) (bh->b_data[i]);
+               checksum += (uint8_t)(bh->b_data[i]);
        for (i = 5; i < 16; i++)
-               checksum += (uint8_t) (bh->b_data[i]);
+               checksum += (uint8_t)(bh->b_data[i]);
        if (checksum != tag_p->tagChecksum) {
                printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
                goto error_out;
@@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
        /* Verify the descriptor CRC */
        if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
            le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
-                                                  le16_to_cpu(tag_p->
-                                                              descCRCLength),
-                                                  0)) {
+                                                  le16_to_cpu(tag_p->descCRCLength), 0)) {
                return bh;
        }
        udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
                  block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
                  le16_to_cpu(tag_p->descCRCLength));
 
-      error_out:
+error_out:
        brelse(bh);
        return NULL;
 }
@@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
 
 void udf_update_tag(char *data, int length)
 {
-       tag *tptr = (tag *) data;
+       tag *tptr = (tag *)data;
        int i;
 
        length -= sizeof(tag);
@@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length)
 
        for (i = 0; i < 16; i++)
                if (i != 4)
-                       tptr->tagChecksum += (uint8_t) (data[i]);
+                       tptr->tagChecksum += (uint8_t)(data[i]);
 }
 
 void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
                 uint32_t loc, int length)
 {
-       tag *tptr = (tag *) data;
+       tag *tptr = (tag *)data;
        tptr->tagIdent = cpu_to_le16(ident);
        tptr->descVersion = cpu_to_le16(version);
        tptr->tagSerialNum = cpu_to_le16(snum);