diff mbox series

[linux-next] drm/i915/display: Remove unused variable and its assignment.

Message ID 20211018084331.851975-1-luo.penghao@zte.com.cn (mailing list archive)
State New, archived
Headers show
Series [linux-next] drm/i915/display: Remove unused variable and its assignment. | expand

Commit Message

CGEL Oct. 18, 2021, 8:43 a.m. UTC
Variable is not used in functions, and its assignment is redundant too.
So it should be deleted.

The clang_analyzer complains as follows:

drivers/gpu/drm/i915/display/intel_dpll.c:1653:2 warning:
Value stored to 'bestm1' is never read.

drivers/gpu/drm/i915/display/intel_dpll.c:1651:2 warning:
Value stored to 'bestn' is never read.

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: luo penghao <luo.penghao@zte.com.cn>
---
 drivers/gpu/drm/i915/display/intel_dpll.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Ville Syrjälä Oct. 18, 2021, 8:57 a.m. UTC | #1
On Mon, Oct 18, 2021 at 08:43:31AM +0000, luo penghao wrote:
> Variable is not used in functions, and its assignment is redundant too.
> So it should be deleted.
> 
> The clang_analyzer complains as follows:
> 
> drivers/gpu/drm/i915/display/intel_dpll.c:1653:2 warning:
> Value stored to 'bestm1' is never read.
> 
> drivers/gpu/drm/i915/display/intel_dpll.c:1651:2 warning:
> Value stored to 'bestn' is never read.
> 
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: luo penghao <luo.penghao@zte.com.cn>
> ---
>  drivers/gpu/drm/i915/display/intel_dpll.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dpll.c b/drivers/gpu/drm/i915/display/intel_dpll.c
> index b84ed4a..28b1616 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpll.c
> +++ b/drivers/gpu/drm/i915/display/intel_dpll.c
> @@ -1644,13 +1644,11 @@ static void chv_prepare_pll(const struct intel_crtc_state *crtc_state)
>  	enum pipe pipe = crtc->pipe;
>  	enum dpio_channel port = vlv_pipe_to_channel(pipe);
>  	u32 loopfilter, tribuf_calcntr;
> -	u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac;
> +	u32 bestm2, bestp1, bestp2, bestm2_frac;
>  	u32 dpio_val;
>  	int vco;
>  
> -	bestn = crtc_state->dpll.n;

This one we could use. For some reason we hardcode it to
1 now, which is correct for our use cases but I don't really
see a reason to hardcode it here. We are supposed to calculate
it correctly after all, and chv_crtc_clock_get() also just blindly
reads it out.

>  	bestm2_frac = crtc_state->dpll.m2 & 0x3fffff;
> -	bestm1 = crtc_state->dpll.m1;

This one is a bit trickier since I don't think the spec even
gives us other values. But we could assert that it's correct.

Some something along these lines I think would be best:
+ drm_WARN_ON(&dev_priv->drm, bestm1 != 2);
  vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW1(port),
                 DPIO_CHV_M1_DIV_BY_2 |
- 		 1 << DPIO_CHV_N_DIV_SHIFT);
+ 		 bestn << DPIO_CHV_N_DIV_SHIFT);
luo.penghao@zte.com.cn Oct. 19, 2021, 2:22 a.m. UTC | #2
PiBUaGlzIG9uZSB3ZSBjb3VsZCB1c2UuIEZvciBzb21lIHJlYXNvbiB3ZSBoYXJkY29kZSBpdCB0
bw0KDQoNCg0KPiAxIG5vdywgd2hpY2ggaXMgY29ycmVjdCBmb3Igb3VyIHVzZSBjYXNlcyBidXQg
SSBkb24ndCByZWFsbHk+IHNlZSBhIHJlYXNvbiB0byBoYXJkY29kZSBpdCBoZXJlLiBXZSBhcmUg
c3VwcG9zZWQgdG8gY2FsY3VsYXRlPiBpdCBjb3JyZWN0bHkgYWZ0ZXIgYWxsLCBhbmQgY2h2X2Ny
dGNfY2xvY2tfZ2V0KCkgYWxzbyBqdXN0IGJsaW5kbHk+IHJlYWRzIGl0IG91dC4+ID4gPiAgICAg
IGJlc3RtMl9mcmFjID0gY3J0Y19zdGF0ZS0+ZHBsbC5tMiAmIDB4M2ZmZmZmOz4gPiAtICAgIGJl
c3RtMSA9IGNydGNfc3RhdGUtPmRwbGwubTE7PiA+IFRoaXMgb25lIGlzIGEgYml0IHRyaWNraWVy
IHNpbmNlIEkgZG9uJ3QgdGhpbmsgdGhlIHNwZWMgZXZlbj4gZ2l2ZXMgdXMgb3RoZXIgdmFsdWVz
LiBCdXQgd2UgY291bGQgYXNzZXJ0IHRoYXQgaXQncyBjb3JyZWN0Lj4gPiBTb21lIHNvbWV0aGlu
ZyBhbG9uZyB0aGVzZSBsaW5lcyBJIHRoaW5rIHdvdWxkIGJlIGJlc3Q6PiArIGRybV9XQVJOX09O
KCZkZXZfcHJpdi0+ZHJtLCBiZXN0bTEgIT0gMik7PiAgIHZsdl9kcGlvX3dyaXRlKGRldl9wcml2
LCBwaXBlLCBDSFZfUExMX0RXMShwb3J0KSw+ICAgICAgICAgICAgICAgICAgRFBJT19DSFZfTTFf
RElWX0JZXzIgfD4gLSAgICAgICAgICAxIDw8IERQSU9fQ0hWX05fRElWX1NISUZUKTs+ICsgICAg
ICAgICAgYmVzdG4gPDwgRFBJT19DSFZfTl9ESVZfU0hJRlQpOw0KDQoNCg0KDQoNCg0KVGhhbmtz
IGZvciB5b3VyIGtpbmQgcmVzcG9uc2UgISBEb2VzIHRoYXQgbWVhbnMgdGhlIHZhcmlhYmxlIHdp
bGwgYmUNCg0KDQp1c2VkIGJ5IHRoZSBoYXJkd2FyZe+8n2lmIHNvIGFzIGZhciBhcyBJIHNlZSBp
dCwgSSBkb24ndCBzZWVtIHRvIHNlZSB0aGUNCg0KDQpyZWxldmFudCBpbnRlcmZhY2Uu
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dpll.c b/drivers/gpu/drm/i915/display/intel_dpll.c
index b84ed4a..28b1616 100644
--- a/drivers/gpu/drm/i915/display/intel_dpll.c
+++ b/drivers/gpu/drm/i915/display/intel_dpll.c
@@ -1644,13 +1644,11 @@  static void chv_prepare_pll(const struct intel_crtc_state *crtc_state)
 	enum pipe pipe = crtc->pipe;
 	enum dpio_channel port = vlv_pipe_to_channel(pipe);
 	u32 loopfilter, tribuf_calcntr;
-	u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac;
+	u32 bestm2, bestp1, bestp2, bestm2_frac;
 	u32 dpio_val;
 	int vco;
 
-	bestn = crtc_state->dpll.n;
 	bestm2_frac = crtc_state->dpll.m2 & 0x3fffff;
-	bestm1 = crtc_state->dpll.m1;
 	bestm2 = crtc_state->dpll.m2 >> 22;
 	bestp1 = crtc_state->dpll.p1;
 	bestp2 = crtc_state->dpll.p2;