mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Antony Pavlov <antonynpavlov@gmail.com>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [RFC 2/5] add rtc support
Date: Fri, 11 Jul 2014 09:31:56 +0400	[thread overview]
Message-ID: <20140711093156.890f5ab97d35d93249d006c8@gmail.com> (raw)
In-Reply-To: <20140710214030.GH23235@pengutronix.de>

On Thu, 10 Jul 2014 23:40:30 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> On Thu, Jul 10, 2014 at 12:33:16PM +0400, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> >  drivers/Kconfig       |  1 +
> >  drivers/Makefile      |  1 +
> >  drivers/rtc/Kconfig   | 16 +++++++++++++
> >  drivers/rtc/Makefile  |  6 +++++
> >  drivers/rtc/class.c   | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
> >  drivers/rtc/rtc-lib.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++
> >  include/linux/rtc.h   | 46 ++++++++++++++++++++++++++++++++++++
> >  include/rtc.h         |  2 ++
> >  8 files changed, 198 insertions(+)
> > 
> > diff --git a/drivers/Kconfig b/drivers/Kconfig
> > index 12a9d8c..d38032c 100644
> > --- a/drivers/Kconfig
> > +++ b/drivers/Kconfig
> > @@ -28,5 +28,6 @@ source "drivers/bus/Kconfig"
> >  source "drivers/regulator/Kconfig"
> >  source "drivers/reset/Kconfig"
> >  source "drivers/pci/Kconfig"
> > +source "drivers/rtc/Kconfig"
> >  
> >  endmenu
> > diff --git a/drivers/Makefile b/drivers/Makefile
> > index 1990e86..4591f9a 100644
> > --- a/drivers/Makefile
> > +++ b/drivers/Makefile
> > @@ -27,3 +27,4 @@ obj-y += bus/
> >  obj-$(CONFIG_REGULATOR) += regulator/
> >  obj-$(CONFIG_RESET_CONTROLLER) += reset/
> >  obj-$(CONFIG_PCI) += pci/
> > +obj-y += rtc/
> > diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
> > new file mode 100644
> > index 0000000..f148266
> > --- /dev/null
> > +++ b/drivers/rtc/Kconfig
> > @@ -0,0 +1,16 @@
> > +#
> > +# RTC class/drivers configuration
> > +#
> > +
> > +config RTC_LIB
> > +	bool
> > +
> > +menuconfig RTC_CLASS
> > +        bool "Real Time Clock"
> > +        default n
> > +        depends on !S390 && !UML

I suppose i can drop thess two lines.

> > +        select RTC_LIB
> > +        help
> > +          Generic RTC class support. If you say yes here, you will
> > +          be allowed to plug one or more RTCs to your system. You will
> > +          probably want to enable one or more of the interfaces below.
> > diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
> > new file mode 100644
> > index 0000000..7d1b5bc
> > --- /dev/null
> > +++ b/drivers/rtc/Makefile
> > @@ -0,0 +1,6 @@
> > +#
> > +# Makefile for RTC class/drivers.
> > +#
> > +
> > +obj-$(CONFIG_RTC_LIB)           += rtc-lib.o
> > +obj-$(CONFIG_RTC_CLASS)         += class.o
> > diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c
> > new file mode 100644
> > index 0000000..b808f3d
> > --- /dev/null
> > +++ b/drivers/rtc/class.c
> > @@ -0,0 +1,62 @@
> > +#include <linux/err.h>
> > +#include <rtc.h>
> > +#include <linux/rtc.h>
> > +
> > +LIST_HEAD(rtc_list);
> > +EXPORT_SYMBOL(rtc_list);
> > +
> > +struct rtc_device *rtc_lookup(const char *name)
> > +{
> > +	struct rtc_device *r;
> > +
> > +	if (!name)
> > +		return ERR_PTR(-ENODEV);
> > +
> > +	list_for_each_entry(r, &rtc_list, list) {
> > +		if (!strcmp(dev_name(&r->class_dev), name))
> > +			return r;
> > +	}
> > +
> > +	return ERR_PTR(-ENODEV);
> > +}
> > +EXPORT_SYMBOL(rtc_lookup);
> > +
> > +int rtc_read_time(struct rtc_device *rtc, struct rtc_time *tm)
> > +{
> > +	return rtc->ops->read_time(rtc, tm);
> > +}
> > +EXPORT_SYMBOL(rtc_read_time);
> > +
> > +int rtc_register(struct rtc_device *rtcdev)
> > +{
> > +	struct device_d *dev = &rtcdev->class_dev;
> > +
> > +	dev->id = DEVICE_ID_DYNAMIC;
> > +	strcpy(dev->name, "rtc");
> > +	if (rtcdev->dev)
> > +		dev->parent = rtcdev->dev;
> > +	platform_device_register(dev);
> 
> Please check the return value.
> 
> > +
> > +	list_add_tail(&rtcdev->list, &rtc_list);
> > +
> > +	return 0;
> > +}
> > +EXPORT_SYMBOL(rtc_register);
> > +
> > +#if 0
> > +int rtc_unregister(struct rtc_device *cdev)
> > +{
> > +	struct device_d *dev = &cdev->class_dev;
> > +	int status;
> > +
> > +	list_del(&cdev->list);
> > +	if (list_empty(&rtc_list))
> > +		initialized = CONSOLE_UNINITIALIZED;
> > +
> > +	status = unregister_device(dev);
> > +	if (!status)
> > +		memset(cdev, 0, sizeof(*cdev));
> > +	return status;
> > +}
> > +EXPORT_SYMBOL(rtc_unregister);
> > +#endif
> 
> CONSOLE_UNINITIALIZED? This probably wouldn't compile if it wasn't
> ifdeffed. I think we can just remove this.

Please see TODOs in the '[RFC 0/5] add rtc support' message:

 * rtc_unregister() is not realized.

I suppose that most (but not all) of RTC chips does not need any deinitialization routines.
So I have not realized the rtc_unregister() routine.


-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2014-07-11  5:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-10  8:33 [RFC 0/5] " Antony Pavlov
2014-07-10  8:33 ` [RFC 1/5] lib: import 'bcd' from linux-3.15 Antony Pavlov
2014-07-10  8:33 ` [RFC 2/5] add rtc support Antony Pavlov
2014-07-10 21:40   ` Sascha Hauer
2014-07-11  5:31     ` Antony Pavlov [this message]
2014-07-10  8:33 ` [RFC 3/5] i2c: import SMBus stuff from linux Antony Pavlov
2014-07-10  8:33 ` [RFC 4/5] rtc: add ds1307 support Antony Pavlov
2014-07-10  8:33 ` [RFC 5/5] commands: add hwclock Antony Pavlov
2014-07-10 21:45   ` Sascha Hauer
2014-07-11  5:59     ` Antony Pavlov
2014-07-11  6:07       ` Sascha Hauer
2014-07-11  5:37 ` [RFC 0/5] add rtc support Sascha Hauer
2014-07-11  6:12   ` Antony Pavlov
2014-07-11  6:10     ` Sascha Hauer
2014-07-11  6:32       ` Antony Pavlov
2014-07-11  6:37         ` Sascha Hauer
2014-07-11 11:27     ` Antony Pavlov

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=20140711093156.890f5ab97d35d93249d006c8@gmail.com \
    --to=antonynpavlov@gmail.com \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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