Re: [PATCH 02/16 v2] pramfs: super block operations

2010-11-06 Thread Marco Stornelli
Il 06/11/2010 14:12, James Hogan ha scritto:
> Hi,
> 
> On Sat, Nov 06, 2010 at 09:56:39AM +0100, Marco Stornelli wrote:
>> From: Marco Stornelli 
>>
>> Super block operations.
>>
>> Signed-off-by: Marco Stornelli 
>> ---
>> diff -Nurp linux-2.6.36-orig/fs/pramfs/super.c linux-2.6.36/fs/pramfs/super.c
>> --- linux-2.6.36-orig/fs/pramfs/super.c  1970-01-01 01:00:00.0 
>> +0100
>> +++ linux-2.6.36/fs/pramfs/super.c   2010-09-25 14:09:47.0 +0200
> 
>> +pram_dbg("max name length %d\n", PRAM_NAME_LEN);
> 
> I get a warning on this line that could be avoided:
> 
> fs/pramfs/super.c: In function ‘pram_init’:
> fs/pramfs/super.c:308: warning: format ‘%d’ expects type ‘int’, but
> argument 2 has type ‘long unsigned int’
> 
> Cheers
> James
> 


Mmmm, very strange, I don't have that warning, maybe the compiler
version. I'll fix it with an int cast to avoid it.

Marco
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/16 v2] pramfs: super block operations

2010-11-06 Thread Marco Stornelli
Il 06/11/2010 12:16, James Hogan ha scritto:
> Hi Marco,
> 
> On Sat, Nov 06, 2010 at 09:56:39AM +0100, Marco Stornelli wrote:
>> From: Marco Stornelli 
>> +static void pram_set_blocksize(struct super_block *sb, unsigned long size)
>> +{
>> +int bits;
>> +
>> +/*
>> +* We've already validated the user input and the value here must be
>> +* between PRAM_MAX_BLOCK_SIZE and PRAM_MIN_BLOCK_SIZE
>> +* and it must be a power of 2.
>> +*/
> 
> Should this comment have spaces after the tabs to be consistent with the
> other multiline comments (pram_ioremap) and the coding style?
> 

Ok, no problem.

Thanks for the review.

Regards,

Marco
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/16 v2] pramfs: super block operations

2010-11-06 Thread James Hogan
Hi,

On Sat, Nov 06, 2010 at 09:56:39AM +0100, Marco Stornelli wrote:
> From: Marco Stornelli 
> 
> Super block operations.
> 
> Signed-off-by: Marco Stornelli 
> ---
> diff -Nurp linux-2.6.36-orig/fs/pramfs/super.c linux-2.6.36/fs/pramfs/super.c
> --- linux-2.6.36-orig/fs/pramfs/super.c   1970-01-01 01:00:00.0 
> +0100
> +++ linux-2.6.36/fs/pramfs/super.c2010-09-25 14:09:47.0 +0200

> + pram_dbg("max name length %d\n", PRAM_NAME_LEN);

I get a warning on this line that could be avoided:

fs/pramfs/super.c: In function ‘pram_init’:
fs/pramfs/super.c:308: warning: format ‘%d’ expects type ‘int’, but
argument 2 has type ‘long unsigned int’

Cheers
James
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 02/16 v2] pramfs: super block operations

2010-11-06 Thread James Hogan
Hi Marco,

On Sat, Nov 06, 2010 at 09:56:39AM +0100, Marco Stornelli wrote:
> From: Marco Stornelli 
> +static void pram_set_blocksize(struct super_block *sb, unsigned long size)
> +{
> + int bits;
> +
> + /*
> + * We've already validated the user input and the value here must be
> + * between PRAM_MAX_BLOCK_SIZE and PRAM_MIN_BLOCK_SIZE
> + * and it must be a power of 2.
> + */

Should this comment have spaces after the tabs to be consistent with the
other multiline comments (pram_ioremap) and the coding style?

> + bits = fls(size) - 1;
> + sb->s_blocksize_bits = bits;
> + sb->s_blocksize = (1< +}
> +
> +static inline void *pram_ioremap(phys_addr_t phys_addr, ssize_t size)
> +{
> + void *retval;
> +
> + /*
> +  * NOTE: Userland may not map this resource, we will mark the region so
> +  * /dev/mem and the sysfs MMIO access will not be allowed. This
> +  * restriction depends on STRICT_DEVMEM option. If this option is
> +  * disabled or not available we mark the region only as busy.
> +  */
> + retval = request_mem_region_exclusive(phys_addr, size, "pramfs");
> + if (!retval)
> + goto fail;
> +
> + retval = ioremap_nocache(phys_addr, size);
> +
> + if (retval)
> + wrprotect(retval, size);
> +fail:
> + return retval;
> +}

Cheers
James
--
To unsubscribe from this list: send the line "unsubscribe linux-embedded" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 02/16 v2] pramfs: super block operations

