Message ID | 20200905204151.25343-1-digetx@gmail.com |
---|---|
Headers | show |
Series | Improvements for Tegra I2C driver | expand |
06.09.2020 00:56, Michał Mirosław пишет: > On Sat, Sep 05, 2020 at 11:41:30PM +0300, Dmitry Osipenko wrote: >> Use clk-bulk helpers and factor out clocks initialization into separate >> function in order to make code cleaner. > [...] >> --- a/drivers/i2c/busses/i2c-tegra.c >> +++ b/drivers/i2c/busses/i2c-tegra.c > [...] >> static const struct tegra_i2c_hw_feature tegra194_i2c_hw = { >> .has_continue_xfer_support = true, >> .has_per_pkt_xfer_complete_irq = true, >> - .has_single_clk_source = true, >> .clk_divisor_hs_mode = 1, >> .clk_divisor_std_mode = 0x4f, >> .clk_divisor_fast_mode = 0x3c, > [...] >> +static int tegra_i2c_init_clocks(struct tegra_i2c_dev *i2c_dev) >> +{ >> + unsigned int i; >> + int err; >> + >> + err = devm_clk_bulk_get_all(i2c_dev->dev, &i2c_dev->clocks); >> + if (err < 0) >> + return err; >> + >> + i2c_dev->nclocks = err > [...] > > You loose checking whether number of clocks matches the device version. > Is this intended? Yes, it's not needed. The check wasn't really needed in the first place.
On Sat, Sep 05, 2020 at 11:41:36PM +0300, Dmitry Osipenko wrote: > The "dma" variable of tegra_i2c_xfer_msg() function doesn't bring much in > regards to readability and generation of the code, hence let's remove it > to clean up code a tad. [...] > --- a/drivers/i2c/busses/i2c-tegra.c > +++ b/drivers/i2c/busses/i2c-tegra.c [...] > + if (i2c_dev->is_curr_dma_xfer) { [...] In this case I like the previous code better: just because there are less letters to read. :-) Best Regards, Michał Mirosław
06.09.2020 01:23, Michał Mirosław пишет: > On Sat, Sep 05, 2020 at 11:41:36PM +0300, Dmitry Osipenko wrote: >> The "dma" variable of tegra_i2c_xfer_msg() function doesn't bring much in >> regards to readability and generation of the code, hence let's remove it >> to clean up code a tad. > [...] >> --- a/drivers/i2c/busses/i2c-tegra.c >> +++ b/drivers/i2c/busses/i2c-tegra.c > [...] >> + if (i2c_dev->is_curr_dma_xfer) { > [...] > > In this case I like the previous code better: just because there are > less letters to read. :-) Besides readability, I also don't like much that the is_curr_dma_xfer is initialized in tegra_i2c_xfer_msg() and then could be overridden by tegra_i2c_config_fifo_trig(). In a result the "dma" variable confuses me since it's not instantly obvious why it's set after tegra_i2c_config_fifo_trig(). Looking at the final result, I think it's better to have the variable removed. It makes code more consistent, IMO.
On Sun, Sep 06, 2020 at 01:36:20AM +0300, Dmitry Osipenko wrote: > 06.09.2020 01:23, Michał Mirosław пишет: > > On Sat, Sep 05, 2020 at 11:41:36PM +0300, Dmitry Osipenko wrote: > >> The "dma" variable of tegra_i2c_xfer_msg() function doesn't bring much in > >> regards to readability and generation of the code, hence let's remove it > >> to clean up code a tad. > > [...] > >> --- a/drivers/i2c/busses/i2c-tegra.c > >> +++ b/drivers/i2c/busses/i2c-tegra.c > > [...] > >> + if (i2c_dev->is_curr_dma_xfer) { > > [...] > > > > In this case I like the previous code better: just because there are > > less letters to read. :-) > > Besides readability, I also don't like much that the is_curr_dma_xfer is > initialized in tegra_i2c_xfer_msg() and then could be overridden by > tegra_i2c_config_fifo_trig(). In a result the "dma" variable confuses me > since it's not instantly obvious why it's set after > tegra_i2c_config_fifo_trig(). > > Looking at the final result, I think it's better to have the variable > removed. It makes code more consistent, IMO. If it could be changed in some callee, then indeed it is better. In this case I would include this information in the commit msg. Best Regards, Michał Mirosław
06.09.2020 01:47, Michał Mirosław пишет: > On Sat, Sep 05, 2020 at 11:41:50PM +0300, Dmitry Osipenko wrote: >> Make all comments to be consistent in regards to capitalization and >> punctuation, correct spelling and grammar errors. > [...] >> - /* Rounds down to not include partial word at the end of buf */ >> + /* rounds down to not include partial word at the end of buffer */ >> words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD; >> >> - /* It's very common to have < 4 bytes, so optimize that case. */ >> + /* it's very common to have < 4 bytes, so optimize that case */ >> if (words_to_transfer) { >> if (words_to_transfer > tx_fifo_avail) >> words_to_transfer = tx_fifo_avail; >> >> /* >> - * Update state before writing to FIFO. If this casues us >> + * Update state before writing to FIFO. If this causes us >> * to finish writing all bytes (AKA buf_remaining goes to 0) we >> * have a potential for an interrupt (PACKET_XFER_COMPLETE is >> * not maskable). We need to make sure that the isr sees >> @@ -800,8 +799,8 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) >> } > > Those first letters don't look consistently capitalized. :-) In my experience, the more common kernel style is a lowercase for single-line comments and the opposite for the multi-line comments. Hence, should be good. If you're meaning something else, then please clarify.
On Sun, Sep 06, 2020 at 01:53:56AM +0300, Dmitry Osipenko wrote: > 06.09.2020 01:47, Michał Mirosław пишет: > > On Sat, Sep 05, 2020 at 11:41:50PM +0300, Dmitry Osipenko wrote: > >> Make all comments to be consistent in regards to capitalization and > >> punctuation, correct spelling and grammar errors. > > [...] > >> - /* Rounds down to not include partial word at the end of buf */ > >> + /* rounds down to not include partial word at the end of buffer */ > >> words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD; > >> > >> - /* It's very common to have < 4 bytes, so optimize that case. */ > >> + /* it's very common to have < 4 bytes, so optimize that case */ > >> if (words_to_transfer) { > >> if (words_to_transfer > tx_fifo_avail) > >> words_to_transfer = tx_fifo_avail; > >> > >> /* > >> - * Update state before writing to FIFO. If this casues us > >> + * Update state before writing to FIFO. If this causes us > >> * to finish writing all bytes (AKA buf_remaining goes to 0) we > >> * have a potential for an interrupt (PACKET_XFER_COMPLETE is > >> * not maskable). We need to make sure that the isr sees > >> @@ -800,8 +799,8 @@ static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev) > >> } > > > > Those first letters don't look consistently capitalized. :-) > > In my experience, the more common kernel style is a lowercase for > single-line comments and the opposite for the multi-line comments. > Hence, should be good. If you're meaning something else, then please > clarify. I don't have a strong opinion about this, but my preference is: If it's a full sentence, make it look so. Best Regards, Michał Mirosław
On Sat, Sep 05, 2020 at 11:41:20PM +0300, Dmitry Osipenko wrote: > Hello! > > This series performs refactoring of the Tegra I2C driver code and hardens > the atomic-transfer mode. [...] Pending comments, all LGTM. Best Regards, Michał Mirosław
06.09.2020 02:16, Michał Mirosław пишет: > On Sat, Sep 05, 2020 at 11:41:20PM +0300, Dmitry Osipenko wrote: >> Hello! >> >> This series performs refactoring of the Tegra I2C driver code and hardens >> the atomic-transfer mode. > [...] > > Pending comments, all LGTM. Thank you!