mirror of
https://github.com/torvalds/linux.git
synced 2024-11-28 15:11:31 +00:00
tools: ynl-gen: support excluding tricky ops
The ethtool family has a small handful of quite tricky ops and a lot of simple very useful ops. Teach ynl-gen to skip ops so that we can bypass the tricky ones. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
b30a1f305b
commit
008bcd6835
@ -334,7 +334,7 @@ class SpecFamily(SpecElement):
|
||||
consts dict of all constants/enums
|
||||
fixed_header string, optional name of family default fixed header struct
|
||||
"""
|
||||
def __init__(self, spec_path, schema_path=None):
|
||||
def __init__(self, spec_path, schema_path=None, exclude_ops=None):
|
||||
with open(spec_path, "r") as stream:
|
||||
prefix = '# SPDX-License-Identifier: '
|
||||
first = stream.readline().strip()
|
||||
@ -349,6 +349,8 @@ class SpecFamily(SpecElement):
|
||||
|
||||
super().__init__(self, spec)
|
||||
|
||||
self._exclude_ops = exclude_ops if exclude_ops else []
|
||||
|
||||
self.proto = self.yaml.get('protocol', 'genetlink')
|
||||
self.msg_id_model = self.yaml['operations'].get('enum-model', 'unified')
|
||||
|
||||
@ -449,7 +451,13 @@ class SpecFamily(SpecElement):
|
||||
req_val = None
|
||||
if rsp_val == rsp_val_next:
|
||||
rsp_val = None
|
||||
|
||||
skip = False
|
||||
for exclude in self._exclude_ops:
|
||||
skip |= bool(exclude.match(elem['name']))
|
||||
if not skip:
|
||||
op = self.new_operation(elem, req_val, rsp_val)
|
||||
|
||||
req_val = req_val_next
|
||||
rsp_val = rsp_val_next
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
import argparse
|
||||
import collections
|
||||
import os
|
||||
import re
|
||||
import yaml
|
||||
|
||||
from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, SpecEnumEntry
|
||||
@ -739,7 +740,7 @@ class Operation(SpecOperation):
|
||||
|
||||
|
||||
class Family(SpecFamily):
|
||||
def __init__(self, file_name):
|
||||
def __init__(self, file_name, exclude_ops):
|
||||
# Added by resolve:
|
||||
self.c_name = None
|
||||
delattr(self, "c_name")
|
||||
@ -754,7 +755,7 @@ class Family(SpecFamily):
|
||||
self.hooks = None
|
||||
delattr(self, "hooks")
|
||||
|
||||
super().__init__(file_name)
|
||||
super().__init__(file_name, exclude_ops=exclude_ops)
|
||||
|
||||
self.fam_key = c_upper(self.yaml.get('c-family-name', self.yaml["name"] + '_FAMILY_NAME'))
|
||||
self.ver_key = c_upper(self.yaml.get('c-version-name', self.yaml["name"] + '_FAMILY_VERSION'))
|
||||
@ -2241,6 +2242,7 @@ def main():
|
||||
parser.add_argument('--header', dest='header', action='store_true', default=None)
|
||||
parser.add_argument('--source', dest='header', action='store_false')
|
||||
parser.add_argument('--user-header', nargs='+', default=[])
|
||||
parser.add_argument('--exclude-op', action='append', default=[])
|
||||
parser.add_argument('-o', dest='out_file', type=str)
|
||||
args = parser.parse_args()
|
||||
|
||||
@ -2249,8 +2251,10 @@ def main():
|
||||
if args.header is None:
|
||||
parser.error("--header or --source is required")
|
||||
|
||||
exclude_ops = [re.compile(expr) for expr in args.exclude_op]
|
||||
|
||||
try:
|
||||
parsed = Family(args.spec)
|
||||
parsed = Family(args.spec, exclude_ops)
|
||||
if parsed.license != '((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)':
|
||||
print('Spec license:', parsed.license)
|
||||
print('License must be: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause)')
|
||||
|
Loading…
Reference in New Issue
Block a user