drm/msm/dp: use ARRAY_SIZE for calculating num_descs
PATCH 1/1 drm/msm/dp: use ARRAY_SIZE for calculating num_descs
If for some reason the msm_dp_config::descs array starts from non-zero index or contains the hole, setting the msm_dp_config::num_descs might be not that obvious and error-prone. Use ARRAY_SIZE to set this field rather than encoding the value manually.
--- drivers/gpu/drm/msm/dp/dp_display.c | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-)
drivers/gpu/drm/msm/dp/dp_display.c +27 -19
@@ -131,35 +131,43 @@ struct msm_dp_config {size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +}; +static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sc7180_dp_descs, + .num_descs =ARRAY_SIZE (sc7180_dp_descs), +}; + +static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, };static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs =2 , + .descs = sc7280_dp_descs, + .num_descs =ARRAY_SIZE (sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, };static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs =3 , + .descs = sc8180x_dp_descs, + .num_descs =ARRAY_SIZE (sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, };static const struct msm_dp_config sm8350_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sm8350_dp_descs, + .num_descs =ARRAY_SIZE (sm8350_dp_descs), };static const struct of_device_id dp_dt_match[] = {
Signature · 1 line
2.35.1
Quoting Dmitry Baryshkov (2022-06-27 09:54:13)
Quoted 8 lines
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
Quoted 22 lines · Dmitry Baryshkov
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/dp/dp_display.c | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +3
-0@@ -131,35 +131,43 @@ struct msm_dp_config {size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +};
drivers/gpu/drm/msm/dp/dp_display.c struct msm_dp_config { · line 142
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +5
-4+static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sc7180_dp_descs, + .num_descs =ARRAY_SIZE (sc7180_dp_descs), +}; +
why you want to do that?
It is very clear only one entry, why you want to make it 2 entry here?
can you just embedded MSM_DP_COTROLLER_x into struct msm_dp_config?
Quoted 46 lines
drivers/gpu/drm/msm/dp/dp_display.c +19
-15+static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, };static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs =2 , + .descs = sc7280_dp_descs, + .num_descs =ARRAY_SIZE (sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, };static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs =3 , + .descs = sc8180x_dp_descs, + .num_descs =ARRAY_SIZE (sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, };static const struct msm_dp_config sm8350_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sm8350_dp_descs, + .num_descs =ARRAY_SIZE (sm8350_dp_descs), };static const struct of_device_id dp_dt_match[] = {
Quoted 38 lines · Kuogee Hsieh
Quoted 22 lines · Dmitry Baryshkov
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/dp/dp_display.c | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +3
-0@@ -131,35 +131,43 @@ struct msm_dp_config {size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +};drivers/gpu/drm/msm/dp/dp_display.c struct msm_dp_config { · line 142
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +5
-4+static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sc7180_dp_descs, + .num_descs =ARRAY_SIZE (sc7180_dp_descs), +}; +why you want to do that?
Quoted 3 lines
It is very clear only one entry, why you want to make it 2 entry here?
can you just embedded
MSM_DP_COTROLLER_xinto structmsm_dp_config?
Because we had enough stories of using a manually set 'number of something' field. So I'd prefer to have it done automatically. Also using the indexed array spares us from 'look for the DP controller number N' functions. You can just get it.
Quoted 47 lines
Quoted 47 lines
drivers/gpu/drm/msm/dp/dp_display.c +19
-15+static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, };static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs =2 , + .descs = sc7280_dp_descs, + .num_descs =ARRAY_SIZE (sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, };static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs =3 , + .descs = sc8180x_dp_descs, + .num_descs =ARRAY_SIZE (sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, };static const struct msm_dp_config sm8350_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sm8350_dp_descs, + .num_descs =ARRAY_SIZE (sm8350_dp_descs), };static const struct of_device_id dp_dt_match[] = {
Signature · 2 lines
With best wishes Dmitry
Quoted 37 lines · Dmitry Baryshkov
Quoted 36 lines · Kuogee Hsieh
Quoted 22 lines · Dmitry Baryshkov
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/gpu/drm/msm/dp/dp_display.c | 46 +++++++++++++++++------------ 1 file changed, 27 insertions(+), 19 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +3
-0@@ -131,35 +131,43 @@ struct msm_dp_config {size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +};drivers/gpu/drm/msm/dp/dp_display.c struct msm_dp_config { · line 142
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +5
-4+static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sc7180_dp_descs, + .num_descs =ARRAY_SIZE (sc7180_dp_descs), +}; +why you want to do that?
Quoted 7 lines
Quoted 3 lines
It is very clear only one entry, why you want to make it 2 entry here?
can you just embedded
MSM_DP_COTROLLER_xinto structmsm_dp_config?Because we had enough stories of using a manually set 'number of something' field. So I'd prefer to have it done automatically. Also using the indexed array spares us from 'look for the DP controller number N' functions. You can just get it.
static const struct msm_dp_config sc7280_dp_cfg = {
.descs = (const struct msm_dp_desc[]) {
[MSM_DP_CONTROLLER_1] = { .io_start = 0x0aea0000, .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true },
},
.num_descs = ARRAY_SIZE(sc7280_dp_descs),
};At above example table, it just waste one entry. is it ok?
can you elaborate more on 'look for the DP controller number N' functions, where is it?
Quoted 48 lines
Quoted 46 lines
Quoted 46 lines
drivers/gpu/drm/msm/dp/dp_display.c +19
-15+static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, };static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0aea0000 , .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs =2 , + .descs = sc7280_dp_descs, + .num_descs =ARRAY_SIZE (sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, };static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1 ] = { .io_start =0x0ae98000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2 ] = { .io_start =0x0ae9a000 , .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs =3 , + .descs = sc8180x_dp_descs, + .num_descs =ARRAY_SIZE (sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, };static const struct msm_dp_config sm8350_dp_cfg = { - .descs = (const struct msm_dp_desc []) { - [MSM_DP_CONTROLLER_0 ] = { .io_start =0x0ae90000 , .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs =1 , + .descs = sm8350_dp_descs, + .num_descs =ARRAY_SIZE (sm8350_dp_descs), };static const struct of_device_id dp_dt_match[] = {
Quoted 50 lines · Kuogee Hsieh
Quoted 40 lines · Dmitry Baryshkov
Quoted 39 lines · Kuogee Hsieh
Quoted 25 lines · Dmitry Baryshkov
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>---
drivers/gpu/drm/msm/dp/dp_display.c| 46
+++++++++++++++++------------1 file changed, 27 insertions(+), 19 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +4
-0@@ -131,35 +131,43 @@ struct msm_dp_config { size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +}; +drivers/gpu/drm/msm/dp/dp_display.c struct msm_dp_config { · line 144
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +4
-4static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs = 1, + .descs = sc7180_dp_descs, + .num_descs = ARRAY_SIZE(sc7180_dp_descs), +}; +why you want to do that?
Quoted 7 lines
Quoted 3 lines
It is very clear only one entry, why you want to make it 2 entry here?
can you just embedded
MSM_DP_COTROLLER_xinto structmsm_dp_config?Because we had enough stories of using a manually set 'number of something' field. So I'd prefer to have it done automatically. Also using the indexed array spares us from 'look for the DP controller number N' functions. You can just get it.
Quoted 6 lines
static const struct
msm_dp_configsc7280_dp_cfg= {
.descs = (const struct msm_dp_desc[]) { [MSM_DP_CONTROLLER_1] = { .io_start =0x0aea0000,
.connector_type =DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true },
},
.num_descs =ARRAY_SIZE(sc7280_dp_descs),
This will not work.
Quoted 3 lines
};
At above example table, it just waste one entry. is it ok?
I'd assume this is an interim development state. Then it's fine. In the final version one would fill all existing DP controllers starting from 0.
Quoted 2 lines
can you elaborate more on 'look for the DP controller number N' functions, where is it?
Ignore this.
Quoted 62 lines
Quoted 62 lines
Quoted 60 lines
Quoted 60 lines
drivers/gpu/drm/msm/dp/dp_display.c +17
-11+static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1] = { .io_start = 0x0aea0000, .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, }; static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1] = { .io_start = 0x0aea0000, .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs = 2, + .descs = sc7280_dp_descs, + .num_descs = ARRAY_SIZE(sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1] = { .io_start = 0x0ae98000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2] = { .io_start = 0x0ae9a000, .connector_type = DRM_MODE_CONNECTOR_eDP }, }; static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1] = { .io_start = 0x0ae98000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2] = { .io_start = 0x0ae9a000, .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs = 3, + .descs = sc8180x_dp_descs, + .num_descs = ARRAY_SIZE(sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000,.connector_type =
DRM_MODE_CONNECTOR_DisplayPort}, };static const struct
msm_dp_configsm8350_dp_cfg= { - .descs = (const struct msm_dp_desc[]) {
- [MSM_DP_CONTROLLER_0] = { .io_start =0x0ae90000, .connector_type =DRM_MODE_CONNECTOR_DisplayPort},
- },
- .num_descs = 1,
+ .descs =sm8350_dp_descs,
+ .num_descs =ARRAY_SIZE(sm8350_dp_descs),
};static const struct
of_device_iddp_dt_match[] = {
Signature · 2 lines
With best wishes Dmitry
Kuogee Hsieh
Reviewed-byQuoted 5 lines · Dmitry Baryshkov
Quoted 4 lines · Kuogee Hsieh
Quoted 2 lines · Dmitry Baryshkov
Quoted 1 line · Kuogee Hsieh
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines · Dmitry Baryshkov
Quoted 7 lines
If for some reason the
msm_dp_config::descsarray starts from non-zero index or contains the hole, setting themsm_dp_config::num_descsmight be not that obvious and error-prone. UseARRAY_SIZEto set this field rather than encoding the value manually.Reported-by Kuogee Hsieh <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>
Quoted 121 lines
Quoted 38 lines
Quoted 30 lines
Quoted 30 lines
Quoted 18 lines
---
drivers/gpu/drm/msm/dp/dp_display.c| 46
+++++++++++++++++------------1 file changed, 27 insertions(+), 19 deletions(-)drivers/gpu/drm/msm/dp/dp_display.c +4
-0@@ -131,35 +131,43 @@ struct msm_dp_config { size_t num_descs; }; +static const struct msm_dp_desc sc7180_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, +}; +drivers/gpu/drm/msm/dp/dp_display.c struct msm_dp_config { · line 144
Quoted 10 lines
drivers/gpu/drm/msm/dp/dp_display.c +4
-4static const struct msm_dp_config sc7180_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - }, - .num_descs = 1, + .descs = sc7180_dp_descs, + .num_descs = ARRAY_SIZE(sc7180_dp_descs), +}; +why you want to do that?
Quoted 7 lines
Quoted 3 lines
It is very clear only one entry, why you want to make it 2 entry here?
can you just embedded
MSM_DP_COTROLLER_xinto structmsm_dp_config?Because we had enough stories of using a manually set 'number of something' field. So I'd prefer to have it done automatically. Also using the indexed array spares us from 'look for the DP controller number N' functions. You can just get it.
Quoted 5 lines
static const struct
msm_dp_configsc7280_dp_cfg= {
.descs = (const struct msm_dp_desc[]) {
[MSM_DP_CONTROLLER_1] = { .io_start =0x0aea0000, .connector_type =DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, },
.num_descs =ARRAY_SIZE(sc7280_dp_descs),This will not work.
Quoted 3 lines
};
At above example table, it just waste one entry. is it ok?
I'd assume this is an interim development state. Then it's fine. In the final version one would fill all existing DP controllers starting from 0.
Quoted 2 lines
can you elaborate more on 'look for the DP controller number N' functions, where is it?
Ignore this.
Quoted 62 lines
Quoted 62 lines
Quoted 60 lines
Quoted 60 lines
drivers/gpu/drm/msm/dp/dp_display.c +17
-11+static const struct msm_dp_desc sc7280_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, + [MSM_DP_CONTROLLER_1] = { .io_start = 0x0aea0000, .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, }; static const struct msm_dp_config sc7280_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort, .wide_bus_en = true }, - [MSM_DP_CONTROLLER_1] = { .io_start = 0x0aea0000, .connector_type = DRM_MODE_CONNECTOR_eDP, .wide_bus_en = true }, - }, - .num_descs = 2, + .descs = sc7280_dp_descs, + .num_descs = ARRAY_SIZE(sc7280_dp_descs), +}; + +static const struct msm_dp_desc sc8180x_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_1] = { .io_start = 0x0ae98000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, + [MSM_DP_CONTROLLER_2] = { .io_start = 0x0ae9a000, .connector_type = DRM_MODE_CONNECTOR_eDP }, }; static const struct msm_dp_config sc8180x_dp_cfg = { - .descs = (const struct msm_dp_desc[]) { - [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_1] = { .io_start = 0x0ae98000, .connector_type = DRM_MODE_CONNECTOR_DisplayPort }, - [MSM_DP_CONTROLLER_2] = { .io_start = 0x0ae9a000, .connector_type = DRM_MODE_CONNECTOR_eDP }, - }, - .num_descs = 3, + .descs = sc8180x_dp_descs, + .num_descs = ARRAY_SIZE(sc8180x_dp_descs), +}; + +static const struct msm_dp_desc sm8350_dp_descs[] = { + [MSM_DP_CONTROLLER_0] = { .io_start = 0x0ae90000,.connector_type =
DRM_MODE_CONNECTOR_DisplayPort}, };static const struct
msm_dp_configsm8350_dp_cfg= { - .descs = (const struct msm_dp_desc[]) {
- [MSM_DP_CONTROLLER_0] = { .io_start =0x0ae90000, .connector_type =DRM_MODE_CONNECTOR_DisplayPort},
- },
- .num_descs = 1,
+ .descs =sm8350_dp_descs,
+ .num_descs =ARRAY_SIZE(sm8350_dp_descs),
};static const struct
of_device_iddp_dt_match[] = {