2013-07-02 16:50:47

by Alexander Shiyan

[permalink] [raw]
Subject: [PATCH 1/3] rtc: ds1742: Using devm_ioremap_resource()


Signed-off-by: Alexander Shiyan <[email protected]>
---
drivers/rtc/rtc-ds1742.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index eccdc62..9fba0ae 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -56,7 +56,6 @@ struct rtc_plat_data {
void __iomem *ioaddr_nvram;
void __iomem *ioaddr_rtc;
size_t size_nvram;
- size_t size;
unsigned long last_jiffies;
struct bin_attribute nvram_attr;
};
@@ -168,22 +167,17 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
void __iomem *ioaddr;
int ret = 0;

- res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
- if (!res)
- return -ENODEV;
pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return -ENOMEM;
- pdata->size = resource_size(res);
- if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
- pdev->name))
- return -EBUSY;
- ioaddr = devm_ioremap(&pdev->dev, res->start, pdata->size);
- if (!ioaddr)
- return -ENOMEM;
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ ioaddr = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(ioaddr))
+ return PTR_ERR(ioaddr);

pdata->ioaddr_nvram = ioaddr;
- pdata->size_nvram = pdata->size - RTC_SIZE;
+ pdata->size_nvram = resource_size(res) - RTC_SIZE;
pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;

sysfs_bin_attr_init(&pdata->nvram_attr);
--
1.8.1.5


2013-07-02 16:50:40

by Alexander Shiyan

[permalink] [raw]
Subject: [PATCH 2/3] rtc: ds1742: Remove unused field "rtc" from private structure


Signed-off-by: Alexander Shiyan <[email protected]>
---
drivers/rtc/rtc-ds1742.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 9fba0ae..139934f 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -52,7 +52,6 @@
#define RTC_BATT_FLAG 0x80

struct rtc_plat_data {
- struct rtc_device *rtc;
void __iomem *ioaddr_nvram;
void __iomem *ioaddr_rtc;
size_t size_nvram;
@@ -206,7 +205,6 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
&ds1742_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc))
return PTR_ERR(rtc);
- pdata->rtc = rtc;

ret = sysfs_create_bin_file(&pdev->dev.kobj, &pdata->nvram_attr);

--
1.8.1.5

2013-07-02 17:18:25

by Alexander Shiyan

[permalink] [raw]
Subject: [PATCH 3/3] rtc: ds1742: Report to RTC core if retrieved time is invalid


Signed-off-by: Alexander Shiyan <[email protected]>
---
drivers/rtc/rtc-ds1742.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index 139934f..17b73fd 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -115,11 +115,7 @@ static int ds1742_rtc_read_time(struct device *dev, struct rtc_time *tm)
/* year is 1900 + tm->tm_year */
tm->tm_year = bcd2bin(year) + bcd2bin(century) * 100 - 1900;

- if (rtc_valid_tm(tm) < 0) {
- dev_err(dev, "retrieved date/time is not valid.\n");
- rtc_time_to_tm(0, tm);
- }
- return 0;
+ return rtc_valid_tm(tm);
}

static const struct rtc_class_ops ds1742_rtc_ops = {
--
1.8.1.5

2013-07-20 14:03:43

by Alexander Shiyan

[permalink] [raw]
Subject: Re: [PATCH 1/3] rtc: ds1742: Using devm_ioremap_resource()

On Tue, 2 Jul 2013 20:50:00 +0400
Alexander Shiyan <[email protected]> wrote:

>
> Signed-off-by: Alexander Shiyan <[email protected]>
> ---
> drivers/rtc/rtc-ds1742.c | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
> index eccdc62..9fba0ae 100644
> --- a/drivers/rtc/rtc-ds1742.c
> +++ b/drivers/rtc/rtc-ds1742.c
> @@ -56,7 +56,6 @@ struct rtc_plat_data {
> void __iomem *ioaddr_nvram;
> void __iomem *ioaddr_rtc;
> size_t size_nvram;
> - size_t size;
> unsigned long last_jiffies;
> struct bin_attribute nvram_attr;
> };
> @@ -168,22 +167,17 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
> void __iomem *ioaddr;
> int ret = 0;
>
> - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> - if (!res)
> - return -ENODEV;
> pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
> if (!pdata)
> return -ENOMEM;
> - pdata->size = resource_size(res);
> - if (!devm_request_mem_region(&pdev->dev, res->start, pdata->size,
> - pdev->name))
> - return -EBUSY;
> - ioaddr = devm_ioremap(&pdev->dev, res->start, pdata->size);
> - if (!ioaddr)
> - return -ENOMEM;
> +
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + ioaddr = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(ioaddr))
> + return PTR_ERR(ioaddr);
>
> pdata->ioaddr_nvram = ioaddr;
> - pdata->size_nvram = pdata->size - RTC_SIZE;
> + pdata->size_nvram = resource_size(res) - RTC_SIZE;
> pdata->ioaddr_rtc = ioaddr + pdata->size_nvram;
>
> sysfs_bin_attr_init(&pdata->nvram_attr);
> --

Ping

--
Alexander Shiyan <[email protected]>