Skip to content

Commit

Permalink
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-cor…
Browse files Browse the repository at this point in the history
…e-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6: (60 commits)
  uio: make uio_info's name and version const
  UIO: Documentation for UIO ioport info handling
  UIO: Pass information about ioports to userspace (V2)
  UIO: uio_pdrv_genirq: allow custom irq_flags
  UIO: use pci_ioremap_bar() in drivers/uio
  arm: struct device - replace bus_id with dev_name(), dev_set_name()
  libata: struct device - replace bus_id with dev_name(), dev_set_name()
  avr: struct device - replace bus_id with dev_name(), dev_set_name()
  block: struct device - replace bus_id with dev_name(), dev_set_name()
  chris: struct device - replace bus_id with dev_name(), dev_set_name()
  dmi: struct device - replace bus_id with dev_name(), dev_set_name()
  gadget: struct device - replace bus_id with dev_name(), dev_set_name()
  gpio: struct device - replace bus_id with dev_name(), dev_set_name()
  gpu: struct device - replace bus_id with dev_name(), dev_set_name()
  hwmon: struct device - replace bus_id with dev_name(), dev_set_name()
  i2o: struct device - replace bus_id with dev_name(), dev_set_name()
  IA64: struct device - replace bus_id with dev_name(), dev_set_name()
  i7300_idle: struct device - replace bus_id with dev_name(), dev_set_name()
  infiniband: struct device - replace bus_id with dev_name(), dev_set_name()
  ISDN: struct device - replace bus_id with dev_name(), dev_set_name()
  ...
  • Loading branch information
torvalds committed Jan 7, 2009
2 parents 5fec8bd + b8ac9fc commit 40d7ee5
Show file tree
Hide file tree
Showing 129 changed files with 1,063 additions and 701 deletions.
101 changes: 99 additions & 2 deletions Documentation/DocBook/uio-howto.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ GPL version 2.
</abstract>

<revhistory>
<revision>
<revnumber>0.6</revnumber>
<date>2008-12-05</date>
<authorinitials>hjk</authorinitials>
<revremark>Added description of portio sysfs attributes.</revremark>
</revision>
<revision>
<revnumber>0.5</revnumber>
<date>2008-05-22</date>
Expand Down Expand Up @@ -318,6 +324,54 @@ interested in translating it, please email me
offset = N * getpagesize();
</programlisting>

<para>
Sometimes there is hardware with memory-like regions that can not be
mapped with the technique described here, but there are still ways to
access them from userspace. The most common example are x86 ioports.
On x86 systems, userspace can access these ioports using
<function>ioperm()</function>, <function>iopl()</function>,
<function>inb()</function>, <function>outb()</function>, and similar
functions.
</para>
<para>
Since these ioport regions can not be mapped, they will not appear under
<filename>/sys/class/uio/uioX/maps/</filename> like the normal memory
described above. Without information about the port regions a hardware
has to offer, it becomes difficult for the userspace part of the
driver to find out which ports belong to which UIO device.
</para>
<para>
To address this situation, the new directory
<filename>/sys/class/uio/uioX/portio/</filename> was added. It only
exists if the driver wants to pass information about one or more port
regions to userspace. If that is the case, subdirectories named
<filename>port0</filename>, <filename>port1</filename>, and so on,
will appear underneath
<filename>/sys/class/uio/uioX/portio/</filename>.
</para>
<para>
Each <filename>portX/</filename> directory contains three read-only
files that show start, size, and type of the port region:
</para>
<itemizedlist>
<listitem>
<para>
<filename>start</filename>: The first port of this region.
</para>
</listitem>
<listitem>
<para>
<filename>size</filename>: The number of ports in this region.
</para>
</listitem>
<listitem>
<para>
<filename>porttype</filename>: A string describing the type of port.
</para>
</listitem>
</itemizedlist>


</sect1>
</chapter>

Expand All @@ -339,12 +393,12 @@ offset = N * getpagesize();

<itemizedlist>
<listitem><para>
<varname>char *name</varname>: Required. The name of your driver as
<varname>const char *name</varname>: Required. The name of your driver as
it will appear in sysfs. I recommend using the name of your module for this.
</para></listitem>

<listitem><para>
<varname>char *version</varname>: Required. This string appears in
<varname>const char *version</varname>: Required. This string appears in
<filename>/sys/class/uio/uioX/version</filename>.
</para></listitem>

Expand All @@ -355,6 +409,13 @@ mapping you need to fill one of the <varname>uio_mem</varname> structures.
See the description below for details.
</para></listitem>

<listitem><para>
<varname>struct uio_port port[ MAX_UIO_PORTS_REGIONS ]</varname>: Required
if you want to pass information about ioports to userspace. For each port
region you need to fill one of the <varname>uio_port</varname> structures.
See the description below for details.
</para></listitem>

<listitem><para>
<varname>long irq</varname>: Required. If your hardware generates an
interrupt, it's your modules task to determine the irq number during
Expand Down Expand Up @@ -448,6 +509,42 @@ Please do not touch the <varname>kobj</varname> element of
<varname>struct uio_mem</varname>! It is used by the UIO framework
to set up sysfs files for this mapping. Simply leave it alone.
</para>

