Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5296795pxv; Wed, 21 Jul 2021 01:58:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt3IO+NfTA7WKQpAwYvCp3LyrM5X4/dN9qWW8c57gKfJyOb/K6hv/SnVEOoKRGNGeTSelf X-Received: by 2002:a05:6830:78c:: with SMTP id w12mr21947358ots.162.1626857914768; Wed, 21 Jul 2021 01:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626857914; cv=none; d=google.com; s=arc-20160816; b=kDzJxxjVje3K7x2CKmflxTuxpBOmQr1cDFHsSD5wf9eEeGw6zk4++J6RjhOEew9gHf bLiXnRY+Srgx2l92td99RHQGckYFmH8cTwji3bIdY3uzxXYb1z/4n5IpWMmVUDSScauQ kQz2Hak5hsKO9CRXURKK5Nq+juh2X13cMeZGwZMxqgUouLfKmlPsKoBE8Sk3eVaFDtaE yFOTpblEu7kW/ymX8bMm8tDD6oXvipw8cLMk8/4vXUwQQxqz+y8L8zUjbKRtDUEMMo/Z jhPPHz4snLgTUuKZSr535Ex+0z3gkm0NNK/1rvW3b++pG8lanN8Jm0k2Fk/iUYKVI/SK 4qhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=lbKLsQWsN6fkb7O6ZUlhoVVqav5/VwdwpLNKtHOA70E=; b=yL7Lvwqt5uP9jJj6CVwrjB92009nW2/dQJrOPo5ItJj9jPmiVi2Ui5KUUplUI2E692 54E1Fw/3+DAZ7xYGO5jObuIX6q0+gV2WGBe3BG40PINAwklq9AahHZ7cRxfKDOOO6/B5 Zf8gwH6zN1/f8xuyj13ApoQQ4Djh6fNxki9EGrLdPrP2BfH+z2l7403OUer4ZGud0t/w wovop2UgEEki9XVDvden5EF0nrZGBH0nHmGL8ALSzp3ivQuO96y4dBlkvZ1mGdR5zizC b3N9A8Xt691rSN5v5fhM7Hl3F4jkVZY8FncqLP3fH9x+FYctuIEQcTBrqkYnZtuVcQBj 2afQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h9si30915678jaj.25.2021.07.21.01.58.22; Wed, 21 Jul 2021 01:58:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237010AbhGUIMy (ORCPT + 99 others); Wed, 21 Jul 2021 04:12:54 -0400 Received: from mga04.intel.com ([192.55.52.120]:29425 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236899AbhGUH5g (ORCPT ); Wed, 21 Jul 2021 03:57:36 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10051"; a="209494670" X-IronPort-AV: E=Sophos;i="5.84,257,1620716400"; d="scan'208";a="209494670" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 01:37:52 -0700 X-IronPort-AV: E=Sophos;i="5.84,257,1620716400"; d="scan'208";a="470087364" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 01:37:51 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1m67jd-00GYqL-0s; Wed, 21 Jul 2021 11:37:45 +0300 Date: Wed, 21 Jul 2021 11:37:45 +0300 From: Andy Shevchenko To: Jean Delvare Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] i2c: parport: Switch to use module_parport_driver() Message-ID: References: <20210712141119.22426-1-andriy.shevchenko@linux.intel.com> <20210721102146.66a486bc@endymion> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210721102146.66a486bc@endymion> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 10:21:46AM +0200, Jean Delvare wrote: > Hi Andy, > > On Mon, 12 Jul 2021 17:11:19 +0300, Andy Shevchenko wrote: > > Switch to use module_parport_driver() to reduce boilerplate code. > > This has the downside of moving the sanity check of the type parameter > to run time, instead of driver load time. In particular this means that > loading the i2c-parport driver without specifying the type will no > longer fail. And this is actually an advantage of the change if you think about it. Now we can have a module that won't fail at boot time and give the user a chance to amend parameter at run time if it was wrong at boot time. > The driver will load successfully, but won't do anything. > > While I prefer user errors to be reported as soon as possible, I don't > really mind here, as parallel port drivers are not something worth > debating over at this point in time. As a matter of fact, I can't > possibly test this change as I no longer have a parallel port on any of > my systems. > > So if that's the direction we want to take then so be it. > > Reviewed-by: Jean Delvare Thanks! > > Signed-off-by: Andy Shevchenko > > --- > > v2: fixed compilation error (Jean, LKP) > > drivers/i2c/busses/i2c-parport.c | 36 ++++++++++---------------------- > > 1 file changed, 11 insertions(+), 25 deletions(-) > > > > diff --git a/drivers/i2c/busses/i2c-parport.c b/drivers/i2c/busses/i2c-parport.c > > index a535889acca6..231145c48728 100644 > > --- a/drivers/i2c/busses/i2c-parport.c > > +++ b/drivers/i2c/busses/i2c-parport.c > > @@ -267,6 +267,16 @@ static void i2c_parport_attach(struct parport *port) > > int i; > > struct pardev_cb i2c_parport_cb; > > > > + if (type < 0) { > > + pr_warn("adapter type unspecified\n"); > > + return; > > + } > > + > > + if (type >= ARRAY_SIZE(adapter_parm)) { > > + pr_warn("invalid type (%d)\n", type); > > + return; > > + } > > + > > for (i = 0; i < MAX_DEVICE; i++) { > > if (parport[i] == -1) > > continue; > > @@ -392,32 +402,8 @@ static struct parport_driver i2c_parport_driver = { > > .detach = i2c_parport_detach, > > .devmodel = true, > > }; > > - > > -/* ----- Module loading, unloading and information ------------------------ */ > > - > > -static int __init i2c_parport_init(void) > > -{ > > - if (type < 0) { > > - pr_warn("adapter type unspecified\n"); > > - return -ENODEV; > > - } > > - > > - if (type >= ARRAY_SIZE(adapter_parm)) { > > - pr_warn("invalid type (%d)\n", type); > > - return -ENODEV; > > - } > > - > > - return parport_register_driver(&i2c_parport_driver); > > -} > > - > > -static void __exit i2c_parport_exit(void) > > -{ > > - parport_unregister_driver(&i2c_parport_driver); > > -} > > +module_parport_driver(i2c_parport_driver); > > > > MODULE_AUTHOR("Jean Delvare "); > > MODULE_DESCRIPTION("I2C bus over parallel port"); > > MODULE_LICENSE("GPL"); > > - > > -module_init(i2c_parport_init); > > -module_exit(i2c_parport_exit); > > > -- > Jean Delvare > SUSE L3 Support -- With Best Regards, Andy Shevchenko