Skip to contentSkip to conversation

ROUND_UP macro cleanup in arch/parisc

PATCH In review Milind Arun Choudhary 2 participants 3 messages Apr 1, 2007 – Apr 4, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ROUND_UP macro cleanup in arch/parisc

ROUND_UP macro cleanup, use ALIGN where ever appropriate

---
 hpux/fs.c             |    5 ++---
 kernel/sys_parisc32.c |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/parisc/hpux/fs.c +2 -3
index 4204cd1..7ff5546 100644
@@ -21,6 +21,7 @@
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/file.h>
@@ -70,7 +71,6 @@ struct getdents_callback {
 };
 
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
-#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
 
 static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 		u64 ino, unsigned d_type)
@@ -78,7 +78,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 	struct hpux_dirent * dirent;
 	struct getdents_callback * buf = (struct getdents_callback *) __buf;
 	ino_t d_ino;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1,sizeof(long));
 
 	buf->error = -EINVAL;	/* only used if we fail.. */
 	if (reclen > buf->count)
@@ -103,7 +103,6 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 }
 
 #undef NAME_OFFSET
-#undef ROUND_UP
 
 int hpux_getdents(unsigned int fd, struct hpux_dirent *dirent, unsigned int count)
 {
arch/parisc/kernel/sys_parisc32.c +1 -2
index ce3245f..e590880 100644
@@ -311,14 +311,13 @@ struct readdir32_callback {
 	int count;
 };
 
-#define ROUND_UP(x,a)	((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
 static int filldir32 (void *__buf, const char *name, int namlen,
 			loff_t offset, u64 ino, unsigned int d_type)
 {
 	struct linux32_dirent __user * dirent;
 	struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
 	u32 d_ino;
 
 	buf->error = -EINVAL;	/* only used if we fail.. */
Signature · 1 line
Milind Arun Choudhary
#1 lore raw
Quoted 3 lines · Milind Arun Choudhary

ROUND_UP macro cleanup, use ALIGN where ever appropriate

Also looks good to me. Just one white space nit we can fixup by hand.

Quoted 29 lines
---
 hpux/fs.c             |    5 ++---
 kernel/sys_parisc32.c |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/parisc/hpux/fs.c +1 -1
index 4204cd1..7ff5546 100644
@@ -21,6 +21,7 @@
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/file.h>
@@ -70,7 +71,6 @@ struct getdents_callback {
 };
 
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
-#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
 
 static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 		u64 ino, unsigned d_type)

arch/parisc/hpux/fs.c static int filldir(void * __buf, const char * name, int namlen, loff_t offset, · line 81

Quoted 5 lines
arch/parisc/hpux/fs.c +1 -1
@@ -78,7 +78,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 	struct hpux_dirent * dirent;
 	struct getdents_callback * buf = (struct getdents_callback *) __buf;
 	ino_t d_ino;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1,sizeof(long));

Nit: I'd want a blank space after the comma.

thanks,
grant

Quoted 34 lines
arch/parisc/hpux/fs.c +0 -1
 	buf->error = -EINVAL;	/* only used if we fail.. */
 	if (reclen > buf->count)
@@ -103,7 +103,6 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 }
 
 #undef NAME_OFFSET
-#undef ROUND_UP
 
 int hpux_getdents(unsigned int fd, struct hpux_dirent *dirent, unsigned int count)
 {
arch/parisc/kernel/sys_parisc32.c +1 -2
index ce3245f..e590880 100644
@@ -311,14 +311,13 @@ struct readdir32_callback {
 	int count;
 };
 
-#define ROUND_UP(x,a)	((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
 static int filldir32 (void *__buf, const char *name, int namlen,
 			loff_t offset, u64 ino, unsigned int d_type)
 {
 	struct linux32_dirent __user * dirent;
 	struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
 	u32 d_ino;
 
 	buf->error = -EINVAL;	/* only used if we fail.. */
Signature · 2 lines
-- 
Milind Arun Choudhary

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/kernel-janitors

#2 lore raw
In reply to Milind Arun Choudhary
Quoted 3 lines · Milind Arun Choudhary

ROUND_UP macro cleanup, use ALIGN where ever appropriate

Also looks good to me. Just one white space nit we can fixup by hand.

Quoted 29 lines
---
 hpux/fs.c             |    5 ++---
 kernel/sys_parisc32.c |    3 +--
 2 files changed, 3 insertions(+), 5 deletions(-)
arch/parisc/hpux/fs.c +1 -1
index 4204cd1..7ff5546 100644
@@ -21,6 +21,7 @@
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/sched.h>
 #include <linux/file.h>
@@ -70,7 +71,6 @@ struct getdents_callback {
 };
 
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char *) (de)))
-#define ROUND_UP(x) (((x)+sizeof(long)-1) & ~(sizeof(long)-1))
 
 static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 		u64 ino, unsigned d_type)

arch/parisc/hpux/fs.c static int filldir(void * __buf, const char * name, int namlen, loff_t offset, · line 81

Quoted 5 lines
arch/parisc/hpux/fs.c +1 -1
@@ -78,7 +78,7 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 	struct hpux_dirent * dirent;
 	struct getdents_callback * buf = (struct getdents_callback *) __buf;
 	ino_t d_ino;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1,sizeof(long));

Nit: I'd want a blank space after the comma.

thanks,
grant

Quoted 34 lines
arch/parisc/hpux/fs.c +0 -1
 	buf->error = -EINVAL;	/* only used if we fail.. */
 	if (reclen > buf->count)
@@ -103,7 +103,6 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
 }
 
 #undef NAME_OFFSET
-#undef ROUND_UP
 
 int hpux_getdents(unsigned int fd, struct hpux_dirent *dirent, unsigned int count)
 {
arch/parisc/kernel/sys_parisc32.c +1 -2
index ce3245f..e590880 100644
@@ -311,14 +311,13 @@ struct readdir32_callback {
 	int count;
 };
 
-#define ROUND_UP(x,a)	((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
 static int filldir32 (void *__buf, const char *name, int namlen,
 			loff_t offset, u64 ino, unsigned int d_type)
 {
 	struct linux32_dirent __user * dirent;
 	struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
-	int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
+	int reclen = ALIGN(NAME_OFFSET(dirent) + namlen + 1, 4);
 	u32 d_ino;
 
 	buf->error = -EINVAL;	/* only used if we fail.. */
Signature · 2 lines
-- 
Milind Arun Choudhary

_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux