[PATCH 2/2] leds: lm3533: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 8272 4608 64 129443290 drivers/leds/leds-lm3533.o File size after: text data bss dec hex filename 8368 4512 64 129443290 drivers/leds/leds-lm3533.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/leds/leds-lm3533.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c index 5b529dc..72224b5 100644 --- a/drivers/leds/leds-lm3533.c +++ b/drivers/leds/leds-lm3533.c @@ -626,7 +626,7 @@ static umode_t lm3533_led_attr_is_visible(struct kobject *kobj, return mode; }; -static struct attribute_group lm3533_led_attribute_group = { +static const struct attribute_group lm3533_led_attribute_group = { .is_visible = lm3533_led_attr_is_visible, .attrs = lm3533_led_attributes }; -- 2.7.4
[PATCH 1/2] leds: blinkm: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 8657 3496 64 122172fb9 drivers/leds/leds-blinkm.o File size after: text data bss dec hex filename 8753 3400 64 122172fb9 drivers/leds/leds-blinkm.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/leds/leds-blinkm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index 617fe97..d03ed6b 100644 --- a/drivers/leds/leds-blinkm.c +++ b/drivers/leds/leds-blinkm.c @@ -298,7 +298,7 @@ static struct attribute *blinkm_attrs[] = { NULL, }; -static struct attribute_group blinkm_group = { +static const struct attribute_group blinkm_group = { .name = "blinkm", .attrs = blinkm_attrs, }; -- 2.7.4
[PATCH 1/2] leds: blinkm: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 8657 3496 64 122172fb9 drivers/leds/leds-blinkm.o File size after: text data bss dec hex filename 8753 3400 64 122172fb9 drivers/leds/leds-blinkm.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/leds/leds-blinkm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-blinkm.c b/drivers/leds/leds-blinkm.c index 617fe97..d03ed6b 100644 --- a/drivers/leds/leds-blinkm.c +++ b/drivers/leds/leds-blinkm.c @@ -298,7 +298,7 @@ static struct attribute *blinkm_attrs[] = { NULL, }; -static struct attribute_group blinkm_group = { +static const struct attribute_group blinkm_group = { .name = "blinkm", .attrs = blinkm_attrs, }; -- 2.7.4
[PATCH 2/2] leds: lm3533: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 8272 4608 64 129443290 drivers/leds/leds-lm3533.o File size after: text data bss dec hex filename 8368 4512 64 129443290 drivers/leds/leds-lm3533.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/leds/leds-lm3533.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/leds/leds-lm3533.c b/drivers/leds/leds-lm3533.c index 5b529dc..72224b5 100644 --- a/drivers/leds/leds-lm3533.c +++ b/drivers/leds/leds-lm3533.c @@ -626,7 +626,7 @@ static umode_t lm3533_led_attr_is_visible(struct kobject *kobj, return mode; }; -static struct attribute_group lm3533_led_attribute_group = { +static const struct attribute_group lm3533_led_attribute_group = { .is_visible = lm3533_led_attr_is_visible, .attrs = lm3533_led_attributes }; -- 2.7.4
[PATCH] imon: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 3698116776 960 54717d5bd drivers/media/rc/imon.o File size after: text data bss dec hex filename 3717316584 960 54717d5bd drivers/media/rc/imon.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/media/rc/imon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index bd76534..717ba78 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -911,7 +911,7 @@ static struct attribute *imon_display_sysfs_entries[] = { NULL }; -static struct attribute_group imon_display_attr_group = { +static const struct attribute_group imon_display_attr_group = { .attrs = imon_display_sysfs_entries }; @@ -920,7 +920,7 @@ static struct attribute *imon_rf_sysfs_entries[] = { NULL }; -static struct attribute_group imon_rf_attr_group = { +static const struct attribute_group imon_rf_attr_group = { .attrs = imon_rf_sysfs_entries }; -- 2.7.4
[PATCH] imon: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 3698116776 960 54717d5bd drivers/media/rc/imon.o File size after: text data bss dec hex filename 3717316584 960 54717d5bd drivers/media/rc/imon.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/media/rc/imon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c index bd76534..717ba78 100644 --- a/drivers/media/rc/imon.c +++ b/drivers/media/rc/imon.c @@ -911,7 +911,7 @@ static struct attribute *imon_display_sysfs_entries[] = { NULL }; -static struct attribute_group imon_display_attr_group = { +static const struct attribute_group imon_display_attr_group = { .attrs = imon_display_sysfs_entries }; @@ -920,7 +920,7 @@ static struct attribute *imon_rf_sysfs_entries[] = { NULL }; -static struct attribute_group imon_rf_attr_group = { +static const struct attribute_group imon_rf_attr_group = { .attrs = imon_rf_sysfs_entries }; -- 2.7.4
[PATCH] thunderbolt: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 28565 7300 0 358658c19 drivers/thunderbolt/switch.o File size after: text data bss dec hex filename 28661 7204 0 358658c19 drivers/thunderbolt/switch.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/thunderbolt/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index e9391bb..6cd4f14 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -970,7 +970,7 @@ static umode_t switch_attr_is_visible(struct kobject *kobj, return sw->safe_mode ? 0 : attr->mode; } -static struct attribute_group switch_group = { +static const struct attribute_group switch_group = { .is_visible = switch_attr_is_visible, .attrs = switch_attrs, }; -- 2.7.4
[PATCH] thunderbolt: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 28565 7300 0 358658c19 drivers/thunderbolt/switch.o File size after: text data bss dec hex filename 28661 7204 0 358658c19 drivers/thunderbolt/switch.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/thunderbolt/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index e9391bb..6cd4f14 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -970,7 +970,7 @@ static umode_t switch_attr_is_visible(struct kobject *kobj, return sw->safe_mode ? 0 : attr->mode; } -static struct attribute_group switch_group = { +static const struct attribute_group switch_group = { .is_visible = switch_attr_is_visible, .attrs = switch_attrs, }; -- 2.7.4
[PATCH] loop: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 27981 5489 480 33950849e drivers/block/loop.o File size after: text data bss dec hex filename 28320 5421 480 3422185ad drivers/block/loop.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ef83349..a7f35a0 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -798,7 +798,7 @@ static struct attribute *loop_attrs[] = { NULL, }; -static struct attribute_group loop_attribute_group = { +static const struct attribute_group loop_attribute_group = { .name = "loop", .attrs= loop_attrs, }; -- 2.7.4
[PATCH] loop: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 27981 5489 480 33950849e drivers/block/loop.o File size after: text data bss dec hex filename 28320 5421 480 3422185ad drivers/block/loop.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/block/loop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ef83349..a7f35a0 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -798,7 +798,7 @@ static struct attribute *loop_attrs[] = { NULL, }; -static struct attribute_group loop_attribute_group = { +static const struct attribute_group loop_attribute_group = { .name = "loop", .attrs= loop_attrs, }; -- 2.7.4
[PATCH] ACPI / dock: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 7902 3528 64 114942ce6 drivers/acpi/dock.o File size after: text data bss dec hex filename 7998 3432 64 114942ce6 drivers/acpi/dock.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/acpi/dock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 0c00208..2305e1a 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -585,7 +585,7 @@ static struct attribute *dock_attributes[] = { NULL }; -static struct attribute_group dock_attribute_group = { +static const struct attribute_group dock_attribute_group = { .attrs = dock_attributes }; -- 2.7.4
[PATCH] ACPI / dock: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 7902 3528 64 114942ce6 drivers/acpi/dock.o File size after: text data bss dec hex filename 7998 3432 64 114942ce6 drivers/acpi/dock.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/acpi/dock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c index 0c00208..2305e1a 100644 --- a/drivers/acpi/dock.c +++ b/drivers/acpi/dock.c @@ -585,7 +585,7 @@ static struct attribute *dock_attributes[] = { NULL }; -static struct attribute_group dock_attribute_group = { +static const struct attribute_group dock_attribute_group = { .attrs = dock_attributes }; -- 2.7.4
[PATCH 2/2] atm: solos-pci: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 3574028424 832 64996fde4 drivers/atm/solos-pci.o File size after: text data bss dec hex filename 3593228232 832 64996fde4 drivers/atm/solos-pci.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/atm/solos-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index c8f2ca6..3f9c37d 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c @@ -611,7 +611,7 @@ static struct attribute *solos_attrs[] = { NULL }; -static struct attribute_group solos_attr_group = { +static const struct attribute_group solos_attr_group = { .attrs = solos_attrs, .name = "parameters", }; @@ -628,7 +628,7 @@ static struct attribute *gpio_attrs[] = { NULL }; -static struct attribute_group gpio_attr_group = { +static const struct attribute_group gpio_attr_group = { .attrs = gpio_attrs, .name = "gpio", }; -- 2.7.4
[PATCH 2/2] atm: solos-pci: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 3574028424 832 64996fde4 drivers/atm/solos-pci.o File size after: text data bss dec hex filename 3593228232 832 64996fde4 drivers/atm/solos-pci.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/atm/solos-pci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index c8f2ca6..3f9c37d 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c @@ -611,7 +611,7 @@ static struct attribute *solos_attrs[] = { NULL }; -static struct attribute_group solos_attr_group = { +static const struct attribute_group solos_attr_group = { .attrs = solos_attrs, .name = "parameters", }; @@ -628,7 +628,7 @@ static struct attribute *gpio_attrs[] = { NULL }; -static struct attribute_group gpio_attr_group = { +static const struct attribute_group gpio_attr_group = { .attrs = gpio_attrs, .name = "gpio", }; -- 2.7.4
[PATCH 1/2] atm: adummy: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 2033 1448 03481 d99 drivers/atm/adummy.o File size after: text data bss dec hex filename 2129 1352 03481 d99 drivers/atm/adummy.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/atm/adummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c index 1fd25e8..da27ddf 100644 --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c @@ -71,7 +71,7 @@ static struct attribute *adummy_attrs[] = { NULL }; -static struct attribute_group adummy_group_attrs = { +static const struct attribute_group adummy_group_attrs = { .name = NULL, /* We want them in dev's root folder */ .attrs = adummy_attrs }; -- 2.7.4
[PATCH 1/2] atm: adummy: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 2033 1448 03481 d99 drivers/atm/adummy.o File size after: text data bss dec hex filename 2129 1352 03481 d99 drivers/atm/adummy.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/atm/adummy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c index 1fd25e8..da27ddf 100644 --- a/drivers/atm/adummy.c +++ b/drivers/atm/adummy.c @@ -71,7 +71,7 @@ static struct attribute *adummy_attrs[] = { NULL }; -static struct attribute_group adummy_group_attrs = { +static const struct attribute_group adummy_group_attrs = { .name = NULL, /* We want them in dev's root folder */ .attrs = adummy_attrs }; -- 2.7.4
[PATCH] staging: greybus: Remove unnecessary platform_set_drvdata
Unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL. The Coccinelle semantic patch used to make this change is as follows: // @@ struct platform_device *pdev; @@ - platform_set_drvdata(pdev, NULL); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/greybus/arche-platform.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index eced2d2..358b260 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -607,7 +607,6 @@ static int arche_platform_remove(struct platform_device *pdev) device_remove_file(>dev, _attr_state); device_for_each_child(>dev, NULL, arche_remove_child); arche_platform_poweroff_seq(arche_pdata); - platform_set_drvdata(pdev, NULL); if (usb3613_hub_mode_ctrl(false)) dev_warn(arche_pdata->dev, "failed to control hub device\n"); -- 2.7.4
[PATCH] staging: greybus: Remove unnecessary platform_set_drvdata
Unnecessary platform_set_drvdata() has been removed since the driver core clears the driver data to NULL after device release or on probe failure. There is no need to manually clear the device driver data to NULL. The Coccinelle semantic patch used to make this change is as follows: // @@ struct platform_device *pdev; @@ - platform_set_drvdata(pdev, NULL); // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/greybus/arche-platform.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/staging/greybus/arche-platform.c b/drivers/staging/greybus/arche-platform.c index eced2d2..358b260 100644 --- a/drivers/staging/greybus/arche-platform.c +++ b/drivers/staging/greybus/arche-platform.c @@ -607,7 +607,6 @@ static int arche_platform_remove(struct platform_device *pdev) device_remove_file(>dev, _attr_state); device_for_each_child(>dev, NULL, arche_remove_child); arche_platform_poweroff_seq(arche_pdata); - platform_set_drvdata(pdev, NULL); if (usb3613_hub_mode_ctrl(false)) dev_warn(arche_pdata->dev, "failed to control hub device\n"); -- 2.7.4
[PATCH] staging: unisys: visorchipset: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 24124 6216 448 307887844 drivers/staging/unisys/visorbus/visorchipset.o File size after: text data bss dec hex filename 242206120 448 307887844 drivers/staging/unisys/visorbus/visorchipset.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/unisys/visorbus/visorchipset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 2215056..798a92e 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1146,7 +1146,7 @@ static struct attribute *visorchipset_parahotplug_attrs[] = { NULL }; -static struct attribute_group visorchipset_parahotplug_group = { +static const struct attribute_group visorchipset_parahotplug_group = { .name = "parahotplug", .attrs = visorchipset_parahotplug_attrs }; -- 2.7.4
[PATCH] staging: unisys: visorchipset: constify attribute_group structure
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 24124 6216 448 307887844 drivers/staging/unisys/visorbus/visorchipset.o File size after: text data bss dec hex filename 242206120 448 307887844 drivers/staging/unisys/visorbus/visorchipset.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/unisys/visorbus/visorchipset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/unisys/visorbus/visorchipset.c b/drivers/staging/unisys/visorbus/visorchipset.c index 2215056..798a92e 100644 --- a/drivers/staging/unisys/visorbus/visorchipset.c +++ b/drivers/staging/unisys/visorbus/visorchipset.c @@ -1146,7 +1146,7 @@ static struct attribute *visorchipset_parahotplug_attrs[] = { NULL }; -static struct attribute_group visorchipset_parahotplug_group = { +static const struct attribute_group visorchipset_parahotplug_group = { .name = "parahotplug", .attrs = visorchipset_parahotplug_attrs }; -- 2.7.4
[PATCH] staging: unisys: visorbus_main: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 142167304 832 223525750 drivers/staging/unisys/visorbus/visorbus_main.o File size after: text data bss dec hex filename 144087112 832 223525750 drivers/staging/unisys/visorbus/visorbus_main.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 1c785dd..bba10dc 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -249,7 +249,7 @@ static struct attribute *channel_attrs[] = { NULL }; -static struct attribute_group channel_attr_grp = { +static const struct attribute_group channel_attr_grp = { .name = "channel", .attrs = channel_attrs, }; @@ -340,7 +340,7 @@ static struct attribute *dev_attrs[] = { NULL }; -static struct attribute_group dev_attr_grp = { +static const struct attribute_group dev_attr_grp = { .attrs = dev_attrs, }; -- 2.7.4
[PATCH] staging: unisys: visorbus_main: constify attribute_group structures
Functions working with attribute_groups provided by work with const attribute_group. These attribute_group structures do not change at runtime so mark them as const. File size before: text data bss dec hex filename 142167304 832 223525750 drivers/staging/unisys/visorbus/visorbus_main.o File size after: text data bss dec hex filename 144087112 832 223525750 drivers/staging/unisys/visorbus/visorbus_main.o This change was made with the help of Coccinelle. Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/unisys/visorbus/visorbus_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c index 1c785dd..bba10dc 100644 --- a/drivers/staging/unisys/visorbus/visorbus_main.c +++ b/drivers/staging/unisys/visorbus/visorbus_main.c @@ -249,7 +249,7 @@ static struct attribute *channel_attrs[] = { NULL }; -static struct attribute_group channel_attr_grp = { +static const struct attribute_group channel_attr_grp = { .name = "channel", .attrs = channel_attrs, }; @@ -340,7 +340,7 @@ static struct attribute *dev_attrs[] = { NULL }; -static struct attribute_group dev_attr_grp = { +static const struct attribute_group dev_attr_grp = { .attrs = dev_attrs, }; -- 2.7.4
[PATCH v2] staging: media: atomisp: Use kvfree() instead of kfree()/vfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. The resulting wrapper function has been replaced with direct calls to kvfree(). This change was made with the help of the following Coccinelle semantic patch: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Remove wrapper function .../staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 19 +++ .../staging/media/atomisp/pci/atomisp2/atomisp_cmd.h | 1 - .../media/atomisp/pci/atomisp2/atomisp_compat_css20.c | 4 ++-- .../media/atomisp/pci/atomisp2/atomisp_internal.h | 2 -- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c index 97093ba..7bf5dcd 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c @@ -112,19 +112,6 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem) } /* - * Free buffer allocated with atomisp_kernel_malloc()/atomisp_kernel_zalloc - * helper - */ -void atomisp_kernel_free(void *ptr) -{ - /* Verify if buffer was allocated by vmalloc() or kmalloc() */ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); -} - -/* * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field. * subdev->priv is set in mrst.c */ @@ -785,7 +772,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe *pipe) struct atomisp_css_params_with_list, list); list_del(>list); atomisp_free_css_parameters(>params); - atomisp_kernel_free(param); + kvfree(param); } } @@ -1132,7 +1119,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, asd->params.dvs_6axis = NULL; atomisp_free_css_parameters( >frame_params[vb->i]->params); - atomisp_kernel_free(pipe->frame_params[vb->i]); + kvfree(pipe->frame_params[vb->i]); pipe->frame_params[vb->i] = NULL; } @@ -4375,7 +4362,7 @@ int atomisp_set_parameters(struct video_device *vdev, if (css_param) atomisp_free_css_parameters(css_param); if (param) - atomisp_kernel_free(param); + kvfree(param); return ret; } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h index 8e6d9df..1ccd911 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h @@ -80,7 +80,6 @@ static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address) */ void *atomisp_kernel_malloc(size_t bytes); void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem); -void atomisp_kernel_free(void *ptr); /* * Interrupt functions diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c index b830b24..2b6d7bb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c @@ -1676,7 +1676,7 @@ int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd) stream_info.metadata_info.size); if (!asd->params.metadata_user[i]) { while (--i >= 0) { - atomisp_kernel_free(asd->params.metadata_user[i]); + kvfree(asd->params.metadata_user[i]); asd->params.metadata_user[i] = NULL; } return -ENOMEM; @@ -1692,7 +1692,7 @@ void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd) for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) { if (asd->params.metadata_user[i]) { - atomisp_kernel_free(asd->params.metadata_user[i]); + kvfree(asd->params.metadata_user[i]); asd->params.metadata_user[i] = NULL; } } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h index d366713..afced4f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h @@ -312,8 +312,6 @@ extern struct device *at
[PATCH v2] staging: media: atomisp: Use kvfree() instead of kfree()/vfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. The resulting wrapper function has been replaced with direct calls to kvfree(). This change was made with the help of the following Coccinelle semantic patch: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Remove wrapper function .../staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 19 +++ .../staging/media/atomisp/pci/atomisp2/atomisp_cmd.h | 1 - .../media/atomisp/pci/atomisp2/atomisp_compat_css20.c | 4 ++-- .../media/atomisp/pci/atomisp2/atomisp_internal.h | 2 -- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c index 97093ba..7bf5dcd 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c @@ -112,19 +112,6 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem) } /* - * Free buffer allocated with atomisp_kernel_malloc()/atomisp_kernel_zalloc - * helper - */ -void atomisp_kernel_free(void *ptr) -{ - /* Verify if buffer was allocated by vmalloc() or kmalloc() */ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); -} - -/* * get sensor:dis71430/ov2720 related info from v4l2_subdev->priv data field. * subdev->priv is set in mrst.c */ @@ -785,7 +772,7 @@ void atomisp_flush_params_queue(struct atomisp_video_pipe *pipe) struct atomisp_css_params_with_list, list); list_del(>list); atomisp_free_css_parameters(>params); - atomisp_kernel_free(param); + kvfree(param); } } @@ -1132,7 +1119,7 @@ void atomisp_buf_done(struct atomisp_sub_device *asd, int error, asd->params.dvs_6axis = NULL; atomisp_free_css_parameters( >frame_params[vb->i]->params); - atomisp_kernel_free(pipe->frame_params[vb->i]); + kvfree(pipe->frame_params[vb->i]); pipe->frame_params[vb->i] = NULL; } @@ -4375,7 +4362,7 @@ int atomisp_set_parameters(struct video_device *vdev, if (css_param) atomisp_free_css_parameters(css_param); if (param) - atomisp_kernel_free(param); + kvfree(param); return ret; } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h index 8e6d9df..1ccd911 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.h @@ -80,7 +80,6 @@ static inline void __iomem *atomisp_get_io_virt_addr(unsigned int address) */ void *atomisp_kernel_malloc(size_t bytes); void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem); -void atomisp_kernel_free(void *ptr); /* * Interrupt functions diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c index b830b24..2b6d7bb 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_compat_css20.c @@ -1676,7 +1676,7 @@ int atomisp_alloc_metadata_output_buf(struct atomisp_sub_device *asd) stream_info.metadata_info.size); if (!asd->params.metadata_user[i]) { while (--i >= 0) { - atomisp_kernel_free(asd->params.metadata_user[i]); + kvfree(asd->params.metadata_user[i]); asd->params.metadata_user[i] = NULL; } return -ENOMEM; @@ -1692,7 +1692,7 @@ void atomisp_free_metadata_output_buf(struct atomisp_sub_device *asd) for (i = 0; i < ATOMISP_METADATA_TYPE_NUM; i++) { if (asd->params.metadata_user[i]) { - atomisp_kernel_free(asd->params.metadata_user[i]); + kvfree(asd->params.metadata_user[i]); asd->params.metadata_user[i] = NULL; } } diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h index d366713..afced4f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_internal.h @@ -312,8 +312,6 @@ extern struct device *atomisp_dev; extern void *atomisp_k
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
On Sat, Jul 8, 2017 at 4:58 AM, Bernd Petrovitsch <be...@petrovitsch.priv.at> wrote: > On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote: > [...] >> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool >> zero_mem) >> */ >> void atomisp_kernel_free(void *ptr) >> { >> - /* Verify if buffer was allocated by vmalloc() or kmalloc() >> */ >> - if (is_vmalloc_addr(ptr)) >> - vfree(ptr); >> - else >> - kfree(ptr); >> + kvfree(ptr); >> } >> >> /* > > Why not get rid of the trivial wrapper function completely? > Oh yes, i'll send a v2. Amitoj
Re: [PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
On Sat, Jul 8, 2017 at 4:58 AM, Bernd Petrovitsch wrote: > On Fri, 2017-07-07 at 20:41 -0400, Amitoj Kaur Chawla wrote: > [...] >> --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c >> @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool >> zero_mem) >> */ >> void atomisp_kernel_free(void *ptr) >> { >> - /* Verify if buffer was allocated by vmalloc() or kmalloc() >> */ >> - if (is_vmalloc_addr(ptr)) >> - vfree(ptr); >> - else >> - kfree(ptr); >> + kvfree(ptr); >> } >> >> /* > > Why not get rid of the trivial wrapper function completely? > Oh yes, i'll send a v2. Amitoj
[PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. Consequently removed an unnecessary comment. The Coccinelle semantic patch used to make the change is as follows: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); @@ expression a; @@ - if(...) { kfree(a); } - else { vfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c index 97093ba..a156dd424 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem) */ void atomisp_kernel_free(void *ptr) { - /* Verify if buffer was allocated by vmalloc() or kmalloc() */ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); + kvfree(ptr); } /* -- 2.7.4
[PATCH 2/2] staging: media: atomisp2: Replace kfree()/vfree() with kvfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. Consequently removed an unnecessary comment. The Coccinelle semantic patch used to make the change is as follows: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); @@ expression a; @@ - if(...) { kfree(a); } - else { vfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c | 6 +- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c index 97093ba..a156dd424 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_cmd.c @@ -117,11 +117,7 @@ void *atomisp_kernel_zalloc(size_t bytes, bool zero_mem) */ void atomisp_kernel_free(void *ptr) { - /* Verify if buffer was allocated by vmalloc() or kmalloc() */ - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); + kvfree(ptr); } /* -- 2.7.4
[PATCH 1/2] staging: media: atomisp2: css2400: Replace kfree()/vfree() with kvfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. The Coccinelle semantic patch used to make the change is as follows: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); @@ expression a; @@ - if(...) { kfree(a); } - else { vfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c index 73c7658..1b0708f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c @@ -2029,10 +2029,7 @@ void *sh_css_calloc(size_t N, size_t size) void sh_css_free(void *ptr) { - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); + kvfree(ptr); } /* For Acceleration API: Flush FW (shared buffer pointer) arguments */ -- 2.7.4
[PATCH 1/2] staging: media: atomisp2: css2400: Replace kfree()/vfree() with kvfree()
Conditionally calling kfree()/vfree() can be replaced by a call to kvfree() which handles both kmalloced memory and vmalloced memory. The Coccinelle semantic patch used to make the change is as follows: // @@ expression a; @@ - if(...) { vfree(a); } - else { kfree(a); } + kvfree(a); @@ expression a; @@ - if(...) { kfree(a); } - else { vfree(a); } + kvfree(a); // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c index 73c7658..1b0708f 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/css2400/sh_css.c @@ -2029,10 +2029,7 @@ void *sh_css_calloc(size_t N, size_t size) void sh_css_free(void *ptr) { - if (is_vmalloc_addr(ptr)) - vfree(ptr); - else - kfree(ptr); + kvfree(ptr); } /* For Acceleration API: Flush FW (shared buffer pointer) arguments */ -- 2.7.4
[PATCH] staging: comedi: Use offset_in_page macro
Use offset_in_page macro instead of (var & ~PAGE_MASK) The Coccinelle semantic patch used to make this change is as follows: // @@ unsigned long p; @@ - p & ~PAGE_MASK + offset_in_page(p) // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/comedi/comedi_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 8e9b30b..b455ff6 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -165,7 +165,7 @@ int comedi_buf_map_put(struct comedi_buf_map *bm) int comedi_buf_map_access(struct comedi_buf_map *bm, unsigned long offset, void *buf, int len, int write) { - unsigned int pgoff = offset & ~PAGE_MASK; + unsigned int pgoff = offset_in_page(offset); unsigned long pg = offset >> PAGE_SHIFT; int done = 0; -- 2.7.4
[PATCH] staging: comedi: Use offset_in_page macro
Use offset_in_page macro instead of (var & ~PAGE_MASK) The Coccinelle semantic patch used to make this change is as follows: // @@ unsigned long p; @@ - p & ~PAGE_MASK + offset_in_page(p) // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/comedi/comedi_buf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 8e9b30b..b455ff6 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -165,7 +165,7 @@ int comedi_buf_map_put(struct comedi_buf_map *bm) int comedi_buf_map_access(struct comedi_buf_map *bm, unsigned long offset, void *buf, int len, int write) { - unsigned int pgoff = offset & ~PAGE_MASK; + unsigned int pgoff = offset_in_page(offset); unsigned long pg = offset >> PAGE_SHIFT; int done = 0; -- 2.7.4
[PATCH] staging: media: atomisp: Remove unnecessary return statement in void function
Return statement at the end of a void function is useless. The Coccinelle semantic patch used to make this change is as follows: // @@ identifier f; expression e; @@ void f(...) { <... - return e; ...> } // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 5729539..22c0342 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -636,7 +636,7 @@ void hmm_vunmap(ia_css_ptr virt) return; } - return hmm_bo_vunmap(bo); + hmm_bo_vunmap(bo); } int hmm_pool_register(unsigned int pool_size, -- 2.7.4
[PATCH] staging: media: atomisp: Remove unnecessary return statement in void function
Return statement at the end of a void function is useless. The Coccinelle semantic patch used to make this change is as follows: // @@ identifier f; expression e; @@ void f(...) { <... - return e; ...> } // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c index 5729539..22c0342 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/hmm/hmm.c @@ -636,7 +636,7 @@ void hmm_vunmap(ia_css_ptr virt) return; } - return hmm_bo_vunmap(bo); + hmm_bo_vunmap(bo); } int hmm_pool_register(unsigned int pool_size, -- 2.7.4
[PATCH] staging: rtl8723bs: Remove unnecessary cast in kfree
Remove unnecassary casts in the argument to kfree. Found using Coccinelle. The semantic patch used to find this is as follows: // @@ type T; expression *f; @@ - kfree((T *)(f)); + kfree(f); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 9167413..79d8383 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -766,7 +766,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, exit: - kfree((u8 *)pwep); + kfree(pwep); return ret; } @@ -2500,7 +2500,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, ret = wpa_set_encryption(dev, param, param_len); exit: - kfree((u8 *)param); + kfree(param); return ret; } @@ -3767,7 +3767,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (copy_from_user(param, p->pointer, p->length)) { - kfree((u8 *)param); + kfree(param); ret = -EFAULT; goto out; } @@ -3801,7 +3801,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (ret == 0 && copy_to_user(p->pointer, param, p->length)) ret = -EFAULT; - kfree((u8 *)param); + kfree(param); out: @@ -4130,7 +4130,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, } exit: - kfree((u8 *)pwep); + kfree(pwep); return ret; @@ -4713,7 +4713,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) if (copy_from_user(param, p->pointer, p->length)) { - kfree((u8 *)param); + kfree(param); ret = -EFAULT; goto out; } @@ -4817,7 +4817,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) ret = -EFAULT; - kfree((u8 *)param); + kfree(param); out: -- 2.7.4
[PATCH] staging: rtl8723bs: Remove unnecessary cast in kfree
Remove unnecassary casts in the argument to kfree. Found using Coccinelle. The semantic patch used to find this is as follows: // @@ type T; expression *f; @@ - kfree((T *)(f)); + kfree(f); // Signed-off-by: Amitoj Kaur Chawla --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 9167413..79d8383 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -766,7 +766,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, exit: - kfree((u8 *)pwep); + kfree(pwep); return ret; } @@ -2500,7 +2500,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, ret = wpa_set_encryption(dev, param, param_len); exit: - kfree((u8 *)param); + kfree(param); return ret; } @@ -3767,7 +3767,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (copy_from_user(param, p->pointer, p->length)) { - kfree((u8 *)param); + kfree(param); ret = -EFAULT; goto out; } @@ -3801,7 +3801,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) if (ret == 0 && copy_to_user(p->pointer, param, p->length)) ret = -EFAULT; - kfree((u8 *)param); + kfree(param); out: @@ -4130,7 +4130,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, } exit: - kfree((u8 *)pwep); + kfree(pwep); return ret; @@ -4713,7 +4713,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) if (copy_from_user(param, p->pointer, p->length)) { - kfree((u8 *)param); + kfree(param); ret = -EFAULT; goto out; } @@ -4817,7 +4817,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) ret = -EFAULT; - kfree((u8 *)param); + kfree(param); out: -- 2.7.4
Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
On Mon, Aug 1, 2016 at 4:53 PM, SF Markus Elfringwrote: >> +@vz1 depends on patch && !context && !org && !report@ >> +type T; >> +T *d; >> +statement S; >> +@@ >> + >> +d = >> +-vmalloc >> ++vzalloc >> + (...); >> +if (!d) S >> +- memset(d, 0, sizeof(T)); >> + >> +@vz2 depends on patch && !context && !org && !report@ >> +expression d; >> +statement S; >> +@@ >> + >> +d = >> +-vmalloc >> ++vzalloc >> + (...); >> +if (!d) S >> +- memset(d, 0, sizeof(*d)); > > I suggest to take another look at a few implementation details. > > 1. Would it make sense to merge such SmPL rules into one >so that code duplication could be reduced a bit >in such a script? > > 2. How do you think about to extend the shown check list >with the function "kvm_kvzalloc"? > Hi Markus, kvm_kvzalloc function doesn't fit the same pattern as the other functions in this semantic patch, and is kvm specific, so the semantic patch looks fine as is. Thanks, Amitoj > 3. Do you want to maintain a growing (?) function name list manually? > > Regards, > Markus
Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
On Mon, Aug 1, 2016 at 4:53 PM, SF Markus Elfring wrote: >> +@vz1 depends on patch && !context && !org && !report@ >> +type T; >> +T *d; >> +statement S; >> +@@ >> + >> +d = >> +-vmalloc >> ++vzalloc >> + (...); >> +if (!d) S >> +- memset(d, 0, sizeof(T)); >> + >> +@vz2 depends on patch && !context && !org && !report@ >> +expression d; >> +statement S; >> +@@ >> + >> +d = >> +-vmalloc >> ++vzalloc >> + (...); >> +if (!d) S >> +- memset(d, 0, sizeof(*d)); > > I suggest to take another look at a few implementation details. > > 1. Would it make sense to merge such SmPL rules into one >so that code duplication could be reduced a bit >in such a script? > > 2. How do you think about to extend the shown check list >with the function "kvm_kvzalloc"? > Hi Markus, kvm_kvzalloc function doesn't fit the same pattern as the other functions in this semantic patch, and is kvm specific, so the semantic patch looks fine as is. Thanks, Amitoj > 3. Do you want to maintain a growing (?) function name list manually? > > Regards, > Markus
[PATCH v2] drm/tegra: dpaux: Modify error handling
devm_pinctrl_register returns an ERR_PTR in case of error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = devm_pinctrl_register(...); if( -!e +IS_ERR(e) ) { <+... return - ... + PTR_ERR(e) ; ...+> } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Correct typo drivers/gpu/drm/tegra/dpaux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 059f409..2fde44c 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -539,9 +539,9 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->desc.owner = THIS_MODULE; dpaux->pinctrl = devm_pinctrl_register(>dev, >desc, dpaux); - if (!dpaux->pinctrl) { + if (IS_ERR(dpaux->pinctrl)) { dev_err(>dev, "failed to register pincontrol\n"); - return -ENODEV; + return PTR_ERR(dpaux->pinctrl); } #endif /* enable and clear all interrupts */ -- 1.9.1
[PATCH v2] drm/tegra: dpaux: Modify error handling
devm_pinctrl_register returns an ERR_PTR in case of error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = devm_pinctrl_register(...); if( -!e +IS_ERR(e) ) { <+... return - ... + PTR_ERR(e) ; ...+> } Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Correct typo drivers/gpu/drm/tegra/dpaux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 059f409..2fde44c 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -539,9 +539,9 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->desc.owner = THIS_MODULE; dpaux->pinctrl = devm_pinctrl_register(>dev, >desc, dpaux); - if (!dpaux->pinctrl) { + if (IS_ERR(dpaux->pinctrl)) { dev_err(>dev, "failed to register pincontrol\n"); - return -ENODEV; + return PTR_ERR(dpaux->pinctrl); } #endif /* enable and clear all interrupts */ -- 1.9.1
[PATCH] drm/nouveau/tegra: Modify error handling
iommu_domain_alloc returns NULL on error so replace an incorrect IS_ERR check with a NULL check. The Coccinelle semantic patch used to find this issue is as follows: @@ expression e; statement S; @@ *e = iommu_domain_alloc(...); if (IS_ERR(e)) S Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c index 939682f..ffd8def 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -102,7 +102,7 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) if (iommu_present(_bus_type)) { tdev->iommu.domain = iommu_domain_alloc(_bus_type); - if (IS_ERR(tdev->iommu.domain)) + if (!tdev->iommu.domain) goto error; /* -- 1.9.1
[PATCH] drm/nouveau/tegra: Modify error handling
iommu_domain_alloc returns NULL on error so replace an incorrect IS_ERR check with a NULL check. The Coccinelle semantic patch used to find this issue is as follows: @@ expression e; statement S; @@ *e = iommu_domain_alloc(...); if (IS_ERR(e)) S Signed-off-by: Amitoj Kaur Chawla --- drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c index 939682f..ffd8def 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/device/tegra.c @@ -102,7 +102,7 @@ nvkm_device_tegra_probe_iommu(struct nvkm_device_tegra *tdev) if (iommu_present(_bus_type)) { tdev->iommu.domain = iommu_domain_alloc(_bus_type); - if (IS_ERR(tdev->iommu.domain)) + if (!tdev->iommu.domain) goto error; /* -- 1.9.1
[PATCH] drm/tegra: dpaux: Modify error handling
devm_pinctrl_register returns an ERR_PTR in case of error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = devm_pinxtrl_register(...); if( -!e +IS_ERR(e) ) { <+... return - ... + PTR_ERR(e) ; ...+> } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/gpu/drm/tegra/dpaux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 059f409..2fde44c 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -539,9 +539,9 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->desc.owner = THIS_MODULE; dpaux->pinctrl = devm_pinctrl_register(>dev, >desc, dpaux); - if (!dpaux->pinctrl) { + if (IS_ERR(dpaux->pinctrl)) { dev_err(>dev, "failed to register pincontrol\n"); - return -ENODEV; + return PTR_ERR(dpaux->pinctrl); } #endif /* enable and clear all interrupts */ -- 1.9.1
[PATCH] drm/tegra: dpaux: Modify error handling
devm_pinctrl_register returns an ERR_PTR in case of error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = devm_pinxtrl_register(...); if( -!e +IS_ERR(e) ) { <+... return - ... + PTR_ERR(e) ; ...+> } Signed-off-by: Amitoj Kaur Chawla --- drivers/gpu/drm/tegra/dpaux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c index 059f409..2fde44c 100644 --- a/drivers/gpu/drm/tegra/dpaux.c +++ b/drivers/gpu/drm/tegra/dpaux.c @@ -539,9 +539,9 @@ static int tegra_dpaux_probe(struct platform_device *pdev) dpaux->desc.owner = THIS_MODULE; dpaux->pinctrl = devm_pinctrl_register(>dev, >desc, dpaux); - if (!dpaux->pinctrl) { + if (IS_ERR(dpaux->pinctrl)) { dev_err(>dev, "failed to register pincontrol\n"); - return -ENODEV; + return PTR_ERR(dpaux->pinctrl); } #endif /* enable and clear all interrupts */ -- 1.9.1
[PATCH] MIPS: ath79: Modify error handling
clk_register_fixed_factor returns an ERR_PTR in case of an error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to find this issue is as follows: @@ expression e; statement S; @@ *e = clk_register_fixed_factor(...); if (!e) S Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- arch/mips/ath79/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 2e73784..cc3a1e3 100644 --- a/arch/mips/ath79/clock.c +++ b/arch/mips/ath79/clock.c @@ -96,7 +96,7 @@ static struct clk * __init ath79_reg_ffclk(const char *name, struct clk *clk; clk = clk_register_fixed_factor(NULL, name, parent_name, 0, mult, div); - if (!clk) + if (IS_ERR(clk)) panic("failed to allocate %s clock structure", name); return clk; -- 1.9.1
[PATCH] MIPS: ath79: Modify error handling
clk_register_fixed_factor returns an ERR_PTR in case of an error and should have an IS_ERR check instead of a null check. The Coccinelle semantic patch used to find this issue is as follows: @@ expression e; statement S; @@ *e = clk_register_fixed_factor(...); if (!e) S Signed-off-by: Amitoj Kaur Chawla --- arch/mips/ath79/clock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/ath79/clock.c b/arch/mips/ath79/clock.c index 2e73784..cc3a1e3 100644 --- a/arch/mips/ath79/clock.c +++ b/arch/mips/ath79/clock.c @@ -96,7 +96,7 @@ static struct clk * __init ath79_reg_ffclk(const char *name, struct clk *clk; clk = clk_register_fixed_factor(NULL, name, parent_name, 0, mult, div); - if (!clk) + if (IS_ERR(clk)) panic("failed to allocate %s clock structure", name); return clk; -- 1.9.1
[PATCH] sunrpc: Remove unnecessary variable
The variable `err` is not used anywhere and just returns the predefined value `0` at the end of the function. Hence, remove the variable and return 0 explicitly. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- net/sunrpc/clnt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b7f2104..0a775fa 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -184,7 +184,6 @@ static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, struct super_block *sb) { struct dentry *dentry; - int err = 0; switch (event) { case RPC_PIPEFS_MOUNT: @@ -201,7 +200,7 @@ static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, printk(KERN_ERR "%s: unknown event: %ld\n", __func__, event); return -ENOTSUPP; } - return err; + return 0; } static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event, -- 1.9.1
[PATCH] sunrpc: Remove unnecessary variable
The variable `err` is not used anywhere and just returns the predefined value `0` at the end of the function. Hence, remove the variable and return 0 explicitly. Signed-off-by: Amitoj Kaur Chawla --- net/sunrpc/clnt.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b7f2104..0a775fa 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -184,7 +184,6 @@ static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, struct super_block *sb) { struct dentry *dentry; - int err = 0; switch (event) { case RPC_PIPEFS_MOUNT: @@ -201,7 +200,7 @@ static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event, printk(KERN_ERR "%s: unknown event: %ld\n", __func__, event); return -ENOTSUPP; } - return err; + return 0; } static int __rpc_pipefs_event(struct rpc_clnt *clnt, unsigned long event, -- 1.9.1
[PATCH v3] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
This script detects cases which have incorrect error handling for devm_ioremap_resource function, employing a NULL test instead of an IS_ERR() test. Acked-by: Julia Lawall <julia.law...@lip6.fr> Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Changed script to correct error handling instead of just detecting cases of incorrect error handling Changes in v3: -Reverted to original script in v1 to ensure no error in modifying inconsistent paths. .../null/devm_ioremap_resource_test.cocci | 38 ++ 1 file changed, 38 insertions(+) create mode 100644 scripts/coccinelle/null/devm_ioremap_resource_test.cocci diff --git a/scripts/coccinelle/null/devm_ioremap_resource_test.cocci b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci new file mode 100644 index 000..734dbd3 --- /dev/null +++ b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci @@ -0,0 +1,38 @@ +/// Correct error handling for devm_ioremap_resource +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla +// Keywords: devm,devm_ioremap_resource + +virtual context +virtual org +virtual report + +// + +@err depends on context || org || report@ +statement S; +expression e; +position j0; +@@ + + e = devm_ioremap_resource(...); +* if (!e@j0) S +// + +@script:python err_org depends on org@ +j0 << err.j0; +@@ + +msg = "Incorrect error handling." +coccilib.org.print_todo(j0[0], msg) + +// + +@script:python err_report depends on report@ +j0 << err.j0; +@@ + +msg = "Incorrect error handling." +coccilib.report.print_report(j0[0], msg) + -- 1.9.1
[PATCH v3] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
This script detects cases which have incorrect error handling for devm_ioremap_resource function, employing a NULL test instead of an IS_ERR() test. Acked-by: Julia Lawall Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Changed script to correct error handling instead of just detecting cases of incorrect error handling Changes in v3: -Reverted to original script in v1 to ensure no error in modifying inconsistent paths. .../null/devm_ioremap_resource_test.cocci | 38 ++ 1 file changed, 38 insertions(+) create mode 100644 scripts/coccinelle/null/devm_ioremap_resource_test.cocci diff --git a/scripts/coccinelle/null/devm_ioremap_resource_test.cocci b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci new file mode 100644 index 000..734dbd3 --- /dev/null +++ b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci @@ -0,0 +1,38 @@ +/// Correct error handling for devm_ioremap_resource +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla +// Keywords: devm,devm_ioremap_resource + +virtual context +virtual org +virtual report + +// + +@err depends on context || org || report@ +statement S; +expression e; +position j0; +@@ + + e = devm_ioremap_resource(...); +* if (!e@j0) S +// + +@script:python err_org depends on org@ +j0 << err.j0; +@@ + +msg = "Incorrect error handling." +coccilib.org.print_todo(j0[0], msg) + +// + +@script:python err_report depends on report@ +j0 << err.j0; +@@ + +msg = "Incorrect error handling." +coccilib.report.print_report(j0[0], msg) + -- 1.9.1
[PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm
To indicate an error, debugfs_create_file can return an ERR_PTR for !CONFIG_DEBUG_FS and NULL otherwise, so in case the result is dereferenced there should be a previous IS_ERR and a NULL check. The Coccinelle semantic patch used to find the issue is as follows: @@ expression e; identifier f; @@ * e = debugfs_create_file(...); ... when != e == NULL e->f Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8a1752f..9ff70a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1198,6 +1198,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) adev, _ttm_vram_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->mc.mc_vram_size); adev->mman.vram = ent; @@ -1205,6 +1207,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) adev, _ttm_gtt_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->mc.gtt_size); adev->mman.gtt = ent; -- 1.9.1
[PATCH] drm/amdgpu: Modify error handling in amdgpu_ttm
To indicate an error, debugfs_create_file can return an ERR_PTR for !CONFIG_DEBUG_FS and NULL otherwise, so in case the result is dereferenced there should be a previous IS_ERR and a NULL check. The Coccinelle semantic patch used to find the issue is as follows: @@ expression e; identifier f; @@ * e = debugfs_create_file(...); ... when != e == NULL e->f Signed-off-by: Amitoj Kaur Chawla --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 8a1752f..9ff70a7 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1198,6 +1198,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) adev, _ttm_vram_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->mc.mc_vram_size); adev->mman.vram = ent; @@ -1205,6 +1207,8 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) adev, _ttm_gtt_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->mc.gtt_size); adev->mman.gtt = ent; -- 1.9.1
[PATCH] drm/amdgpu: Modify error handling
To indicate an error, debugfs_create_file can return an ERR_PTR for !CONFIG_DEBUG_FS and NULL otherwise, so in case the result is dereferenced there should be a previous IS_ERR and a NULL check. The Coccinelle semantic patch used to find the issue is as follows: @@ expression e; identifier f; @@ * e = debugfs_create_file(...); ... when != e == NULL e->f Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 6553146..4c1a2bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2143,6 +2143,8 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) adev, _debugfs_regs_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->rmmio_size); adev->debugfs_regs = ent; -- 1.9.1
[PATCH] drm/amdgpu: Modify error handling
To indicate an error, debugfs_create_file can return an ERR_PTR for !CONFIG_DEBUG_FS and NULL otherwise, so in case the result is dereferenced there should be a previous IS_ERR and a NULL check. The Coccinelle semantic patch used to find the issue is as follows: @@ expression e; identifier f; @@ * e = debugfs_create_file(...); ... when != e == NULL e->f Signed-off-by: Amitoj Kaur Chawla --- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 6553146..4c1a2bc 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -2143,6 +2143,8 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) adev, _debugfs_regs_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->rmmio_size); adev->debugfs_regs = ent; -- 1.9.1
[PATCH] iommu/exynos: Modify error handling
of_platform_device_create returns NULL on error so an IS_ERR test is incorrect here and a NULL check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = of_platform_device_create(...); if( -IS_ERR(e) +!e ) { <+... return - PTR_ERR(e) + -ENODEV ; ...+> } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/iommu/exynos-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 97c41b8..2888bbf 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1242,8 +1242,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np) exynos_iommu_init(); pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); + if (!pdev) + return -ENODEV; of_iommu_set_ops(np, _iommu_ops); return 0; -- 1.9.1
[PATCH] iommu/exynos: Modify error handling
of_platform_device_create returns NULL on error so an IS_ERR test is incorrect here and a NULL check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = of_platform_device_create(...); if( -IS_ERR(e) +!e ) { <+... return - PTR_ERR(e) + -ENODEV ; ...+> } Signed-off-by: Amitoj Kaur Chawla --- drivers/iommu/exynos-iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index 97c41b8..2888bbf 100644 --- a/drivers/iommu/exynos-iommu.c +++ b/drivers/iommu/exynos-iommu.c @@ -1242,8 +1242,8 @@ static int __init exynos_iommu_of_setup(struct device_node *np) exynos_iommu_init(); pdev = of_platform_device_create(np, NULL, platform_bus_type.dev_root); - if (IS_ERR(pdev)) - return PTR_ERR(pdev); + if (!pdev) + return -ENODEV; of_iommu_set_ops(np, _iommu_ops); return 0; -- 1.9.1
[PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
This script finds instances of allocate and memset which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> Acked-by: Julia Lawall <julia.law...@lip6.fr> --- Changes in v2: -Modified commit message and subject Changes in v3: -Modified comment scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memset. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_
[PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
This script finds instances of allocate and memset which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla Acked-by: Julia Lawall --- Changes in v2: -Modified commit message and subject Changes in v3: -Modified comment scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memset. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_context depends on !patch && (context || org || report)@ +statemen
[PATCH] i2c: Modify error handling
devm_gpiod_get returns an ERR_PTR on error so a null check is incorrect and an IS_ERR check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; statement S; @@ e = devm_gpiod_get(...); if( - !e + IS_ERR(e) ) { ... - return ...; + return PTR_ERR(e); } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/media/i2c/adp1653.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 7e9cbf7..54b355e 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -466,9 +466,9 @@ static int adp1653_of_init(struct i2c_client *client, of_node_put(child); pd->enable_gpio = devm_gpiod_get(>dev, "enable", GPIOD_OUT_LOW); - if (!pd->enable_gpio) { + if (IS_ERR(pd->enable_gpio)) { dev_err(>dev, "Error getting GPIO\n"); - return -EINVAL; + return PTR_ERR(pd->enable_gpio); } return 0; -- 1.9.1
[PATCH] i2c: Modify error handling
devm_gpiod_get returns an ERR_PTR on error so a null check is incorrect and an IS_ERR check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; statement S; @@ e = devm_gpiod_get(...); if( - !e + IS_ERR(e) ) { ... - return ...; + return PTR_ERR(e); } Signed-off-by: Amitoj Kaur Chawla --- drivers/media/i2c/adp1653.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/adp1653.c b/drivers/media/i2c/adp1653.c index 7e9cbf7..54b355e 100644 --- a/drivers/media/i2c/adp1653.c +++ b/drivers/media/i2c/adp1653.c @@ -466,9 +466,9 @@ static int adp1653_of_init(struct i2c_client *client, of_node_put(child); pd->enable_gpio = devm_gpiod_get(>dev, "enable", GPIOD_OUT_LOW); - if (!pd->enable_gpio) { + if (IS_ERR(pd->enable_gpio)) { dev_err(>dev, "Error getting GPIO\n"); - return -EINVAL; + return PTR_ERR(pd->enable_gpio); } return 0; -- 1.9.1
[PATCH] s390/pci: Remove unnecessary if condition
Remove unnecessary error handling because the only failure value that can be returned is NULL and so the test can never be true. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = debugfs_create_file(...); - if(IS_ERR(e)) { e = NULL; } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- arch/s390/pci/pci_debug.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c index 4129b0a..8a25b04 100644 --- a/arch/s390/pci/pci_debug.c +++ b/arch/s390/pci/pci_debug.c @@ -139,8 +139,6 @@ void zpci_debug_init_device(struct zpci_dev *zdev) S_IFREG | S_IRUGO | S_IWUSR, zdev->debugfs_dev, zdev, _pci_perf_fops); - if (IS_ERR(zdev->debugfs_perf)) - zdev->debugfs_perf = NULL; } void zpci_debug_exit_device(struct zpci_dev *zdev) -- 1.9.1
[PATCH] s390/pci: Remove unnecessary if condition
Remove unnecessary error handling because the only failure value that can be returned is NULL and so the test can never be true. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = debugfs_create_file(...); - if(IS_ERR(e)) { e = NULL; } Signed-off-by: Amitoj Kaur Chawla --- arch/s390/pci/pci_debug.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/s390/pci/pci_debug.c b/arch/s390/pci/pci_debug.c index 4129b0a..8a25b04 100644 --- a/arch/s390/pci/pci_debug.c +++ b/arch/s390/pci/pci_debug.c @@ -139,8 +139,6 @@ void zpci_debug_init_device(struct zpci_dev *zdev) S_IFREG | S_IRUGO | S_IWUSR, zdev->debugfs_dev, zdev, _pci_perf_fops); - if (IS_ERR(zdev->debugfs_perf)) - zdev->debugfs_perf = NULL; } void zpci_debug_exit_device(struct zpci_dev *zdev) -- 1.9.1
[PATCH] MIPS: Modify error handling
debugfs_create_file returns NULL on error so an IS_ERR test is incorrect here and a NULL check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = debugfs_create_file(...); if( -IS_ERR(e) +!e ) { <+... return - PTR_ERR(e) + -ENOMEM ; ...+> } Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- arch/mips/mm/sc-debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c index 5eefe32..01f1154 100644 --- a/arch/mips/mm/sc-debugfs.c +++ b/arch/mips/mm/sc-debugfs.c @@ -73,8 +73,8 @@ static int __init sc_debugfs_init(void) file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL, _prefetch_fops); - if (IS_ERR(file)) - return PTR_ERR(file); + if (!file) + return -ENOMEM; return 0; } -- 1.9.1
[PATCH] MIPS: Modify error handling
debugfs_create_file returns NULL on error so an IS_ERR test is incorrect here and a NULL check is required. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ e = debugfs_create_file(...); if( -IS_ERR(e) +!e ) { <+... return - PTR_ERR(e) + -ENOMEM ; ...+> } Signed-off-by: Amitoj Kaur Chawla --- arch/mips/mm/sc-debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/mm/sc-debugfs.c b/arch/mips/mm/sc-debugfs.c index 5eefe32..01f1154 100644 --- a/arch/mips/mm/sc-debugfs.c +++ b/arch/mips/mm/sc-debugfs.c @@ -73,8 +73,8 @@ static int __init sc_debugfs_init(void) file = debugfs_create_file("prefetch", S_IRUGO | S_IWUSR, dir, NULL, _prefetch_fops); - if (IS_ERR(file)) - return PTR_ERR(file); + if (!file) + return -ENOMEM; return 0; } -- 1.9.1
[PATCH v2] Coccinelle: Script to replace allocate and memset with zalloc functions
This script finds instances of allocate and memset which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Modified commit message and subject scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memcpy. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_context depends on !patch && (context || org || report)@ +statement S; +expression d; +position
[PATCH v2] Coccinelle: Script to replace allocate and memset with zalloc functions
This script finds instances of allocate and memset which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Modified commit message and subject scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memcpy. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_context depends on !patch && (context || org || report)@ +statement S; +expression d; +position j0; +@@ + +d@j0 = +*
[PATCH v2] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
This script detects cases which have incorrect error handling for devm_ioremap_resource function, employing a NULL test instead of an IS_ERR() test. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Changed script to correct error handling instead of just detecting cases of incorrect error handling .../null/devm_ioremap_resource_test.cocci | 66 ++ 1 file changed, 66 insertions(+) create mode 100644 scripts/coccinelle/null/devm_ioremap_resource_test.cocci diff --git a/scripts/coccinelle/null/devm_ioremap_resource_test.cocci b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci new file mode 100644 index 000..671970a --- /dev/null +++ b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci @@ -0,0 +1,66 @@ +/// Correct error handling for devm_ioremap_resource +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla +// Keywords: devm, devm_ioremap_resource + +virtual patch +virtual context +virtual org +virtual report + +@err depends on patch && !context && !org && !report@ +expression e,e1; +@@ + + e = devm_ioremap_resource(...); + if( +-e == NULL ++IS_ERR(e) +) +{ + ... + return +- e1 ++ PTR_ERR(e) + ; + } + +// + +@err_context depends on !patch && (context || org || report)@ +expression e, e1; +position j0, j1; +@@ + + e@j0 = devm_ioremap_resource(...); + if( +* e == NULL +) +{ + ... + return +* e1@j1 + ; + } + +// + +@script:python err_org depends on org@ +j0 << err_context.j0; +j1 << err_context.j1; +@@ + +msg = "Incorrect error handling." +coccilib.org.print_todo(j0[0], msg) +coccilib.org.print_link(j1[0], "") + +// + +@script:python err_report depends on report@ +j0 << err_context.j0; +j1 << err_context.j1; +@@ + +msg = "Incorrect error handling around line %s." % (j1[0].line) +coccilib.report.print_report(j0[0], msg) -- 1.9.1
[PATCH v2] Coccinelle: Script to replace NULL test with IS_ERR test for devm_ioremap_resource
This script detects cases which have incorrect error handling for devm_ioremap_resource function, employing a NULL test instead of an IS_ERR() test. Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Changed script to correct error handling instead of just detecting cases of incorrect error handling .../null/devm_ioremap_resource_test.cocci | 66 ++ 1 file changed, 66 insertions(+) create mode 100644 scripts/coccinelle/null/devm_ioremap_resource_test.cocci diff --git a/scripts/coccinelle/null/devm_ioremap_resource_test.cocci b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci new file mode 100644 index 000..671970a --- /dev/null +++ b/scripts/coccinelle/null/devm_ioremap_resource_test.cocci @@ -0,0 +1,66 @@ +/// Correct error handling for devm_ioremap_resource +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla +// Keywords: devm, devm_ioremap_resource + +virtual patch +virtual context +virtual org +virtual report + +@err depends on patch && !context && !org && !report@ +expression e,e1; +@@ + + e = devm_ioremap_resource(...); + if( +-e == NULL ++IS_ERR(e) +) +{ + ... + return +- e1 ++ PTR_ERR(e) + ; + } + +// + +@err_context depends on !patch && (context || org || report)@ +expression e, e1; +position j0, j1; +@@ + + e@j0 = devm_ioremap_resource(...); + if( +* e == NULL +) +{ + ... + return +* e1@j1 + ; + } + +// + +@script:python err_org depends on org@ +j0 << err_context.j0; +j1 << err_context.j1; +@@ + +msg = "Incorrect error handling." +coccilib.org.print_todo(j0[0], msg) +coccilib.org.print_link(j1[0], "") + +// + +@script:python err_report depends on report@ +j0 << err_context.j0; +j1 << err_context.j1; +@@ + +msg = "Incorrect error handling around line %s." % (j1[0].line) +coccilib.report.print_report(j0[0], msg) -- 1.9.1
[PATCH] Coccinelle: Script to replace allocate and memcpy with zalloc functions
This script finds instances of allocate and memcpy which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memcpy. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_context depends on !patch && (context || org || report)@ +statement S; +expression d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc +
[PATCH] Coccinelle: Script to replace allocate and memcpy with zalloc functions
This script finds instances of allocate and memcpy which can be replaced with a direct call to zalloc equivalent of a function. Signed-off-by: Amitoj Kaur Chawla --- scripts/coccinelle/api/zalloc.cocci | 556 1 file changed, 556 insertions(+) create mode 100644 scripts/coccinelle/api/zalloc.cocci diff --git a/scripts/coccinelle/api/zalloc.cocci b/scripts/coccinelle/api/zalloc.cocci new file mode 100644 index 000..4f94e43 --- /dev/null +++ b/scripts/coccinelle/api/zalloc.cocci @@ -0,0 +1,556 @@ +/// Prefer zalloc functions instead of using allocate and memcpy. +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@dma1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_pool_alloc ++dma_pool_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vz1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vz2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc ++vzalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@vzn1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@vzn2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-vmalloc_node ++vzalloc_node + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@pci1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@pci2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-pci_alloc_consistent ++pci_zalloc_consistent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@kmem1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@kmem2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-kmem_cache_alloc ++kmem_cache_zalloc + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@dma3 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@dma4 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-dma_alloc_coherent ++dma_zalloc_coherent + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); +@acpi1 depends on patch && !context && !org && !report@ +type T; +T *d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(T)); + +@acpi2 depends on patch && !context && !org && !report@ +expression d; +statement S; +@@ + +d = +-acpi_os_allocate ++acpi_os_allocate_zeroed + (...); +if (!d) S +- memset(d, 0, sizeof(*d)); + +// + +@dma1_context depends on !patch && (context || org || report)@ +type T; +statement S; +T *d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +if (!d) S +*memset(d, 0, sizeof(T)); + +@dma2_context depends on !patch && (context || org || report)@ +statement S; +expression d; +position j0; +@@ + +d@j0 = +* dma_pool_alloc + (...); +
[PATCH] clocksource/drivers/timer-sp804: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/clocksource/timer-sp804.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index 5f45b9a..8d2d9a6 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -57,8 +57,7 @@ static long __init sp804_get_clock_rate(struct clk *clk) rate = clk_get_rate(clk); if (rate < 0) { pr_err("sp804: clock failed to get rate: %ld\n", rate); - clk_disable(clk); - clk_unprepare(clk); + clk_disable_unprepare(clk); clk_put(clk); } -- 1.9.1
[PATCH] clocksource/drivers/timer-sp804: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla --- drivers/clocksource/timer-sp804.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index 5f45b9a..8d2d9a6 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -57,8 +57,7 @@ static long __init sp804_get_clock_rate(struct clk *clk) rate = clk_get_rate(clk); if (rate < 0) { pr_err("sp804: clock failed to get rate: %ld\n", rate); - clk_disable(clk); - clk_unprepare(clk); + clk_disable_unprepare(clk); clk_put(clk); } -- 1.9.1
[PATCH] drm: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index fca97d3..8378b2c 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -229,8 +229,7 @@ static int fsl_dcu_drm_pm_suspend(struct device *dev) drm_kms_helper_poll_disable(fsl_dev->drm); regcache_cache_only(fsl_dev->regmap, true); regcache_mark_dirty(fsl_dev->regmap); - clk_disable(fsl_dev->clk); - clk_unprepare(fsl_dev->clk); + clk_disable_unprepare(fsl_dev->clk); return 0; } -- 1.9.1
[PATCH] drm: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla --- drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c index fca97d3..8378b2c 100644 --- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c +++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_drv.c @@ -229,8 +229,7 @@ static int fsl_dcu_drm_pm_suspend(struct device *dev) drm_kms_helper_poll_disable(fsl_dev->drm); regcache_cache_only(fsl_dev->regmap, true); regcache_mark_dirty(fsl_dev->regmap); - clk_disable(fsl_dev->clk); - clk_unprepare(fsl_dev->clk); + clk_disable_unprepare(fsl_dev->clk); return 0; } -- 1.9.1
[PATCH] ARM: sa1111: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- arch/arm/common/sa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/common/sa.c b/arch/arm/common/sa.c index 3d22494..368d571 100644 --- a/arch/arm/common/sa.c +++ b/arch/arm/common/sa.c @@ -831,8 +831,7 @@ static void __sa_remove(struct sa *sachip) sa_writel(0, irqbase + SA_WAKEEN0); sa_writel(0, irqbase + SA_WAKEEN1); - clk_disable(sachip->clk); - clk_unprepare(sachip->clk); + clk_disable_unprepare(sachip->clk); if (sachip->irq != NO_IRQ) { irq_set_chained_handler_and_data(sachip->irq, NULL, NULL); -- 1.9.1
[PATCH] ARM: sa1111: Use clk_disable_unprepare
Replace clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla --- arch/arm/common/sa.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/common/sa.c b/arch/arm/common/sa.c index 3d22494..368d571 100644 --- a/arch/arm/common/sa.c +++ b/arch/arm/common/sa.c @@ -831,8 +831,7 @@ static void __sa_remove(struct sa *sachip) sa_writel(0, irqbase + SA_WAKEEN0); sa_writel(0, irqbase + SA_WAKEEN1); - clk_disable(sachip->clk); - clk_unprepare(sachip->clk); + clk_disable_unprepare(sachip->clk); if (sachip->irq != NO_IRQ) { irq_set_chained_handler_and_data(sachip->irq, NULL, NULL); -- 1.9.1
[PATCH v2] 2c: mv64xxx: Use clk_enable_prepare and clk_disable_unprepare
Replace clk_enable and clk_prepare with clk_enable_prepare and clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_prepare(e); - clk_enable(e); + clk_prepare_enable(e); @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Rebased patch drivers/i2c/busses/i2c-mv64xxx.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 43207f5..79bae48 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -910,10 +910,8 @@ mv64xxx_i2c_probe(struct platform_device *pd) #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ drv_data->clk = devm_clk_get(>dev, NULL); - if (!IS_ERR(drv_data->clk)) { - clk_prepare(drv_data->clk); - clk_enable(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_prepare_enable(drv_data->clk); #endif if (pdata) { drv_data->freq_m = pdata->freq_m; @@ -966,10 +964,8 @@ exit_reset: exit_clk: #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ - if (!IS_ERR(drv_data->clk)) { - clk_disable(drv_data->clk); - clk_unprepare(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_disable_unprepare(drv_data->clk); #endif return rc; } @@ -985,10 +981,8 @@ mv64xxx_i2c_remove(struct platform_device *dev) reset_control_assert(drv_data->rstc); #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ - if (!IS_ERR(drv_data->clk)) { - clk_disable(drv_data->clk); - clk_unprepare(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_disable_unprepare(drv_data->clk); #endif return 0; -- 1.9.1
[PATCH v2] 2c: mv64xxx: Use clk_enable_prepare and clk_disable_unprepare
Replace clk_enable and clk_prepare with clk_enable_prepare and clk_disable and clk_unprepare with clk_disable_unprepare. The Coccinelle semantic patch used to make this change is as follows: @@ expression e; @@ - clk_prepare(e); - clk_enable(e); + clk_prepare_enable(e); @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Rebased patch drivers/i2c/busses/i2c-mv64xxx.c | 18 ++ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/busses/i2c-mv64xxx.c b/drivers/i2c/busses/i2c-mv64xxx.c index 43207f5..79bae48 100644 --- a/drivers/i2c/busses/i2c-mv64xxx.c +++ b/drivers/i2c/busses/i2c-mv64xxx.c @@ -910,10 +910,8 @@ mv64xxx_i2c_probe(struct platform_device *pd) #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ drv_data->clk = devm_clk_get(>dev, NULL); - if (!IS_ERR(drv_data->clk)) { - clk_prepare(drv_data->clk); - clk_enable(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_prepare_enable(drv_data->clk); #endif if (pdata) { drv_data->freq_m = pdata->freq_m; @@ -966,10 +964,8 @@ exit_reset: exit_clk: #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ - if (!IS_ERR(drv_data->clk)) { - clk_disable(drv_data->clk); - clk_unprepare(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_disable_unprepare(drv_data->clk); #endif return rc; } @@ -985,10 +981,8 @@ mv64xxx_i2c_remove(struct platform_device *dev) reset_control_assert(drv_data->rstc); #if defined(CONFIG_HAVE_CLK) /* Not all platforms have a clk */ - if (!IS_ERR(drv_data->clk)) { - clk_disable(drv_data->clk); - clk_unprepare(drv_data->clk); - } + if (!IS_ERR(drv_data->clk)) + clk_disable_unprepare(drv_data->clk); #endif return 0; -- 1.9.1
[PATCH] Coccinelle: Script to use roundup and DIV_ROUND_UP
This script replaces manual calculations by using the predefined macros in kernel.h, DIV_ROUND_UP and roundup for readability purposes. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- scripts/coccinelle/api/roundup.cocci | 215 +++ 1 file changed, 215 insertions(+) create mode 100644 scripts/coccinelle/api/roundup.cocci diff --git a/scripts/coccinelle/api/roundup.cocci b/scripts/coccinelle/api/roundup.cocci new file mode 100644 index 000..af97cd2 --- /dev/null +++ b/scripts/coccinelle/api/roundup.cocci @@ -0,0 +1,215 @@ +/// Use DIV_ROUND_UP and roundup to improve readability +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@haskernel@ +@@ + +#include + +@round1 depends on haskernel && patch && !context && !org && !report@ +expression x, y; +@@ + +( +- (((x + (y - 1)) / y) * y) ++ roundup(x, y) +| +- (((x + y - 1) / y) * y) ++ roundup(x, y) +) + +@round2 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression x, y; +@@ + +- roundup((x), y) ++ roundup(x, y) + +@round3 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression x, y; +@@ + +- roundup(x, (y)) ++ roundup(x, y) + +@round4 depends on haskernel && patch && !context && !org && !report@ +expression n,d; +@@ + +( +- ((n + d - 1) / d) ++ DIV_ROUND_UP(n,d) +| +- ((n + (d - 1)) / d) ++ DIV_ROUND_UP(n,d) +) + +@round5 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression n,d; +@@ + +- DIV_ROUND_UP((n),d) ++ DIV_ROUND_UP(n,d) + +@round6 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression n,d; +@@ + +- DIV_ROUND_UP(n,(d)) ++ DIV_ROUND_UP(n,d) + +// + +@round1_context depends on haskernel && !patch && (context || org || report)@ +expression e, x, y; +position j,j0; +@@ + +( +* (((x@j + (y - 1)) / y) *@e@j0 y) +| +* (((x@j + y - 1) / y) *@e@j0 y) +) + +@round2_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression x, y; +position j0; +@@ + +* roundup@j0((x), y) + +@round3_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression x, y; +position j0; +@@ + +* roundup@j0(x, (y)) + +@round4_context depends on haskernel && !patch && (context || org || report)@ +expression e, d, n; +position j!=round1_context.j; +position j0; +@@ + +( +* ((n@j + d - 1) /@e@j0 d) +| +* ((n@j + (d - 1)) /@e@j0 d) +) + +@round5_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression d, n; +position j0; +@@ + +* DIV_ROUND_UP@j0((n),d) + +@round6_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression d, n; +position j0; +@@ + +* DIV_ROUND_UP@j0(n,(d)) + +// + +@script:python round1_org depends on org@ +j0 << round1_context.j0; +@@ + +msg = "WARNING: Replace with roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round2_org depends on org@ +j0 << round2_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round3_org depends on org@ +j0 << round3_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the second argument of roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round4_org depends on org@ +j0 << round4_context.j0; +@@ + +msg = "WARNING: Replace with DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +@script:python round5_org depends on org@ +j0 << round5_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +@script:python round6_org depends on org@ +j0 << round6_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the second argument of DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +// + +@script:python round1_report depends on report@ +j0 << round1_context.j0; +@@ + +msg = "WARNING: Replace with roundup." +coccilib.report.print_report(j0[0], msg) + +@script:python round2_report depends on report@ +j0 << round2_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of roundup." +coccilib.report.print_report(j0[0], msg) + +@script:python roun
[PATCH] Coccinelle: Script to use roundup and DIV_ROUND_UP
This script replaces manual calculations by using the predefined macros in kernel.h, DIV_ROUND_UP and roundup for readability purposes. Signed-off-by: Amitoj Kaur Chawla --- scripts/coccinelle/api/roundup.cocci | 215 +++ 1 file changed, 215 insertions(+) create mode 100644 scripts/coccinelle/api/roundup.cocci diff --git a/scripts/coccinelle/api/roundup.cocci b/scripts/coccinelle/api/roundup.cocci new file mode 100644 index 000..af97cd2 --- /dev/null +++ b/scripts/coccinelle/api/roundup.cocci @@ -0,0 +1,215 @@ +/// Use DIV_ROUND_UP and roundup to improve readability +/// +// Confidence: High +// Copyright: (C) 2016 Amitoj Kaur Chawla + +virtual patch +virtual context +virtual org +virtual report + +@haskernel@ +@@ + +#include + +@round1 depends on haskernel && patch && !context && !org && !report@ +expression x, y; +@@ + +( +- (((x + (y - 1)) / y) * y) ++ roundup(x, y) +| +- (((x + y - 1) / y) * y) ++ roundup(x, y) +) + +@round2 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression x, y; +@@ + +- roundup((x), y) ++ roundup(x, y) + +@round3 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression x, y; +@@ + +- roundup(x, (y)) ++ roundup(x, y) + +@round4 depends on haskernel && patch && !context && !org && !report@ +expression n,d; +@@ + +( +- ((n + d - 1) / d) ++ DIV_ROUND_UP(n,d) +| +- ((n + (d - 1)) / d) ++ DIV_ROUND_UP(n,d) +) + +@round5 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression n,d; +@@ + +- DIV_ROUND_UP((n),d) ++ DIV_ROUND_UP(n,d) + +@round6 depends on haskernel && patch && !context && !org && !report + disable paren@ +expression n,d; +@@ + +- DIV_ROUND_UP(n,(d)) ++ DIV_ROUND_UP(n,d) + +// + +@round1_context depends on haskernel && !patch && (context || org || report)@ +expression e, x, y; +position j,j0; +@@ + +( +* (((x@j + (y - 1)) / y) *@e@j0 y) +| +* (((x@j + y - 1) / y) *@e@j0 y) +) + +@round2_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression x, y; +position j0; +@@ + +* roundup@j0((x), y) + +@round3_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression x, y; +position j0; +@@ + +* roundup@j0(x, (y)) + +@round4_context depends on haskernel && !patch && (context || org || report)@ +expression e, d, n; +position j!=round1_context.j; +position j0; +@@ + +( +* ((n@j + d - 1) /@e@j0 d) +| +* ((n@j + (d - 1)) /@e@j0 d) +) + +@round5_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression d, n; +position j0; +@@ + +* DIV_ROUND_UP@j0((n),d) + +@round6_context depends on haskernel && !patch && (context || org || report) + disable paren@ +expression d, n; +position j0; +@@ + +* DIV_ROUND_UP@j0(n,(d)) + +// + +@script:python round1_org depends on org@ +j0 << round1_context.j0; +@@ + +msg = "WARNING: Replace with roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round2_org depends on org@ +j0 << round2_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round3_org depends on org@ +j0 << round3_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the second argument of roundup." +coccilib.org.print_todo(j0[0], msg) + +@script:python round4_org depends on org@ +j0 << round4_context.j0; +@@ + +msg = "WARNING: Replace with DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +@script:python round5_org depends on org@ +j0 << round5_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +@script:python round6_org depends on org@ +j0 << round6_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the second argument of DIV_ROUND_UP." +coccilib.org.print_todo(j0[0], msg) + +// + +@script:python round1_report depends on report@ +j0 << round1_context.j0; +@@ + +msg = "WARNING: Replace with roundup." +coccilib.report.print_report(j0[0], msg) + +@script:python round2_report depends on report@ +j0 << round2_context.j0; +@@ + +msg = "WARNING: Unneeded parentheses in the first argument of roundup." +coccilib.report.print_report(j0[0], msg) + +@script:python round3_report depends on report@
[PATCH v2] sound: oss: Remove useless initialisation
Remove useless initialisation of variable whose value is reinitialised later. The Coccinelle semantic patch used to make this change is as follows: @@ type T; identifier x; constant C; expression e; @@ T x - = C ; x = e; Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- Changes in v2: -Modify commit message sound/oss/ad1848.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 10c8de1..6368e5c 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -254,7 +254,7 @@ static void ad_write(ad1848_info * devc, int reg, int data) static void wait_for_calibration(ad1848_info * devc) { - int timeout = 0; + int timeout; /* * Wait until the auto calibration process has finished. -- 1.9.1
[PATCH v2] sound: oss: Remove useless initialisation
Remove useless initialisation of variable whose value is reinitialised later. The Coccinelle semantic patch used to make this change is as follows: @@ type T; identifier x; constant C; expression e; @@ T x - = C ; x = e; Signed-off-by: Amitoj Kaur Chawla --- Changes in v2: -Modify commit message sound/oss/ad1848.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 10c8de1..6368e5c 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -254,7 +254,7 @@ static void ad_write(ad1848_info * devc, int reg, int data) static void wait_for_calibration(ad1848_info * devc) { - int timeout = 0; + int timeout; /* * Wait until the auto calibration process has finished. -- 1.9.1
[PATCH] sound: oss: Remove useless initialisation
@@ type T; identifier x; constant C; expression e; @@ T x - = C ; x = e; Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- sound/oss/ad1848.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 10c8de1..6368e5c 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -254,7 +254,7 @@ static void ad_write(ad1848_info * devc, int reg, int data) static void wait_for_calibration(ad1848_info * devc) { - int timeout = 0; + int timeout; /* * Wait until the auto calibration process has finished. -- 1.9.1
[PATCH] sound: oss: Remove useless initialisation
@@ type T; identifier x; constant C; expression e; @@ T x - = C ; x = e; Signed-off-by: Amitoj Kaur Chawla --- sound/oss/ad1848.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/oss/ad1848.c b/sound/oss/ad1848.c index 10c8de1..6368e5c 100644 --- a/sound/oss/ad1848.c +++ b/sound/oss/ad1848.c @@ -254,7 +254,7 @@ static void ad_write(ad1848_info * devc, int reg, int data) static void wait_for_calibration(ad1848_info * devc) { - int timeout = 0; + int timeout; /* * Wait until the auto calibration process has finished. -- 1.9.1
Re: [PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
On Mon, Jul 4, 2016 at 8:36 PM, Amitoj Kaur Chawla <amitoj1...@gmail.com> wrote: > On Mon, Jul 4, 2016 at 8:29 PM, Mark Brown <broo...@kernel.org> wrote: >> On Mon, Jul 04, 2016 at 04:52:43PM +0200, Julia Lawall wrote: >>> On Mon, 4 Jul 2016, Mark Brown wrote: >> >>> > Please use subject lines matching the style for the subsystem. This >>> > makes it easier for people to identify relevant patches. >> >>> The point is that ASOC should be ASoC? Ther aren't many patches on this >>> file, and two of the three have the same subject line as the above, but >>> with ASoC rather than ASOC. >> >> Yes, that's the case here (this is one of my pre-canned responses and I >> didn't yet figure out a sensible way to make it parameterized yet, >> should add a bit about trawling git log though). > > Sorry for the error. I'll send a v2. > > Amitoj I see the patch has already been applied with the corrected subject line. Amitoj
Re: [PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
On Mon, Jul 4, 2016 at 8:36 PM, Amitoj Kaur Chawla wrote: > On Mon, Jul 4, 2016 at 8:29 PM, Mark Brown wrote: >> On Mon, Jul 04, 2016 at 04:52:43PM +0200, Julia Lawall wrote: >>> On Mon, 4 Jul 2016, Mark Brown wrote: >> >>> > Please use subject lines matching the style for the subsystem. This >>> > makes it easier for people to identify relevant patches. >> >>> The point is that ASOC should be ASoC? Ther aren't many patches on this >>> file, and two of the three have the same subject line as the above, but >>> with ASoC rather than ASOC. >> >> Yes, that's the case here (this is one of my pre-canned responses and I >> didn't yet figure out a sensible way to make it parameterized yet, >> should add a bit about trawling git log though). > > Sorry for the error. I'll send a v2. > > Amitoj I see the patch has already been applied with the corrected subject line. Amitoj
Re: [PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
On Mon, Jul 4, 2016 at 8:29 PM, Mark Brownwrote: > On Mon, Jul 04, 2016 at 04:52:43PM +0200, Julia Lawall wrote: >> On Mon, 4 Jul 2016, Mark Brown wrote: > >> > Please use subject lines matching the style for the subsystem. This >> > makes it easier for people to identify relevant patches. > >> The point is that ASOC should be ASoC? Ther aren't many patches on this >> file, and two of the three have the same subject line as the above, but >> with ASoC rather than ASOC. > > Yes, that's the case here (this is one of my pre-canned responses and I > didn't yet figure out a sensible way to make it parameterized yet, > should add a bit about trawling git log though). Sorry for the error. I'll send a v2. Amitoj
Re: [PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
On Mon, Jul 4, 2016 at 8:29 PM, Mark Brown wrote: > On Mon, Jul 04, 2016 at 04:52:43PM +0200, Julia Lawall wrote: >> On Mon, 4 Jul 2016, Mark Brown wrote: > >> > Please use subject lines matching the style for the subsystem. This >> > makes it easier for people to identify relevant patches. > >> The point is that ASOC should be ASoC? Ther aren't many patches on this >> file, and two of the three have the same subject line as the above, but >> with ASoC rather than ASOC. > > Yes, that's the case here (this is one of my pre-canned responses and I > didn't yet figure out a sensible way to make it parameterized yet, > should add a bit about trawling git log though). Sorry for the error. I'll send a v2. Amitoj
[PATCH] ASOC: atmel-pdmic: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- sound/soc/atmel/atmel-pdmic.c | 5 - 1 file changed, 5 deletions(-) diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index aee4787..5f56da6 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -624,11 +624,6 @@ static int atmel_pdmic_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "no memory resource\n"); - return -ENXIO; - } - io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) { ret = PTR_ERR(io_base); -- 1.9.1
[PATCH] ASOC: atmel-pdmic: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla --- sound/soc/atmel/atmel-pdmic.c | 5 - 1 file changed, 5 deletions(-) diff --git a/sound/soc/atmel/atmel-pdmic.c b/sound/soc/atmel/atmel-pdmic.c index aee4787..5f56da6 100644 --- a/sound/soc/atmel/atmel-pdmic.c +++ b/sound/soc/atmel/atmel-pdmic.c @@ -624,11 +624,6 @@ static int atmel_pdmic_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "no memory resource\n"); - return -ENXIO; - } - io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) { ret = PTR_ERR(io_base); -- 1.9.1
[PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- sound/soc/atmel/atmel-classd.c | 5 - 1 file changed, 5 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 6107de9..6d9b8b4 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -593,11 +593,6 @@ static int atmel_classd_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "no memory resource\n"); - return -ENXIO; - } - io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) { ret = PTR_ERR(io_base); -- 1.9.1
[PATCH] ASOC: Atmel: ClassD: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla --- sound/soc/atmel/atmel-classd.c | 5 - 1 file changed, 5 deletions(-) diff --git a/sound/soc/atmel/atmel-classd.c b/sound/soc/atmel/atmel-classd.c index 6107de9..6d9b8b4 100644 --- a/sound/soc/atmel/atmel-classd.c +++ b/sound/soc/atmel/atmel-classd.c @@ -593,11 +593,6 @@ static int atmel_classd_probe(struct platform_device *pdev) } res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (!res) { - dev_err(dev, "no memory resource\n"); - return -ENXIO; - } - io_base = devm_ioremap_resource(dev, res); if (IS_ERR(io_base)) { ret = PTR_ERR(io_base); -- 1.9.1
[PATCH] crypto: bfin_crc: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/crypto/bfin_crc.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index 95b7396..10db7df 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -588,11 +588,6 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev) crypto_init_queue(>queue, CRC_CCRYPTO_QUEUE_LENGTH); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(>dev, "Cannot get IORESOURCE_MEM\n"); - return -ENOENT; - } - crc->regs = devm_ioremap_resource(dev, res); if (IS_ERR((void *)crc->regs)) { dev_err(>dev, "Cannot map CRC IO\n"); -- 1.9.1
[PATCH] crypto: bfin_crc: Simplify use of devm_ioremap_resource
Remove unneeded error handling on the result of a call to platform_get_resource when the value is passed to devm_ioremap_resource. The Coccinelle semantic patch that makes this change is as follows: // @@ expression pdev,res,n,e,e1; expression ret != 0; identifier l; @@ - res = platform_get_resource(pdev, IORESOURCE_MEM, n); ... when != res - if (res == NULL) { ... \(goto l;\|return ret;\) } ... when != res + res = platform_get_resource(pdev, IORESOURCE_MEM, n); e = devm_ioremap_resource(e1, res); // Signed-off-by: Amitoj Kaur Chawla --- drivers/crypto/bfin_crc.c | 5 - 1 file changed, 5 deletions(-) diff --git a/drivers/crypto/bfin_crc.c b/drivers/crypto/bfin_crc.c index 95b7396..10db7df 100644 --- a/drivers/crypto/bfin_crc.c +++ b/drivers/crypto/bfin_crc.c @@ -588,11 +588,6 @@ static int bfin_crypto_crc_probe(struct platform_device *pdev) crypto_init_queue(>queue, CRC_CCRYPTO_QUEUE_LENGTH); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); - if (res == NULL) { - dev_err(>dev, "Cannot get IORESOURCE_MEM\n"); - return -ENOENT; - } - crc->regs = devm_ioremap_resource(dev, res); if (IS_ERR((void *)crc->regs)) { dev_err(>dev, "Cannot map CRC IO\n"); -- 1.9.1
[PATCH] RDMA/cxgb3: Use AF_INET for sin_family field
Elsewhere the sin_family field holds a value with a name of the form AF_..., so it seems reasonable to do so here as well. Also the values of PF_INET and AF_INET are the same. The Coccinelle semantic patch that makes this change is as follows: // @@ struct sockaddr_in sip; @@ ( sip.sin_family == - PF_INET + AF_INET | sip.sin_family != - PF_INET + AF_INET | sip.sin_family = - PF_INET + AF_INET ) // Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/infiniband/hw/cxgb3/iwch_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index 3e8431b..04bbf17 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c @@ -1396,10 +1396,10 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) state_set(_ep->com, CONNECTING); child_ep->com.tdev = tdev; child_ep->com.cm_id = NULL; - child_ep->com.local_addr.sin_family = PF_INET; + child_ep->com.local_addr.sin_family = AF_INET; child_ep->com.local_addr.sin_port = req->local_port; child_ep->com.local_addr.sin_addr.s_addr = req->local_ip; - child_ep->com.remote_addr.sin_family = PF_INET; + child_ep->com.remote_addr.sin_family = AF_INET; child_ep->com.remote_addr.sin_port = req->peer_port; child_ep->com.remote_addr.sin_addr.s_addr = req->peer_ip; get_ep(_ep->com); -- 1.9.1
[PATCH] RDMA/cxgb3: Use AF_INET for sin_family field
Elsewhere the sin_family field holds a value with a name of the form AF_..., so it seems reasonable to do so here as well. Also the values of PF_INET and AF_INET are the same. The Coccinelle semantic patch that makes this change is as follows: // @@ struct sockaddr_in sip; @@ ( sip.sin_family == - PF_INET + AF_INET | sip.sin_family != - PF_INET + AF_INET | sip.sin_family = - PF_INET + AF_INET ) // Signed-off-by: Amitoj Kaur Chawla --- drivers/infiniband/hw/cxgb3/iwch_cm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c b/drivers/infiniband/hw/cxgb3/iwch_cm.c index 3e8431b..04bbf17 100644 --- a/drivers/infiniband/hw/cxgb3/iwch_cm.c +++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c @@ -1396,10 +1396,10 @@ static int pass_accept_req(struct t3cdev *tdev, struct sk_buff *skb, void *ctx) state_set(_ep->com, CONNECTING); child_ep->com.tdev = tdev; child_ep->com.cm_id = NULL; - child_ep->com.local_addr.sin_family = PF_INET; + child_ep->com.local_addr.sin_family = AF_INET; child_ep->com.local_addr.sin_port = req->local_port; child_ep->com.local_addr.sin_addr.s_addr = req->local_ip; - child_ep->com.remote_addr.sin_family = PF_INET; + child_ep->com.remote_addr.sin_family = AF_INET; child_ep->com.remote_addr.sin_port = req->peer_port; child_ep->com.remote_addr.sin_addr.s_addr = req->peer_ip; get_ep(_ep->com); -- 1.9.1
[PATCH] bcache: Use setup_timer and mod_timer
Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. The Coccinelle semantic patch that fixes one part of this issue is as follows: @@ expression t,d,f,e1; identifier x1; statement S1; @@ ( -t.data = d; | -t.function = f; | -init_timer(); +setup_timer(,f,d); | -init_timer_on_stack(); +setup_timer_on_stack(,f,d); ) <... when != S1 t.x1 = e1; ...> Also convert calls to add_timer and intialisation of timer's expire field to a call to mod_timer which is more compact. Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/md/bcache/stats.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index 0ca072c..094d6d6 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -233,9 +233,6 @@ void bch_cache_accounting_init(struct cache_accounting *acc, kobject_init(>day.kobj,_stats_ktype); closure_init(>cl, parent); - init_timer(>timer); - acc->timer.expires = jiffies + accounting_delay; - acc->timer.data = (unsigned long) acc; - acc->timer.function = scale_accounting; - add_timer(>timer); + setup_timer(>timer, scale_accounting, (unsigned long) acc); + mod_timer(>timer, jiffies + accounting_delay); } -- 1.9.1
[PATCH] bcache: Use setup_timer and mod_timer
Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. The Coccinelle semantic patch that fixes one part of this issue is as follows: @@ expression t,d,f,e1; identifier x1; statement S1; @@ ( -t.data = d; | -t.function = f; | -init_timer(); +setup_timer(,f,d); | -init_timer_on_stack(); +setup_timer_on_stack(,f,d); ) <... when != S1 t.x1 = e1; ...> Also convert calls to add_timer and intialisation of timer's expire field to a call to mod_timer which is more compact. Signed-off-by: Amitoj Kaur Chawla --- drivers/md/bcache/stats.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/md/bcache/stats.c b/drivers/md/bcache/stats.c index 0ca072c..094d6d6 100644 --- a/drivers/md/bcache/stats.c +++ b/drivers/md/bcache/stats.c @@ -233,9 +233,6 @@ void bch_cache_accounting_init(struct cache_accounting *acc, kobject_init(>day.kobj,_stats_ktype); closure_init(>cl, parent); - init_timer(>timer); - acc->timer.expires = jiffies + accounting_delay; - acc->timer.data = (unsigned long) acc; - acc->timer.function = scale_accounting; - add_timer(>timer); + setup_timer(>timer, scale_accounting, (unsigned long) acc); + mod_timer(>timer, jiffies + accounting_delay); } -- 1.9.1
[PATCH] atm: horizon: Use setup_timer
Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. The Coccinelle semantic patch that fixes this problem is as follows: @@ expression t,d,f,e1; identifier x1; statement S1; @@ ( -t.data = d; | -t.function = f; | -init_timer(); +setup_timer(,f,d); | -init_timer_on_stack(); +setup_timer_on_stack(,f,d); ) <... when != S1 t.x1 = e1; ...> Signed-off-by: Amitoj Kaur Chawla <amitoj1...@gmail.com> --- drivers/atm/horizon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c index 527bbd5..5fc81e2 100644 --- a/drivers/atm/horizon.c +++ b/drivers/atm/horizon.c @@ -2795,9 +2795,7 @@ static int hrz_probe(struct pci_dev *pci_dev, dev->atm_dev->ci_range.vpi_bits = vpi_bits; dev->atm_dev->ci_range.vci_bits = 10-vpi_bits; - init_timer(>housekeeping); - dev->housekeeping.function = do_housekeeping; - dev->housekeeping.data = (unsigned long) dev; + setup_timer(>housekeeping, do_housekeeping, (unsigned long) dev); mod_timer(>housekeeping, jiffies); out: -- 1.9.1
[PATCH] atm: horizon: Use setup_timer
Convert a call to init_timer and accompanying intializations of the timer's data and function fields to a call to setup_timer. The Coccinelle semantic patch that fixes this problem is as follows: @@ expression t,d,f,e1; identifier x1; statement S1; @@ ( -t.data = d; | -t.function = f; | -init_timer(); +setup_timer(,f,d); | -init_timer_on_stack(); +setup_timer_on_stack(,f,d); ) <... when != S1 t.x1 = e1; ...> Signed-off-by: Amitoj Kaur Chawla --- drivers/atm/horizon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c index 527bbd5..5fc81e2 100644 --- a/drivers/atm/horizon.c +++ b/drivers/atm/horizon.c @@ -2795,9 +2795,7 @@ static int hrz_probe(struct pci_dev *pci_dev, dev->atm_dev->ci_range.vpi_bits = vpi_bits; dev->atm_dev->ci_range.vci_bits = 10-vpi_bits; - init_timer(>housekeeping); - dev->housekeeping.function = do_housekeeping; - dev->housekeeping.data = (unsigned long) dev; + setup_timer(>housekeeping, do_housekeeping, (unsigned long) dev); mod_timer(>housekeeping, jiffies); out: -- 1.9.1