* [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data
@ 2020-12-16 14:33 Rafał Miłecki
2020-12-16 14:33 ` [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level Rafał Miłecki
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Rafał Miłecki @ 2020-12-16 14:33 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul
Cc: Al Cooper, Florian Fainelli, bcm-kernel-feedback-list,
devicetree, linux-kernel, Rafał Miłecki
From: Rafał Miłecki <rafal@milecki.pl>
1. Use of_device_get_match_data() helper to simplify the code
2. Check for NULL as a good practice
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/phy/broadcom/phy-brcm-usb.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
index 63f922a5f29b..f0f01060bd12 100644
--- a/drivers/phy/broadcom/phy-brcm-usb.c
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -11,6 +11,7 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/phy/phy.h>
#include <linux/platform_device.h>
#include <linux/interrupt.h>
@@ -431,7 +432,6 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
struct device_node *dn = pdev->dev.of_node;
int err;
const char *mode;
- const struct of_device_id *match;
void (*dvr_init)(struct brcm_usb_init_params *params);
const struct match_chip_info *info;
struct regmap *rmap;
@@ -445,8 +445,9 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
priv->ini.family_id = brcmstb_get_family_id();
priv->ini.product_id = brcmstb_get_product_id();
- match = of_match_node(brcm_usb_dt_ids, dev->of_node);
- info = match->data;
+ info = of_device_get_match_data(&pdev->dev);
+ if (!info)
+ return -ENOENT;
dvr_init = info->init_func;
(*dvr_init)(&priv->ini);
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level
2020-12-16 14:33 [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Rafał Miłecki
@ 2020-12-16 14:33 ` Rafał Miłecki
2020-12-16 17:26 ` Florian Fainelli
2020-12-16 17:25 ` [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Florian Fainelli
2021-01-13 11:57 ` Vinod Koul
2 siblings, 1 reply; 5+ messages in thread
From: Rafał Miłecki @ 2020-12-16 14:33 UTC (permalink / raw)
To: Kishon Vijay Abraham I, Vinod Koul
Cc: Al Cooper, Florian Fainelli, bcm-kernel-feedback-list,
devicetree, linux-kernel, Rafał Miłecki
From: Rafał Miłecki <rafal@milecki.pl>
This is slightly cleaner solution that assures noone assings a wrong
function to the pointer.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
drivers/phy/broadcom/phy-brcm-usb.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/phy/broadcom/phy-brcm-usb.c b/drivers/phy/broadcom/phy-brcm-usb.c
index f0f01060bd12..116fb23aebd9 100644
--- a/drivers/phy/broadcom/phy-brcm-usb.c
+++ b/drivers/phy/broadcom/phy-brcm-usb.c
@@ -35,7 +35,7 @@ struct value_to_name_map {
};
struct match_chip_info {
- void *init_func;
+ void (*init_func)(struct brcm_usb_init_params *params);
u8 required_regs[BRCM_REGS_MAX + 1];
u8 optional_reg;
};
@@ -432,7 +432,6 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
struct device_node *dn = pdev->dev.of_node;
int err;
const char *mode;
- void (*dvr_init)(struct brcm_usb_init_params *params);
const struct match_chip_info *info;
struct regmap *rmap;
int x;
@@ -448,8 +447,8 @@ static int brcm_usb_phy_probe(struct platform_device *pdev)
info = of_device_get_match_data(&pdev->dev);
if (!info)
return -ENOENT;
- dvr_init = info->init_func;
- (*dvr_init)(&priv->ini);
+
+ info->init_func(&priv->ini);
dev_dbg(dev, "Best mapping table is for %s\n",
priv->ini.family_name);
--
2.26.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data
2020-12-16 14:33 [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Rafał Miłecki
2020-12-16 14:33 ` [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level Rafał Miłecki
@ 2020-12-16 17:25 ` Florian Fainelli
2021-01-13 11:57 ` Vinod Koul
2 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-12-16 17:25 UTC (permalink / raw)
To: Rafał Miłecki, Kishon Vijay Abraham I, Vinod Koul
Cc: Al Cooper, Florian Fainelli, bcm-kernel-feedback-list,
devicetree, linux-kernel, Rafał Miłecki
On 12/16/20 6:33 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> 1. Use of_device_get_match_data() helper to simplify the code
> 2. Check for NULL as a good practice
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level
2020-12-16 14:33 ` [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level Rafał Miłecki
@ 2020-12-16 17:26 ` Florian Fainelli
0 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2020-12-16 17:26 UTC (permalink / raw)
To: Rafał Miłecki, Kishon Vijay Abraham I, Vinod Koul
Cc: Al Cooper, Florian Fainelli, bcm-kernel-feedback-list,
devicetree, linux-kernel, Rafał Miłecki
On 12/16/20 6:33 AM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> This is slightly cleaner solution that assures noone assings a wrong
> function to the pointer.
>
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data
2020-12-16 14:33 [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Rafał Miłecki
2020-12-16 14:33 ` [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level Rafał Miłecki
2020-12-16 17:25 ` [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Florian Fainelli
@ 2021-01-13 11:57 ` Vinod Koul
2 siblings, 0 replies; 5+ messages in thread
From: Vinod Koul @ 2021-01-13 11:57 UTC (permalink / raw)
To: Rafał Miłecki
Cc: Kishon Vijay Abraham I, Al Cooper, Florian Fainelli,
bcm-kernel-feedback-list, devicetree, linux-kernel,
Rafał Miłecki
On 16-12-20, 15:33, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
>
> 1. Use of_device_get_match_data() helper to simplify the code
> 2. Check for NULL as a good practice
Applied both, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-01-13 11:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 14:33 [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Rafał Miłecki
2020-12-16 14:33 ` [PATCH 2/2] phy: phy-brcm-usb: specify init function format at struct level Rafał Miłecki
2020-12-16 17:26 ` Florian Fainelli
2020-12-16 17:25 ` [PATCH 1/2] phy: phy-brcm-usb: improve getting OF matching data Florian Fainelli
2021-01-13 11:57 ` Vinod Koul
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.