Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5283497pxv; Wed, 21 Jul 2021 01:33:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9nDAY0jyqXH2ngJjHylMuQcmoPlN9K2wyC4eUFfX7LB+352fA4djcnkDvwf2IflLIA/b3 X-Received: by 2002:a17:906:2642:: with SMTP id i2mr37701145ejc.323.1626856434714; Wed, 21 Jul 2021 01:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626856434; cv=none; d=google.com; s=arc-20160816; b=A4yNT0/7PEXJ4dc9ehzXKWAMIcZe3jRTIHMoqsoWx1+Ui/QQg1f4N9+HH6n+gMXcFU hyAtutzyQa0UBI8t/xvaNgkigC6FrZ999p+RwJkP4ZWc66mWHN/iV2x4s+jI4A0nyfoT czcf5ZIXNuntTynCW1ArBDZ3NiGvkI0ka11a8yxS/sFpQ+FC6DFERBIw0rhWTyac0TAL Mm7v1S89L7LxVT3gLyZhVpeuAjExRgiddaM6y2sTuNhGqcKl+RZsPlvjSJDNc3vOUQkJ 1iWACN8Y+dkpp2LzJ5YyUvZ3aTumn3n8QxfkPe2Mqp8mf2/Q5awT+4eISIIQ0BcGQ1+B NCPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature:dkim-signature; bh=tcl5cDaIqMqE73ZOqGYcVvyHb9eNkCSZ2iF/c1CRjCM=; b=RT8BYYJIQloo2dX6Ebg7IVgH6lFepYCenlrst6aCQHbvd7Cmoo46Je0MM4moKmwKja nYc46wt4ffrxUgBhSmzhBSwc33yn0TOEs59ICq6ti2tP/0PBSkvM46cJUBvJuNScOQ2o w7BuKdPjE3NhRYoHCSTi1njoUNlAt1wgiKA/rs+2PQM77jO3yuW74ttMyD5yng+If5kw +7PeW+coyFW5qbo0ru1q/QXehPFw05UXSdw/CFOVx5FJTOMr76wXYtvgEqb4ozO1IduQ Ru6snHHswoyyPxSB7AjQ+mBM78zNGa6hE8V59mvNa5RWrVvtpYintqjS6HqGu30QK1r1 UCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=anyXctr5; dkim=neutral (no key) header.i=@suse.de; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h2si26461214ejx.355.2021.07.21.01.33.31; Wed, 21 Jul 2021 01:33:54 -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; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=anyXctr5; dkim=neutral (no key) header.i=@suse.de; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237097AbhGUHuv (ORCPT + 99 others); Wed, 21 Jul 2021 03:50:51 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:38450 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234630AbhGUHlX (ORCPT ); Wed, 21 Jul 2021 03:41:23 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4671F1FE7C; Wed, 21 Jul 2021 08:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1626855711; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tcl5cDaIqMqE73ZOqGYcVvyHb9eNkCSZ2iF/c1CRjCM=; b=anyXctr5WzEJX8ZuGNc4atC6Qe2T/8PH78c7Pq5ensllQyfOBRG/dqGX7l4XR5VREILJTq PCUTYgQp/ahe4N64AZD3QIlh9sSyDt7MDu1eY1YTkeZ3ePlDdz7pob0pzgHKn6cFLWrX4R xrP72CSWpsLniQymRT+7eqW22oqmWvI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1626855711; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tcl5cDaIqMqE73ZOqGYcVvyHb9eNkCSZ2iF/c1CRjCM=; b=a4YxmfT55TUjivfjD/lVONl60kzHpD3Pk3vzXYw2qvNFHQFF0idO6SKCqwQmYt0FSKu7fR hR8qWESklDplLCBg== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id 0E7C913BC9; Wed, 21 Jul 2021 08:21:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id tVM0AB/Z92BkIgAAGKfGzw (envelope-from ); Wed, 21 Jul 2021 08:21:50 +0000 Date: Wed, 21 Jul 2021 10:21:46 +0200 From: Jean Delvare To: Andy Shevchenko 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: <20210721102146.66a486bc@endymion> In-Reply-To: <20210712141119.22426-1-andriy.shevchenko@linux.intel.com> References: <20210712141119.22426-1-andriy.shevchenko@linux.intel.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.32; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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 > 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