[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH v2] nandwrite: implement -n (read/write without ecc)
From:       Bartosz_Gołaszewski <bartekgola () gmail ! com>
Date:       2015-11-16 20:44:30
Message-ID: CAFdkumgCqs=JGOTQeJ9ErqGJ+HhNSFYxT9kKesRhqGx69Q2PhQ () mail ! gmail ! com
[Download RAW message or body]

2015-11-16 21:23 GMT+01:00 Baruch Siach <baruch@tkos.co.il>:
> Hi Aaro,
>
> On Mon, Nov 16, 2015 at 10:14:05PM +0200, Aaro Koskinen wrote:
>> On Mon, Nov 16, 2015 at 06:20:51AM +0200, Baruch Siach wrote:
>> > On Mon, Nov 16, 2015 at 02:10:53AM +0200, Aaro Koskinen wrote:
>> > > @@ -144,6 +147,9 @@ int nandwrite_main(int argc UNUSED_PARAM, char **argv)
>> > >   fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY);
>> > >   xioctl(fd, MEMGETINFO, &meminfo);
>> > >
>> > > + if ((opts & OPT_n) && ioctl(fd, MTDFILEMODE, MTD_FILE_MODE_RAW))
>> > > +         bb_simple_perror_msg_and_die("MTDFILEMODE");
>> >
>> > Why not just use xioctl instead of open coding it?
>>
>> xioctl() takes pointer argument.
>
> So how about
>
>    xioctl(fd, MTDFILEMODE, (void *)MTD_FILE_MODE_RAW);
>

There's

static ALWAYS_INLINE void *itoptr(int i)
{
    return (void*)(intptr_t)i;
}

that I used in i2c-tools implementation. You can always move it to
include/libbb.h and reuse it.

-- 
Best regards,
Bartosz Golaszewski
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic