mirror of
https://github.com/dgibson/dtc.git
synced 2025-10-13 16:27:39 -04:00
checks: replace strstr and strrchr with strends
Makes the logic more clear Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com> Message-Id: <20210504035944.8453-4-ilya.lipnitskiy@gmail.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
09c6a6e887
commit
ad4abfadb6
1 changed files with 7 additions and 18 deletions
25
checks.c
25
checks.c
|
@ -687,8 +687,7 @@ static void check_names_is_string_list(struct check *c, struct dt_info *dti,
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
|
|
||||||
for_each_property(node, prop) {
|
for_each_property(node, prop) {
|
||||||
const char *s = strrchr(prop->name, '-');
|
if (!strends(prop->name, "-names"))
|
||||||
if (!s || !streq(s, "-names"))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
c->data = prop->name;
|
c->data = prop->name;
|
||||||
|
@ -1488,24 +1487,17 @@ WARNING_PROPERTY_PHANDLE_CELLS(thermal_sensors, "thermal-sensors", "#thermal-sen
|
||||||
|
|
||||||
static bool prop_is_gpio(struct property *prop)
|
static bool prop_is_gpio(struct property *prop)
|
||||||
{
|
{
|
||||||
char *str;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* *-gpios and *-gpio can appear in property names,
|
* *-gpios and *-gpio can appear in property names,
|
||||||
* so skip over any false matches (only one known ATM)
|
* so skip over any false matches (only one known ATM)
|
||||||
*/
|
*/
|
||||||
if (strstr(prop->name, ",nr-gpios"))
|
if (strends(prop->name, ",nr-gpios"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
str = strrchr(prop->name, '-');
|
return strends(prop->name, "-gpios") ||
|
||||||
if (str)
|
streq(prop->name, "gpios") ||
|
||||||
str++;
|
strends(prop->name, "-gpio") ||
|
||||||
else
|
streq(prop->name, "gpio");
|
||||||
str = prop->name;
|
|
||||||
if (!(streq(str, "gpios") || streq(str, "gpio")))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_gpios_property(struct check *c,
|
static void check_gpios_property(struct check *c,
|
||||||
|
@ -1540,13 +1532,10 @@ static void check_deprecated_gpio_property(struct check *c,
|
||||||
struct property *prop;
|
struct property *prop;
|
||||||
|
|
||||||
for_each_property(node, prop) {
|
for_each_property(node, prop) {
|
||||||
char *str;
|
|
||||||
|
|
||||||
if (!prop_is_gpio(prop))
|
if (!prop_is_gpio(prop))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
str = strstr(prop->name, "gpio");
|
if (!strends(prop->name, "gpio"))
|
||||||
if (!streq(str, "gpio"))
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FAIL_PROP(c, dti, node, prop,
|
FAIL_PROP(c, dti, node, prop,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue