Skip to content

Commit 44504b2

Browse files
committed
of: change of_match_device to work with struct device
The of_node pointer is now stored directly in struct device, so of_match_device() should work with any device, not just struct of_device. This patch changes the interface to of_match_device() to accept a struct device instead of struct of_device. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
1 parent 4018294 commit 44504b2

4 files changed

Lines changed: 9 additions & 12 deletions

File tree

‎drivers/macintosh/macio_asic.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,12 @@ static struct macio_chip *macio_on_hold;
3939

4040
static int macio_bus_match(struct device *dev, struct device_driver *drv)
4141
{
42-
struct macio_dev * macio_dev = to_macio_device(dev);
4342
const struct of_device_id * matches = drv->of_match_table;
4443

4544
if (!matches)
4645
return 0;
4746

48-
return of_match_device(matches, &macio_dev->ofdev) != NULL;
47+
return of_match_device(matches, dev) != NULL;
4948
}
5049

5150
struct macio_dev *macio_dev_get(struct macio_dev *dev)
@@ -83,7 +82,7 @@ static int macio_device_probe(struct device *dev)
8382

8483
macio_dev_get(macio_dev);
8584

86-
match = of_match_device(drv->driver.of_match_table, &macio_dev->ofdev);
85+
match = of_match_device(drv->driver.of_match_table, dev);
8786
if (match)
8887
error = drv->probe(macio_dev, match);
8988
if (error)

‎drivers/of/device.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,19 @@
1010
#include <asm/errno.h>
1111

1212
/**
13-
* of_match_device - Tell if an of_device structure has a matching
14-
* of_match structure
13+
* of_match_device - Tell if a struct device matches an of_device_id list
1514
* @ids: array of of device match structures to search in
1615
* @dev: the of device structure to match against
1716
*
1817
* Used by a driver to check whether an of_device present in the
1918
* system is in its list of supported devices.
2019
*/
2120
const struct of_device_id *of_match_device(const struct of_device_id *matches,
22-
const struct of_device *dev)
21+
const struct device *dev)
2322
{
24-
if (!dev->dev.of_node)
23+
if (!dev->of_node)
2524
return NULL;
26-
return of_match_node(matches, dev->dev.of_node);
25+
return of_match_node(matches, dev->of_node);
2726
}
2827
EXPORT_SYMBOL(of_match_device);
2928

‎drivers/of/platform.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ extern struct device_attribute of_platform_device_attrs[];
2121

2222
static int of_platform_bus_match(struct device *dev, struct device_driver *drv)
2323
{
24-
struct of_device *of_dev = to_of_device(dev);
2524
const struct of_device_id *matches = drv->of_match_table;
2625

2726
if (!matches)
2827
return 0;
2928

30-
return of_match_device(matches, of_dev) != NULL;
29+
return of_match_device(matches, dev) != NULL;
3130
}
3231

3332
static int of_platform_device_probe(struct device *dev)
@@ -45,7 +44,7 @@ static int of_platform_device_probe(struct device *dev)
4544

4645
of_dev_get(of_dev);
4746

48-
match = of_match_device(drv->driver.of_match_table, of_dev);
47+
match = of_match_device(drv->driver.of_match_table, dev);
4948
if (match)
5049
error = drv->probe(of_dev, match);
5150
if (error)

‎include/linux/of_device.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define to_of_device(d) container_of(d, struct of_device, dev)
1212

1313
extern const struct of_device_id *of_match_device(
14-
const struct of_device_id *matches, const struct of_device *dev);
14+
const struct of_device_id *matches, const struct device *dev);
1515

1616
extern struct of_device *of_dev_get(struct of_device *dev);
1717
extern void of_dev_put(struct of_device *dev);

0 commit comments

Comments
 (0)