Discussion:
Further changes to smb(4) API
Michael Gmelin
2015-05-03 14:49:49 UTC
Permalink
Porting some interesting features, r281985 also introduced a breaking
ABI/API change to the smbus interface. As Juli pointed out, since this
is not backwards compatible anyway, we might as well go the whole nine
yards and try to make the interface as good as possible. There's still
plenty of time to 11-RELEASE and I'm willing to incorporate further
changes, assuming there is enough feedback.

As there are only a few ports using this interface and they're all
very similar in the way it is used, it would be really good to get some
feedback from actual users of this interface in real world projects.

Juli suggested as a first step to change rbuf and wbuf in smbcmd from
char* to void* to avoid casting in case of SMB_READW and SMB_WRITEW.

Based on what I've seen in ports using this API, they all seem to
create wrapper functions around these ioctl commands anyway, so I'm
curious if it wouldn't make sense to provide functions that wrap
the smb interface in a library (either in base or as a port):

sysutils/bsdhwmon:
uint8_t read_byte(int fd, int slave, const char idxreg);
void write_byte(int fd, int slave, const char idxreg, const char value);

sysutils/consolehm:
int ReadByte(u_char *return_value, int addr);
int WriteByte(int addr, int value);

sysutils/gkrellm2:
static gint
get_data(int iodev, u_char command, int interface, u_char *ret);

sysutils/healthd:
static int WriteByte(int addr,int value);
static int ReadByte(int addr);

sysutils/xmbmon:
int smbioctl_readB(int slave, int addr);
void smbioctl_writeB(int slave, int addr, int value);
int smbioctl_readW(int smb_slave, int addr);
void smbioctl_writeW(int slave, int addr, int value);

Cheers,
Michael
--
Michael Gmelin
Adrian Chadd
2015-05-03 17:26:49 UTC
Permalink
Yes, please do create a library.


-a
Post by Michael Gmelin
Porting some interesting features, r281985 also introduced a breaking
ABI/API change to the smbus interface. As Juli pointed out, since this
is not backwards compatible anyway, we might as well go the whole nine
yards and try to make the interface as good as possible. There's still
plenty of time to 11-RELEASE and I'm willing to incorporate further
changes, assuming there is enough feedback.
As there are only a few ports using this interface and they're all
very similar in the way it is used, it would be really good to get some
feedback from actual users of this interface in real world projects.
Juli suggested as a first step to change rbuf and wbuf in smbcmd from
char* to void* to avoid casting in case of SMB_READW and SMB_WRITEW.
Based on what I've seen in ports using this API, they all seem to
create wrapper functions around these ioctl commands anyway, so I'm
curious if it wouldn't make sense to provide functions that wrap
uint8_t read_byte(int fd, int slave, const char idxreg);
void write_byte(int fd, int slave, const char idxreg, const char value);
int ReadByte(u_char *return_value, int addr);
int WriteByte(int addr, int value);
static gint
get_data(int iodev, u_char command, int interface, u_char *ret);
static int WriteByte(int addr,int value);
static int ReadByte(int addr);
int smbioctl_readB(int slave, int addr);
void smbioctl_writeB(int slave, int addr, int value);
int smbioctl_readW(int smb_slave, int addr);
void smbioctl_writeW(int slave, int addr, int value);
Cheers,
Michael
--
Michael Gmelin
_______________________________________________
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
Loading...