* drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
@ 2022-06-06 19:35 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-06-06 19:35 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 9978 bytes --]
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Javier Martinez Canillas <javierm@redhat.com>
CC: Maxime Ripard <maxime@cerno.tech>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: f2906aa863381afb0015a9eb7fefad885d4e5a56
commit: a61732e808672cfa8c8c6028bcf9feacb953ef40 drm: Add driver for Solomon SSD130x OLED displays
date: 4 months ago
:::::: branch date: 19 hours ago
:::::: commit date: 4 months ago
compiler: s390-linux-gcc (GCC) 11.3.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout a61732e808672cfa8c8c6028bcf9feacb953ef40
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
cppcheck warnings: (new ones prefixed by >>)
drivers/md/dm-integrity.c:4493:7: warning: Local variable 'r' shadows outer variable [shadowVariable]
int r;
^
drivers/md/dm-integrity.c:3966:6: note: Shadowed declaration
int r;
^
drivers/md/dm-integrity.c:4493:7: note: Shadow variable
int r;
^
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
drivers/gpu/drm/solomon/ssd130x.c:585:7: warning: Redundant initialization for 'mode'. The initialized value is overwritten before it is read. [redundantInitialization]
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
drivers/gpu/drm/solomon/ssd130x.c:582:32: note: mode is initialized
struct drm_display_mode *mode = &ssd130x->mode;
^
drivers/gpu/drm/solomon/ssd130x.c:585:7: note: mode is overwritten
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
>> drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
^
--
>> drivers/media/i2c/ov7670.c:1283:7: warning: Parameter 'matrix' can be declared with const [constParameter]
int matrix[CMATRIX_LEN])
^
>> drivers/md/dm-crypt.c:2920:6: warning: Redundant initialization for 'ret'. The initialized value is overwritten before it is read. [redundantInitialization]
ret = crypt_alloc_tfms(cc, cipher_api);
^
drivers/md/dm-crypt.c:2866:10: note: ret is initialized
int ret = -EINVAL;
^
drivers/md/dm-crypt.c:2920:6: note: ret is overwritten
ret = crypt_alloc_tfms(cc, cipher_api);
^
>> drivers/md/dm-integrity.c:2268:3: warning: Address of local auto-variable assigned to a function parameter. [autoVariables]
dio->completion = &read_comp;
^
vim +/buf +348 drivers/gpu/drm/solomon/ssd130x.c
a61732e808672c Javier Martinez Canillas 2022-02-14 347
a61732e808672c Javier Martinez Canillas 2022-02-14 @348 static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
a61732e808672c Javier Martinez Canillas 2022-02-14 349 struct drm_rect *rect)
a61732e808672c Javier Martinez Canillas 2022-02-14 350 {
a61732e808672c Javier Martinez Canillas 2022-02-14 351 unsigned int x = rect->x1;
a61732e808672c Javier Martinez Canillas 2022-02-14 352 unsigned int y = rect->y1;
a61732e808672c Javier Martinez Canillas 2022-02-14 353 unsigned int width = drm_rect_width(rect);
a61732e808672c Javier Martinez Canillas 2022-02-14 354 unsigned int height = drm_rect_height(rect);
a61732e808672c Javier Martinez Canillas 2022-02-14 355 unsigned int line_length = DIV_ROUND_UP(width, 8);
a61732e808672c Javier Martinez Canillas 2022-02-14 356 unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8);
a61732e808672c Javier Martinez Canillas 2022-02-14 357 u32 array_idx = 0;
a61732e808672c Javier Martinez Canillas 2022-02-14 358 int ret, i, j, k;
a61732e808672c Javier Martinez Canillas 2022-02-14 359 u8 *data_array = NULL;
a61732e808672c Javier Martinez Canillas 2022-02-14 360
a61732e808672c Javier Martinez Canillas 2022-02-14 361 data_array = kcalloc(width, pages, GFP_KERNEL);
a61732e808672c Javier Martinez Canillas 2022-02-14 362 if (!data_array)
a61732e808672c Javier Martinez Canillas 2022-02-14 363 return -ENOMEM;
a61732e808672c Javier Martinez Canillas 2022-02-14 364
a61732e808672c Javier Martinez Canillas 2022-02-14 365 /*
a61732e808672c Javier Martinez Canillas 2022-02-14 366 * The screen is divided in pages, each having a height of 8
a61732e808672c Javier Martinez Canillas 2022-02-14 367 * pixels, and the width of the screen. When sending a byte of
a61732e808672c Javier Martinez Canillas 2022-02-14 368 * data to the controller, it gives the 8 bits for the current
a61732e808672c Javier Martinez Canillas 2022-02-14 369 * column. I.e, the first byte are the 8 bits of the first
a61732e808672c Javier Martinez Canillas 2022-02-14 370 * column, then the 8 bits for the second column, etc.
a61732e808672c Javier Martinez Canillas 2022-02-14 371 *
a61732e808672c Javier Martinez Canillas 2022-02-14 372 *
a61732e808672c Javier Martinez Canillas 2022-02-14 373 * Representation of the screen, assuming it is 5 bits
a61732e808672c Javier Martinez Canillas 2022-02-14 374 * wide. Each letter-number combination is a bit that controls
a61732e808672c Javier Martinez Canillas 2022-02-14 375 * one pixel.
a61732e808672c Javier Martinez Canillas 2022-02-14 376 *
a61732e808672c Javier Martinez Canillas 2022-02-14 377 * A0 A1 A2 A3 A4
a61732e808672c Javier Martinez Canillas 2022-02-14 378 * B0 B1 B2 B3 B4
a61732e808672c Javier Martinez Canillas 2022-02-14 379 * C0 C1 C2 C3 C4
a61732e808672c Javier Martinez Canillas 2022-02-14 380 * D0 D1 D2 D3 D4
a61732e808672c Javier Martinez Canillas 2022-02-14 381 * E0 E1 E2 E3 E4
a61732e808672c Javier Martinez Canillas 2022-02-14 382 * F0 F1 F2 F3 F4
a61732e808672c Javier Martinez Canillas 2022-02-14 383 * G0 G1 G2 G3 G4
a61732e808672c Javier Martinez Canillas 2022-02-14 384 * H0 H1 H2 H3 H4
a61732e808672c Javier Martinez Canillas 2022-02-14 385 *
a61732e808672c Javier Martinez Canillas 2022-02-14 386 * If you want to update this screen, you need to send 5 bytes:
a61732e808672c Javier Martinez Canillas 2022-02-14 387 * (1) A0 B0 C0 D0 E0 F0 G0 H0
a61732e808672c Javier Martinez Canillas 2022-02-14 388 * (2) A1 B1 C1 D1 E1 F1 G1 H1
a61732e808672c Javier Martinez Canillas 2022-02-14 389 * (3) A2 B2 C2 D2 E2 F2 G2 H2
a61732e808672c Javier Martinez Canillas 2022-02-14 390 * (4) A3 B3 C3 D3 E3 F3 G3 H3
a61732e808672c Javier Martinez Canillas 2022-02-14 391 * (5) A4 B4 C4 D4 E4 F4 G4 H4
a61732e808672c Javier Martinez Canillas 2022-02-14 392 */
a61732e808672c Javier Martinez Canillas 2022-02-14 393
a61732e808672c Javier Martinez Canillas 2022-02-14 394 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width);
a61732e808672c Javier Martinez Canillas 2022-02-14 395 if (ret < 0)
a61732e808672c Javier Martinez Canillas 2022-02-14 396 goto out_free;
a61732e808672c Javier Martinez Canillas 2022-02-14 397
a61732e808672c Javier Martinez Canillas 2022-02-14 398 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages);
a61732e808672c Javier Martinez Canillas 2022-02-14 399 if (ret < 0)
a61732e808672c Javier Martinez Canillas 2022-02-14 400 goto out_free;
a61732e808672c Javier Martinez Canillas 2022-02-14 401
a61732e808672c Javier Martinez Canillas 2022-02-14 402 for (i = y / 8; i < y / 8 + pages; i++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 403 int m = 8;
a61732e808672c Javier Martinez Canillas 2022-02-14 404
a61732e808672c Javier Martinez Canillas 2022-02-14 405 /* Last page may be partial */
a61732e808672c Javier Martinez Canillas 2022-02-14 406 if (8 * (i + 1) > ssd130x->height)
a61732e808672c Javier Martinez Canillas 2022-02-14 407 m = ssd130x->height % 8;
a61732e808672c Javier Martinez Canillas 2022-02-14 408 for (j = x; j < x + width; j++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 409 u8 data = 0;
a61732e808672c Javier Martinez Canillas 2022-02-14 410
a61732e808672c Javier Martinez Canillas 2022-02-14 411 for (k = 0; k < m; k++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 412 u8 byte = buf[(8 * i + k) * line_length + j / 8];
a61732e808672c Javier Martinez Canillas 2022-02-14 413 u8 bit = (byte >> (j % 8)) & 1;
a61732e808672c Javier Martinez Canillas 2022-02-14 414
a61732e808672c Javier Martinez Canillas 2022-02-14 415 data |= bit << k;
a61732e808672c Javier Martinez Canillas 2022-02-14 416 }
a61732e808672c Javier Martinez Canillas 2022-02-14 417 data_array[array_idx++] = data;
a61732e808672c Javier Martinez Canillas 2022-02-14 418 }
a61732e808672c Javier Martinez Canillas 2022-02-14 419 }
a61732e808672c Javier Martinez Canillas 2022-02-14 420
a61732e808672c Javier Martinez Canillas 2022-02-14 421 ret = ssd130x_write_data(ssd130x, data_array, width * pages);
a61732e808672c Javier Martinez Canillas 2022-02-14 422
a61732e808672c Javier Martinez Canillas 2022-02-14 423 out_free:
a61732e808672c Javier Martinez Canillas 2022-02-14 424 kfree(data_array);
a61732e808672c Javier Martinez Canillas 2022-02-14 425 return ret;
a61732e808672c Javier Martinez Canillas 2022-02-14 426 }
a61732e808672c Javier Martinez Canillas 2022-02-14 427
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
* drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
@ 2022-07-16 2:51 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-07-16 2:51 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 12440 bytes --]
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Javier Martinez Canillas <javierm@redhat.com>
CC: Maxime Ripard <maxime@cerno.tech>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9b59ec8d50a1f28747ceff9a4f39af5deba9540e
commit: a61732e808672cfa8c8c6028bcf9feacb953ef40 drm: Add driver for Solomon SSD130x OLED displays
date: 5 months ago
:::::: branch date: 9 hours ago
:::::: commit date: 5 months ago
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout a61732e808672cfa8c8c6028bcf9feacb953ef40
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
cppcheck warnings: (new ones prefixed by >>)
>> drivers/media/cec/platform/cros-ec/cros-ec-cec.c:97:26: warning: Local variable 'msg' shadows outer variable [shadowVariable]
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:97:26: note: Shadowed declaration
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:97:26: note: Shadow variable
struct cros_ec_command msg;
^
>> drivers/media/cec/platform/cros-ec/cros-ec-cec.c:98:28: warning: Local variable 'data' shadows outer variable [shadowVariable]
struct ec_params_cec_set data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:98:28: note: Shadowed declaration
struct ec_params_cec_set data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:98:28: note: Shadow variable
struct ec_params_cec_set data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:123:26: warning: Local variable 'msg' shadows outer variable [shadowVariable]
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:123:26: note: Shadowed declaration
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:123:26: note: Shadow variable
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:124:30: warning: Local variable 'data' shadows outer variable [shadowVariable]
struct ec_params_cec_write data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:124:30: note: Shadowed declaration
struct ec_params_cec_write data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:124:30: note: Shadow variable
struct ec_params_cec_write data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:147:26: warning: Local variable 'msg' shadows outer variable [shadowVariable]
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:147:26: note: Shadowed declaration
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:147:26: note: Shadow variable
struct cros_ec_command msg;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:148:28: warning: Local variable 'data' shadows outer variable [shadowVariable]
struct ec_params_cec_set data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:148:28: note: Shadowed declaration
struct ec_params_cec_set data;
^
drivers/media/cec/platform/cros-ec/cros-ec-cec.c:148:28: note: Shadow variable
struct ec_params_cec_set data;
^
--
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
drivers/gpu/drm/solomon/ssd130x.c:585:7: warning: Redundant initialization for 'mode'. The initialized value is overwritten before it is read. [redundantInitialization]
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
drivers/gpu/drm/solomon/ssd130x.c:582:32: note: mode is initialized
struct drm_display_mode *mode = &ssd130x->mode;
^
drivers/gpu/drm/solomon/ssd130x.c:585:7: note: mode is overwritten
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
>> drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
^
--
>> drivers/media/pci/ddbridge/ddbridge-mci.c:110:42: warning: Parameter 'key' can be declared with const [constParameter]
static struct mci_base *match_base(void *key)
^
--
>> drivers/media/pci/ddbridge/ddbridge-core.c:2516:2: warning: Signed integer overflow for expression '0x000000ff<<(24&0x1f)'. [integerOverflow]
IRQ_HANDLE_BYTE(24);
^
vim +/buf +348 drivers/gpu/drm/solomon/ssd130x.c
a61732e808672cf Javier Martinez Canillas 2022-02-14 347
a61732e808672cf Javier Martinez Canillas 2022-02-14 @348 static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
a61732e808672cf Javier Martinez Canillas 2022-02-14 349 struct drm_rect *rect)
a61732e808672cf Javier Martinez Canillas 2022-02-14 350 {
a61732e808672cf Javier Martinez Canillas 2022-02-14 351 unsigned int x = rect->x1;
a61732e808672cf Javier Martinez Canillas 2022-02-14 352 unsigned int y = rect->y1;
a61732e808672cf Javier Martinez Canillas 2022-02-14 353 unsigned int width = drm_rect_width(rect);
a61732e808672cf Javier Martinez Canillas 2022-02-14 354 unsigned int height = drm_rect_height(rect);
a61732e808672cf Javier Martinez Canillas 2022-02-14 355 unsigned int line_length = DIV_ROUND_UP(width, 8);
a61732e808672cf Javier Martinez Canillas 2022-02-14 356 unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8);
a61732e808672cf Javier Martinez Canillas 2022-02-14 357 u32 array_idx = 0;
a61732e808672cf Javier Martinez Canillas 2022-02-14 358 int ret, i, j, k;
a61732e808672cf Javier Martinez Canillas 2022-02-14 359 u8 *data_array = NULL;
a61732e808672cf Javier Martinez Canillas 2022-02-14 360
a61732e808672cf Javier Martinez Canillas 2022-02-14 361 data_array = kcalloc(width, pages, GFP_KERNEL);
a61732e808672cf Javier Martinez Canillas 2022-02-14 362 if (!data_array)
a61732e808672cf Javier Martinez Canillas 2022-02-14 363 return -ENOMEM;
a61732e808672cf Javier Martinez Canillas 2022-02-14 364
a61732e808672cf Javier Martinez Canillas 2022-02-14 365 /*
a61732e808672cf Javier Martinez Canillas 2022-02-14 366 * The screen is divided in pages, each having a height of 8
a61732e808672cf Javier Martinez Canillas 2022-02-14 367 * pixels, and the width of the screen. When sending a byte of
a61732e808672cf Javier Martinez Canillas 2022-02-14 368 * data to the controller, it gives the 8 bits for the current
a61732e808672cf Javier Martinez Canillas 2022-02-14 369 * column. I.e, the first byte are the 8 bits of the first
a61732e808672cf Javier Martinez Canillas 2022-02-14 370 * column, then the 8 bits for the second column, etc.
a61732e808672cf Javier Martinez Canillas 2022-02-14 371 *
a61732e808672cf Javier Martinez Canillas 2022-02-14 372 *
a61732e808672cf Javier Martinez Canillas 2022-02-14 373 * Representation of the screen, assuming it is 5 bits
a61732e808672cf Javier Martinez Canillas 2022-02-14 374 * wide. Each letter-number combination is a bit that controls
a61732e808672cf Javier Martinez Canillas 2022-02-14 375 * one pixel.
a61732e808672cf Javier Martinez Canillas 2022-02-14 376 *
a61732e808672cf Javier Martinez Canillas 2022-02-14 377 * A0 A1 A2 A3 A4
a61732e808672cf Javier Martinez Canillas 2022-02-14 378 * B0 B1 B2 B3 B4
a61732e808672cf Javier Martinez Canillas 2022-02-14 379 * C0 C1 C2 C3 C4
a61732e808672cf Javier Martinez Canillas 2022-02-14 380 * D0 D1 D2 D3 D4
a61732e808672cf Javier Martinez Canillas 2022-02-14 381 * E0 E1 E2 E3 E4
a61732e808672cf Javier Martinez Canillas 2022-02-14 382 * F0 F1 F2 F3 F4
a61732e808672cf Javier Martinez Canillas 2022-02-14 383 * G0 G1 G2 G3 G4
a61732e808672cf Javier Martinez Canillas 2022-02-14 384 * H0 H1 H2 H3 H4
a61732e808672cf Javier Martinez Canillas 2022-02-14 385 *
a61732e808672cf Javier Martinez Canillas 2022-02-14 386 * If you want to update this screen, you need to send 5 bytes:
a61732e808672cf Javier Martinez Canillas 2022-02-14 387 * (1) A0 B0 C0 D0 E0 F0 G0 H0
a61732e808672cf Javier Martinez Canillas 2022-02-14 388 * (2) A1 B1 C1 D1 E1 F1 G1 H1
a61732e808672cf Javier Martinez Canillas 2022-02-14 389 * (3) A2 B2 C2 D2 E2 F2 G2 H2
a61732e808672cf Javier Martinez Canillas 2022-02-14 390 * (4) A3 B3 C3 D3 E3 F3 G3 H3
a61732e808672cf Javier Martinez Canillas 2022-02-14 391 * (5) A4 B4 C4 D4 E4 F4 G4 H4
a61732e808672cf Javier Martinez Canillas 2022-02-14 392 */
a61732e808672cf Javier Martinez Canillas 2022-02-14 393
a61732e808672cf Javier Martinez Canillas 2022-02-14 394 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width);
a61732e808672cf Javier Martinez Canillas 2022-02-14 395 if (ret < 0)
a61732e808672cf Javier Martinez Canillas 2022-02-14 396 goto out_free;
a61732e808672cf Javier Martinez Canillas 2022-02-14 397
a61732e808672cf Javier Martinez Canillas 2022-02-14 398 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages);
a61732e808672cf Javier Martinez Canillas 2022-02-14 399 if (ret < 0)
a61732e808672cf Javier Martinez Canillas 2022-02-14 400 goto out_free;
a61732e808672cf Javier Martinez Canillas 2022-02-14 401
a61732e808672cf Javier Martinez Canillas 2022-02-14 402 for (i = y / 8; i < y / 8 + pages; i++) {
a61732e808672cf Javier Martinez Canillas 2022-02-14 403 int m = 8;
a61732e808672cf Javier Martinez Canillas 2022-02-14 404
a61732e808672cf Javier Martinez Canillas 2022-02-14 405 /* Last page may be partial */
a61732e808672cf Javier Martinez Canillas 2022-02-14 406 if (8 * (i + 1) > ssd130x->height)
a61732e808672cf Javier Martinez Canillas 2022-02-14 407 m = ssd130x->height % 8;
a61732e808672cf Javier Martinez Canillas 2022-02-14 408 for (j = x; j < x + width; j++) {
a61732e808672cf Javier Martinez Canillas 2022-02-14 409 u8 data = 0;
a61732e808672cf Javier Martinez Canillas 2022-02-14 410
a61732e808672cf Javier Martinez Canillas 2022-02-14 411 for (k = 0; k < m; k++) {
a61732e808672cf Javier Martinez Canillas 2022-02-14 412 u8 byte = buf[(8 * i + k) * line_length + j / 8];
a61732e808672cf Javier Martinez Canillas 2022-02-14 413 u8 bit = (byte >> (j % 8)) & 1;
a61732e808672cf Javier Martinez Canillas 2022-02-14 414
a61732e808672cf Javier Martinez Canillas 2022-02-14 415 data |= bit << k;
a61732e808672cf Javier Martinez Canillas 2022-02-14 416 }
a61732e808672cf Javier Martinez Canillas 2022-02-14 417 data_array[array_idx++] = data;
a61732e808672cf Javier Martinez Canillas 2022-02-14 418 }
a61732e808672cf Javier Martinez Canillas 2022-02-14 419 }
a61732e808672cf Javier Martinez Canillas 2022-02-14 420
a61732e808672cf Javier Martinez Canillas 2022-02-14 421 ret = ssd130x_write_data(ssd130x, data_array, width * pages);
a61732e808672cf Javier Martinez Canillas 2022-02-14 422
a61732e808672cf Javier Martinez Canillas 2022-02-14 423 out_free:
a61732e808672cf Javier Martinez Canillas 2022-02-14 424 kfree(data_array);
a61732e808672cf Javier Martinez Canillas 2022-02-14 425 return ret;
a61732e808672cf Javier Martinez Canillas 2022-02-14 426 }
a61732e808672cf Javier Martinez Canillas 2022-02-14 427
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
* drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
@ 2022-04-23 4:26 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2022-04-23 4:26 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 8658 bytes --]
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Javier Martinez Canillas <javierm@redhat.com>
CC: Maxime Ripard <maxime@cerno.tech>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c00c5e1d157bec0ef0b0b59aa5482eb8dc7e8e49
commit: a61732e808672cfa8c8c6028bcf9feacb953ef40 drm: Add driver for Solomon SSD130x OLED displays
date: 9 weeks ago
:::::: branch date: 3 hours ago
:::::: commit date: 9 weeks ago
compiler: arc-elf-gcc (GCC) 11.2.0
reproduce (cppcheck warning):
# apt-get install cppcheck
git checkout a61732e808672cfa8c8c6028bcf9feacb953ef40
cppcheck --quiet --enable=style,performance,portability --template=gcc FILE
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
cppcheck possible warnings: (new ones prefixed by >>, may not real problems)
drivers/gpu/drm/solomon/ssd130x.c:585:7: warning: Redundant initialization for 'mode'. The initialized value is overwritten before it is read. [redundantInitialization]
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
drivers/gpu/drm/solomon/ssd130x.c:582:32: note: mode is initialized
struct drm_display_mode *mode = &ssd130x->mode;
^
drivers/gpu/drm/solomon/ssd130x.c:585:7: note: mode is overwritten
mode = drm_mode_duplicate(connector->dev, &ssd130x->mode);
^
>> drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter]
static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
^
vim +/buf +348 drivers/gpu/drm/solomon/ssd130x.c
a61732e808672c Javier Martinez Canillas 2022-02-14 347
a61732e808672c Javier Martinez Canillas 2022-02-14 @348 static int ssd130x_update_rect(struct ssd130x_device *ssd130x, u8 *buf,
a61732e808672c Javier Martinez Canillas 2022-02-14 349 struct drm_rect *rect)
a61732e808672c Javier Martinez Canillas 2022-02-14 350 {
a61732e808672c Javier Martinez Canillas 2022-02-14 351 unsigned int x = rect->x1;
a61732e808672c Javier Martinez Canillas 2022-02-14 352 unsigned int y = rect->y1;
a61732e808672c Javier Martinez Canillas 2022-02-14 353 unsigned int width = drm_rect_width(rect);
a61732e808672c Javier Martinez Canillas 2022-02-14 354 unsigned int height = drm_rect_height(rect);
a61732e808672c Javier Martinez Canillas 2022-02-14 355 unsigned int line_length = DIV_ROUND_UP(width, 8);
a61732e808672c Javier Martinez Canillas 2022-02-14 356 unsigned int pages = DIV_ROUND_UP(y % 8 + height, 8);
a61732e808672c Javier Martinez Canillas 2022-02-14 357 u32 array_idx = 0;
a61732e808672c Javier Martinez Canillas 2022-02-14 358 int ret, i, j, k;
a61732e808672c Javier Martinez Canillas 2022-02-14 359 u8 *data_array = NULL;
a61732e808672c Javier Martinez Canillas 2022-02-14 360
a61732e808672c Javier Martinez Canillas 2022-02-14 361 data_array = kcalloc(width, pages, GFP_KERNEL);
a61732e808672c Javier Martinez Canillas 2022-02-14 362 if (!data_array)
a61732e808672c Javier Martinez Canillas 2022-02-14 363 return -ENOMEM;
a61732e808672c Javier Martinez Canillas 2022-02-14 364
a61732e808672c Javier Martinez Canillas 2022-02-14 365 /*
a61732e808672c Javier Martinez Canillas 2022-02-14 366 * The screen is divided in pages, each having a height of 8
a61732e808672c Javier Martinez Canillas 2022-02-14 367 * pixels, and the width of the screen. When sending a byte of
a61732e808672c Javier Martinez Canillas 2022-02-14 368 * data to the controller, it gives the 8 bits for the current
a61732e808672c Javier Martinez Canillas 2022-02-14 369 * column. I.e, the first byte are the 8 bits of the first
a61732e808672c Javier Martinez Canillas 2022-02-14 370 * column, then the 8 bits for the second column, etc.
a61732e808672c Javier Martinez Canillas 2022-02-14 371 *
a61732e808672c Javier Martinez Canillas 2022-02-14 372 *
a61732e808672c Javier Martinez Canillas 2022-02-14 373 * Representation of the screen, assuming it is 5 bits
a61732e808672c Javier Martinez Canillas 2022-02-14 374 * wide. Each letter-number combination is a bit that controls
a61732e808672c Javier Martinez Canillas 2022-02-14 375 * one pixel.
a61732e808672c Javier Martinez Canillas 2022-02-14 376 *
a61732e808672c Javier Martinez Canillas 2022-02-14 377 * A0 A1 A2 A3 A4
a61732e808672c Javier Martinez Canillas 2022-02-14 378 * B0 B1 B2 B3 B4
a61732e808672c Javier Martinez Canillas 2022-02-14 379 * C0 C1 C2 C3 C4
a61732e808672c Javier Martinez Canillas 2022-02-14 380 * D0 D1 D2 D3 D4
a61732e808672c Javier Martinez Canillas 2022-02-14 381 * E0 E1 E2 E3 E4
a61732e808672c Javier Martinez Canillas 2022-02-14 382 * F0 F1 F2 F3 F4
a61732e808672c Javier Martinez Canillas 2022-02-14 383 * G0 G1 G2 G3 G4
a61732e808672c Javier Martinez Canillas 2022-02-14 384 * H0 H1 H2 H3 H4
a61732e808672c Javier Martinez Canillas 2022-02-14 385 *
a61732e808672c Javier Martinez Canillas 2022-02-14 386 * If you want to update this screen, you need to send 5 bytes:
a61732e808672c Javier Martinez Canillas 2022-02-14 387 * (1) A0 B0 C0 D0 E0 F0 G0 H0
a61732e808672c Javier Martinez Canillas 2022-02-14 388 * (2) A1 B1 C1 D1 E1 F1 G1 H1
a61732e808672c Javier Martinez Canillas 2022-02-14 389 * (3) A2 B2 C2 D2 E2 F2 G2 H2
a61732e808672c Javier Martinez Canillas 2022-02-14 390 * (4) A3 B3 C3 D3 E3 F3 G3 H3
a61732e808672c Javier Martinez Canillas 2022-02-14 391 * (5) A4 B4 C4 D4 E4 F4 G4 H4
a61732e808672c Javier Martinez Canillas 2022-02-14 392 */
a61732e808672c Javier Martinez Canillas 2022-02-14 393
a61732e808672c Javier Martinez Canillas 2022-02-14 394 ret = ssd130x_set_col_range(ssd130x, ssd130x->col_offset + x, width);
a61732e808672c Javier Martinez Canillas 2022-02-14 395 if (ret < 0)
a61732e808672c Javier Martinez Canillas 2022-02-14 396 goto out_free;
a61732e808672c Javier Martinez Canillas 2022-02-14 397
a61732e808672c Javier Martinez Canillas 2022-02-14 398 ret = ssd130x_set_page_range(ssd130x, ssd130x->page_offset + y / 8, pages);
a61732e808672c Javier Martinez Canillas 2022-02-14 399 if (ret < 0)
a61732e808672c Javier Martinez Canillas 2022-02-14 400 goto out_free;
a61732e808672c Javier Martinez Canillas 2022-02-14 401
a61732e808672c Javier Martinez Canillas 2022-02-14 402 for (i = y / 8; i < y / 8 + pages; i++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 403 int m = 8;
a61732e808672c Javier Martinez Canillas 2022-02-14 404
a61732e808672c Javier Martinez Canillas 2022-02-14 405 /* Last page may be partial */
a61732e808672c Javier Martinez Canillas 2022-02-14 406 if (8 * (i + 1) > ssd130x->height)
a61732e808672c Javier Martinez Canillas 2022-02-14 407 m = ssd130x->height % 8;
a61732e808672c Javier Martinez Canillas 2022-02-14 408 for (j = x; j < x + width; j++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 409 u8 data = 0;
a61732e808672c Javier Martinez Canillas 2022-02-14 410
a61732e808672c Javier Martinez Canillas 2022-02-14 411 for (k = 0; k < m; k++) {
a61732e808672c Javier Martinez Canillas 2022-02-14 412 u8 byte = buf[(8 * i + k) * line_length + j / 8];
a61732e808672c Javier Martinez Canillas 2022-02-14 413 u8 bit = (byte >> (j % 8)) & 1;
a61732e808672c Javier Martinez Canillas 2022-02-14 414
a61732e808672c Javier Martinez Canillas 2022-02-14 415 data |= bit << k;
a61732e808672c Javier Martinez Canillas 2022-02-14 416 }
a61732e808672c Javier Martinez Canillas 2022-02-14 417 data_array[array_idx++] = data;
a61732e808672c Javier Martinez Canillas 2022-02-14 418 }
a61732e808672c Javier Martinez Canillas 2022-02-14 419 }
a61732e808672c Javier Martinez Canillas 2022-02-14 420
a61732e808672c Javier Martinez Canillas 2022-02-14 421 ret = ssd130x_write_data(ssd130x, data_array, width * pages);
a61732e808672c Javier Martinez Canillas 2022-02-14 422
a61732e808672c Javier Martinez Canillas 2022-02-14 423 out_free:
a61732e808672c Javier Martinez Canillas 2022-02-14 424 kfree(data_array);
a61732e808672c Javier Martinez Canillas 2022-02-14 425 return ret;
a61732e808672c Javier Martinez Canillas 2022-02-14 426 }
a61732e808672c Javier Martinez Canillas 2022-02-14 427
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-07-16 2:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-06 19:35 drivers/gpu/drm/solomon/ssd130x.c:348:68: warning: Parameter 'buf' can be declared with const [constParameter] kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2022-07-16 2:51 kernel test robot
2022-04-23 4:26 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.