iicsmb: SMB_MAXBLOCKSIZE can be used again

The constant was set to the correct value in r308242.
While there, fix iicsmb_bread() to not use a value of an out parameter
'count'.

MFC after:	3 weeks
X-MFC after:	r308242
This commit is contained in:
Andriy Gapon 2016-11-11 15:11:54 +00:00
parent 678d569fc2
commit 88cc0bb940
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=308530

View File

@ -57,6 +57,7 @@ __FBSDID("$FreeBSD$");
#include <dev/iicbus/iiconf.h>
#include <dev/iicbus/iicbus.h>
#include <dev/smbus/smb.h>
#include <dev/smbus/smbconf.h>
#include "iicbus_if.h"
@ -432,7 +433,7 @@ iicsmb_bwrite(device_t dev, u_char slave, char cmd, u_char count, char *buf)
};
int error;
if (count > 32 || count == 0)
if (count > SMB_MAXBLOCKSIZE || count == 0)
return (SMB_EINVAL);
error = TRANSFER_MSGS(dev, msgs);
return (iic2smb_error(error));
@ -450,12 +451,6 @@ iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf)
};
device_t parent = device_get_parent(dev);
int error;
u_char bufsz;
/* Stash output buffer size before overwriting it. */
bufsz = *count;
if (bufsz == 0)
return (SMB_EINVAL);
/* Have to do this because the command is split in two transfers. */
error = iicbus_request_bus(parent, dev, IIC_WAIT);
@ -465,18 +460,13 @@ iicsmb_bread(device_t dev, u_char slave, char cmd, u_char *count, char *buf)
/*
* If the slave offers an empty or a too long reply,
* read one byte to generate the stop or abort.
* XXX 32 is hardcoded until SMB_MAXBLOCKSIZE is restored
* to sanity.
*/
if (*count > 32 || *count == 0)
if (*count > SMB_MAXBLOCKSIZE || *count == 0)
block_msg[0].len = 1;
/* If longer than the buffer, then clamp at the buffer size. */
if (*count > bufsz)
block_msg[0].len = bufsz;
else
block_msg[0].len = *count;
error = TRANSFER_MSGS(dev, block_msg);
if (*count > 32 || *count == 0)
if (*count > SMB_MAXBLOCKSIZE || *count == 0)
error = SMB_EINVAL;
}
(void)iicbus_release_bus(parent, dev);