hidraw(4): Return actual length of read data from HIDIOCG* ioctls

To match Linux.

MFC after:	3 days

(cherry picked from commit 8d4d08d571)
This commit is contained in:
Vladimir Kondratyev 2025-04-27 12:07:35 +03:00
parent 2880e12cc9
commit d04cc28f97

View file

@ -915,8 +915,14 @@ hidraw_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
default:
panic("Invalid report type");
}
return (hid_get_report(sc->sc_dev, addr, len, NULL,
reptype, id));
error = hid_get_report(sc->sc_dev, addr, len, &actsize,
reptype, id);
if (error == 0) {
if (id == 0)
actsize++;
td->td_retval[0] = actsize;
}
return (error);
case HIDIOCGRAWUNIQ(0):
strlcpy(addr, sc->sc_hw->serial, len);