Skip to contentSkip to conversation

staging: media: atomisp: Remove useless cast.

PATCH Superseded Varsha Rao 2 participants 5 messages Mar 9, 2017 1 message not in the archive

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Varsha Rao

author
#1 lore raw

PATCH 1/2 staging: media: atomisp: Remove useless cast.

Explicit type casting of variable, with same type as that of variable, is not required. The following coccinelle script is used to remove it.

@@
type T;
T *ptr;
T p;
@@
(
- (T *)(&p)
+ &p
|
- (T *)ptr
+ ptr
|
- (T *)(ptr)
+ ptr
|
- (T)(p)
+ p
)

---
 drivers/staging/media/atomisp/i2c/gc2235.c               | 16 ++++++++--------
 drivers/staging/media/atomisp/i2c/mt9m114.c              |  4 ++--
 drivers/staging/media/atomisp/i2c/ov2722.c               |  6 +++---
 .../atomisp2/css2400/runtime/isys/src/isys_dma_rmgr.c    |  2 +-
 .../media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c |  8 ++++----
 drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c     |  2 +-
 6 files changed, 19 insertions(+), 19 deletions(-)
drivers/staging/media/atomisp/i2c/gc2235.c +8 -8
index 37a83c7..0c3fa70 100644
@@ -278,7 +278,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
 	if (ret)
 		return ret;
 
-	buf->crop_horizontal_start = ((u16)reg_val_h << 8) | (u16)reg_val;
+	buf->crop_horizontal_start = (reg_val_h << 8) | reg_val;
 
 	ret =  gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_V_CROP_START_H, &reg_val_h);
@@ -287,7 +287,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
 	if (ret)
 		return ret;
 
-	buf->crop_vertical_start = ((u16)reg_val_h << 8) | (u16)reg_val;
+	buf->crop_vertical_start = (reg_val_h << 8) | reg_val;
 
 	ret = gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_H_OUTSIZE_H, &reg_val_h);
@@ -295,7 +295,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
 					GC2235_H_OUTSIZE_L, &reg_val);
 	if (ret)
 		return ret;
-	buf->output_width = ((u16)reg_val_h << 8) | (u16)reg_val;
+	buf->output_width = (reg_val_h << 8) | reg_val;
 
 	ret = gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_V_OUTSIZE_H, &reg_val_h);
@@ -303,7 +303,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
 					GC2235_V_OUTSIZE_L, &reg_val);
 	if (ret)
 		return ret;
-	buf->output_height = ((u16)reg_val_h << 8) | (u16)reg_val;
+	buf->output_height = (reg_val_h << 8) | reg_val;
 
 	buf->crop_horizontal_end = buf->crop_horizontal_start +
 						buf->output_width - 1;
@@ -317,7 +317,7 @@ static int gc2235_get_intg_factor(struct i2c_client *client,
 	if (ret)
 		return ret;
 
-	dummy = ((u16)reg_val_h << 8) | (u16)reg_val;
+	dummy = (reg_val_h << 8) | reg_val;
 
 	ret = gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_SH_DELAY_H, &reg_val_h);
@@ -702,9 +702,9 @@ static int distance(struct gc2235_resolution *res, u32 w, u32 h)
 	h_ratio = (res->height << 13) / h;
 	if (h_ratio == 0)
 		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
+	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
+	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
 		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
@@ -873,7 +873,7 @@ static int gc2235_detect(struct i2c_client *client)
 	}
 	ret = gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_SENSOR_ID_L, &low);
