mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-15 08:44:14 +08:00
rtc: isl1208: avoid possible sysfs race
Use rtc_add_group to add the common sysfs group to avoid a possible race condition. [Denis.Osterland@diehl.com: use to_i2c_client(dev->parent)] Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> The move of atrim, dtrim usr sysfs properties from i2c device to rtc device require to access them via dev->parent. This patch also aligns timestamp0.
This commit is contained in:
parent
f1c8bc332e
commit
1b4c794fda
@ -518,7 +518,7 @@ static ssize_t timestamp0_store(struct device *dev,
|
|||||||
struct device_attribute *attr,
|
struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = dev_get_drvdata(dev);
|
struct i2c_client *client = to_i2c_client(dev->parent);
|
||||||
int sr;
|
int sr;
|
||||||
|
|
||||||
sr = isl1208_i2c_get_sr(client);
|
sr = isl1208_i2c_get_sr(client);
|
||||||
@ -540,7 +540,7 @@ static ssize_t timestamp0_store(struct device *dev,
|
|||||||
static ssize_t timestamp0_show(struct device *dev,
|
static ssize_t timestamp0_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct i2c_client *client = dev_get_drvdata(dev);
|
struct i2c_client *client = to_i2c_client(dev->parent);
|
||||||
u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
|
u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, };
|
||||||
struct rtc_time tm;
|
struct rtc_time tm;
|
||||||
int sr;
|
int sr;
|
||||||
@ -650,7 +650,7 @@ static ssize_t
|
|||||||
isl1208_sysfs_show_atrim(struct device *dev,
|
isl1208_sysfs_show_atrim(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int atr = isl1208_i2c_get_atr(to_i2c_client(dev));
|
int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent));
|
||||||
if (atr < 0)
|
if (atr < 0)
|
||||||
return atr;
|
return atr;
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ static ssize_t
|
|||||||
isl1208_sysfs_show_dtrim(struct device *dev,
|
isl1208_sysfs_show_dtrim(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev));
|
int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent));
|
||||||
if (dtr < 0)
|
if (dtr < 0)
|
||||||
return dtr;
|
return dtr;
|
||||||
|
|
||||||
@ -676,7 +676,7 @@ static ssize_t
|
|||||||
isl1208_sysfs_show_usr(struct device *dev,
|
isl1208_sysfs_show_usr(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
int usr = isl1208_i2c_get_usr(to_i2c_client(dev));
|
int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent));
|
||||||
if (usr < 0)
|
if (usr < 0)
|
||||||
return usr;
|
return usr;
|
||||||
|
|
||||||
@ -701,7 +701,10 @@ isl1208_sysfs_store_usr(struct device *dev,
|
|||||||
if (usr < 0 || usr > 0xffff)
|
if (usr < 0 || usr > 0xffff)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count;
|
if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr))
|
||||||
|
return -EIO;
|
||||||
|
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
|
static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr,
|
||||||
@ -765,7 +768,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||||||
rtc->ops = &isl1208_rtc_ops;
|
rtc->ops = &isl1208_rtc_ops;
|
||||||
|
|
||||||
i2c_set_clientdata(client, rtc);
|
i2c_set_clientdata(client, rtc);
|
||||||
dev_set_drvdata(&rtc->dev, client);
|
|
||||||
|
|
||||||
rc = isl1208_i2c_get_sr(client);
|
rc = isl1208_i2c_get_sr(client);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
@ -804,7 +806,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||||||
evdet_irq = of_irq_get_byname(np, "evdet");
|
evdet_irq = of_irq_get_byname(np, "evdet");
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files);
|
rc = rtc_add_group(rtc, &isl1208_rtc_sysfs_files);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
@ -821,14 +823,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
|||||||
return rtc_register_device(rtc);
|
return rtc_register_device(rtc);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
isl1208_remove(struct i2c_client *client)
|
|
||||||
{
|
|
||||||
sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct i2c_device_id isl1208_id[] = {
|
static const struct i2c_device_id isl1208_id[] = {
|
||||||
{ "isl1208", TYPE_ISL1208 },
|
{ "isl1208", TYPE_ISL1208 },
|
||||||
{ "isl1218", TYPE_ISL1218 },
|
{ "isl1218", TYPE_ISL1218 },
|
||||||
@ -851,7 +845,6 @@ static struct i2c_driver isl1208_driver = {
|
|||||||
.of_match_table = of_match_ptr(isl1208_of_match),
|
.of_match_table = of_match_ptr(isl1208_of_match),
|
||||||
},
|
},
|
||||||
.probe = isl1208_probe,
|
.probe = isl1208_probe,
|
||||||
.remove = isl1208_remove,
|
|
||||||
.id_table = isl1208_id,
|
.id_table = isl1208_id,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user