Am 05.12.2017 um 13:16 schrieb Dan Carpenter:
> On Mon, Dec 04, 2017 at 09:59:02PM +0200, Marcus Wolf wrote:
>> Keep in mind, that if you split the functions, in the interface
>> implementation you also need more code:
>>
>> SET_CHECKED(rf69_set_sync_enable(dev->spi, rx_cfg->enable_sync));
>>
>> will have to be converted in something like
>>
>> if (rx_cfg->enable_sync)
>>      SET_CHECKED(rf69_set_sync_enbable(dev->spi);
>> else
>>      SET_CHECKED(rf69_set_sync_disable(dev->spi);
>>
> 
> Here's what the code looks like right now:
> 
>    198          /* packet config */
>    199          /* enable */
>    200          SET_CHECKED(rf69_set_sync_enable(dev->spi, 
> rx_cfg->enable_sync));
>    201          if (rx_cfg->enable_sync == optionOn)
>    202          {
>    203                  SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
> afterSyncInterrupt));
>    204          }
>    205          else
>    206          {
>    207                  SET_CHECKED(rf69_set_fifo_fill_condition(dev->spi, 
> always));
>    208          }
> 
> That's for the rx_cfg.  We have related but different code for the
> tx_cfg.  It's strange to me that we can enable sync for rx and not for
> tx...  How does that work when the setting ends up getting stored in the
> same register?
> 
> The new code would look like this:
> 
>       if (rx_cfg->enable_sync) {
>               ret = rf69_enable_sync(spi);
                      ^^^^^^^^^^^^^^^^^^^^^
>               if (ret)
>                       return ret;
>               ret = rf69_set_fifo_fill_condition(dev->spi, 
> afterSyncInterrupt);
>               if (ret)
>                       return ret;
>       } else {
>               ret = rf69_disable_sync(dev->spi);
>               if (ret)
>                       return ret;
>               ret = rf69_set_fifo_fill_condition(dev->spi, always);
>               if (ret)
>                       return ret;
>       }
> 
> It's not the greatest, but it's not the worst...  The configuration for
> ->enable_sync is a bit spread out and it might be nice to move it all to
> one function?
> 
> I liked Simon's naming scheme and I thought it was clear what the
> rf69_set_sync(spi, false) function would do.
  ^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Simon, it seems like Marcus and I both are Ok with your style choices.
> Do whatever seems best when you implement the code.  If it's awkward to
> break up the functions then don't.
> 
> regards,
> dan carpenter
> 

Hi Dan,

now I am a bit confused.

My favourit:
------------
rf69_set_sync_enable(spi, false)
rf69_set_amp_enable(spi, false)
rf69_set_crc_enable(spi, false)

I prefer to keep the enable (or comparable), because it shows, what the
function is doing. For sync, for example, there are several setter:
size, tolerance, values ... AND enable (or comparable).

All functions in rf69.c should start with rf69_get or rf69_set.


Simons proposal:
----------------
rf69_set_sync_enable(spi)
rf69_set_sync_disable(spi)
rf69_set_amp_enable(spi)
rf69_set_amp_disable(spi)
rf69_set_crc_enable(spi)
rf69_set_crc_disable(spi)

I don't like that, because it's blowing up the code without bringing
extra feature (see my last mail).


In your code example, you use Simons proposal, but in your explaination
below, you show the original style - although you refer to Simons sheme...


Cheers,

Marcus

Reply via email to