-	id = ((((u16) high) << 8) | (u16) low);
+	id = (((high) << 8) | low);
 
 	if (id != GC2235_ID) {
 		dev_err(&client->dev, "sensor ID error, 0x%x\n", id);
drivers/staging/media/atomisp/i2c/mt9m114.c +2 -2
index 8762124..514b112 100644
@@ -618,9 +618,9 @@ static int distance(struct mt9m114_res_struct const *res, u32 w, u32 h)
 	h_ratio = (res->height << 13) / h;
 	if (h_ratio == 0)
 		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
+	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
+	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
 		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
drivers/staging/media/atomisp/i2c/ov2722.c +3 -3
index 43e872a..f615898 100644
@@ -807,9 +807,9 @@ static int distance(struct ov2722_resolution *res, u32 w, u32 h)
 	h_ratio = (res->height << 13) / h;
 	if (h_ratio == 0)
 		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
+	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
+	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
 		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
@@ -998,7 +998,7 @@ static int ov2722_detect(struct i2c_client *client)
 	}
 	ret = ov2722_read_reg(client, OV2722_8BIT,
 					OV2722_SC_CMMN_CHIP_ID_L, &low);
-	id = ((((u16) high) << 8) | (u16) low);
+	id = (((high) << 8) | low);
 
 	if ((id != OV2722_ID) && (id != OV2720_ID)) {
 		dev_err(&client->dev, "sensor ID error\n");
drivers/staging/media/atomisp/pci/atomisp2/css2400/runtime/isys/src/isys_dma_rmgr.c +1 -1
index d99150a..5032627 100644
@@ -69,7 +69,7 @@ bool ia_css_isys_dma_channel_rmgr_acquire(
 		for (i = ISYS2401_DMA_CHANNEL_0; i < N_ISYS2401_DMA_CHANNEL; i++) {
 			if (bitop_getbit(cur_rsrc->active_table, i) == 0) {
 				bitop_setbit(cur_rsrc->active_table, i);
-				*channel = (isys2401_dma_channel)i;
+				*channel = i;
 				cur_rsrc->num_active++;
 				retval = true;
 				break;
drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css_firmware.c +4 -4
index eba96cc..b294e6d 100644
@@ -122,7 +122,7 @@ sh_css_load_blob_info(const char *fw, const struct ia_css_fw_info *bi, struct ia
 	/* Special case: only one binary in fw */
 	if (bi == NULL) bi = (const struct ia_css_fw_info *)fw;
 
-	name = (const char *)fw + bi->blob.prog_name_offset;
+	name = fw + bi->blob.prog_name_offset;
 	blob = (const unsigned char *)fw + bi->blob.offset;
 
 	/* sanity check */
@@ -201,7 +201,7 @@ sh_css_check_firmware_version(const char *fw_data)
 	struct sh_css_fw_bi_file_h *file_header;
 
 	firmware_header = (struct firmware_header *)fw_data;
-	file_header = (struct sh_css_fw_bi_file_h *)&firmware_header->file_header;
+	file_header = &firmware_header->file_header;
 
 	if (strcmp(file_header->version, release_version) != 0) {
 		return false;
@@ -221,8 +221,8 @@ sh_css_load_firmware(const char *fw_data,
 	bool valid_firmware = false;
 
 	firmware_header = (struct firmware_header *)fw_data;
-	file_header = (struct sh_css_fw_bi_file_h *)&firmware_header->file_header;
-	binaries = (struct ia_css_fw_info *)&firmware_header->binary_header;
+	file_header = &firmware_header->file_header;
+	binaries = &firmware_header->binary_header;
 	strncpy(FW_rel_ver_name, file_header->version, min(sizeof(FW_rel_ver_name), sizeof(file_header->version)) - 1);
 	valid_firmware = sh_css_check_firmware_version(fw_data);
 	if (!valid_firmware) {
drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +1 -1
index 358d340..a32c981 100644
@@ -553,7 +553,7 @@ int hmm_set(ia_css_ptr virt, int c, unsigned int bytes)
 		vptr = hmm_bo_vmap(bo, true);
 		if (vptr) {
 			vptr = vptr + (virt - bo->start);
-			memset((void *)vptr, c, bytes);
+			memset(vptr, c, bytes);
 			clflush_cache_range(vptr, bytes);
 			hmm_bo_vunmap(bo);
 			return 0;
Signature · 1 line
2.9.3
#2 lore raw

drivers/staging/media/atomisp/i2c/gc2235.c static int gc2235_detect(struct i2c_client *client) · line 876

Quoted 6 lines
drivers/staging/media/atomisp/i2c/gc2235.c +1 -1
@@ -873,7 +873,7 @@ static int gc2235_detect(struct i2c_client *client)
 	}
 	ret = gc2235_read_reg(client, GC2235_8BIT,
 					GC2235_SENSOR_ID_L, &low);
-	id = ((((u16) high) << 8) | (u16) low);
+	id = (((high) << 8) | low);

Useless parens.

Quoted 23 lines
drivers/staging/media/atomisp/i2c/gc2235.c +0 -0
 	if (id != GC2235_ID) {
 		dev_err(&client->dev, "sensor ID error, 0x%x\n", id);
drivers/staging/media/atomisp/i2c/mt9m114.c +2 -2
index 8762124..514b112 100644
@@ -618,9 +618,9 @@ static int distance(struct mt9m114_res_struct const *res, u32 w, u32 h)
 	h_ratio = (res->height << 13) / h;
 	if (h_ratio == 0)
 		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
+	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
-	if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  ||
+	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
 		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
drivers/staging/media/atomisp/i2c/ov2722.c +0 -0
index 43e872a..f615898 100644

drivers/staging/media/atomisp/i2c/ov2722.c static int distance(struct ov2722_resolution *res, u32 w, u32 h) · line 810

Quoted 5 lines
drivers/staging/media/atomisp/i2c/ov2722.c +1 -1
@@ -807,9 +807,9 @@ static int distance(struct ov2722_resolution *res, u32 w, u32 h)
 	h_ratio = (res->height << 13) / h;
 	if (h_ratio == 0)
 		return -1;
-	match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192));
+	match   = abs(((w_ratio << 13) / h_ratio) - (8192));

More useless parens.

julia

author
#3 lore raw
Quoted 37 lines · Julia Lawall

drivers/staging/media/atomisp/i2c/gc2235.c static int gc2235_detect(struct i2c_client *client) · line 876

Quoted 7 lines
drivers/staging/media/atomisp/i2c/gc2235.c +1 -1
@@ -873,7 +873,7 @@ static int gc2235_detect(struct i2c_client *client) 
         } 
         ret = gc2235_read_reg(client, GC2235_8BIT, 
                                         GC2235_SENSOR_ID_L, &low); 
-        id = ((((u16) high) << 8) | (u16) low); 
+        id = (((high) << 8) | low); 

Useless parens.

Review

Quoted 3 lines
drivers/staging/media/atomisp/i2c/gc2235.c +0 -0
         if (id != GC2235_ID) { 
                 dev_err(&client->dev, "sensor ID error, 0x%x\n", id); 
(quoted diff) +0 -0

b/drivers/staging/media/atomisp/i2c/mt9m114.c

drivers/staging/media/atomisp/i2c/mt9m114.c static int distance(struct mt9m114_res_struct const

Quoted 4 lines

index 8762124..514b112 100644

drivers/staging/media/atomisp/i2c/mt9m114.c +0 -0
@@ -618,9 +618,9 @@ static int distance(struct mt9m114_res_struct const 

*res, u32 w, u32 h)

Review

Quoted 12 lines
drivers/staging/media/atomisp/i2c/mt9m114.c +2 -2
         h_ratio = (res->height << 13) / h; 
         if (h_ratio == 0) 
                 return -1; 
-        match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192)); 
+        match   = abs(((w_ratio << 13) / h_ratio) - (8192)); 
 
-        if ((w_ratio < (int)8192) || (h_ratio < (int)8192)  || 
+        if ((w_ratio < 8192) || (h_ratio < 8192)  || 
                 (match > LARGEST_ALLOWED_RATIO_MISMATCH)) 
                 return -1; 
 
(quoted diff) +0 -0

b/drivers/staging/media/atomisp/i2c/ov2722.c

drivers/staging/media/atomisp/i2c/ov2722.c static int distance(struct ov2722_resolution *res,

Quoted 4 lines

index 43e872a..f615898 100644

drivers/staging/media/atomisp/i2c/ov2722.c +0 -0
@@ -807,9 +807,9 @@ static int distance(struct ov2722_resolution *res, 

u32 w, u32 h)

Quoted 8 lines

drivers/staging/media/atomisp/i2c/ov2722.c static int distance(struct ov2722_resolution *res, · line 810

Quoted 5 lines
drivers/staging/media/atomisp/i2c/ov2722.c +1 -1
         h_ratio = (res->height << 13) / h; 
         if (h_ratio == 0) 
                 return -1; 
-        match   = abs(((w_ratio << 13) / h_ratio) - ((int)8192)); 
+        match   = abs(((w_ratio << 13) / h_ratio) - (8192)); 

More useless parens.

I will send a new patchset.

Thanks,
Varsha

author
#4 lore raw

PATCH 2/2 staging: media: atomisp: Match alignment with open parenthesis.

In reply to a message not in the archive

This patch matches alignment with open parenthesis and fixes the checkpatch issue.

---
 drivers/staging/media/atomisp/i2c/gc2235.c  | 2 +-
 drivers/staging/media/atomisp/i2c/mt9m114.c | 2 +-
 drivers/staging/media/atomisp/i2c/ov2722.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/i2c/gc2235.c +1 -1
index 0c3fa70..e07e2c8 100644
@@ -705,7 +705,7 @@ static int distance(struct gc2235_resolution *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
drivers/staging/media/atomisp/i2c/mt9m114.c +1 -1
index 514b112..be2aca5 100644
@@ -621,7 +621,7 @@ static int distance(struct mt9m114_res_struct const *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
drivers/staging/media/atomisp/i2c/ov2722.c +1 -1
index f615898..0976236 100644
@@ -810,7 +810,7 @@ static int distance(struct ov2722_resolution *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
Signature · 1 line
2.9.3
#5 lore raw

Re: [Outreachy kernel] [PATCH 2/2] staging: media: atomisp: Match alignment with open parenthesis.

Quoted 15 lines · Varsha Rao

This patch matches alignment with open parenthesis and fixes the checkpatch issue.

---
 drivers/staging/media/atomisp/i2c/gc2235.c  | 2 +-
 drivers/staging/media/atomisp/i2c/mt9m114.c | 2 +-
 drivers/staging/media/atomisp/i2c/ov2722.c  | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/i2c/gc2235.c +0 -0
index 0c3fa70..e07e2c8 100644

drivers/staging/media/atomisp/i2c/gc2235.c static int distance(struct gc2235_resolution *res, u32 w, u32 h) · line 707

Quoted 3 lines
drivers/staging/media/atomisp/i2c/gc2235.c +0 -0
@@ -705,7 +705,7 @@ static int distance(struct gc2235_resolution *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||

At the same time, you could replace the double space before the final || by a single space. It happens in all the cases.

julia

Quoted 41 lines
drivers/staging/media/atomisp/i2c/gc2235.c +1 -1
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
drivers/staging/media/atomisp/i2c/mt9m114.c +1 -1
index 514b112..be2aca5 100644
@@ -621,7 +621,7 @@ static int distance(struct mt9m114_res_struct const *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
drivers/staging/media/atomisp/i2c/ov2722.c +1 -2
index f615898..0976236 100644
@@ -810,7 +810,7 @@ static int distance(struct ov2722_resolution *res, u32 w, u32 h)
 	match   = abs(((w_ratio << 13) / h_ratio) - (8192));
 
 	if ((w_ratio < 8192) || (h_ratio < 8192)  ||
-		(match > LARGEST_ALLOWED_RATIO_MISMATCH))
+	    (match > LARGEST_ALLOWED_RATIO_MISMATCH))
 		return -1;
 
 	return w_ratio + h_ratio;
--

2.9.3

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/58c16ed0.0ac0620a.fbb6d.de95%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.