Re: [PATCH] watchdog: ebc-c384_wdt: Migrate to the regmap API

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 11, 2023 at 06:04:08AM -0800, Guenter Roeck wrote:
> On Fri, Mar 10, 2023 at 07:44:04PM -0500, William Breathitt Gray wrote:
> > The regmap API supports IO port accessors so we can take advantage of
> > regmap abstractions rather than handling access to the device registers
> > directly in the driver.
> > 
> > Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> > Signed-off-by: William Breathitt Gray <william.gray@xxxxxxxxxx>
> 
> I assume you did, but just to be sure: Did you test this on hardware ?

I've only done a build test; I no longer have access to a WINSYSTEMS
EBC-C384 motherboard to test this on real hardware. I've CC'd Paul
Demetrotion and the WINSYSTEMS tech support list to this thread as
hopefully one of the WINSYSTEMS engineers may help us test this.

> > @@ -37,43 +40,54 @@ module_param(timeout, uint, 0);
> >  MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds (default="
> >  	__MODULE_STRING(WATCHDOG_TIMEOUT) ")");
> >  
> > +static const struct regmap_range ebc_c384_wdt_wr_ranges[] = {
> > +	regmap_reg_range(0x1, 0x2),
> 
> Any reasons for not using defines ?

I feel direct addresses are somewhat clearer in this context. Regmap
configurations describe the address range of valid read and write
operations. Although the range for this device is simple, other devices
might have multiple ranges with gaps of invalid addresses.

For example, our valid write address range is 0x1-0x2 here:

    regmap_reg_range(0x1, 0x2)

Which is much clearer than trying to match these to register defines:

    regmap_reg_range(CFG_REG, PET_REG)

Because it's not immediately clear that CFG_REG to PET_REG is a
contiguous address range.

> > +};
> > +static const struct regmap_access_table ebc_c384_wdt_wr_table = {
> > +	.yes_ranges = ebc_c384_wdt_wr_ranges,
> > +	.n_yes_ranges = ARRAY_SIZE(ebc_c384_wdt_wr_ranges),
> > +};
> > +static const struct regmap_config ebc_c384_wdt_regmap_config = {
> > +	.reg_bits = 8,
> > +	.reg_stride = 1,
> > +	.val_bits = 8,
> > +	.io_port = true,
> > +	.max_register = 0x2,
> 
> Any reason for not using a define ?

Same reason as above: `max_register = 0x2` is already clear enough and
`max_register = EBC_C384_MAX_REGISTER` wouldn't add any substantial
clarity.

> > +	.wr_table = &ebc_c384_wdt_wr_table,
> > +};
> > +
> >  static int ebc_c384_wdt_start(struct watchdog_device *wdev)
> >  {
> > +	struct regmap *const map = wdev->driver_data;
> 
> Please use watchdog_get_drvdata() and watchdog_set_drvdata() when accessing
> or setting watchdog driver data.
> 
> Guenter

I'll adjust the driver_data interactions in my v2 submission to utilize
watchdog_get_drvdata() and watchdog_set_drvdata().

William Breathitt Gray

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux