Skip to contentSkip to conversation

drivers/hwmon/pmbus/ibm-cffps.c:144:48: sparse: cast to restricted __be16

PATCH Guenter Roeck 1 participant 1 message Dec 14, 2017 1 message not in the archive Hardware monitoring

lore
Share & tools
lore

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

Guenter Roeck

author maintainer
#1 lore raw
Quoted 35 lines · kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
head:   99f691882e7733651625ff23f199c4086dee1f89
commit: 99f691882e7733651625ff23f199c4086dee1f89 [20/20] hwmon: (pmbus) cffps: Add debugfs entries
reproduce:
        # apt-get install sparse
        git checkout 99f691882e7733651625ff23f199c4086dee1f89
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__

sparse warnings: (new ones prefixed by >>)

vim +144 drivers/hwmon/pmbus/ibm-cffps.c

   116	
   117	static ssize_t ibm_cffps_debugfs_op(struct file *file, char __user *buf,
   118					    size_t count, loff_t *ppos)
   119	{
   120		u8 cmd;
   121		int i, rc;
   122		int *idxp = file->private_data;
   123		int idx = *idxp;
   124		struct ibm_cffps *psu = to_psu(idxp, idx);
   125		char data[I2C_SMBUS_BLOCK_MAX] = { 0 };
   126	
   127		switch (idx) {
   128		case CFFPS_DEBUGFS_INPUT_HISTORY:
   129			return ibm_cffps_read_input_history(psu, buf, count, ppos);
   130		case CFFPS_DEBUGFS_FRU:
   131			cmd = CFFPS_FRU_CMD;
   132			break;
   133		case CFFPS_DEBUGFS_PN:
   134			cmd = CFFPS_PN_CMD;
   135			break;
Quoted 9 lines
   136		case CFFPS_DEBUGFS_SN:
   137			cmd = CFFPS_SN_CMD;
   138			break;
   139		case CFFPS_DEBUGFS_CCIN:
   140			rc = i2c_smbus_read_word_data(psu->client, CFFPS_CCIN_CMD);
   141			if (rc < 0)
   142				return rc;
   143	
Quoted 1 line

144 rc = snprintf(data, 5, "%04X", be16_to_cpu(rc));

I fixed that up in my tree by calling i2c_smbus_read_word_swapped() above. No need to send a followup patch.

Quoted 32 lines
   145			goto done;
   146		case CFFPS_DEBUGFS_FW:
   147			for (i = 0; i < CFFPS_FW_NUM_BYTES; ++i) {
   148				rc = i2c_smbus_read_byte_data(psu->client,
   149							      CFFPS_FW_CMD_START + i);
   150				if (rc < 0)
   151					return rc;
   152	
   153				snprintf(&data[i * 2], 3, "%02X", rc);
   154			}
   155	
   156			rc = i * 2;
   157			goto done;
   158		default:
   159			return -EINVAL;
   160		}
   161	
   162		rc = i2c_smbus_read_block_data(psu->client, cmd, data);
   163		if (rc < 0)
   164			return rc;
   165	
   166	done:
   167		data[rc] = '\n';
   168		rc += 2;
   169	
   170		return simple_read_from_buffer(buf, count, ppos, data, rc);
   171	}
   172	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation