Lines Matching +full:version +full:- +full:major

1 // SPDX-License-Identifier: GPL-2.0
3 /* Driver for ETAS GmbH ES58X USB CAN(-FD) Bus Interfaces.
21 * es58x_parse_sw_version() - Extract boot loader or firmware version.
25 * to parse the firmware version or to "BL" to parse the
26 * bootloader version.
29 * version number all prefixed by a magic string and concatenated with
35 * Parse @prod_info and store the version number in
39 * Return: zero on success, -EINVAL if @prefix contains an invalid
40 * value and -EBADMSG if @prod_info could not be parsed.
45 struct es58x_sw_version *version; in es58x_parse_sw_version() local
46 int major, minor, revision; in es58x_parse_sw_version() local
49 version = &es58x_dev->firmware_version; in es58x_parse_sw_version()
51 version = &es58x_dev->bootloader_version; in es58x_parse_sw_version()
53 return -EINVAL; in es58x_parse_sw_version()
58 return -EBADMSG; in es58x_parse_sw_version()
59 /* Go to beginning of the version number */ in es58x_parse_sw_version()
63 return -EBADMSG; in es58x_parse_sw_version()
66 if (sscanf(prod_info, "%2u.%2u.%2u", &major, &minor, &revision) != 3) in es58x_parse_sw_version()
67 return -EBADMSG; in es58x_parse_sw_version()
69 version->major = major; in es58x_parse_sw_version()
70 version->minor = minor; in es58x_parse_sw_version()
71 version->revision = revision; in es58x_parse_sw_version()
77 * es58x_parse_hw_rev() - Extract hardware revision number.
90 * Return: zero on success, -EBADMSG if @prod_info could not be
97 int major, minor; in es58x_parse_hw_rev() local
102 return -EBADMSG; in es58x_parse_hw_rev()
106 return -EBADMSG; in es58x_parse_hw_rev()
109 if (sscanf(prod_info, "%c%3u/%3u", &letter, &major, &minor) != 3) in es58x_parse_hw_rev()
110 return -EBADMSG; in es58x_parse_hw_rev()
112 es58x_dev->hardware_revision.letter = letter; in es58x_parse_hw_rev()
113 es58x_dev->hardware_revision.major = major; in es58x_parse_hw_rev()
114 es58x_dev->hardware_revision.minor = minor; in es58x_parse_hw_rev()
120 * es58x_parse_product_info() - Parse the ES58x product information
125 * firmware version, the bootloader version and the hardware
128 * If the function fails, set the version or revision to an invalid
135 .major = -1, in es58x_parse_product_info()
136 .minor = -1, in es58x_parse_product_info()
137 .revision = -1, in es58x_parse_product_info()
141 .major = -1, in es58x_parse_product_info()
142 .minor = -1, in es58x_parse_product_info()
146 es58x_dev->firmware_version = sw_version_not_set; in es58x_parse_product_info()
147 es58x_dev->bootloader_version = sw_version_not_set; in es58x_parse_product_info()
148 es58x_dev->hardware_revision = hw_revision_not_set; in es58x_parse_product_info()
150 prod_info = usb_cache_string(es58x_dev->udev, ES58X_PROD_INFO_IDX); in es58x_parse_product_info()
152 dev_warn(es58x_dev->dev, in es58x_parse_product_info()
160 dev_info(es58x_dev->dev, in es58x_parse_product_info()
167 * es58x_sw_version_is_valid() - Check if the version is a valid number.
168 * @sw_ver: Version number of either the firmware or the bootloader.
170 * If any of the software version sub-numbers do not fit on two
171 * digits, the version is invalid, most probably because the product
174 * Return: @true if the software version is valid, @false otherwise.
178 return sw_ver->major < 100 && sw_ver->minor < 100 && in es58x_sw_version_is_valid()
179 sw_ver->revision < 100; in es58x_sw_version_is_valid()
183 * es58x_hw_revision_is_valid() - Check if the revision is a valid number.
187 * any of the hardware revision sub-numbers do not fit on three
195 return isalnum(hw_rev->letter) && hw_rev->major < 1000 && in es58x_hw_revision_is_valid()
196 hw_rev->minor < 1000; in es58x_hw_revision_is_valid()
200 * es58x_devlink_info_get() - Report the product information.
205 * Report the firmware version, the bootloader version, the hardware
215 struct es58x_sw_version *fw_ver = &es58x_dev->firmware_version; in es58x_devlink_info_get()
216 struct es58x_sw_version *bl_ver = &es58x_dev->bootloader_version; in es58x_devlink_info_get()
217 struct es58x_hw_revision *hw_rev = &es58x_dev->hardware_revision; in es58x_devlink_info_get()
223 fw_ver->major, fw_ver->minor, fw_ver->revision); in es58x_devlink_info_get()
233 bl_ver->major, bl_ver->minor, bl_ver->revision); in es58x_devlink_info_get()
243 hw_rev->letter, hw_rev->major, hw_rev->minor); in es58x_devlink_info_get()
251 return devlink_info_serial_number_put(req, es58x_dev->udev->serial); in es58x_devlink_info_get()