Re: [PATCH] mtd: Allocate bdi objects dynamically
On 12/01/2016 07:14 PM, Brian Norris wrote: > On Thu, Dec 01, 2016 at 04:39:23PM +0100, Marek Vasut wrote: >> On 11/29/2016 09:12 AM, Sandeep Jain wrote: >>> On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: On 11/03/2016 12:34 PM, Sandeep Jain wrote: > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain>> wrote: >>> From: Steve Longerbeam >>> >>> The MTD backing dev info objects mtd_bdi was statically allocated. >>> So when MTD is built as a loadable module, this object fall in the >>> vmalloc address space. >>> >>> The problem with that, is that the BDI APIs use wake_up_bit(), which >>> calls >>> virt_to_page() to retrieve the memory zone of the page containing the >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or >>> highmem addresses. >>> >>> Fix this by allocating the BDI objects dynamically with kmalloc. The >>> objects now fall in the logical address space so that BDI APIs will >>> work in all cases (mtd builtin or module). >>> >>> Signed-off-by: Steve Longerbeam >>> Signed-off-by: Jim Baxter >>> Signed-off-by: Sandeep Jain >> >> Reviewed-by: Richard Weinberger I don't see any obvious problem either: Reviewed-by: Marek Vasut >> >> Bump? > > Applied to l2-mtd.git. > Thanks ! -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
On 12/01/2016 07:14 PM, Brian Norris wrote: > On Thu, Dec 01, 2016 at 04:39:23PM +0100, Marek Vasut wrote: >> On 11/29/2016 09:12 AM, Sandeep Jain wrote: >>> On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: On 11/03/2016 12:34 PM, Sandeep Jain wrote: > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain >> wrote: >>> From: Steve Longerbeam >>> >>> The MTD backing dev info objects mtd_bdi was statically allocated. >>> So when MTD is built as a loadable module, this object fall in the >>> vmalloc address space. >>> >>> The problem with that, is that the BDI APIs use wake_up_bit(), which >>> calls >>> virt_to_page() to retrieve the memory zone of the page containing the >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or >>> highmem addresses. >>> >>> Fix this by allocating the BDI objects dynamically with kmalloc. The >>> objects now fall in the logical address space so that BDI APIs will >>> work in all cases (mtd builtin or module). >>> >>> Signed-off-by: Steve Longerbeam >>> Signed-off-by: Jim Baxter >>> Signed-off-by: Sandeep Jain >> >> Reviewed-by: Richard Weinberger I don't see any obvious problem either: Reviewed-by: Marek Vasut >> >> Bump? > > Applied to l2-mtd.git. > Thanks ! -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
On Thu, Dec 01, 2016 at 04:39:23PM +0100, Marek Vasut wrote: > On 11/29/2016 09:12 AM, Sandeep Jain wrote: > > On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: > >> On 11/03/2016 12:34 PM, Sandeep Jain wrote: > >>> On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain> wrote: > > From: Steve Longerbeam > > > > The MTD backing dev info objects mtd_bdi was statically allocated. > > So when MTD is built as a loadable module, this object fall in the > > vmalloc address space. > > > > The problem with that, is that the BDI APIs use wake_up_bit(), which > > calls > > virt_to_page() to retrieve the memory zone of the page containing the > > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > > highmem addresses. > > > > Fix this by allocating the BDI objects dynamically with kmalloc. The > > objects now fall in the logical address space so that BDI APIs will > > work in all cases (mtd builtin or module). > > > > Signed-off-by: Steve Longerbeam > > Signed-off-by: Jim Baxter > > Signed-off-by: Sandeep Jain > > Reviewed-by: Richard Weinberger > >> > >> I don't see any obvious problem either: > >> Reviewed-by: Marek Vasut > > Bump? Applied to l2-mtd.git.
Re: [PATCH] mtd: Allocate bdi objects dynamically
On Thu, Dec 01, 2016 at 04:39:23PM +0100, Marek Vasut wrote: > On 11/29/2016 09:12 AM, Sandeep Jain wrote: > > On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: > >> On 11/03/2016 12:34 PM, Sandeep Jain wrote: > >>> On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain > wrote: > > From: Steve Longerbeam > > > > The MTD backing dev info objects mtd_bdi was statically allocated. > > So when MTD is built as a loadable module, this object fall in the > > vmalloc address space. > > > > The problem with that, is that the BDI APIs use wake_up_bit(), which > > calls > > virt_to_page() to retrieve the memory zone of the page containing the > > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > > highmem addresses. > > > > Fix this by allocating the BDI objects dynamically with kmalloc. The > > objects now fall in the logical address space so that BDI APIs will > > work in all cases (mtd builtin or module). > > > > Signed-off-by: Steve Longerbeam > > Signed-off-by: Jim Baxter > > Signed-off-by: Sandeep Jain > > Reviewed-by: Richard Weinberger > >> > >> I don't see any obvious problem either: > >> Reviewed-by: Marek Vasut > > Bump? Applied to l2-mtd.git.
Re: [PATCH] mtd: Allocate bdi objects dynamically
On 11/29/2016 09:12 AM, Sandeep Jain wrote: > Dear Maintainers, >This patch is already reviewed twice with no issues. > Requesting your attention for patch merge. > > Thanks & Regards, > Sandeep Jain > > On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: >> On 11/03/2016 12:34 PM, Sandeep Jain wrote: >>> Dear Maintainers, >>> This patch is reviewed by Richard. >>> Requesting for Maintainer's attention for patch merge. >>> >>> Thanks & Regards, >>> Sandeep Jain >>> >>> On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jainwrote: > From: Steve Longerbeam > > The MTD backing dev info objects mtd_bdi was statically allocated. > So when MTD is built as a loadable module, this object fall in the > vmalloc address space. > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > virt_to_page() to retrieve the memory zone of the page containing the > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > highmem addresses. > > Fix this by allocating the BDI objects dynamically with kmalloc. The > objects now fall in the logical address space so that BDI APIs will > work in all cases (mtd builtin or module). > > Signed-off-by: Steve Longerbeam > Signed-off-by: Jim Baxter > Signed-off-by: Sandeep Jain Reviewed-by: Richard Weinberger >> >> I don't see any obvious problem either: >> Reviewed-by: Marek Vasut Bump? -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
On 11/29/2016 09:12 AM, Sandeep Jain wrote: > Dear Maintainers, >This patch is already reviewed twice with no issues. > Requesting your attention for patch merge. > > Thanks & Regards, > Sandeep Jain > > On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: >> On 11/03/2016 12:34 PM, Sandeep Jain wrote: >>> Dear Maintainers, >>> This patch is reviewed by Richard. >>> Requesting for Maintainer's attention for patch merge. >>> >>> Thanks & Regards, >>> Sandeep Jain >>> >>> On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain wrote: > From: Steve Longerbeam > > The MTD backing dev info objects mtd_bdi was statically allocated. > So when MTD is built as a loadable module, this object fall in the > vmalloc address space. > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > virt_to_page() to retrieve the memory zone of the page containing the > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > highmem addresses. > > Fix this by allocating the BDI objects dynamically with kmalloc. The > objects now fall in the logical address space so that BDI APIs will > work in all cases (mtd builtin or module). > > Signed-off-by: Steve Longerbeam > Signed-off-by: Jim Baxter > Signed-off-by: Sandeep Jain Reviewed-by: Richard Weinberger >> >> I don't see any obvious problem either: >> Reviewed-by: Marek Vasut Bump? -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
Dear Maintainers, This patch is already reviewed twice with no issues. Requesting your attention for patch merge. Thanks & Regards, Sandeep Jain On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: > On 11/03/2016 12:34 PM, Sandeep Jain wrote: > > Dear Maintainers, > > This patch is reviewed by Richard. > > Requesting for Maintainer's attention for patch merge. > > > > Thanks & Regards, > > Sandeep Jain > > > > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain> >> wrote: > >>> From: Steve Longerbeam > >>> > >>> The MTD backing dev info objects mtd_bdi was statically allocated. > >>> So when MTD is built as a loadable module, this object fall in the > >>> vmalloc address space. > >>> > >>> The problem with that, is that the BDI APIs use wake_up_bit(), which calls > >>> virt_to_page() to retrieve the memory zone of the page containing the > >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > >>> highmem addresses. > >>> > >>> Fix this by allocating the BDI objects dynamically with kmalloc. The > >>> objects now fall in the logical address space so that BDI APIs will > >>> work in all cases (mtd builtin or module). > >>> > >>> Signed-off-by: Steve Longerbeam > >>> Signed-off-by: Jim Baxter > >>> Signed-off-by: Sandeep Jain > >> > >> Reviewed-by: Richard Weinberger > > I don't see any obvious problem either: > Reviewed-by: Marek Vasut > > -- > Best regards, > Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
Dear Maintainers, This patch is already reviewed twice with no issues. Requesting your attention for patch merge. Thanks & Regards, Sandeep Jain On Sat, Nov 05, 2016 at 08:22:31AM +0100, Marek Vasut wrote: > On 11/03/2016 12:34 PM, Sandeep Jain wrote: > > Dear Maintainers, > > This patch is reviewed by Richard. > > Requesting for Maintainer's attention for patch merge. > > > > Thanks & Regards, > > Sandeep Jain > > > > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain > >> wrote: > >>> From: Steve Longerbeam > >>> > >>> The MTD backing dev info objects mtd_bdi was statically allocated. > >>> So when MTD is built as a loadable module, this object fall in the > >>> vmalloc address space. > >>> > >>> The problem with that, is that the BDI APIs use wake_up_bit(), which calls > >>> virt_to_page() to retrieve the memory zone of the page containing the > >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > >>> highmem addresses. > >>> > >>> Fix this by allocating the BDI objects dynamically with kmalloc. The > >>> objects now fall in the logical address space so that BDI APIs will > >>> work in all cases (mtd builtin or module). > >>> > >>> Signed-off-by: Steve Longerbeam > >>> Signed-off-by: Jim Baxter > >>> Signed-off-by: Sandeep Jain > >> > >> Reviewed-by: Richard Weinberger > > I don't see any obvious problem either: > Reviewed-by: Marek Vasut > > -- > Best regards, > Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
On 11/03/2016 12:34 PM, Sandeep Jain wrote: > Dear Maintainers, > This patch is reviewed by Richard. > Requesting for Maintainer's attention for patch merge. > > Thanks & Regards, > Sandeep Jain > > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jainwrote: >>> From: Steve Longerbeam >>> >>> The MTD backing dev info objects mtd_bdi was statically allocated. >>> So when MTD is built as a loadable module, this object fall in the >>> vmalloc address space. >>> >>> The problem with that, is that the BDI APIs use wake_up_bit(), which calls >>> virt_to_page() to retrieve the memory zone of the page containing the >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or >>> highmem addresses. >>> >>> Fix this by allocating the BDI objects dynamically with kmalloc. The >>> objects now fall in the logical address space so that BDI APIs will >>> work in all cases (mtd builtin or module). >>> >>> Signed-off-by: Steve Longerbeam >>> Signed-off-by: Jim Baxter >>> Signed-off-by: Sandeep Jain >> >> Reviewed-by: Richard Weinberger I don't see any obvious problem either: Reviewed-by: Marek Vasut -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
On 11/03/2016 12:34 PM, Sandeep Jain wrote: > Dear Maintainers, > This patch is reviewed by Richard. > Requesting for Maintainer's attention for patch merge. > > Thanks & Regards, > Sandeep Jain > > On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: >> On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain wrote: >>> From: Steve Longerbeam >>> >>> The MTD backing dev info objects mtd_bdi was statically allocated. >>> So when MTD is built as a loadable module, this object fall in the >>> vmalloc address space. >>> >>> The problem with that, is that the BDI APIs use wake_up_bit(), which calls >>> virt_to_page() to retrieve the memory zone of the page containing the >>> wait_queue to wake up, and virt_to_page() is not valid for vmalloc or >>> highmem addresses. >>> >>> Fix this by allocating the BDI objects dynamically with kmalloc. The >>> objects now fall in the logical address space so that BDI APIs will >>> work in all cases (mtd builtin or module). >>> >>> Signed-off-by: Steve Longerbeam >>> Signed-off-by: Jim Baxter >>> Signed-off-by: Sandeep Jain >> >> Reviewed-by: Richard Weinberger I don't see any obvious problem either: Reviewed-by: Marek Vasut -- Best regards, Marek Vasut
Re: [PATCH] mtd: Allocate bdi objects dynamically
Dear Maintainers, This patch is reviewed by Richard. Requesting for Maintainer's attention for patch merge. Thanks & Regards, Sandeep Jain On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jainwrote: > > From: Steve Longerbeam > > > > The MTD backing dev info objects mtd_bdi was statically allocated. > > So when MTD is built as a loadable module, this object fall in the > > vmalloc address space. > > > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > > virt_to_page() to retrieve the memory zone of the page containing the > > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > > highmem addresses. > > > > Fix this by allocating the BDI objects dynamically with kmalloc. The > > objects now fall in the logical address space so that BDI APIs will > > work in all cases (mtd builtin or module). > > > > Signed-off-by: Steve Longerbeam > > Signed-off-by: Jim Baxter > > Signed-off-by: Sandeep Jain > > Reviewed-by: Richard Weinberger > > -- > Thanks, > //richard
Re: [PATCH] mtd: Allocate bdi objects dynamically
Dear Maintainers, This patch is reviewed by Richard. Requesting for Maintainer's attention for patch merge. Thanks & Regards, Sandeep Jain On Sat, Sep 17, 2016 at 04:41:47PM +0200, Richard Weinberger wrote: > On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain wrote: > > From: Steve Longerbeam > > > > The MTD backing dev info objects mtd_bdi was statically allocated. > > So when MTD is built as a loadable module, this object fall in the > > vmalloc address space. > > > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > > virt_to_page() to retrieve the memory zone of the page containing the > > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > > highmem addresses. > > > > Fix this by allocating the BDI objects dynamically with kmalloc. The > > objects now fall in the logical address space so that BDI APIs will > > work in all cases (mtd builtin or module). > > > > Signed-off-by: Steve Longerbeam > > Signed-off-by: Jim Baxter > > Signed-off-by: Sandeep Jain > > Reviewed-by: Richard Weinberger > > -- > Thanks, > //richard
Re: [PATCH] mtd: Allocate bdi objects dynamically
On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jainwrote: > From: Steve Longerbeam > > The MTD backing dev info objects mtd_bdi was statically allocated. > So when MTD is built as a loadable module, this object fall in the > vmalloc address space. > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > virt_to_page() to retrieve the memory zone of the page containing the > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > highmem addresses. > > Fix this by allocating the BDI objects dynamically with kmalloc. The > objects now fall in the logical address space so that BDI APIs will > work in all cases (mtd builtin or module). > > Signed-off-by: Steve Longerbeam > Signed-off-by: Jim Baxter > Signed-off-by: Sandeep Jain Reviewed-by: Richard Weinberger -- Thanks, //richard
Re: [PATCH] mtd: Allocate bdi objects dynamically
On Thu, Aug 4, 2016 at 4:01 PM, Sandeep Jain wrote: > From: Steve Longerbeam > > The MTD backing dev info objects mtd_bdi was statically allocated. > So when MTD is built as a loadable module, this object fall in the > vmalloc address space. > > The problem with that, is that the BDI APIs use wake_up_bit(), which calls > virt_to_page() to retrieve the memory zone of the page containing the > wait_queue to wake up, and virt_to_page() is not valid for vmalloc or > highmem addresses. > > Fix this by allocating the BDI objects dynamically with kmalloc. The > objects now fall in the logical address space so that BDI APIs will > work in all cases (mtd builtin or module). > > Signed-off-by: Steve Longerbeam > Signed-off-by: Jim Baxter > Signed-off-by: Sandeep Jain Reviewed-by: Richard Weinberger -- Thanks, //richard
[PATCH] mtd: Allocate bdi objects dynamically
From: Steve LongerbeamThe MTD backing dev info objects mtd_bdi was statically allocated. So when MTD is built as a loadable module, this object fall in the vmalloc address space. The problem with that, is that the BDI APIs use wake_up_bit(), which calls virt_to_page() to retrieve the memory zone of the page containing the wait_queue to wake up, and virt_to_page() is not valid for vmalloc or highmem addresses. Fix this by allocating the BDI objects dynamically with kmalloc. The objects now fall in the logical address space so that BDI APIs will work in all cases (mtd builtin or module). Signed-off-by: Steve Longerbeam Signed-off-by: Jim Baxter Signed-off-by: Sandeep Jain --- drivers/mtd/mtdcore.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index e3936b8..9015b94 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -47,8 +47,7 @@ #include "mtdcore.h" -static struct backing_dev_info mtd_bdi = { -}; +static struct backing_dev_info *mtd_bdi; #ifdef CONFIG_PM_SLEEP @@ -397,7 +396,7 @@ int add_mtd_device(struct mtd_info *mtd) if (WARN_ONCE(mtd->backing_dev_info, "MTD already registered\n")) return -EEXIST; - mtd->backing_dev_info = _bdi; + mtd->backing_dev_info = mtd_bdi; BUG_ON(mtd->writesize == 0); mutex_lock(_table_mutex); @@ -1668,18 +1667,20 @@ static const struct file_operations mtd_proc_ops = { /**/ /* Init code */ -static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name) +static struct backing_dev_info * __init mtd_bdi_init(char *name) { + struct backing_dev_info *bdi; int ret; - ret = bdi_init(bdi); - if (!ret) - ret = bdi_register(bdi, NULL, "%s", name); + bdi = kzalloc(sizeof(*bdi), GFP_KERNEL); + if (!bdi) + return ERR_PTR(-ENOMEM); + ret = bdi_setup_and_register(bdi, name); if (ret) - bdi_destroy(bdi); + kfree(bdi); - return ret; + return ret ? ERR_PTR(ret) : bdi; } static struct proc_dir_entry *proc_mtd; @@ -1692,9 +1693,11 @@ static int __init init_mtd(void) if (ret) goto err_reg; - ret = mtd_bdi_init(_bdi, "mtd"); - if (ret) + mtd_bdi = mtd_bdi_init("mtd"); + if (IS_ERR(mtd_bdi)) { + ret = PTR_ERR(mtd_bdi); goto err_bdi; + } proc_mtd = proc_create("mtd", 0, NULL, _proc_ops); @@ -1707,6 +1710,8 @@ static int __init init_mtd(void) out_procfs: if (proc_mtd) remove_proc_entry("mtd", NULL); + bdi_destroy(mtd_bdi); + kfree(mtd_bdi); err_bdi: class_unregister(_class); err_reg: @@ -1720,7 +1725,8 @@ static void __exit cleanup_mtd(void) if (proc_mtd) remove_proc_entry("mtd", NULL); class_unregister(_class); - bdi_destroy(_bdi); + bdi_destroy(mtd_bdi); + kfree(mtd_bdi); idr_destroy(_idr); } -- 1.7.9.5
[PATCH] mtd: Allocate bdi objects dynamically
From: Steve Longerbeam The MTD backing dev info objects mtd_bdi was statically allocated. So when MTD is built as a loadable module, this object fall in the vmalloc address space. The problem with that, is that the BDI APIs use wake_up_bit(), which calls virt_to_page() to retrieve the memory zone of the page containing the wait_queue to wake up, and virt_to_page() is not valid for vmalloc or highmem addresses. Fix this by allocating the BDI objects dynamically with kmalloc. The objects now fall in the logical address space so that BDI APIs will work in all cases (mtd builtin or module). Signed-off-by: Steve Longerbeam Signed-off-by: Jim Baxter Signed-off-by: Sandeep Jain --- drivers/mtd/mtdcore.c | 30 ++ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index e3936b8..9015b94 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -47,8 +47,7 @@ #include "mtdcore.h" -static struct backing_dev_info mtd_bdi = { -}; +static struct backing_dev_info *mtd_bdi; #ifdef CONFIG_PM_SLEEP @@ -397,7 +396,7 @@ int add_mtd_device(struct mtd_info *mtd) if (WARN_ONCE(mtd->backing_dev_info, "MTD already registered\n")) return -EEXIST; - mtd->backing_dev_info = _bdi; + mtd->backing_dev_info = mtd_bdi; BUG_ON(mtd->writesize == 0); mutex_lock(_table_mutex); @@ -1668,18 +1667,20 @@ static const struct file_operations mtd_proc_ops = { /**/ /* Init code */ -static int __init mtd_bdi_init(struct backing_dev_info *bdi, const char *name) +static struct backing_dev_info * __init mtd_bdi_init(char *name) { + struct backing_dev_info *bdi; int ret; - ret = bdi_init(bdi); - if (!ret) - ret = bdi_register(bdi, NULL, "%s", name); + bdi = kzalloc(sizeof(*bdi), GFP_KERNEL); + if (!bdi) + return ERR_PTR(-ENOMEM); + ret = bdi_setup_and_register(bdi, name); if (ret) - bdi_destroy(bdi); + kfree(bdi); - return ret; + return ret ? ERR_PTR(ret) : bdi; } static struct proc_dir_entry *proc_mtd; @@ -1692,9 +1693,11 @@ static int __init init_mtd(void) if (ret) goto err_reg; - ret = mtd_bdi_init(_bdi, "mtd"); - if (ret) + mtd_bdi = mtd_bdi_init("mtd"); + if (IS_ERR(mtd_bdi)) { + ret = PTR_ERR(mtd_bdi); goto err_bdi; + } proc_mtd = proc_create("mtd", 0, NULL, _proc_ops); @@ -1707,6 +1710,8 @@ static int __init init_mtd(void) out_procfs: if (proc_mtd) remove_proc_entry("mtd", NULL); + bdi_destroy(mtd_bdi); + kfree(mtd_bdi); err_bdi: class_unregister(_class); err_reg: @@ -1720,7 +1725,8 @@ static void __exit cleanup_mtd(void) if (proc_mtd) remove_proc_entry("mtd", NULL); class_unregister(_class); - bdi_destroy(_bdi); + bdi_destroy(mtd_bdi); + kfree(mtd_bdi); idr_destroy(_idr); } -- 1.7.9.5