<para>
Sometimes, your device can have one or more port regions which can not be
mapped to userspace. But if there are other possibilities for userspace to
access these ports, it makes sense to make information about the ports
available in sysfs. For each region, you have to set up a
<varname>struct uio_port</varname> in the <varname>port[]</varname> array.
Here's a description of the fields of <varname>struct uio_port</varname>:
</para>

<itemizedlist>
<listitem><para>
<varname>char *porttype</varname>: Required. Set this to one of the predefined
constants. Use <varname>UIO_PORT_X86</varname> for the ioports found in x86
architectures.
</para></listitem>

<listitem><para>
<varname>unsigned long start</varname>: Required if the port region is used.
Fill in the number of the first port of this region.
</para></listitem>

<listitem><para>
<varname>unsigned long size</varname>: Fill in the number of ports in this
region. If <varname>size</varname> is zero, the region is considered unused.
Note that you <emphasis>must</emphasis> initialize <varname>size</varname>
with zero for all unused regions.
</para></listitem>
</itemizedlist>

<para>
Please do not touch the <varname>portio</varname> element of
<varname>struct uio_port</varname>! It is used internally by the UIO
framework to set up sysfs files for this region. Simply leave it alone.
</para>

</sect1>

<sect1 id="adding_irq_handler">
Expand Down
4 changes: 2 additions & 2 deletions Documentation/kobject.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ the name of the kobject, call kobject_rename():

int kobject_rename(struct kobject *kobj, const char *new_name);

Note kobject_rename does perform any locking or have a solid notion of
what names are valid so the provide must provide their own sanity checking
kobject_rename does not perform any locking or have a solid notion of
what names are valid so the caller must provide their own sanity checking
and serialization.

There is a function called kobject_set_name() but that is legacy cruft and
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/ecard.c
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
ec->dma = NO_DMA;
ec->ops = &ecard_default_ops;

