public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Yang Rui Rui <ruirui.r.yang@tieto.com>
To: "Artem.Bityutskiy@nokia.com" <Artem.Bityutskiy@nokia.com>
Cc: Yang Ruirui R <ruirui.r.yang@tietoenator.com>,
	"ext-phil.2.carmody@nokia.com" <ext-phil.2.carmody@nokia.com>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	"ext-jani.1.nikula@nokia.com" <ext-jani.1.nikula@nokia.com>
Subject: Re: [PATCH 02/02] force module loaded with partitions set
Date: Mon, 14 Mar 2011 17:12:57 +0800	[thread overview]
Message-ID: <4D7DDC19.6080404@tieto.com> (raw)
In-Reply-To: <1300092812.2727.9.camel@localhost>

On 03/14/2011 04:53 PM, Artem Bityutskiy wrote:
> On Mon, 2011-03-14 at 16:57 +0800, Yang Rui Rui wrote:
>> On 03/14/2011 04:43 PM, Artem Bityutskiy wrote:
>>> On Mon, 2011-03-14 at 09:51 +0800, Yang Ruirui wrote:
>>>> From: Yang Ruirui<ruirui.r.yang@tieto.com>
>>>>
>>>> partitions can not be set after module loaded, the moduel param
>> mode is 0444.
>>>>
>>>> this patch force module loaded with param partitions set, if user
>> does not
>>>> set partitions then give out a warning and return -EINVAL
>>>>
>>>> Signed-off-by: Yang Ruirui<ruirui.r.yang@tieto.com>
>>>> Tested-by: Shao Yanqing<yanqing.shao@tieto.com>
>>>> Tested-by: Xiao Yang<yang.xiao@tieto.com>
>>>> ---
>>>>    drivers/mtd/mtdswap.c |    6 ++++++
>>>>    1 file changed, 6 insertions(+)
>>>>
>>>> --- mtd-2.6-fc2ff59.orig/drivers/mtd/mtdswap.c	2011-03-14
>> 09:36:09.283329099 +0800
>>>> +++ mtd-2.6-fc2ff59/drivers/mtd/mtdswap.c	2011-03-14
>> 09:46:30.229993534 +0800
>>>> @@ -1569,6 +1569,12 @@ static struct mtd_blktrans_ops mtdswap_o
>>>>
>>>>    static int __init mtdswap_modinit(void)
>>>>    {
>>>> +	if (!partitions[0]) {
>>>> +		printk(KERN_WARNING
>>>> +			"Please load mtdswap with correct partitions param\n");
>>>> +		return -EINVAL;
>>>> +	}
>>>
>>> I think a similar check is done in mtdswap_add_mtd() ?
>>>
>>>
>>
>> Yes, that one should be removed if this is ok. This module just waste
>> memory without partitions set. And there's no chance to pass in the
>> params.
>
> I agree that the problem you are solving exist. But I think I do not
> agree with the solution. There are many other ways to end up with
> mtdswap module loaded but not functioning, e.g., users passes incorrect
> module parameters. Basically, any failed check in 'mtdswap_add_mtd()'.
>
> IOW, you are solving just one of many similar issues.

Right, agree.

>
> I think you should rather re-work the framework a bit and make the
> "->add_mtd()" call-back return an integer error code. Then we could just
> return errors on error and prevent the module from being loaded.
>

I'm thinking is it possible to pass partitions param later? ie. use sysfs attribute?

Anyway, I will check the code again to see if can change as your suggestion.

-- 
Thanks
Yang Ruirui

  reply	other threads:[~2011-03-14  9:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-14  1:51 [PATCH 02/02] force module loaded with partitions set Yang Ruirui
2011-03-14  8:43 ` Artem Bityutskiy
2011-03-14  8:57   ` Yang Rui Rui
2011-03-14  8:53     ` Artem Bityutskiy
2011-03-14  9:12       ` Yang Rui Rui [this message]
2011-03-14  9:33         ` Artem Bityutskiy
2011-03-17  8:50           ` Yang Rui Rui
2011-03-17  8:51             ` Artem Bityutskiy
2011-03-17  9:24               ` Yang Rui Rui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D7DDC19.6080404@tieto.com \
    --to=ruirui.r.yang@tieto.com \
    --cc=Artem.Bityutskiy@nokia.com \
    --cc=dwmw2@infradead.org \
    --cc=ext-jani.1.nikula@nokia.com \
    --cc=ext-phil.2.carmody@nokia.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=ruirui.r.yang@tietoenator.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox