[PATCH v2 12/30] cxlflash: Refine host/device attributes

Matthew R. Ochs mrochs at linux.vnet.ibm.com
Sat Sep 19 09:56:25 AEST 2015


> On Sep 18, 2015, at 4:34 PM, Brian King <brking at linux.vnet.ibm.com> wrote:
> On 09/16/2015 04:29 PM, Matthew R. Ochs wrote:
>> 
>> +	ssize_t bytes = 0;
>> +	__be64 __iomem *fc_port;
>> +
>> +	if (port >= NUM_FC_PORTS)
>> +		return 0;
>> +
>> +	fc_port = &afu->afu_map->global.fc_port[port][0];
>> +
>> +	for (i = 0; i < CXLFLASH_NUM_VLUNS; i++, buf += 22)
> 
> Rather than this bug prone hard coded 22, how about never incrementing buf and do something
> similar to this:
> 
>> +		bytes += scnprintf(buf, PAGE_SIZE, "%03d: %016llX\n",
>> +				   i, readq_be(&fc_port[i]));
> 
> 		bytes += scnprintf(&buf[bytes], PAGE_SIZE, "%03d: %016llX\n",
> 				   i, readq_be(&fc_port[i]));
> 
>> +	return bytes;
>> +}
>> +

Great suggestion! Will fix in v3.


-matt


More information about the Linuxppc-dev mailing list