From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 42DAA45C8C; Wed, 6 Nov 2024 04:55:50 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 184BA427E2; Wed, 6 Nov 2024 04:55:50 +0100 (CET) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 5CF33427B6 for ; Wed, 6 Nov 2024 04:55:48 +0100 (CET) Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-20e6981ca77so64792515ad.2 for ; Tue, 05 Nov 2024 19:55:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1730865347; x=1731470147; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=mjaxvVVESG3BDu60Er2dQ4I6ehLGBOzXyhyLKUI3jXQ=; b=mgRV0HQ9N79StVxALz2nVrph/70oj/m21mjRjWA2E7t0b0n+3yr9mzOUKL94CVtvEI g6ESiQwP3PihGfvEXNSEQeSGoUv5+DgN6hsLRxEHuX9fmO8r/d0cPwcBIBXXWfETss+N 6qeuHn3mFcjO9M/n6wwTK1XM7nXVPfs6wTsgkA9skZXhtMz1u+CiCSDc7zgERKm3PjBB DTPk6ximTnnak/kv+Y4mIOjAhFR68mHepWeE5qCgmgklVM9r8tM+eqyOF0eq9ePybgwb /4yRdGGrKWjBnc5M9NFQnFLb9vzgijMvZZORJVo5OmlwDCZz4NSgk93Wqrv+mpvh3qvE UoGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730865347; x=1731470147; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mjaxvVVESG3BDu60Er2dQ4I6ehLGBOzXyhyLKUI3jXQ=; b=Dp/ETCk7p/zxbel7rVMLXnNPyO75bfOaCdFielGzU3BiYMIkRzvQ7zi0KlS+Jvyu/W 6vHEjH7nGUmPIxk7nHbFcwPV2GqsNHnNE24pxLVTxGRTmmZt58dau5rTy6gw1clW6r4y BTZ4SfFXXjcHfOFvpWatEiigmeUEp1DKuYa4iWX30jH1pMfrglpK+h8244cSzhZZzrU8 4vMqsbdYLlaEBYTW+IlMYklYM1WMRJXQQxew7VuH0XnYMEpK/xlaf164VJagNghykEB9 XTsEQRAX643DgIFjO3jkrTC4BBRVcVNUKdlhmNr/3zWqBnEJnD+sHV8RHnsBcyH8PCMO hPHA== X-Gm-Message-State: AOJu0Yz9usg9Liil2O68yAVyNCVxgrCIhiAOF4AnYJZa2G3aEdYBlfi4 0Rbz3B/bAZCUXNQVpqSRzF3stin2gKBV/AFiqwdh9mgMJ28NKfenfGzk5lmzyBM= X-Google-Smtp-Source: AGHT+IHPNhPlVLp6U7Ly5DLFrMwGtAVy1lVxJXBRopp419L8TEqCRdeYJp93YtP5qAe8DibmUUfXhw== X-Received: by 2002:a17:902:d50e:b0:20c:bda8:3a10 with SMTP id d9443c01a7336-21103c5a090mr293909755ad.37.1730865347400; Tue, 05 Nov 2024 19:55:47 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-211057c083fsm85782025ad.187.2024.11.05.19.55.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 19:55:47 -0800 (PST) Date: Tue, 5 Nov 2024 19:55:45 -0800 From: Stephen Hemminger To: liwencheng Cc: dev@dpdk.org Subject: Re: [PATCH v1 2/2] /usertools/dpdk-devbind:add the binding and unbinding of platform device Message-ID: <20241105195545.20c0327c@hermes.local> In-Reply-To: <1730455640-1084345-2-git-send-email-liwencheng@phytium.com.cn> References: <1730455640-1084345-1-git-send-email-liwencheng@phytium.com.cn> <1730455640-1084345-2-git-send-email-liwencheng@phytium.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, 1 Nov 2024 10:07:20 +0000 liwencheng wrote: > +def unbind_platform_one(dev_name): > + filename = "/sys/bus/platform/devices/%s/driver" % dev_name > + > + if exists(filename): > + try: > + f = open(os.path.join(filename, "unbind"), "w") > + except OSError as err: > + sys.exit("Error: unbind failed for %s - Cannot open %s: %s" % > + (dev_name, os.path.join(filename, "unbind"), err)) > + f.write(dev_name) > + f.close() > + filename = "/sys/bus/platform/devices/%s/driver_override" % dev_name > + try: > + f = open(filename, "w") > + except OSError as err: > + sys.exit("Error: unbind failed for %s - Cannot open %s: %s" % > + (dev_name, filename, err)) > + f.write("") > + f.close() > + print("Successfully unbind platform device %s" % dev_name) > + > + Looks fine, but probably worth the effort in the future to update to current Python style guidelines. Applies to all of devbind. Acked-by: Stephen Hemminger ************* Module dpdk-devbind usertools/dpdk-devbind.py:1:0: C0114: Missing module docstring (missing-module-docstring) usertools/dpdk-devbind.py:1:0: C0103: Module name "dpdk-devbind" doesn't conform to snake_case naming style (invalid-name) usertools/dpdk-devbind.py:104:0: C0103: Constant name "loaded_modules" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:107:0: C0103: Constant name "b_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:108:0: C0103: Constant name "status_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:109:0: C0103: Constant name "force_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:110:0: C0103: Constant name "noiommu_flag" doesn't conform to UPPER_CASE naming style (invalid-name) usertools/dpdk-devbind.py:115:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:116:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:142:17: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:150:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:151:4: W0601: Global variable 'platform_devices' undefined at the module level (global-variable-undefined) usertools/dpdk-devbind.py:157:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:171:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:212:33: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:226:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:234:4: W0602: Using global for 'devices' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:235:4: W0602: Using global for 'dpdk_drivers' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:246:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:248:31: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:278:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:278:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:299:51: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:230:0: R0912: Too many branches (21/12) (too-many-branches) usertools/dpdk-devbind.py:311:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:312:4: C0200: Consider using enumerate instead of iterating with range and len (consider-using-enumerate) usertools/dpdk-devbind.py:312:4: R1702: Too many nested blocks (6/5) (too-many-nested-blocks) usertools/dpdk-devbind.py:343:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:343:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:352:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:356:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:357:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:361:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:363:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:367:19: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:361:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:369:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:371:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:375:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:369:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:382:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:388:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:393:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:395:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:397:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:395:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:403:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:404:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:407:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:410:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:414:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:417:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:419:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:425:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:428:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:417:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:430:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:432:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:439:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:442:10: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:430:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:453:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:460:18: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:474:19: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:477:20: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:479:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:483:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:486:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:491:23: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:493:20: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:495:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:500:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:504:22: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:509:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:493:20: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:511:12: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:513:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:528:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:537:15: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:511:12: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:540:16: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:542:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:548:21: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:445:0: R0911: Too many return statements (9/6) (too-many-return-statements) usertools/dpdk-devbind.py:445:0: R0912: Too many branches (18/12) (too-many-branches) usertools/dpdk-devbind.py:445:0: R0915: Too many statements (61/50) (too-many-statements) usertools/dpdk-devbind.py:540:16: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) usertools/dpdk-devbind.py:556:8: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:556:17: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:582:4: W0602: Using global for 'noiommu_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:586:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:596:13: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) usertools/dpdk-devbind.py:605:4: W0602: Using global for 'devices' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:614:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:622:17: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:644:18: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:644:62: W0631: Using possibly undefined loop variable 'd' (undefined-loop-variable) usertools/dpdk-devbind.py:645:8: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:645:17: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:665:10: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:672:31: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:677:31: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:683:0: C0116: Missing function or method docstring (missing-function-docstring) usertools/dpdk-devbind.py:684:4: W0602: Using global for 'dpdk_drivers' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:690:4: C0206: Consider iterating with .items() (consider-using-dict-items) usertools/dpdk-devbind.py:690:13: C0201: Consider iterating the dictionary directly instead of calling .keys() (consider-iterating-dictionary) usertools/dpdk-devbind.py:704:14: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:712:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:718:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:722:24: C0209: Formatting a regular string which could be an f-string (consider-using-f-string) usertools/dpdk-devbind.py:731:7: E0606: Possibly using variable 'status_dev' before assignment (possibly-used-before-assignment) usertools/dpdk-devbind.py:777:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:778:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:779:4: W0601: Global variable 'status_dev' undefined at the module level (global-variable-undefined) usertools/dpdk-devbind.py:780:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:781:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:782:4: W0603: Using the global statement (global-statement) usertools/dpdk-devbind.py:887:4: W0602: Using global for 'b_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:888:4: W0602: Using global for 'status_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:889:4: W0602: Using global for 'force_flag' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:890:4: W0602: Using global for 'args' but no assignment is done (global-variable-not-assigned) usertools/dpdk-devbind.py:916:9: W1514: Using open without explicitly specifying an encoding (unspecified-encoding) ------------------------------------------------------------------ Your code has been rated at 7.69/10 (previous run: 7.69/10, +0.00)