rtc: nvmem: remove nvram ABI
The nvram sysfs attributes have been deprecated at least since v4.13, more than 3 years ago and nobody ever complained about the deprecation warning. Remove the sysfs attributes now. [Bartosz: remove the declaration of rtc_nvmem_unregister()] Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Link: https://lore.kernel.org/r/20201109163409.24301-5-brgl@bgdev.pl
This commit is contained in:
parent
4d49ffc7a2
commit
25ece30561
@ -339,8 +339,6 @@ static void devm_rtc_release_device(struct device *dev, void *res)
|
|||||||
{
|
{
|
||||||
struct rtc_device *rtc = *(struct rtc_device **)res;
|
struct rtc_device *rtc = *(struct rtc_device **)res;
|
||||||
|
|
||||||
rtc_nvmem_unregister(rtc);
|
|
||||||
|
|
||||||
if (rtc->registered)
|
if (rtc->registered)
|
||||||
rtc_device_unregister(rtc);
|
rtc_device_unregister(rtc);
|
||||||
else
|
else
|
||||||
|
@ -9,74 +9,7 @@
|
|||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/nvmem-consumer.h>
|
#include <linux/nvmem-consumer.h>
|
||||||
#include <linux/rtc.h>
|
#include <linux/rtc.h>
|
||||||
#include <linux/slab.h>
|
|
||||||
#include <linux/sysfs.h>
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Deprecated ABI compatibility, this should be removed at some point
|
|
||||||
*/
|
|
||||||
|
|
||||||
static const char nvram_warning[] = "Deprecated ABI, please use nvmem";
|
|
||||||
|
|
||||||
static ssize_t
|
|
||||||
rtc_nvram_read(struct file *filp, struct kobject *kobj,
|
|
||||||
struct bin_attribute *attr,
|
|
||||||
char *buf, loff_t off, size_t count)
|
|
||||||
{
|
|
||||||
dev_warn_once(kobj_to_dev(kobj), nvram_warning);
|
|
||||||
|
|
||||||
return nvmem_device_read(attr->private, off, count, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static ssize_t
|
|
||||||
rtc_nvram_write(struct file *filp, struct kobject *kobj,
|
|
||||||
struct bin_attribute *attr,
|
|
||||||
char *buf, loff_t off, size_t count)
|
|
||||||
{
|
|
||||||
dev_warn_once(kobj_to_dev(kobj), nvram_warning);
|
|
||||||
|
|
||||||
return nvmem_device_write(attr->private, off, count, buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int rtc_nvram_register(struct rtc_device *rtc,
|
|
||||||
struct nvmem_device *nvmem, size_t size)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
|
|
||||||
rtc->nvram = kzalloc(sizeof(*rtc->nvram), GFP_KERNEL);
|
|
||||||
if (!rtc->nvram)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
rtc->nvram->attr.name = "nvram";
|
|
||||||
rtc->nvram->attr.mode = 0644;
|
|
||||||
rtc->nvram->private = nvmem;
|
|
||||||
|
|
||||||
sysfs_bin_attr_init(rtc->nvram);
|
|
||||||
|
|
||||||
rtc->nvram->read = rtc_nvram_read;
|
|
||||||
rtc->nvram->write = rtc_nvram_write;
|
|
||||||
rtc->nvram->size = size;
|
|
||||||
|
|
||||||
err = sysfs_create_bin_file(&rtc->dev.parent->kobj,
|
|
||||||
rtc->nvram);
|
|
||||||
if (err) {
|
|
||||||
kfree(rtc->nvram);
|
|
||||||
rtc->nvram = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void rtc_nvram_unregister(struct rtc_device *rtc)
|
|
||||||
{
|
|
||||||
sysfs_remove_bin_file(&rtc->dev.parent->kobj, rtc->nvram);
|
|
||||||
kfree(rtc->nvram);
|
|
||||||
rtc->nvram = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* New ABI, uses nvmem
|
|
||||||
*/
|
|
||||||
int rtc_nvmem_register(struct rtc_device *rtc,
|
int rtc_nvmem_register(struct rtc_device *rtc,
|
||||||
struct nvmem_config *nvmem_config)
|
struct nvmem_config *nvmem_config)
|
||||||
{
|
{
|
||||||
@ -88,20 +21,7 @@ int rtc_nvmem_register(struct rtc_device *rtc,
|
|||||||
nvmem_config->dev = rtc->dev.parent;
|
nvmem_config->dev = rtc->dev.parent;
|
||||||
nvmem_config->owner = rtc->owner;
|
nvmem_config->owner = rtc->owner;
|
||||||
nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config);
|
nvmem = devm_nvmem_register(rtc->dev.parent, nvmem_config);
|
||||||
if (IS_ERR(nvmem))
|
|
||||||
return PTR_ERR(nvmem);
|
|
||||||
|
|
||||||
/* Register the old ABI */
|
return PTR_ERR_OR_ZERO(nvmem);
|
||||||
if (rtc->nvram_old_abi)
|
|
||||||
rtc_nvram_register(rtc, nvmem, nvmem_config->size);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rtc_nvmem_register);
|
EXPORT_SYMBOL_GPL(rtc_nvmem_register);
|
||||||
|
|
||||||
void rtc_nvmem_unregister(struct rtc_device *rtc)
|
|
||||||
{
|
|
||||||
/* unregister the old ABI */
|
|
||||||
if (rtc->nvram)
|
|
||||||
rtc_nvram_unregister(rtc);
|
|
||||||
}
|
|
||||||
|
@ -863,7 +863,6 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
|
|||||||
cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
|
cmos_rtc.rtc->ops = &cmos_rtc_ops_no_alarm;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmos_rtc.rtc->nvram_old_abi = true;
|
|
||||||
retval = rtc_register_device(cmos_rtc.rtc);
|
retval = rtc_register_device(cmos_rtc.rtc);
|
||||||
if (retval)
|
if (retval)
|
||||||
goto cleanup2;
|
goto cleanup2;
|
||||||
|
@ -694,7 +694,6 @@ static int ds1305_probe(struct spi_device *spi)
|
|||||||
ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
ds1305->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
|
|
||||||
ds1305_nvmem_cfg.priv = ds1305;
|
ds1305_nvmem_cfg.priv = ds1305;
|
||||||
ds1305->rtc->nvram_old_abi = true;
|
|
||||||
status = rtc_register_device(ds1305->rtc);
|
status = rtc_register_device(ds1305->rtc);
|
||||||
if (status)
|
if (status)
|
||||||
return status;
|
return status;
|
||||||
|
@ -2016,7 +2016,6 @@ static int ds1307_probe(struct i2c_client *client,
|
|||||||
.priv = ds1307,
|
.priv = ds1307,
|
||||||
};
|
};
|
||||||
|
|
||||||
ds1307->rtc->nvram_old_abi = true;
|
|
||||||
rtc_nvmem_register(ds1307->rtc, &nvmem_cfg);
|
rtc_nvmem_register(ds1307->rtc, &nvmem_cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,7 +399,6 @@ static int ds1343_probe(struct spi_device *spi)
|
|||||||
if (IS_ERR(priv->rtc))
|
if (IS_ERR(priv->rtc))
|
||||||
return PTR_ERR(priv->rtc);
|
return PTR_ERR(priv->rtc);
|
||||||
|
|
||||||
priv->rtc->nvram_old_abi = true;
|
|
||||||
priv->rtc->ops = &ds1343_rtc_ops;
|
priv->rtc->ops = &ds1343_rtc_ops;
|
||||||
priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
priv->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
priv->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
|
@ -466,8 +466,6 @@ static int ds1511_rtc_probe(struct platform_device *pdev)
|
|||||||
|
|
||||||
pdata->rtc->ops = &ds1511_rtc_ops;
|
pdata->rtc->ops = &ds1511_rtc_ops;
|
||||||
|
|
||||||
pdata->rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
ret = rtc_register_device(pdata->rtc);
|
ret = rtc_register_device(pdata->rtc);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -294,7 +294,6 @@ static int ds1553_rtc_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(pdata->rtc);
|
return PTR_ERR(pdata->rtc);
|
||||||
|
|
||||||
pdata->rtc->ops = &ds1553_rtc_ops;
|
pdata->rtc->ops = &ds1553_rtc_ops;
|
||||||
pdata->rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
ret = rtc_register_device(pdata->rtc);
|
ret = rtc_register_device(pdata->rtc);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -1316,7 +1316,6 @@ ds1685_rtc_probe(struct platform_device *pdev)
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
rtc_dev->nvram_old_abi = true;
|
|
||||||
nvmem_cfg.priv = rtc;
|
nvmem_cfg.priv = rtc;
|
||||||
ret = rtc_nvmem_register(rtc_dev, &nvmem_cfg);
|
ret = rtc_nvmem_register(rtc_dev, &nvmem_cfg);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -190,7 +190,6 @@ static int ds1742_rtc_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(rtc);
|
return PTR_ERR(rtc);
|
||||||
|
|
||||||
rtc->ops = &ds1742_rtc_ops;
|
rtc->ops = &ds1742_rtc_ops;
|
||||||
rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
ret = rtc_register_device(rtc);
|
ret = rtc_register_device(rtc);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -463,7 +463,6 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
|
|||||||
if (IS_ERR(m48t59->rtc))
|
if (IS_ERR(m48t59->rtc))
|
||||||
return PTR_ERR(m48t59->rtc);
|
return PTR_ERR(m48t59->rtc);
|
||||||
|
|
||||||
m48t59->rtc->nvram_old_abi = true;
|
|
||||||
m48t59->rtc->ops = ops;
|
m48t59->rtc->ops = ops;
|
||||||
|
|
||||||
nvmem_cfg.size = pdata->offset;
|
nvmem_cfg.size = pdata->offset;
|
||||||
|
@ -254,7 +254,6 @@ static int m48t86_rtc_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(info->rtc);
|
return PTR_ERR(info->rtc);
|
||||||
|
|
||||||
info->rtc->ops = &m48t86_rtc_ops;
|
info->rtc->ops = &m48t86_rtc_ops;
|
||||||
info->rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
err = rtc_register_device(info->rtc);
|
err = rtc_register_device(info->rtc);
|
||||||
if (err)
|
if (err)
|
||||||
|
@ -251,7 +251,6 @@ static int __init rp5c01_rtc_probe(struct platform_device *dev)
|
|||||||
return PTR_ERR(rtc);
|
return PTR_ERR(rtc);
|
||||||
|
|
||||||
rtc->ops = &rp5c01_rtc_ops;
|
rtc->ops = &rp5c01_rtc_ops;
|
||||||
rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
priv->rtc = rtc;
|
priv->rtc = rtc;
|
||||||
|
|
||||||
|
@ -585,7 +585,6 @@ static int rv8803_probe(struct i2c_client *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rv8803->rtc->ops = &rv8803_rtc_ops;
|
rv8803->rtc->ops = &rv8803_rtc_ops;
|
||||||
rv8803->rtc->nvram_old_abi = true;
|
|
||||||
rv8803->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
rv8803->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
|
||||||
rv8803->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
rv8803->rtc->range_max = RTC_TIMESTAMP_END_2099;
|
||||||
err = rtc_register_device(rv8803->rtc);
|
err = rtc_register_device(rv8803->rtc);
|
||||||
|
@ -311,7 +311,6 @@ static int stk17ta8_rtc_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(pdata->rtc);
|
return PTR_ERR(pdata->rtc);
|
||||||
|
|
||||||
pdata->rtc->ops = &stk17ta8_rtc_ops;
|
pdata->rtc->ops = &stk17ta8_rtc_ops;
|
||||||
pdata->rtc->nvram_old_abi = true;
|
|
||||||
|
|
||||||
nvmem_cfg.priv = pdata;
|
nvmem_cfg.priv = pdata;
|
||||||
ret = rtc_nvmem_register(pdata->rtc, &nvmem_cfg);
|
ret = rtc_nvmem_register(pdata->rtc, &nvmem_cfg);
|
||||||
|
@ -266,7 +266,6 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev)
|
|||||||
return PTR_ERR(rtc);
|
return PTR_ERR(rtc);
|
||||||
|
|
||||||
rtc->ops = &tx4939_rtc_ops;
|
rtc->ops = &tx4939_rtc_ops;
|
||||||
rtc->nvram_old_abi = true;
|
|
||||||
rtc->range_max = U32_MAX;
|
rtc->range_max = U32_MAX;
|
||||||
|
|
||||||
pdata->rtc = rtc;
|
pdata->rtc = rtc;
|
||||||
|
@ -120,10 +120,6 @@ struct rtc_device {
|
|||||||
|
|
||||||
bool registered;
|
bool registered;
|
||||||
|
|
||||||
/* Old ABI support */
|
|
||||||
bool nvram_old_abi;
|
|
||||||
struct bin_attribute *nvram;
|
|
||||||
|
|
||||||
time64_t range_min;
|
time64_t range_min;
|
||||||
timeu64_t range_max;
|
timeu64_t range_max;
|
||||||
time64_t start_secs;
|
time64_t start_secs;
|
||||||
@ -250,14 +246,12 @@ extern int rtc_hctosys_ret;
|
|||||||
#ifdef CONFIG_RTC_NVMEM
|
#ifdef CONFIG_RTC_NVMEM
|
||||||
int rtc_nvmem_register(struct rtc_device *rtc,
|
int rtc_nvmem_register(struct rtc_device *rtc,
|
||||||
struct nvmem_config *nvmem_config);
|
struct nvmem_config *nvmem_config);
|
||||||
void rtc_nvmem_unregister(struct rtc_device *rtc);
|
|
||||||
#else
|
#else
|
||||||
static inline int rtc_nvmem_register(struct rtc_device *rtc,
|
static inline int rtc_nvmem_register(struct rtc_device *rtc,
|
||||||
struct nvmem_config *nvmem_config)
|
struct nvmem_config *nvmem_config)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_INTF_SYSFS
|
#ifdef CONFIG_RTC_INTF_SYSFS
|
||||||
|
Loading…
Reference in New Issue
Block a user