Message ID | 1560534863-15115-24-git-send-email-suzuki.poulose@arm.com |
---|---|
State | New |
Headers | show |
Series | [v2,01/28] staging: most-core: Use bus_find_device_by_name | expand |
On Fri, 14 Jun 2019, Suzuki K Poulose wrote: > Add a wrapper to driver_find_device() to search for a device > by the of_node pointer, reusing the generic match function. > Also convert the existing users to make use of the new helper. > > Cc: Lee Jones <lee.jones@linaro.org> > Cc: Thor Thayer <thor.thayer@linux.intel.com> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > Cc: "Rafael J. Wysocki" <rafael@kernel.org> > Acked-by: Thor Thayer <thor.thayer@linux.intel.com> > Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> > --- > drivers/amba/tegra-ahb.c | 11 +---------- > drivers/mfd/altera-sysmgr.c | 14 ++------------ > include/linux/device.h | 13 +++++++++++++ > 3 files changed, 16 insertions(+), 22 deletions(-) Looks good to me. For the MFD part. For my own reference: Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org> What is the merge plan? -- Lee Jones [李琼斯] Linaro Services Technical Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Hi Lee On 07/25/2019 11:51 AM, Lee Jones wrote: > On Fri, 14 Jun 2019, Suzuki K Poulose wrote: > >> Add a wrapper to driver_find_device() to search for a device >> by the of_node pointer, reusing the generic match function. >> Also convert the existing users to make use of the new helper. >> >> Cc: Lee Jones <lee.jones@linaro.org> >> Cc: Thor Thayer <thor.thayer@linux.intel.com> >> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> Cc: "Rafael J. Wysocki" <rafael@kernel.org> >> Acked-by: Thor Thayer <thor.thayer@linux.intel.com> >> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> >> --- >> drivers/amba/tegra-ahb.c | 11 +---------- >> drivers/mfd/altera-sysmgr.c | 14 ++------------ >> include/linux/device.h | 13 +++++++++++++ >> 3 files changed, 16 insertions(+), 22 deletions(-) > > Looks good to me. For the MFD part. > > For my own reference: > Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org> Thanks ! Btw, v3 has been posted based on 5.3-rc1. You are in Cc for that. > > What is the merge plan? > With v3, it looks more sensible to merge the patch via Greg's tree. Suzuki
diff --git a/drivers/amba/tegra-ahb.c b/drivers/amba/tegra-ahb.c index aa64eec..57d3b2e 100644 --- a/drivers/amba/tegra-ahb.c +++ b/drivers/amba/tegra-ahb.c @@ -134,22 +134,13 @@ static inline void gizmo_writel(struct tegra_ahb *ahb, u32 value, u32 offset) } #ifdef CONFIG_TEGRA_IOMMU_SMMU -static int tegra_ahb_match_by_smmu(struct device *dev, const void *data) -{ - struct tegra_ahb *ahb = dev_get_drvdata(dev); - const struct device_node *dn = data; - - return (ahb->dev->of_node == dn) ? 1 : 0; -} - int tegra_ahb_enable_smmu(struct device_node *dn) { struct device *dev; u32 val; struct tegra_ahb *ahb; - dev = driver_find_device(&tegra_ahb_driver.driver, NULL, dn, - tegra_ahb_match_by_smmu); + dev = driver_find_device_by_of_node(&tegra_ahb_driver.driver, dn); if (!dev) return -EPROBE_DEFER; ahb = dev_get_drvdata(dev); diff --git a/drivers/mfd/altera-sysmgr.c b/drivers/mfd/altera-sysmgr.c index 2ee14d8..d2a13a5 100644 --- a/drivers/mfd/altera-sysmgr.c +++ b/drivers/mfd/altera-sysmgr.c @@ -88,16 +88,6 @@ static struct regmap_config altr_sysmgr_regmap_cfg = { }; /** - * sysmgr_match_phandle - * Matching function used by driver_find_device(). - * Return: True if match is found, otherwise false. - */ -static int sysmgr_match_phandle(struct device *dev, const void *data) -{ - return dev->of_node == (const struct device_node *)data; -} - -/** * altr_sysmgr_regmap_lookup_by_phandle * Find the sysmgr previous configured in probe() and return regmap property. * Return: regmap if found or error if not found. @@ -117,8 +107,8 @@ struct regmap *altr_sysmgr_regmap_lookup_by_phandle(struct device_node *np, if (!sysmgr_np) return ERR_PTR(-ENODEV); - dev = driver_find_device(&altr_sysmgr_driver.driver, NULL, - (void *)sysmgr_np, sysmgr_match_phandle); + dev = driver_find_device_by_of_node(&altr_sysmgr_driver.driver, + (void *)sysmgr_np); of_node_put(sysmgr_np); if (!dev) return ERR_PTR(-EPROBE_DEFER); diff --git a/include/linux/device.h b/include/linux/device.h index 0d3958e..f929671 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -437,6 +437,19 @@ static inline struct device *driver_find_device_by_name(struct device_driver *dr return driver_find_device(drv, NULL, name, device_match_name); } +/** + * driver_find_device_by_of_node- device iterator for locating a particular device + * by of_node pointer. + * @driver: the driver we're iterating + * @np: of_node pointer to match. + */ +static inline struct device * +driver_find_device_by_of_node(struct device_driver *drv, + const struct device_node *np) +{ + return driver_find_device(drv, NULL, np, device_match_of_node); +} + void driver_deferred_probe_add(struct device *dev); int driver_deferred_probe_check_state(struct device *dev);