Skip to content

Commit

Permalink
rtc: constify rtc_class_ops structures
Browse files Browse the repository at this point in the history
Check for rtc_class_ops structures that are only passed to
devm_rtc_device_register, rtc_device_register,
platform_device_register_data, all of which declare the corresponding
parameter as const.  Declare rtc_class_ops structures that have these
properties as const.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct rtc_class_ops i@p = { ... };

@ok@
identifier r.i;
expression e1,e2,e3,e4;
position p;
@@
(
devm_rtc_device_register(e1,e2,&i@p,e3)
|
rtc_device_register(e1,e2,&i@p,e3)
|
platform_device_register_data(e1,e2,e3,&i@p,e4)
)

@bad@
position p != {r.p,ok.p};
identifier r.i;
@@
i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct rtc_class_ops i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Acked-by: Baruch Siach <baruch@tkos.co.il>
Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
  • Loading branch information
Julia Lawall authored and Alexandre Belloni committed Sep 1, 2016
1 parent 637cac7 commit 34c7b3a
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-at32ap700x.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ static irqreturn_t at32_rtc_interrupt(int irq, void *dev_id)
return ret;
}

static struct rtc_class_ops at32_rtc_ops = {
static const struct rtc_class_ops at32_rtc_ops = {
.read_time = at32_rtc_readtime,
.set_time = at32_rtc_settime,
.read_alarm = at32_rtc_readalarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-coh901331.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static int coh901331_alarm_irq_enable(struct device *dev, unsigned int enabled)
return 0;
}

static struct rtc_class_ops coh901331_ops = {
static const struct rtc_class_ops coh901331_ops = {
.read_time = coh901331_read_time,
.set_mmss = coh901331_set_mmss,
.read_alarm = coh901331_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-davinci.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
return 0;
}

static struct rtc_class_ops davinci_rtc_ops = {
static const struct rtc_class_ops davinci_rtc_ops = {
.ioctl = davinci_rtc_ioctl,
.read_time = davinci_rtc_read_time,
.set_time = davinci_rtc_set_time,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-digicolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ static int dc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
return 0;
}

static struct rtc_class_ops dc_rtc_ops = {
static const struct rtc_class_ops dc_rtc_ops = {
.read_time = dc_rtc_read_time,
.set_mmss = dc_rtc_set_mmss,
.read_alarm = dc_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-ds1302.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ static int ds1302_rtc_get_time(struct device *dev, struct rtc_time *time)
return rtc_valid_tm(time);
}

static struct rtc_class_ops ds1302_rtc_ops = {
static const struct rtc_class_ops ds1302_rtc_ops = {
.read_time = ds1302_rtc_get_time,
.set_time = ds1302_rtc_set_time,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-gemini.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int gemini_rtc_set_time(struct device *dev, struct rtc_time *tm)
return 0;
}

static struct rtc_class_ops gemini_rtc_ops = {
static const struct rtc_class_ops gemini_rtc_ops = {
.read_time = gemini_rtc_read_time,
.set_time = gemini_rtc_set_time,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-jz4740.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable)
return jz4740_rtc_ctrl_set_bits(rtc, JZ_RTC_CTRL_AF_IRQ, enable);
}

static struct rtc_class_ops jz4740_rtc_ops = {
static const struct rtc_class_ops jz4740_rtc_ops = {
.read_time = jz4740_rtc_read_time,
.set_mmss = jz4740_rtc_set_mmss,
.read_alarm = jz4740_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-mcp795.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ static int mcp795_read_time(struct device *dev, struct rtc_time *tim)
return rtc_valid_tm(tim);
}

static struct rtc_class_ops mcp795_rtc_ops = {
static const struct rtc_class_ops mcp795_rtc_ops = {
.read_time = mcp795_read_time,
.set_time = mcp795_set_time
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-mt6397.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ static int mtk_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
return ret;
}

static struct rtc_class_ops mtk_rtc_ops = {
static const struct rtc_class_ops mtk_rtc_ops = {
.read_time = mtk_rtc_read_time,
.set_time = mtk_rtc_set_time,
.read_alarm = mtk_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-nuc900.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static int nuc900_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
return 0;
}

static struct rtc_class_ops nuc900_rtc_ops = {
static const struct rtc_class_ops nuc900_rtc_ops = {
.read_time = nuc900_rtc_read_time,
.set_time = nuc900_rtc_set_time,
.read_alarm = nuc900_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-omap.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ static void omap_rtc_power_off(void)
mdelay(2500);
}

static struct rtc_class_ops omap_rtc_ops = {
static const struct rtc_class_ops omap_rtc_ops = {
.read_time = omap_rtc_read_time,
.set_time = omap_rtc_set_time,
.read_alarm = omap_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-palmas.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static irqreturn_t palmas_rtc_interrupt(int irq, void *context)
return IRQ_HANDLED;
}

static struct rtc_class_ops palmas_rtc_ops = {
static const struct rtc_class_ops palmas_rtc_ops = {
.read_time = palmas_rtc_read_time,
.set_time = palmas_rtc_set_time,
.read_alarm = palmas_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-pcf50633.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static int pcf50633_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
return ret;
}

static struct rtc_class_ops pcf50633_rtc_ops = {
static const struct rtc_class_ops pcf50633_rtc_ops = {
.read_time = pcf50633_rtc_read_time,
.set_time = pcf50633_rtc_set_time,
.read_alarm = pcf50633_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-rx6110.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ static int rx6110_init(struct rx6110_data *rx6110)
return ret;
}

static struct rtc_class_ops rx6110_rtc_ops = {
static const struct rtc_class_ops rx6110_rtc_ops = {
.read_time = rx6110_get_time,
.set_time = rx6110_set_time,
};
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-rx8025.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static int rx8025_alarm_irq_enable(struct device *dev, unsigned int enabled)
return 0;
}

static struct rtc_class_ops rx8025_rtc_ops = {
static const struct rtc_class_ops rx8025_rtc_ops = {
.read_time = rx8025_get_time,
.set_time = rx8025_set_time,
.read_alarm = rx8025_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-spear.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ static int spear_alarm_irq_enable(struct device *dev, unsigned int enabled)
return ret;
}

static struct rtc_class_ops spear_rtc_ops = {
static const struct rtc_class_ops spear_rtc_ops = {
.read_time = spear_rtc_read_time,
.set_time = spear_rtc_set_time,
.read_alarm = spear_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-stmp3xxx.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
return 0;
}

static struct rtc_class_ops stmp3xxx_rtc_ops = {
static const struct rtc_class_ops stmp3xxx_rtc_ops = {
.alarm_irq_enable =
stmp3xxx_alarm_irq_enable,
.read_time = stmp3xxx_rtc_gettime,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ static irqreturn_t tegra_rtc_irq_handler(int irq, void *data)
return IRQ_HANDLED;
}

static struct rtc_class_ops tegra_rtc_ops = {
static const struct rtc_class_ops tegra_rtc_ops = {
.read_time = tegra_rtc_read_time,
.set_time = tegra_rtc_set_time,
.read_alarm = tegra_rtc_read_alarm,
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-twl.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ static irqreturn_t twl_rtc_interrupt(int irq, void *rtc)
return ret;
}

static struct rtc_class_ops twl_rtc_ops = {
static const struct rtc_class_ops twl_rtc_ops = {
.read_time = twl_rtc_read_time,
.set_time = twl_rtc_set_time,
.read_alarm = twl_rtc_read_alarm,
Expand Down

0 comments on commit 34c7b3a

Please sign in to comment.