gdc: add a probed flag to avoid crash [1/1]

PD#SWPL-29848

Problem:
on platforms which GDC are not supported
if create_gdc_work_queue is invoked
a crash occurs

Solution:
add a probed flag to avoid crash
add a interface is_gdc_supported to query

Verify:
g12b/tm2

Change-Id: I65b88294822d8a2c7429d375039fee962b9612aa
Signed-off-by: Cao Jian <jian.cao@amlogic.com>
This commit is contained in:
Cao Jian
2020-07-17 14:18:22 +08:00
committed by Chris
parent dfd7a2da8e
commit 479ffdf842
4 changed files with 18 additions and 1 deletions

View File

@@ -1900,6 +1900,8 @@ static int gdc_platform_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, gdc_dev);
gdc_pwr_config(false);
gdc_manager.probed = 1;
return rc;
}

View File

@@ -324,6 +324,15 @@ static inline int work_queue_no_space(struct gdc_context_s *queue)
return list_empty(&queue->free_queue);
}
bool is_gdc_supported(void)
{
if (gdc_manager.probed)
return true;
return false;
}
EXPORT_SYMBOL(is_gdc_supported);
struct gdc_context_s *create_gdc_work_queue(void)
{
int i;
@@ -331,6 +340,10 @@ struct gdc_context_s *create_gdc_work_queue(void)
struct gdc_context_s *gdc_work_queue;
int empty;
if (!gdc_manager.probed) {
gdc_log(LOG_INFO, "GDC is not supported for this chip\n");
return NULL;
}
gdc_work_queue = kzalloc(sizeof(struct gdc_context_s), GFP_KERNEL);
if (IS_ERR(gdc_work_queue)) {
gdc_log(LOG_ERR, "can't create work queue\n");

View File

@@ -56,6 +56,7 @@ struct gdc_manager_s {
int gdc_state;
int process_queue_state;//thread running flag
struct meson_gdc_dev_t *gdc_dev;
int probed;
};
extern struct gdc_manager_s gdc_manager;

View File

@@ -165,9 +165,10 @@ struct gdc_phy_setting {
char config_name[CONFIG_PATH_LENG];
};
bool is_gdc_supported(void);
struct gdc_context_s *create_gdc_work_queue(void);
int gdc_process_phys(struct gdc_context_s *context,
struct gdc_phy_setting *gs);
struct gdc_context_s *create_gdc_work_queue(void);
int destroy_gdc_work_queue(struct gdc_context_s *gdc_work_queue);
#endif