media: aspeed: Use of_device_get_match_data() helper
Subsystems (2)
PATCH 1/1 media: aspeed: Use of_device_get_match_data() helper
Use of_device_get_match_data() to simplify the code.
--- drivers/media/platform/aspeed-video.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/media/platform/aspeed-video.c +2 -6
@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_irq.h> #include <linux/of_reserved_mem.h> #include <linux/platform_device.h>
@@ -2451,7 +2452,6 @@ MODULE_DEVICE_TABLE(of, aspeed_video_of_match);static int aspeed_video_probe (struct platform_device *pdev) {const struct aspeed_video_config *config; -const struct of_device_id *match;struct aspeed_video *video;int rc;
@@ -2463,11 +2463,7 @@ static int aspeed_video_probe(struct platform_device *pdev)if (IS_ERR (video->base))return PTR_ERR (video->base); - match =of_match_node (aspeed_video_of_match, pdev->dev.of_node); -if (!match) -return -EINVAL ; - - config = match->data; + config =of_device_get_match_data (&pdev->dev); video->version = config->version; video->jpeg_mode = config->jpeg_mode; video->comp_size_read = config->comp_size_read;
Signature · 1 line
2.25.1
Joel Stanley
maintainerQuoted 29 lines · Jammy Huang
Use
of_device_get_match_data()to simplify the code.Signed-off-by Jammy Huang <[email protected]>--- drivers/media/platform/aspeed-video.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/media/platform/aspeed-video.c +1
-1@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_irq.h> #include <linux/of_reserved_mem.h> #include <linux/platform_device.h> @@ -2451,7 +2452,6 @@ MODULE_DEVICE_TABLE(of, aspeed_video_of_match);static int aspeed_video_probe (struct platform_device *pdev) {const struct aspeed_video_config *config; -const struct of_device_id *match;struct aspeed_video *video;int rc;
drivers/media/platform/aspeed-video.c static int aspeed_video_probe(struct platform_device *pdev) · line 2466
Quoted 9 lines
drivers/media/platform/aspeed-video.c +1
-5@@ -2463,11 +2463,7 @@ static int aspeed_video_probe(struct platform_device *pdev)if (IS_ERR (video->base))return PTR_ERR (video->base); - match =of_match_node (aspeed_video_of_match, pdev->dev.of_node); -if (!match) -return -EINVAL ; - - config = match->data; + config =of_device_get_match_data (&pdev->dev);
While normally this driver won't have probed without matching on some data, it would be sensible to add a check for a null pointer here.
Quoted 6 lines
drivers/media/platform/aspeed-video.c +0
-1video->version = config->version; video->jpeg_mode = config->jpeg_mode; video->comp_size_read = config->comp_size_read; --2.25.1
Hi Joel,
Quoted 32 lines · Joel Stanley
Quoted 31 lines · Jammy Huang
Use
of_device_get_match_data()to simplify the code.Signed-off-by Jammy Huang <[email protected]>--- drivers/media/platform/aspeed-video.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/media/platform/aspeed-video.c +1
-1@@ -13,6 +13,7 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/of_device.h> #include <linux/of_irq.h> #include <linux/of_reserved_mem.h> #include <linux/platform_device.h> @@ -2451,7 +2452,6 @@ MODULE_DEVICE_TABLE(of, aspeed_video_of_match);static int aspeed_video_probe (struct platform_device *pdev) {const struct aspeed_video_config *config; -const struct of_device_id *match;struct aspeed_video *video;int rc;@@ -2463,11 +2463,7 @@ static int aspeed_video_probe(struct platform_device *pdev)if (IS_ERR (video->base))return PTR_ERR (video->base);
Quoted 8 lines
drivers/media/platform/aspeed-video.c static int aspeed_video_probe(struct platform_device *pdev) · line 2466
Quoted 6 lines
drivers/media/platform/aspeed-video.c +1
-5- match =of_match_node (aspeed_video_of_match, pdev->dev.of_node); -if (!match) -return -EINVAL ; - - config = match->data; + config =of_device_get_match_data (&pdev->dev);While normally this driver won't have probed without matching on some data, it would be sensible to add a check for a null pointer here.
OK, I will have a updated patch for this later.
Thanks for the help.
Quoted 6 lines
Quoted 6 lines
drivers/media/platform/aspeed-video.c +0
-1video->version = config->version; video->jpeg_mode = config->jpeg_mode; video->comp_size_read = config->comp_size_read; --2.25.1
Signature · 2 lines
Best Regards Jammy