2010-11-06 Thread Marco Stornelli
From: Marco Stornelli 

Super block operations.

Signed-off-by: Marco Stornelli 
---
diff -Nurp linux-2.6.36-orig/fs/pramfs/super.c linux-2.6.36/fs/pramfs/super.c
--- linux-2.6.36-orig/fs/pramfs/super.c 1970-01-01 01:00:00.0 +0100
+++ linux-2.6.36/fs/pramfs/super.c  2010-09-25 14:09:47.0 +0200
@@ -0,0 +1,740 @@
+/*
+ * FILE NAME fs/pramfs/super.c
+ *
+ * BRIEF DESCRIPTION
+ *
+ * Super block operations.
+ *
+ * Copyright 2009-2010 Marco Stornelli 
+ * Copyright 2003 Sony Corporation
+ * Copyright 2003 Matsushita Electric Industrial Co., Ltd.
+ * 2003-2004 (c) MontaVista Software, Inc. , Steve Longerbeam
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "xattr.h"
+#include "pram.h"
+
+static struct super_operations pram_sops;
+static const struct export_operations pram_export_ops;
+static struct kmem_cache *pram_inode_cachep;
+
+#ifdef CONFIG_PRAMFS_TEST
+static void *first_pram_super;
+
+struct pram_super_block *get_pram_super(void)
+{
+   return (struct pram_super_block *)first_pram_super;
+}
+EXPORT_SYMBOL(get_pram_super);
+#endif
+
+static void pram_set_blocksize(struct super_block *sb, unsigned long size)
+{
+   int bits;
+
+   /*
+   * We've already validated the user input and the value here must be
+   * between PRAM_MAX_BLOCK_SIZE and PRAM_MIN_BLOCK_SIZE
+   * and it must be a power of 2.
+   */
+   bits = fls(size) - 1;
+   sb->s_blocksize_bits = bits;
+   sb->s_blocksize = (1< MAX_LFS_FILESIZE)
+   res = MAX_LFS_FILESIZE;
+
+   pram_info("Max file size %llu bytes", res);
+   return res;
+}
+
+enum {
+   Opt_addr, Opt_bpi, Opt_size,
+   Opt_num_inodes, Opt_mode, Opt_uid,
+   Opt_gid, Opt_blocksize, Opt_err
+};
+
+static const match_table_t tokens = {
+   {Opt_bpi,   "physaddr=%x"},
+   {Opt_bpi,   "bpi=%u"},
+   {Opt_size,  "init=%s"},
+   {Opt_num_inodes, "N=%u"},
+   {Opt_mode,  "mode=%o"},
+   {Opt_uid,   "uid=%u"},
+   {Opt_gid,   "gid=%u"},
+   {Opt_blocksize, "bs=%s"},
+   {Opt_err,   NULL},
+};
+
+static phys_addr_t get_phys_addr(void **data)
+{
+   phys_addr_t phys_addr;
+   char *options = (char *) *data;
+
+   if (!options || strncmp(options, "physaddr=", 9) != 0)
+   return (phys_addr_t)ULLONG_MAX;
+   options += 9;
+   phys_addr = (phys_addr_t)simple_strtoull(options, &options, 0);
+   if (*options && *options != ',') {
+   pram_err("Invalid phys addr specification: %s\n",
+  (char *) *data);
+   return (phys_addr_t)ULLONG_MAX;
+   }
+   if (phys_addr & (PAGE_SIZE - 1)) {
+   pram_err("physical address 0x%16llx for pramfs isn't "
+ "aligned to a page boundary\n",
+ (u64)phys_addr);
+   return (phys_addr_t)ULLONG_MAX;
+   }
+   if (*options == ',')
+   options++;
+   *data = (void *) options;
+   return phys_addr;
+}
+
+static int pram_parse_options(char *options, struct pram_sb_info *sbi)
+{
+   char *p, *rest;
+   substring_t args[MAX_OPT_ARGS];
+   int option;
+
+   if (!options)
+   return 0;
+
+   while ((p = strsep(&options, ",")) != NULL) {
+   int token;
+   if (!*p)
+   continue;
+
+   token = match_token(p, tokens, args);
+   switch (token) {
+   case Opt_addr: {
+   /* physaddr managed in get_phys_addr() */
+   break;
+   }
+   case Opt_bpi: {
+   if (match_int(&args[0], &option))
+   goto bad_val;
+   sbi->bpi = option;
+   break;
+   }
+   case Opt_uid: {
+   if (match_int(&args[0], &option))
+   goto bad_val;
+   sbi->uid = option;
+   break;
+   }
+   case Opt_gid: {
+   if (match_int(&args[0], &option))
+   goto bad_val;
+   sbi->gid = option;
+   break;
+   }
+   case Opt_mode: {
+   if (match_octal(&args[0], &option))
+   goto bad_val;
+