Linux-RTC Archive on lore.kernel.org
 help / color / Atom feed
From: Thomas Bogendoerfer <tbogendoerfer@suse.de>
To: Joshua Kinard <kumba@gentoo.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ralf Baechle <ralf@linux-mips.org>,
	Paul Burton <paul.burton@mips.com>,
	James Hogan <jhogan@kernel.org>,
	linux-mips@vger.kernel.org
Subject: Re: [PATCH 3/3] rtc: ds1685: add indirect access method and remove plat_read/plat_write
Date: Mon, 14 Oct 2019 23:20:24 +0200
Message-ID: <20191014232024.f77782b46b1b971bc403d849@suse.de> (raw)
In-Reply-To: <0e160839-9038-6f74-fdb6-8128344fb4b8@gentoo.org>

On Sat, 12 Oct 2019 19:22:01 -0400
Joshua Kinard <kumba@gentoo.org> wrote:

> On 10/11/2019 11:05, Thomas Bogendoerfer wrote:
> > +static void
> > +ds1685_indir_write(struct ds1685_priv *rtc, int reg, u8 value)
> > +{
> > +	writeb(reg, rtc->regs);
> > +	writeb(value, rtc->data);
> > +}
> 
> IP30 applied a mask of 0x7f on the 'reg' parameter on both of its
> read/write functions, which was from Stan's original code.  Is this mask
> not needed any more with the other changes you made to the IP30 code? 

reg is always < 0x80, so I didn't see a point in masking it.

> > +	switch (pdata->access_type) {
> > +	case ds1685_reg_direct:
> > +		rtc->regs = devm_platform_ioremap_resource(pdev, 0);
> > +		if (IS_ERR(rtc->regs))
> > +			return PTR_ERR(rtc->regs);
> > +		rtc->read = ds1685_read;
> > +		rtc->write = ds1685_write;
> > +		break;
> > +	case ds1685_reg_indirect:
> >  		rtc->regs = devm_platform_ioremap_resource(pdev, 0);
> >  		if (IS_ERR(rtc->regs))
> >  			return PTR_ERR(rtc->regs);
> > +		rtc->data = devm_platform_ioremap_resource(pdev, 1);
> > +		if (IS_ERR(rtc->data))
> > +			return PTR_ERR(rtc->data);
> > +		rtc->read = ds1685_indir_read;
> > +		rtc->write = ds1685_indir_write;
> > +		break;
> >  	}
> 
> I believe there should be a default case in the switch statement to catch
> and return -ENXIO so that we don't wind up with rtc->{read,write} being
> NULL.

access_type is an enum and all possible values are covered with cases.
But I'll add a safe guart to check that read/write is set to cover garbled
platform_data. If you want to keep plat_read/plat_write I could add an
additional access_type (which could also be done later, when there is a
real use case).

> I also think the "indir" name isn't really descriptive of why IP32 and
> IP30 effectively have different read/write mechanisms.

IP32 accesses register directly and IP30 indirectly via an address register.
I'll use indirect in function name and some comment to explain.

> Might want to add
> some comments to explain that IP32 uses MMIO and can just directly
> read/write the registers, while IP30 uses PIO and has to go the route of

what's PIO here for you ? RTC address and data register are mapped MMIO
as part of the IOC3 register bar on IP30.

Thomas.

-- 
SUSE Software Solutions Germany GmbH
HRB 247165 (AG München)
Geschäftsführer: Felix Imendörffer

  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-11 15:05 [PATCH 1/3] rts: ds1685: remove not needed fields from private struct Thomas Bogendoerfer
2019-10-11 15:05 ` [PATCH 2/3] rtc: ds1685: use devm_platform_ioremap_resource helper Thomas Bogendoerfer
2019-10-12 22:49   ` Joshua Kinard
2019-10-14 15:51   ` Alexandre Belloni
2019-10-11 15:05 ` [PATCH 3/3] rtc: ds1685: add indirect access method and remove plat_read/plat_write Thomas Bogendoerfer
2019-10-12 23:22   ` Joshua Kinard
2019-10-14 21:20     ` Thomas Bogendoerfer [this message]
2019-10-12 22:41 ` [PATCH 1/3] rts: ds1685: remove not needed fields from private struct Joshua Kinard
2019-10-14 15:50 ` Alexandre Belloni

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191014232024.f77782b46b1b971bc403d849@suse.de \
    --to=tbogendoerfer@suse.de \
    --cc=a.zummo@towertech.it \
    --cc=alexandre.belloni@bootlin.com \
    --cc=jhogan@kernel.org \
    --cc=kumba@gentoo.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=paul.burton@mips.com \
    --cc=ralf@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-RTC Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-rtc/0 linux-rtc/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-rtc linux-rtc/ https://lore.kernel.org/linux-rtc \
		linux-rtc@vger.kernel.org
	public-inbox-index linux-rtc

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-rtc


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git