Message ID | 20220415103139.794790-1-karol.kolacinski@intel.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [intel-next,1/3] ice: remove u16 arithmetic in ice_gnss | expand |
Dear Karol, Am 15.04.22 um 12:31 schrieb Karol Kolacinski: > Change u16 to u32 where arithmetic occured. occur*r*e*s* Why does 16-bit width not work? Kind regards, Paul > Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> > --- > drivers/net/ethernet/intel/ice/ice_gnss.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c > index 57586a2e6dec..f0b2091c3b5f 100644 > --- a/drivers/net/ethernet/intel/ice/ice_gnss.c > +++ b/drivers/net/ethernet/intel/ice/ice_gnss.c > @@ -23,7 +23,7 @@ static void ice_gnss_read(struct kthread_work *work) > struct ice_hw *hw; > __be16 data_len_b; > char *buf = NULL; > - u16 i, data_len; > + u32 i, data_len; Why does the length need to be specified at all, and no native types can be used? Kind regards, Paul > int err = 0; > > pf = gnss->back; > @@ -65,7 +65,7 @@ static void ice_gnss_read(struct kthread_work *work) > mdelay(10); > } > > - data_len = min(data_len, (u16)PAGE_SIZE); > + data_len = min_t(typeof(data_len), data_len, PAGE_SIZE); > data_len = tty_buffer_request_room(port, data_len); > if (!data_len) { > err = -ENOMEM; > @@ -74,7 +74,7 @@ static void ice_gnss_read(struct kthread_work *work) > > /* Read received data */ > for (i = 0; i < data_len; i += bytes_read) { > - u16 bytes_left = data_len - i; > + u32 bytes_left = data_len - i; > > bytes_read = min_t(typeof(bytes_left), bytes_left, ICE_MAX_I2C_DATA_SIZE); >
Dear Paul, Thank you for your review. On 4/15/22 3:51 PM, Paul Menzel wrote: >> Change u16 to u32 where arithmetic occured. > >occur*r*e*s* > >Why does 16-bit width not work? In the previous GNSS patch review, David Laight wrote that I should not do arithmetic on anything smaller than 'int'. > >> Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> >> --- >> drivers/net/ethernet/intel/ice/ice_gnss.c | 6 +++--- >> 1 file changed, 3 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c >> index 57586a2e6dec..f0b2091c3b5f 100644 >> --- a/drivers/net/ethernet/intel/ice/ice_gnss.c >> +++ b/drivers/net/ethernet/intel/ice/ice_gnss.c >> @@ -23,7 +23,7 @@ static void ice_gnss_read(struct kthread_work *work) >> struct ice_hw *hw; >> __be16 data_len_b; >> char *buf = NULL; >> - u16 i, data_len; >> + u32 i, data_len; > >Why does the length need to be specified at all, and no native types can >be used? I changed it to use native type. Length of the buffer is read from the device and then used in a read loop. Kind regards, Karol --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173, 80-298 Gdansk KRS 101882 NIP 957-07-52-316
diff --git a/drivers/net/ethernet/intel/ice/ice_gnss.c b/drivers/net/ethernet/intel/ice/ice_gnss.c index 57586a2e6dec..f0b2091c3b5f 100644 --- a/drivers/net/ethernet/intel/ice/ice_gnss.c +++ b/drivers/net/ethernet/intel/ice/ice_gnss.c @@ -23,7 +23,7 @@ static void ice_gnss_read(struct kthread_work *work) struct ice_hw *hw; __be16 data_len_b; char *buf = NULL; - u16 i, data_len; + u32 i, data_len; int err = 0; pf = gnss->back; @@ -65,7 +65,7 @@ static void ice_gnss_read(struct kthread_work *work) mdelay(10); } - data_len = min(data_len, (u16)PAGE_SIZE); + data_len = min_t(typeof(data_len), data_len, PAGE_SIZE); data_len = tty_buffer_request_room(port, data_len); if (!data_len) { err = -ENOMEM; @@ -74,7 +74,7 @@ static void ice_gnss_read(struct kthread_work *work) /* Read received data */ for (i = 0; i < data_len; i += bytes_read) { - u16 bytes_left = data_len - i; + u32 bytes_left = data_len - i; bytes_read = min_t(typeof(bytes_left), bytes_left, ICE_MAX_I2C_DATA_SIZE);
Change u16 to u32 where arithmetic occured. Signed-off-by: Karol Kolacinski <karol.kolacinski@intel.com> --- drivers/net/ethernet/intel/ice/ice_gnss.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)