Skip to contentSkip to conversation

When to use mtd.h or mtd-user.h

DISCUSSION MikeW 5 participants 9 messages May 15, 2007 – May 17, 2007 Memory technology devices (MTD)

lore
Share & tools
lore

MikeW

author
#0 lore raw

I note some applications for running in userspace say:
#include <linux/mtd/mtd.h>
and some say
#include <mtd/mtd-user.h>

Which is the recommended usage, and why ?

Many thanks,
MikeW

#1 lore raw
Quoted 2 lines · MikeW

I note some applications for running in userspace say:
#include <linux/mtd/mtd.h>

Er, which ones? I don't see anything in mtd-utils that does that.

Quoted 4 lines

and some say
#include <mtd/mtd-user.h>

Which is the recommended usage, and why ?

mtd-user.h because it's been sanitized for inclusion in userspace.

josh

#2 lore raw
In reply to MikeW
Quoted 6 lines · MikeW

I note some applications for running in userspace say:
#include <linux/mtd/mtd.h>
and some say
#include <mtd/mtd-user.h>

Which is the recommended usage, and why ?

i'm not even sure where that first header file would be coming from. it's not part of glibc, and it's not created as part of the sanitized headers by the kernel. are you sure you've seen that in someone's *userspace* code? and the inclusion worked?

in any event, it's that second header file that's correct.

rday

Signature · 7 lines
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================
author
#3 lore raw
Quoted 10 lines · Robert P. J. Day <rpjday <at> mindspring.com> writes:

i'm not even sure where that first header file would be coming from. it's not part of glibc, and it's not created as part of the sanitized headers by the kernel. are you sure you've seen that in someone's *userspace* code? and the inclusion worked?

in any event, it's that second header file that's correct.

rday

The line #include <linux/mtd/mtd.h> is taken from uboot/tools/env/fw_env.c from www.denx.de (v.1.1.4)

There's another usage in openwrt/package/mtd/mtd.c

Both are intended to run as userspace apps.
However, making the mtd-user.h patch allows them to build without complaint.

Thanks,
MikeW

author
#4 lore raw
In reply to MikeW
Quoted 10 lines · MikeW <mw_phil <at> yahoo.co.uk> writes:

I note some applications for running in userspace say:
#include <linux/mtd/mtd.h>
and some say
#include <mtd/mtd-user.h>

Which is the recommended usage, and why ?

Many thanks,
MikeW

Incidentally, I did actually realise which was the *correct* usage, but I wondered why anyone (especially uBoot) would use the other.

Thanks for the comments,
MikeW

#5 lore raw
Quoted 2 lines · MikeW

Incidentally, I did actually realise which was the *correct* usage, but I wondered why anyone (especially uBoot) would use the other.

Because most people send questions but not patches :-) ?

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
author
#6 lore raw
Quoted 7 lines · Artem Bityutskiy <dedekind <at> infradead.org> writes:
Quoted 2 lines · MikeW

Incidentally, I did actually realise which was the *correct* usage, but I wondered why anyone (especially uBoot) would use the other.

Because most people send questions but not patches ?

Trouble is, the people with the questions do not usually consider themselves authoritative enough to send in a patch, since they feel (possibly correctly!) that they do not know the system well enough to be aware of implications of what on the face of it might be a simple 'correction'.

In which case, those who *are* authoritative may, if they have the time and inclination, pick up on the issue and make the correction!

But I would submit patches if I felt sufficiently knowledgeable in the relevant area of code.

Regards,
MikeW (мАйк)

#7 lore raw
Quoted 2 lines · MikeW

In which case, those who *are* authoritative may, if they have the time and inclination, pick up on the issue and make the correction!

But now when you know which header is correct, you could send a patch to uBoot. Also, when you got some answers to some questions, you could send a patch against mtd-www.git and add a FAQ entry. And so on. :-)

Quoted 2 lines

Regards,
MikeW (мАйк)

:-) МайкВ

Signature · 2 lines
Best regards,
Artem Bityutskiy (Битюцкий Артём)
#8 lore raw
In reply to MikeW
Quoted 6 lines · In message <[email protected]> you wrote:

I note some applications for running in userspace say:
#include <linux/mtd/mtd.h>
and some say
#include <mtd/mtd-user.h>

Which is the recommended usage, and why ?

<linux/mtd/mtd.h> used to be used on very old (2.4) kernel versions; <mtd/mtd-user.h> has to be used now.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: [email protected]
The biggest difference between time and space is that you can't reuse
time.                                                 - Merrick Furst