Skip to content

Commit b76e0d4

Browse files
hmynenimpe
authored andcommitted
powerpc/pseries: Use correct data types from pseries_hp_errorlog struct
_be32 type is defined for some elements in pseries_hp_errorlog struct but also used them u32 after be32_to_cpu() conversion. Example: In handle_dlpar_errorlog() hp_elog->_drc_u.drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index); And later assigned to u32 type dlpar_cpu() - u32 drc_index = hp_elog->_drc_u.drc_index; This incorrect usage is giving the following warnings and the patch resolve these warnings with the correct assignment. arch/powerpc/platforms/pseries/dlpar.c:398:53: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected unsigned int [usertype] drc_index @@ got restricted __be32 [usertype] drc_index @@ ... arch/powerpc/platforms/pseries/dlpar.c:418:43: sparse: sparse: incorrect type in assignment (different base types) @@ expected restricted __be32 [usertype] drc_count @@ got unsigned int [usertype] @@ Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202408182142.wuIKqYae-lkp@intel.com/ Closes: https://lore.kernel.org/oe-kbuild-all/202408182302.o7QRO45S-lkp@intel.com/ Signed-off-by: Haren Myneni <haren@linux.ibm.com> v3: - Fix warnings from using incorrect data types in pseries_hp_errorlog struct v2: - Remove pr_info() and TODO comments - Update more information in the commit logs Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240822025028.938332-1-haren@linux.ibm.com
1 parent 65948b0 commit b76e0d4

4 files changed

Lines changed: 10 additions & 27 deletions

File tree

arch/powerpc/platforms/pseries/dlpar.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -331,23 +331,6 @@ int handle_dlpar_errorlog(struct pseries_hp_errorlog *hp_elog)
331331
{
332332
int rc;
333333

334-
/* pseries error logs are in BE format, convert to cpu type */
335-
switch (hp_elog->id_type) {
336-
case PSERIES_HP_ELOG_ID_DRC_COUNT:
337-
hp_elog->_drc_u.drc_count =
338-
be32_to_cpu(hp_elog->_drc_u.drc_count);
339-
break;
340-
case PSERIES_HP_ELOG_ID_DRC_INDEX:
341-
hp_elog->_drc_u.drc_index =
342-
be32_to_cpu(hp_elog->_drc_u.drc_index);
343-
break;
344-
case PSERIES_HP_ELOG_ID_DRC_IC:
345-
hp_elog->_drc_u.ic.count =
346-
be32_to_cpu(hp_elog->_drc_u.ic.count);
347-
hp_elog->_drc_u.ic.index =
348-
be32_to_cpu(hp_elog->_drc_u.ic.index);
349-
}
350-
351334
switch (hp_elog->resource) {
352335
case PSERIES_HP_ELOG_RESOURCE_MEM:
353336
rc = dlpar_memory(hp_elog);

arch/powerpc/platforms/pseries/hotplug-cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ int dlpar_cpu(struct pseries_hp_errorlog *hp_elog)
757757
u32 drc_index;
758758
int rc;
759759

760-
drc_index = hp_elog->_drc_u.drc_index;
760+
drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
761761

762762
lock_device_hotplug();
763763

arch/powerpc/platforms/pseries/hotplug-memory.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -817,16 +817,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
817817
case PSERIES_HP_ELOG_ACTION_ADD:
818818
switch (hp_elog->id_type) {
819819
case PSERIES_HP_ELOG_ID_DRC_COUNT:
820-
count = hp_elog->_drc_u.drc_count;
820+
count = be32_to_cpu(hp_elog->_drc_u.drc_count);
821821
rc = dlpar_memory_add_by_count(count);
822822
break;
823823
case PSERIES_HP_ELOG_ID_DRC_INDEX:
824-
drc_index = hp_elog->_drc_u.drc_index;
824+
drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
825825
rc = dlpar_memory_add_by_index(drc_index);
826826
break;
827827
case PSERIES_HP_ELOG_ID_DRC_IC:
828-
count = hp_elog->_drc_u.ic.count;
829-
drc_index = hp_elog->_drc_u.ic.index;
828+
count = be32_to_cpu(hp_elog->_drc_u.ic.count);
829+
drc_index = be32_to_cpu(hp_elog->_drc_u.ic.index);
830830
rc = dlpar_memory_add_by_ic(count, drc_index);
831831
break;
832832
default:
@@ -838,16 +838,16 @@ int dlpar_memory(struct pseries_hp_errorlog *hp_elog)
838838
case PSERIES_HP_ELOG_ACTION_REMOVE:
839839
switch (hp_elog->id_type) {
840840
case PSERIES_HP_ELOG_ID_DRC_COUNT:
841-
count = hp_elog->_drc_u.drc_count;
841+
count = be32_to_cpu(hp_elog->_drc_u.drc_count);
842842
rc = dlpar_memory_remove_by_count(count);
843843
break;
844844
case PSERIES_HP_ELOG_ID_DRC_INDEX:
845-
drc_index = hp_elog->_drc_u.drc_index;
845+
drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
846846
rc = dlpar_memory_remove_by_index(drc_index);
847847
break;
848848
case PSERIES_HP_ELOG_ID_DRC_IC:
849-
count = hp_elog->_drc_u.ic.count;
850-
drc_index = hp_elog->_drc_u.ic.index;
849+
count = be32_to_cpu(hp_elog->_drc_u.ic.count);
850+
drc_index = be32_to_cpu(hp_elog->_drc_u.ic.index);
851851
rc = dlpar_memory_remove_by_ic(count, drc_index);
852852
break;
853853
default:

arch/powerpc/platforms/pseries/pmem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ int dlpar_hp_pmem(struct pseries_hp_errorlog *hp_elog)
121121
return -EINVAL;
122122
}
123123

124-
drc_index = hp_elog->_drc_u.drc_index;
124+
drc_index = be32_to_cpu(hp_elog->_drc_u.drc_index);
125125

126126
lock_device_hotplug();
127127

0 commit comments

Comments
 (0)