Re: [Cocci] [PATCH v2 0/2] of: of_device.h cleanups
On Thu, Feb 11, 2021 at 05:27:43PM -0600, Rob Herring wrote: > This is a couple of cleanups for of_device.h. They fell out from my > attempt at decoupling of_device.h and of_platform.h which is a mess > and I haven't finished, but there's no reason to wait on these. Reviewed-by: Greg Kroah-Hartman ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] [PATCH 1/2] of: Remove of_dev_{get,put}()
of_dev_get() and of_dev_put are just wrappers for get_device()/put_device() on a platform_device. There's also already platform_device_{get,put}() wrappers for this purpose. Let's update the few users and remove of_dev_{get,put}(). Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: "David S. Miller" Cc: Jakub Kicinski Cc: Frank Rowand Cc: Patrice Chotard Cc: Felipe Balbi Cc: Greg Kroah-Hartman Cc: Julia Lawall Cc: Gilles Muller Cc: Nicolas Palix Cc: Michal Marek Cc: linuxppc-...@lists.ozlabs.org Cc: net...@vger.kernel.org Cc: linux-arm-ker...@lists.infradead.org Cc: linux-...@vger.kernel.org Cc: cocci@systeme.lip6.fr Signed-off-by: Rob Herring --- arch/powerpc/platforms/pseries/ibmebus.c | 4 ++-- drivers/net/ethernet/ibm/emac/core.c | 15 --- drivers/of/device.c | 21 - drivers/of/platform.c| 4 ++-- drivers/of/unittest.c| 2 +- drivers/usb/dwc3/dwc3-st.c | 2 +- include/linux/of_device.h| 3 --- scripts/coccinelle/free/put_device.cocci | 1 - 8 files changed, 14 insertions(+), 38 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ibmebus.c b/arch/powerpc/platforms/pseries/ibmebus.c index 8c6e509f6967..c29328fe94e8 100644 --- a/arch/powerpc/platforms/pseries/ibmebus.c +++ b/arch/powerpc/platforms/pseries/ibmebus.c @@ -355,12 +355,12 @@ static int ibmebus_bus_device_probe(struct device *dev) if (!drv->probe) return error; - of_dev_get(of_dev); + get_device(dev); if (of_driver_match_device(dev, dev->driver)) error = drv->probe(of_dev); if (error) - of_dev_put(of_dev); + put_device(of_dev); return error; } diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c index c00b9097eeea..471be6ec7e8a 100644 --- a/drivers/net/ethernet/ibm/emac/core.c +++ b/drivers/net/ethernet/ibm/emac/core.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -2390,11 +2391,11 @@ static int emac_check_deps(struct emac_instance *dev, static void emac_put_deps(struct emac_instance *dev) { - of_dev_put(dev->mal_dev); - of_dev_put(dev->zmii_dev); - of_dev_put(dev->rgmii_dev); - of_dev_put(dev->mdio_dev); - of_dev_put(dev->tah_dev); + platform_device_put(dev->mal_dev); + platform_device_put(dev->zmii_dev); + platform_device_put(dev->rgmii_dev); + platform_device_put(dev->mdio_dev); + platform_device_put(dev->tah_dev); } static int emac_of_bus_notify(struct notifier_block *nb, unsigned long action, @@ -2435,7 +2436,7 @@ static int emac_wait_deps(struct emac_instance *dev) for (i = 0; i < EMAC_DEP_COUNT; i++) { of_node_put(deps[i].node); if (err) - of_dev_put(deps[i].ofdev); + platform_device_put(deps[i].ofdev); } if (err == 0) { dev->mal_dev = deps[EMAC_DEP_MAL_IDX].ofdev; @@ -2444,7 +2445,7 @@ static int emac_wait_deps(struct emac_instance *dev) dev->tah_dev = deps[EMAC_DEP_TAH_IDX].ofdev; dev->mdio_dev = deps[EMAC_DEP_MDIO_IDX].ofdev; } - of_dev_put(deps[EMAC_DEP_PREV_IDX].ofdev); + platform_device_put(deps[EMAC_DEP_PREV_IDX].ofdev); return err; } diff --git a/drivers/of/device.c b/drivers/of/device.c index aedfaaafd3e7..9a748855b39d 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c @@ -33,27 +33,6 @@ const struct of_device_id *of_match_device(const struct of_device_id *matches, } EXPORT_SYMBOL(of_match_device); -struct platform_device *of_dev_get(struct platform_device *dev) -{ - struct device *tmp; - - if (!dev) - return NULL; - tmp = get_device(&dev->dev); - if (tmp) - return to_platform_device(tmp); - else - return NULL; -} -EXPORT_SYMBOL(of_dev_get); - -void of_dev_put(struct platform_device *dev) -{ - if (dev) - put_device(&dev->dev); -} -EXPORT_SYMBOL(of_dev_put); - int of_device_add(struct platform_device *ofdev) { BUG_ON(ofdev->dev.of_node == NULL); diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 79bd5f5a1bf1..020bf860c72c 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -687,7 +687,7 @@ static int of_platform_notify(struct notifier_block *nb, pdev_parent = of_find_device_by_node(rd->dn->parent); pdev = of_platform_device_create(rd->dn, NULL, pdev_parent ? &pdev_parent->dev : NULL); - of_dev_put(pdev_parent); + platform_device_put(pdev_parent); if (pdev == NULL) { pr_err("%s: failed to create for '%pOF'\n", @@ -712,7 +712,7 @@ static int of_platform_noti
[Cocci] [PATCH 0/2] of: of_device.h cleanups
This is a couple of cleanups for of_device.h. They fell out from my attempt at decoupling of_device.h and of_platform.h which is a mess and I haven't finished, but there's no reason to wait on these. Rob Rob Herring (2): of: Remove of_dev_{get,put}() driver core: platform: Drop of_device_node_put() wrapper arch/powerpc/platforms/pseries/ibmebus.c | 4 ++-- drivers/base/platform.c | 2 +- drivers/net/ethernet/ibm/emac/core.c | 15 --- drivers/of/device.c | 21 - drivers/of/platform.c| 4 ++-- drivers/of/unittest.c| 2 +- drivers/usb/dwc3/dwc3-st.c | 2 +- include/linux/of_device.h| 10 -- scripts/coccinelle/free/put_device.cocci | 1 - 9 files changed, 15 insertions(+), 46 deletions(-) -- 2.27.0 ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] [PATCH 2/2] driver core: platform: Drop of_device_node_put() wrapper
of_device_node_put() is just a wrapper for of_node_put(). The platform driver core is already polluted with of_node pointers and the only 'get' already uses of_node_get() (though typically the get would happen in of_device_alloc()). Cc: Greg Kroah-Hartman Cc: "Rafael J. Wysocki" Cc: Frank Rowand Signed-off-by: Rob Herring --- drivers/base/platform.c | 2 +- include/linux/of_device.h | 7 --- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 95fd1549f87d..c31bc9e92dd1 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -571,7 +571,7 @@ static void platform_device_release(struct device *dev) struct platform_object *pa = container_of(dev, struct platform_object, pdev.dev); - of_device_node_put(&pa->pdev.dev); + of_node_put(&pa->pdev.dev->of_node); kfree(pa->pdev.dev.platform_data); kfree(pa->pdev.mfd_cell); kfree(pa->pdev.resource); diff --git a/include/linux/of_device.h b/include/linux/of_device.h index d7a407dfeecb..1d7992a02e36 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h @@ -38,11 +38,6 @@ extern int of_device_request_module(struct device *dev); extern void of_device_uevent(struct device *dev, struct kobj_uevent_env *env); extern int of_device_uevent_modalias(struct device *dev, struct kobj_uevent_env *env); -static inline void of_device_node_put(struct device *dev) -{ - of_node_put(dev->of_node); -} - static inline struct device_node *of_cpu_device_node_get(int cpu) { struct device *cpu_dev; @@ -94,8 +89,6 @@ static inline int of_device_uevent_modalias(struct device *dev, return -ENODEV; } -static inline void of_device_node_put(struct device *dev) { } - static inline const struct of_device_id *of_match_device( const struct of_device_id *matches, const struct device *dev) { -- 2.27.0 ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] Missing package for Ubuntu 20.04 LTS?
Hi, The Git project recently noticed that our static analysis builds were failing after upgrading to Ubuntu 20.04 due to being unable to find the coccinelle package in the focal suite. https://lore.kernel.org/git/YCGrmsg8J7XT32TM@nand.local/ Searching for coccinelle [1] turns up hits in the xenial, bionic, and groovy suites, but not the focal ones. This appears to have been discussed on this list a couple of times without any conclusion. Is there a planned release of coccinelle that will appear in the focal suite? Thanks, Taylor [1]: https://packages.ubuntu.com/search?keywords=coccinelle [2]: http://archive.ubuntu.com/ubuntu/pool/universe/c/coccinelle/ ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Backward compatibility issue
On Thu, 11 Feb 2021, Denis Efremov wrote: > Hi, one of my patterns started to fail tests on latest coccinelle. > I've bisected the commit that introduces "error". It's: > commit db60e916633d2cb3ae31140364783fdf85ed10f4 > "make information about SmPL iterator and declarer names available to the C > parser" > > To reproduce the error: > $ cd linux > $ git checkout 5b01014759991887b1e450c9def01e58c02ab81b > $ wget > https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci > $ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c > # spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match > net/core/sock.c:718:16-17: ERROR: CVE-2016-9793 > net/core/sock.c:754:16-17: ERROR: CVE-2016-9793 > ... > # spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same > code Thanks for the report. Maybe sometimes making the parser work better actually makes it work worse... I'll check on it. julia > > Thanks, > Denis > ___ > Cocci mailing list > Cocci@systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci > ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
[Cocci] Backward compatibility issue
Hi, one of my patterns started to fail tests on latest coccinelle. I've bisected the commit that introduces "error". It's: commit db60e916633d2cb3ae31140364783fdf85ed10f4 "make information about SmPL iterator and declarer names available to the C parser" To reproduce the error: $ cd linux $ git checkout 5b01014759991887b1e450c9def01e58c02ab81b $ wget https://raw.githubusercontent.com/evdenis/cvehound/master/cvehound/cve/CVE-2016-9793.cocci $ spatch -D detect --cocci-file CVE-2016-9793.cocci net/core/sock.c # spatch before db60e916633d2cb3ae31140364783fdf85ed10f4 will find the match net/core/sock.c:718:16-17: ERROR: CVE-2016-9793 net/core/sock.c:754:16-17: ERROR: CVE-2016-9793 ... # spatch >= db60e916633d2cb3ae31140364783fdf85ed10f4 will not match the same code Thanks, Denis ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci