*sigh* HELP HELP HELP

Abraham vd Merwe abraham at 2d3d.co.za
Wed Jun 6 11:43:09 EDT 2001


Hi Abraham!

Dope, sorry. Found the mistake *blush* I didn't pass a reference to the
region structure in the ioctl().

> Maybe somebody can help here. I've been struggling with this for the past
> half an hour and I can't figure out what's wrong:
> 
> I'm doing a MEMGETREGIONINFO ioctl() as such:
> 
> ------------< snip <------< snip <------< snip <------------
> static int getregions (int fd,struct region_info_user *regions,int *n)
> {
>    int i,err;
>    err = ioctl (fd,MEMGETREGIONCOUNT,n);
>    if (err) return (err);
>    for (i = 0; i < *n; i++)
>      {
>         regions[i].regionindex = i;
>         fprintf (stderr,"%d: regions[%d].regionindex =
> %d\n",__LINE__,i,regions[i].regionindex);
>         err = ioctl (fd,MEMGETREGIONINFO,regions[i]);
>         if (err) return (err);
>      }
>    return (0);
> }
> ------------< snip <------< snip <------< snip <------------
> 
> which in turn I call as such:
> 
> ------------< snip <------< snip <------< snip <------------
>    static struct region_info_user region[1024];
> 
> .
> .
> .
> 
>    err = getregions (fd,region,&n);
>    if (err < 0)
>      {
>         perror ("MEMGETREGIONCOUNT");
>         return;
>      }
> ------------< snip <------< snip <------< snip <------------
> 
> When I run the test program I get:
> 
> ------------< snip <------< snip <------< snip <------------
> root at tinystor:~# ./mtd_debug info
> 43: regions[0].regionindex = 0
> MEMGETREGIONCOUNT: Bad address
> root at tinystor:~#
> ------------< snip <------< snip <------< snip <------------
> 
> I can't find a problem with the user program nor with my driver (I can print
> the mtd->eraseregions structures from the chip driver and it works perfectly)
> 
> Any ideas? What am I doing wrong?

-- 

Regards
 Abraham

I have no doubt the Devil grins,
As seas of ink I spatter.
Ye gods, forgive my "literary" sins--
The other kind don't matter.
		-- Robert W. Service

__________________________________________________________
 Abraham vd Merwe - 2d3D, Inc.

 Device Driver Development, Outsourcing, Embedded Systems

  Cell: +27 82 565 4451         Snailmail:
   Tel: +27 21 761 7549            Block C, Antree Park
   Fax: +27 21 761 7648            Doncaster Road
 Email: abraham at 2d3d.co.za         Kenilworth, 7700
  Http: http://www.2d3d.com        South Africa

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.infradead.org/pipermail/linux-mtd/attachments/20010606/c5960fe9/attachment.bin 


More information about the linux-mtd mailing list