Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 4168
b: refs/heads/master
c: 1071774
h: refs/heads/master
v: v3
  • Loading branch information
Linus Torvalds committed Jul 6, 2005
1 parent 6242922 commit 7485919
Show file tree
Hide file tree
Showing 26 changed files with 227 additions and 100 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 450008b5a62bb09445ae05c4d01d510386c9435d
refs/heads/master: 107177410b754b597028e430725bc3b316936b6b
15 changes: 8 additions & 7 deletions trunk/arch/ppc/syslib/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <asm/errno.h>
#include <asm/of_device.h>

Expand All @@ -15,20 +16,20 @@
* Used by a driver to check whether an of_device present in the
* system is in its list of supported devices.
*/
const struct of_match * of_match_device(const struct of_match *matches,
const struct of_device_id * of_match_device(const struct of_device_id *matches,
const struct of_device *dev)
{
if (!dev->node)
return NULL;
while (matches->name || matches->type || matches->compatible) {
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1;
if (matches->name && matches->name != OF_ANY_MATCH)
if (matches->name[0])
match &= dev->node->name
&& !strcmp(matches->name, dev->node->name);
if (matches->type && matches->type != OF_ANY_MATCH)
if (matches->type[0])
match &= dev->node->type
&& !strcmp(matches->type, dev->node->type);
if (matches->compatible && matches->compatible != OF_ANY_MATCH)
if (matches->compatible[0])
match &= device_is_compatible(dev->node,
matches->compatible);
if (match)
Expand All @@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
{
struct of_device * of_dev = to_of_device(dev);
struct of_platform_driver * of_drv = to_of_platform_driver(drv);
const struct of_match * matches = of_drv->match_table;
const struct of_device_id * matches = of_drv->match_table;

if (!matches)
return 0;
Expand Down Expand Up @@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev)
int error = -ENODEV;
struct of_platform_driver *drv;
struct of_device *of_dev;
const struct of_match *match;
const struct of_device_id *match;

drv = to_of_platform_driver(dev->driver);
of_dev = to_of_device(dev);
Expand Down
15 changes: 8 additions & 7 deletions trunk/arch/ppc64/kernel/of_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <asm/errno.h>
#include <asm/of_device.h>

Expand All @@ -15,20 +16,20 @@
* Used by a driver to check whether an of_device present in the
* system is in its list of supported devices.
*/
const struct of_match * of_match_device(const struct of_match *matches,
const struct of_device_id *of_match_device(const struct of_device_id *matches,
const struct of_device *dev)
{
if (!dev->node)
return NULL;
while (matches->name || matches->type || matches->compatible) {
while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1;
if (matches->name && matches->name != OF_ANY_MATCH)
if (matches->name[0])
match &= dev->node->name
&& !strcmp(matches->name, dev->node->name);
if (matches->type && matches->type != OF_ANY_MATCH)
if (matches->type[0])
match &= dev->node->type
&& !strcmp(matches->type, dev->node->type);
if (matches->compatible && matches->compatible != OF_ANY_MATCH)
if (matches->compatible[0])
match &= device_is_compatible(dev->node,
matches->compatible);
if (match)
Expand All @@ -42,7 +43,7 @@ static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
{
struct of_device * of_dev = to_of_device(dev);
struct of_platform_driver * of_drv = to_of_platform_driver(drv);
const struct of_match * matches = of_drv->match_table;
const struct of_device_id * matches = of_drv->match_table;

if (!matches)
return 0;
Expand Down Expand Up @@ -75,7 +76,7 @@ static int of_device_probe(struct device *dev)
int error = -ENODEV;
struct of_platform_driver *drv;
struct of_device *of_dev;
const struct of_match *match;
const struct of_device_id *match;

drv = to_of_platform_driver(dev->driver);
of_dev = to_of_device(dev);
Expand Down
7 changes: 3 additions & 4 deletions trunk/drivers/i2c/busses/i2c-keywest.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ dispose_iface(struct device *dev)
}

static int
create_iface_macio(struct macio_dev* dev, const struct of_match *match)
create_iface_macio(struct macio_dev* dev, const struct of_device_id *match)
{
return create_iface(dev->ofdev.node, &dev->ofdev.dev);
}
Expand All @@ -710,7 +710,7 @@ dispose_iface_macio(struct macio_dev* dev)
}

static int
create_iface_of_platform(struct of_device* dev, const struct of_match *match)
create_iface_of_platform(struct of_device* dev, const struct of_device_id *match)
{
return create_iface(dev->node, &dev->dev);
}
Expand All @@ -721,10 +721,9 @@ dispose_iface_of_platform(struct of_device* dev)
return dispose_iface(&dev->dev);
}

static struct of_match i2c_keywest_match[] =
static struct of_device_id i2c_keywest_match[] =
{
{
.name = OF_ANY_MATCH,
.type = "i2c",
.compatible = "keywest"
},
Expand Down
12 changes: 2 additions & 10 deletions trunk/drivers/ide/ppc/pmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *pmif, ide_hwif_t *hwif)
* Attach to a macio probed interface
*/
static int __devinit
pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
{
void __iomem *base;
unsigned long regbase;
Expand Down Expand Up @@ -1637,27 +1637,19 @@ pmac_ide_pci_resume(struct pci_dev *pdev)
return rc;
}

static struct of_match pmac_ide_macio_match[] =
static struct of_device_id pmac_ide_macio_match[] =
{
{
.name = "IDE",
.type = OF_ANY_MATCH,
.compatible = OF_ANY_MATCH
},
{
.name = "ATA",
.type = OF_ANY_MATCH,
.compatible = OF_ANY_MATCH
},
{
.name = OF_ANY_MATCH,
.type = "ide",
.compatible = OF_ANY_MATCH
},
{
.name = OF_ANY_MATCH,
.type = "ata",
.compatible = OF_ANY_MATCH
},
{},
};
Expand Down
4 changes: 2 additions & 2 deletions trunk/drivers/ieee1394/ieee1394_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ struct hpsb_packet {

/* These are core internal. */
signed char tlabel;
char ack_code;
char tcode;
signed char ack_code;
unsigned char tcode;

unsigned expect_response:1;
unsigned no_waiter:1;
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/macintosh/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

# Each configuration option enables a list of files.

obj-$(CONFIG_PPC_PMAC) += macio_asic.o
obj-$(CONFIG_PPC_PMAC) += macio_asic.o macio_sysfs.o

obj-$(CONFIG_PMAC_MEDIABAY) += mediabay.o
obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o
Expand Down
78 changes: 76 additions & 2 deletions trunk/drivers/macintosh/macio_asic.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static int macio_bus_match(struct device *dev, struct device_driver *drv)
{
struct macio_dev * macio_dev = to_macio_device(dev);
struct macio_driver * macio_drv = to_macio_driver(drv);
const struct of_match * matches = macio_drv->match_table;
const struct of_device_id * matches = macio_drv->match_table;

if (!matches)
return 0;
Expand Down Expand Up @@ -66,7 +66,7 @@ static int macio_device_probe(struct device *dev)
int error = -ENODEV;
struct macio_driver *drv;
struct macio_dev *macio_dev;
const struct of_match *match;
const struct of_device_id *match;

drv = to_macio_driver(dev->driver);
macio_dev = to_macio_device(dev);
Expand Down Expand Up @@ -126,11 +126,85 @@ static int macio_device_resume(struct device * dev)
return 0;
}

static int macio_hotplug (struct device *dev, char **envp, int num_envp,
char *buffer, int buffer_size)
{
struct macio_dev * macio_dev;
struct of_device * of;
char *scratch, *compat;
int i = 0;
int length = 0;
int cplen, seen = 0;

if (!dev)
return -ENODEV;

macio_dev = to_macio_device(dev);
if (!macio_dev)
return -ENODEV;

of = &macio_dev->ofdev;
scratch = buffer;

/* stuff we want to pass to /sbin/hotplug */
envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
of->node->name);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
++length;
scratch += length;

envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
of->node->type);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
++length;
scratch += length;

/* Since the compatible field can contain pretty much anything
* it's not really legal to split it out with commas. We split it
* up using a number of environment variables instead. */

compat = (char *) get_property(of->node, "compatible", &cplen);
while (compat && cplen > 0) {
int l;
envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length,
"OF_COMPATIBLE_%d=%s", seen, compat);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
length++;
scratch += length;
l = strlen (compat) + 1;
compat += l;
cplen -= l;
seen++;
}

envp[i++] = scratch;
length += scnprintf (scratch, buffer_size - length,
"OF_COMPATIBLE_N=%d", seen);
if ((buffer_size - length <= 0) || (i >= num_envp))
return -ENOMEM;
++length;
scratch += length;

envp[i] = NULL;

return 0;
}

extern struct device_attribute macio_dev_attrs[];

struct bus_type macio_bus_type = {
.name = "macio",
.match = macio_bus_match,
.hotplug = macio_hotplug,
.suspend = macio_device_suspend,
.resume = macio_device_resume,
.dev_attrs = macio_dev_attrs,
};

static int __init macio_bus_driver_init(void)
Expand Down
50 changes: 50 additions & 0 deletions trunk/drivers/macintosh/macio_sysfs.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include <linux/config.h>
#include <linux/kernel.h>
#include <linux/stat.h>
#include <asm/macio.h>


#define macio_config_of_attr(field, format_string) \
static ssize_t \
field##_show (struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
struct macio_dev *mdev = to_macio_device (dev); \
return sprintf (buf, format_string, mdev->ofdev.node->field); \
}

static ssize_t
compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
{
struct of_device *of;
char *compat;
int cplen;
int length = 0;

of = &to_macio_device (dev)->ofdev;
compat = (char *) get_property(of->node, "compatible", &cplen);
if (!compat) {
*buf = '\0';
return 0;
}
while (cplen > 0) {
int l;
length += sprintf (buf, "%s\n", compat);
buf += length;
l = strlen (compat) + 1;
compat += l;
cplen -= l;
}

return length;
}

macio_config_of_attr (name, "%s\n");
macio_config_of_attr (type, "%s\n");

struct device_attribute macio_dev_attrs[] = {
__ATTR_RO(name),
__ATTR_RO(type),
__ATTR_RO(compatible),
__ATTR_NULL
};
7 changes: 2 additions & 5 deletions trunk/drivers/macintosh/mediabay.c
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ static int __pmac media_bay_task(void *x)
}
}

static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_match *match)
static int __devinit media_bay_attach(struct macio_dev *mdev, const struct of_device_id *match)
{
struct media_bay_info* bay;
u32 __iomem *regbase;
Expand Down Expand Up @@ -797,23 +797,20 @@ static struct mb_ops keylargo_mb_ops __pmacdata = {
* Therefore we do it all by polling the media bay once each tick.
*/

static struct of_match media_bay_match[] =
static struct of_device_id media_bay_match[] =
{
{
.name = "media-bay",
.type = OF_ANY_MATCH,
.compatible = "keylargo-media-bay",
.data = &keylargo_mb_ops,
},
{
.name = "media-bay",
.type = OF_ANY_MATCH,
.compatible = "heathrow-media-bay",
.data = &heathrow_mb_ops,
},
{
.name = "media-bay",
.type = OF_ANY_MATCH,
.compatible = "ohare-media-bay",
.data = &ohare_mb_ops,
},
Expand Down
Loading

0 comments on commit 7485919

Please sign in to comment.