devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: "Opensource [Steve Twiss]" <stwiss.opensource@diasemi.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	Alessandro Zummo <a.zummo@towertech.it>,
	DEVICETREE <devicetree@vger.kernel.org>,
	LINUXINPUT <linux-input@vger.kernel.org>,
	LINUXKERNEL <linux-kernel@vger.kernel.org>,
	RTCLINUX <rtc-linux@googlegroups.com>,
	David Dajun Chen <david.chen@diasemi.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Pawel Moll <pawel.moll@arm.com>, Rob Herring <robh+dt@kernel.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Support Opensource <Support.Opensource@diasemi.com>
Subject: Re: [PATCH RFC V1 2/3] rtc: da9063: Add DA9062 RTC capability to DA9063 RTC driver
Date: Tue, 21 Jul 2015 10:39:05 +0200	[thread overview]
Message-ID: <20150721083905.GB2853@piout.net> (raw)
In-Reply-To: <6ED8E3B22081A4459DAC7699F3695FB7014B253FD1@SW-EX-MBX02.diasemi.com>

Hi,

On 21/07/2015 at 08:05:32 +0000, Opensource [Steve Twiss] wrote :
> > > > > +
> > > > > +	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
> > > > > +	if (!rtc)
> > > > > +		return -ENOMEM;
> > > > > +
> > > > > +	if (strncmp(match->name, "dlg,da9063-rtc", 14) == 0) {
> > > > > +		struct da9063 *chip = dev_get_drvdata(pdev->dev.parent);
> > > > > +
> > > > > +		if (chip->variant_code == PMIC_DA9063_AD)
> > > > > +			rtc->config = &da9063_ad_regs;
> > > > > +	} else
> > > > > +		rtc->config = match->data;
> > > >
> > > > You must not do that.
> > > > You should add a new compatible and change the of_compatible string of
> > > > the mfd_cell in drivers/mfd/da9063-core.c onc you know the variant.
> > >
> > > I can check for a binary comparison against the address of the
> > > static const struct of_device_id da9063_compatible_reg_id_table[] = {}
> > > entry for DA9063.
> > 
> > You also must not compare pointers that way. You can use
> > of_device_is_compatible().
> > 
> > > The DA9063 driver already associates "dlg,da9063-rtc" with both BB and AD
> > > register maps. I think that altering the string at this point would break backwards
> > > compatibility in the device tree for the DA9063.
> > 
> > I'm not fond of the backward compatibility exactly for that kind of
> > issue. The proper way to handle it is to have tow different compatible
> > strings because obviously, the BB and AD variants are not compatible.
> 
> I think I understand what you are saying about modifying the mfd_cell in the
> DA9063 core driver at run-time so that it changes the of_compatible string to [something like]
> "dlg,da9063-ad-rtc". That way the RTC driver can be probed using the correct
> string.
> 
> Ok, I think I see now .. I'll make a patch v2 and send it soon.
> 

This is not needed if you simply change your strncmp with
of_device_is_compatible

-- 
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

  reply	other threads:[~2015-07-21  8:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-09  7:45 [PATCH RFC V1 0/3] da9062: Add DA9062 RTC support using the existing DA9063 RTC driver S Twiss
2015-07-09  7:45 ` [PATCH RFC V1 2/3] rtc: da9063: Add DA9062 RTC capability to " S Twiss
2015-07-17 23:45   ` Alexandre Belloni
2015-07-20 17:57     ` Opensource [Steve Twiss]
2015-07-20 21:50       ` Alexandre Belloni
2015-07-21  8:05         ` Opensource [Steve Twiss]
2015-07-21  8:39           ` Alexandre Belloni [this message]
2015-07-09  7:45 ` [PATCH RFC V1 1/3] mfd: da9062: Support for the DA9063 RTC in the DA9062 core S Twiss
2015-07-09  7:45 ` [PATCH RFC V1 3/3] devicetree: da9062: Add device tree bindings for DA9062 RTC S Twiss
2015-07-17 23:47   ` Alexandre Belloni
2015-07-20 17:08     ` Opensource [Steve Twiss]
2015-07-20 21:07       ` Alexandre Belloni
2015-07-09  8:01 ` [PATCH RFC V1 0/3] da9062: Add DA9062 RTC support using the existing DA9063 RTC driver Geert Uytterhoeven
     [not found]   ` <CAMuHMdU_AUZ9nxo25NeaFq1MeeSDZErqkNnDtXsdr7=jLm1kTw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-07-09  8:42     ` Opensource [Steve Twiss]
     [not found]       ` <6ED8E3B22081A4459DAC7699F3695FB7014B23FDDA-68WUHU125fLzLL1Oxlh9IgLouzNaz+3S@public.gmane.org>
2015-07-09  9:06         ` Geert Uytterhoeven

Reply instructions:

You may reply publicly 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=20150721083905.GB2853@piout.net \
    --to=alexandre.belloni@free-electrons.com \
    --cc=Support.Opensource@diasemi.com \
    --cc=a.zummo@towertech.it \
    --cc=david.chen@diasemi.com \
    --cc=devicetree@vger.kernel.org \
    --cc=galak@codeaurora.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=lee.jones@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=rtc-linux@googlegroups.com \
    --cc=sameo@linux.intel.com \
    --cc=stwiss.opensource@diasemi.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).