snprintf(ec->dev.bus_id, sizeof(ec->dev.bus_id), "ecard%d", slot);
dev_set_name(&ec->dev, "ecard%d", slot);
ec->dev.parent = NULL;
ec->dev.bus = &ecard_bus_type;
ec->dev.dma_mask = &ec->dma_mask;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-aaec2000/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static struct clcd_board clcd_plat_data = {

static struct amba_device clcd_device = {
.dev = {
.bus_id = "mb:16",
.init_name = "mb:16",
.coherent_dma_mask = ~0,
.platform_data = &clcd_plat_data,
},
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-ep93xx/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ static struct amba_pl010_data ep93xx_uart_data = {

static struct amba_device uart1_device = {
.dev = {
.bus_id = "apb:uart1",
.init_name = "apb:uart1",
.platform_data = &ep93xx_uart_data,
},
.res = {
Expand All @@ -423,7 +423,7 @@ static struct amba_device uart1_device = {

static struct amba_device uart2_device = {
.dev = {
.bus_id = "apb:uart2",
.init_name = "apb:uart2",
.platform_data = &ep93xx_uart_data,
},
.res = {
Expand All @@ -437,7 +437,7 @@ static struct amba_device uart2_device = {

static struct amba_device uart3_device = {
.dev = {
.bus_id = "apb:uart3",
.init_name = "apb:uart3",
.platform_data = &ep93xx_uart_data,
},
.res = {
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/mach-integrator/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static struct amba_pl010_data integrator_uart_data;

static struct amba_device rtc_device = {
.dev = {
.bus_id = "mb:15",
.init_name = "mb:15",
},
.res = {
.start = INTEGRATOR_RTC_BASE,
Expand All @@ -50,7 +50,7 @@ static struct amba_device rtc_device = {

static struct amba_device uart0_device = {
.dev = {
.bus_id = "mb:16",
.init_name = "mb:16",
.platform_data = &integrator_uart_data,
},
.res = {
Expand All @@ -64,7 +64,7 @@ static struct amba_device uart0_device = {

static struct amba_device uart1_device = {
.dev = {
.bus_id = "mb:17",
.init_name = "mb:17",
.platform_data = &integrator_uart_data,
},
.res = {
Expand All @@ -78,7 +78,7 @@ static struct amba_device uart1_device = {

static struct amba_device kmi0_device = {
.dev = {
.bus_id = "mb:18",
.init_name = "mb:18",
},
.res = {
.start = KMI0_BASE,
Expand All @@ -91,7 +91,7 @@ static struct amba_device kmi0_device = {

static struct amba_device kmi1_device = {
.dev = {
.bus_id = "mb:19",
.init_name = "mb:19",
},
.res = {
.start = KMI1_BASE,
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-integrator/integrator_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ static struct mmc_platform_data mmc_data = {

static struct amba_device mmc_device = {
.dev = {
.bus_id = "mb:1c",
.init_name = "mb:1c",
.platform_data = &mmc_data,
},
.res = {
Expand All @@ -421,7 +421,7 @@ static struct amba_device mmc_device = {

static struct amba_device aaci_device = {
.dev = {
.bus_id = "mb:1d",
.init_name = "mb:1d",
},
.res = {
.start = INTCP_PA_AACI_BASE,
Expand Down Expand Up @@ -532,7 +532,7 @@ static struct clcd_board clcd_data = {

static struct amba_device clcd_device = {
.dev = {
.bus_id = "mb:c0",
.init_name = "mb:c0",
.coherent_dma_mask = ~0,
.platform_data = &clcd_data,
},
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-lh7a40x/clcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ static struct clcd_board clcd_platform_data = {
static struct amba_device name##_device = { \
.dev = { \
.coherent_dma_mask = ~0, \
.bus_id = busid, \
.init_name = busid, \
.platform_data = plat, \
}, \
.res = { \
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-netx/fb.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void clk_put(struct clk *clk)

static struct amba_device fb_device = {
.dev = {
.bus_id = "fb",
.init_name = "fb",
.coherent_dma_mask = ~0,
},
.res = {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-realview/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
static struct amba_device name##_device = { \
.dev = { \
.coherent_dma_mask = ~0, \
.bus_id = busid, \
.init_name = busid, \
.platform_data = plat, \
}, \
.res = { \
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-versatile/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern unsigned int mmc_status(struct device *dev);
static struct amba_device name##_device = { \
.dev = { \
.coherent_dma_mask = ~0, \
.bus_id = busid, \
.init_name = busid, \
.platform_data = plat, \
}, \
.res = { \
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/plat-omap/include/mach/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

#define virt_to_lbus(x) ((x) - PAGE_OFFSET + OMAP1510_LB_OFFSET)
#define lbus_to_virt(x) ((x) - OMAP1510_LB_OFFSET + PAGE_OFFSET)
#define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev->bus_id, "ohci", 4) == 0))
#define is_lbus_device(dev) (cpu_is_omap15xx() && dev && (strncmp(dev_name(dev), "ohci", 4) == 0))

#define __arch_page_to_dma(dev, page) ({is_lbus_device(dev) ? \
(dma_addr_t)virt_to_lbus(page_address(page)) : \
Expand Down
4 changes: 2 additions & 2 deletions arch/avr32/mach-at32ap/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ dump_clock(struct clk *parent, struct clkinf *r)
unsigned i;

/* skip clocks coupled to devices that aren't registered */
if (parent->dev && !parent->dev->bus_id[0] && !parent->users)
if (parent->dev && !dev_name(parent->dev) && !parent->users)
return;

/* <nest spaces> name <pad to end> */
Expand All @@ -214,7 +214,7 @@ dump_clock(struct clk *parent, struct clkinf *r)
parent->users ? "on" : "off", /* NOTE: not-paranoid!! */
clk_get_rate(parent));
if (parent->dev)
seq_printf(r->s, ", for %s", parent->dev->bus_id);
seq_printf(r->s, ", for %s", dev_name(parent->dev));
seq_printf(r->s, "\n");

/* cost of this scan is small, but not linear... */
Expand Down
6 changes: 3 additions & 3 deletions arch/cris/arch-v32/drivers/iop_fw_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
#error "Please contact <[email protected]> for details on how to fix it properly."

static struct device iop_spu_device[2] = {
{ .bus_id = "iop-spu0", },
{ .bus_id = "iop-spu1", },
{ .init_name = "iop-spu0", },
{ .init_name = "iop-spu1", },
};

static struct device iop_mpu_device = {
.bus_id = "iop-mpu",
.init_name = "iop-mpu",
};

static int wait_mpu_idle(void)
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/kernel/pci-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int iommu_detected __read_mostly;
be probably a smaller DMA mask, but this is bug-to-bug compatible
to i386. */
struct device fallback_dev = {
.bus_id = "fallback device",
.init_name = "fallback device",
.coherent_dma_mask = DMA_32BIT_MASK,
.dma_mask = &fallback_dev.coherent_dma_mask,
};
Expand Down
3 changes: 1 addition & 2 deletions arch/ia64/sn/kernel/tiocx.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ cx_device_register(nasid_t nasid, int part_num, int mfg_num,
cx_dev->dev.parent = NULL;
cx_dev->dev.bus = &tiocx_bus_type;
cx_dev->dev.release = tiocx_bus_release;
snprintf(cx_dev->dev.bus_id, BUS_ID_SIZE, "%d",
cx_dev->cx_id.nasid);
dev_set_name(&cx_dev->dev, "%d", cx_dev->cx_id.nasid);
device_register(&cx_dev->dev);
get_device(&cx_dev->dev);

Expand Down
2 changes: 1 addition & 1 deletion arch/mips/kernel/vpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ static int __init vpe_module_init(void)
device_initialize(&vpe_device);
vpe_device.class = &vpe_class,
vpe_device.parent = NULL,
strlcpy(vpe_device.bus_id, "vpe1", BUS_ID_SIZE);
dev_set_name(&vpe_device, "vpe1");
vpe_device.devt = MKDEV(major, minor);
err = device_add(&vpe_device);
if (err) {
Expand Down
15 changes: 0 additions & 15 deletions arch/s390/include/asm/s390_rdev.h

This file was deleted.

Loading

0 comments on commit 40d7ee5

Please sign in to comment.