From patchwork Wed Dec 13 10:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847926 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="RXZzKZFN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxYYQ2383z9sBZ for ; Wed, 13 Dec 2017 21:57:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752656AbdLMK4u (ORCPT ); Wed, 13 Dec 2017 05:56:50 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:40731 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752509AbdLMK4f (ORCPT ); Wed, 13 Dec 2017 05:56:35 -0500 Received: by mail-wm0-f65.google.com with SMTP id f206so4144889wmf.5 for ; Wed, 13 Dec 2017 02:56:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XDME3bddyhQk4fL+xUYAxpwET+OFlHRb3dbsfvz7Ntg=; b=RXZzKZFNl9bbCRA66dzxnlIO6lK66zFN+RZLyCAn8VesPpQ52uwmPtghuOa0BGl8lU 5fpcQB+qF4In4Py1v2ocz1O9WvgZtJIJqMPenBGi7HKlKpbr8FrFsnHqODhrGEpiTlz+ gXio1zi+PhMDnc3SXZTEHLgT0GfiX8tULw8UrU0snlD8PBuRbGveTAgrzet6tHScQrbi GmDA3HmBBfhElBp1dsN6h/c5rwArzyfT4ZT43bzPXpT+vNkQ2/FD9wJsmDEg4iZkvXp8 b8TsQqgxqwnahUvpXLQwhaYFgbtvhCNq48/3/K/GMe6CTxrQ0QywmBUhhE0KdtluEqCC n1/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XDME3bddyhQk4fL+xUYAxpwET+OFlHRb3dbsfvz7Ntg=; b=R8PLp1yaRpW75wEy8s5tCD6By+GTl1WwBDZz2e6QsuKTTchWJK626UhgfnzwVrD7Mt mTs4/6AI2cS0rH7bc454NBTJvhtx6qHk3MybBnNh3leKMEXRaDbbHgsQJcUnY7hq+X1y 5LeOmOIe7BNp4Ua4eli+XC5R/FlxTrPX/6A1AP6ZS7aSgbkUQ6nBBKGyEFSeaK5xt0s2 YjGLg7ehxIfPiHKcEFLnuWFuCh5UpeazOf2k+k45WHu1jK7jM72y8w9dy/JwfaUtaiy7 mtZGnAGe2INpk3jZPHAyiP83R7q3+AUKmIXdSO9Q0TBu+HwnKHoxsctJx2Ev0zxyTrUc c0ng== X-Gm-Message-State: AKGB3mIyf+qP72T91I5snbrE9FJE7P7MYK/1LYYfvOFFyM4FgW1zR/YY 9UNuso1OyyFm+Z014aN2jheXGucVYaU= X-Google-Smtp-Source: ACJfBougYHgQ8Cev1nekKdboB2pQZ/LpwuZvKz+va82yMy65xwR/BuC7tv9EMU9g0ieYX5MdyYn9hQ== X-Received: by 10.28.196.70 with SMTP id u67mr1778692wmf.100.1513162594312; Wed, 13 Dec 2017 02:56:34 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id p15sm456735wre.24.2017.12.13.02.56.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 02:56:33 -0800 (PST) From: Bartosz Golaszewski To: Joe Perches , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Peter Rosin , linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 1/2] eeprom: at24: fix coding style issues Date: Wed, 13 Dec 2017 11:56:23 +0100 Message-Id: <20171213105624.27058-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213105624.27058-1-brgl@bgdev.pl> References: <20171213105624.27058-1-brgl@bgdev.pl> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Fix issues reported by checkpatch for at24.c. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 625b00166117..87b68ef07dfc 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -70,8 +70,8 @@ struct at24_data { */ struct mutex lock; - unsigned write_max; - unsigned num_addresses; + unsigned int write_max; + unsigned int num_addresses; unsigned int offset_adj; struct nvmem_config nvmem_config; @@ -93,7 +93,7 @@ struct at24_data { * * This value is forced to be a power of two so that writes align on pages. */ -static unsigned io_limit = 128; +static unsigned int io_limit = 128; module_param(io_limit, uint, 0); MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); @@ -101,7 +101,7 @@ MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); * Specs often allow 5 msec for a page write, sometimes 20 msec; * it's important to recover from write timeouts. */ -static unsigned write_timeout = 25; +static unsigned int write_timeout = 25; module_param(write_timeout, uint, 0); MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); @@ -111,8 +111,8 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_BITMASK(x) (BIT(x) - 1) /* create non-zero magic value for given eeprom parameters */ -#define AT24_DEVICE_MAGIC(_len, _flags) \ - ((1 << AT24_SIZE_FLAGS | (_flags)) \ +#define AT24_DEVICE_MAGIC(_len, _flags) \ + ((1 << AT24_SIZE_FLAGS | (_flags)) \ << AT24_SIZE_BYTELEN | ilog2(_len)) /* @@ -264,7 +264,7 @@ MODULE_DEVICE_TABLE(acpi, at24_acpi_ids); static struct at24_client *at24_translate_offset(struct at24_data *at24, unsigned int *offset) { - unsigned i; + unsigned int i; if (at24->chip.flags & AT24_FLAG_ADDR16) { i = *offset >> 16; @@ -319,7 +319,7 @@ static ssize_t at24_regmap_read(struct at24_data *at24, char *buf, static size_t at24_adjust_write_count(struct at24_data *at24, unsigned int offset, size_t count) { - unsigned next_page; + unsigned int next_page; /* write_max is at most a page */ if (count > at24->write_max) @@ -515,7 +515,7 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) bool writable; struct at24_data *at24; int err; - unsigned i, num_addresses; + unsigned int i, num_addresses; const struct regmap_config *config; u8 test_byte; From patchwork Wed Dec 13 10:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 847925 X-Patchwork-Delegate: bartekgola@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="qMj6esSU"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3yxYXy6P8Gz9sBZ for ; Wed, 13 Dec 2017 21:56:50 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752357AbdLMK4t (ORCPT ); Wed, 13 Dec 2017 05:56:49 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:43810 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752543AbdLMK4g (ORCPT ); Wed, 13 Dec 2017 05:56:36 -0500 Received: by mail-wm0-f66.google.com with SMTP id n138so4125332wmg.2 for ; Wed, 13 Dec 2017 02:56:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=o25aBwBCheGbZ01vzu9XGg1CWm4TKRvtLXcqk4rMRLM=; b=qMj6esSUryvWrdJYhZlT7SfoAYSq+losknx6DDnvchYZWH3J0g24bVUs/cYRMC8ixh DrtQyXI1cUid77fXq6QpWwPJQ3WS+9ZN0/0H7U3+9UWhx8VzzfsnJuTnYZ2uW2aNwzT/ 7WKFetmixF3OvhXHUZQWCwpo0QHtgWXb4aDSF4CaM1Wo4OMOeh3dN8gkFiF2aem1jijJ L1k24KqakgA/3vT7Em/hfKdEyoQ19qN3/a6lnpH7jiMpeYvht154D8ksERwNYFc92Iz/ PwSQVbIMoJGR43AyLtI/kA7rf2Xyc+c5XnThpuTcaeWM4fcShJpxTHbDI75GotEEnedr L/qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=o25aBwBCheGbZ01vzu9XGg1CWm4TKRvtLXcqk4rMRLM=; b=RHHeJWkLXc9F7yLhj36Gftb5KgSWIw25eZc7bkDwtk9xDcTtotna7waSh/d3jRc8mk fafX5zC5kkMKu/uWS2ifaI3oOkKbRknpu36J4jz50HN9H9IQB3cDG4MKKj+TTrkNyH1z OO3tGWyE5dEULhUB0bebae6brNjgzzYnQet8xPtUWCWRglhMpDW82AL8b3JpFEM51WDL a2X/78FcFvC9lwp21SB8+hYnL2Udc+LqEOE7k/d4ms/JxDxZK2uynFIq5LkbyqqPPG2x HRxf8KIdiI3Ou4cgyeNRxA+jhD+1w05/l4kJb+Jd/zzcd9GJlzYpNM5TdegZuSxmkDu+ c+CQ== X-Gm-Message-State: AKGB3mLL8eYncFIt3sBkhhPb+Im4VO7IKdUlTc7+dKBsu5QtDTriSyMZ phhe1dajxkKKu6cjIXsC0KvXHQ== X-Google-Smtp-Source: ACJfBov3zTYFo/Awxw26MYm6Hyj6QYdPfZYoz0tEG3ebvb8KPU2sk7nfA7anIJRh0vj+Mqj1rBb1nQ== X-Received: by 10.28.102.6 with SMTP id a6mr1511986wmc.63.1513162595605; Wed, 13 Dec 2017 02:56:35 -0800 (PST) Received: from bgdev-debian.baylibre.local ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id p15sm456735wre.24.2017.12.13.02.56.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Dec 2017 02:56:34 -0800 (PST) From: Bartosz Golaszewski To: Joe Perches , Andy Shevchenko , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= , Peter Rosin , linux-i2c@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v4 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Date: Wed, 13 Dec 2017 11:56:24 +0100 Message-Id: <20171213105624.27058-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213105624.27058-1-brgl@bgdev.pl> References: <20171213105624.27058-1-brgl@bgdev.pl> Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org There are a couple symbols defined in the driver source file which are missing the at24_ prefix. This patch fixes that. For module params: use module_param_named() in order to not break userspace. Signed-off-by: Bartosz Golaszewski --- drivers/misc/eeprom/at24.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 87b68ef07dfc..c1d2f7e76f92 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -93,17 +93,17 @@ struct at24_data { * * This value is forced to be a power of two so that writes align on pages. */ -static unsigned int io_limit = 128; -module_param(io_limit, uint, 0); -MODULE_PARM_DESC(io_limit, "Maximum bytes per I/O (default 128)"); +static unsigned int at24_io_limit = 128; +module_param_named(io_limit, at24_io_limit, uint, 0); +MODULE_PARM_DESC(at24_io_limit, "Maximum bytes per I/O (default 128)"); /* * Specs often allow 5 msec for a page write, sometimes 20 msec; * it's important to recover from write timeouts. */ -static unsigned int write_timeout = 25; -module_param(write_timeout, uint, 0); -MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); +static unsigned int at24_write_timeout = 25; +module_param_named(write_timeout, at24_write_timeout, uint, 0); +MODULE_PARM_DESC(at24_write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_SIZE_BYTELEN 5 #define AT24_SIZE_FLAGS 8 @@ -126,8 +126,9 @@ MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); * iteration of processing the request. Both should be unsigned integers * holding at least 32 bits. */ -#define loop_until_timeout(tout, op_time) \ - for (tout = jiffies + msecs_to_jiffies(write_timeout), op_time = 0; \ +#define at24_loop_until_timeout(tout, op_time) \ + for (tout = jiffies + msecs_to_jiffies(at24_write_timeout), \ + op_time = 0; \ op_time ? time_before(op_time, tout) : true; \ usleep_range(1000, 1500), op_time = jiffies) @@ -290,13 +291,13 @@ static ssize_t at24_regmap_read(struct at24_data *at24, char *buf, regmap = at24_client->regmap; client = at24_client->client; - if (count > io_limit) - count = io_limit; + if (count > at24_io_limit) + count = at24_io_limit; /* adjust offset for mac and serial read ops */ offset += at24->offset_adj; - loop_until_timeout(timeout, read_time) { + at24_loop_until_timeout(timeout, read_time) { ret = regmap_bulk_read(regmap, offset, buf, count); dev_dbg(&client->dev, "read %zu@%d --> %d (%ld)\n", count, offset, ret, jiffies); @@ -347,7 +348,7 @@ static ssize_t at24_regmap_write(struct at24_data *at24, const char *buf, client = at24_client->client; count = at24_adjust_write_count(at24, offset, count); - loop_until_timeout(timeout, write_time) { + at24_loop_until_timeout(timeout, write_time) { ret = regmap_bulk_write(regmap, offset, buf, count); dev_dbg(&client->dev, "write %zu@%d --> %d (%ld)\n", count, offset, ret, jiffies); @@ -613,7 +614,8 @@ static int at24_probe(struct i2c_client *client, const struct i2c_device_id *id) writable = !(chip.flags & AT24_FLAG_READONLY); if (writable) { - at24->write_max = min_t(unsigned int, chip.page_size, io_limit); + at24->write_max = min_t(unsigned int, + chip.page_size, at24_io_limit); if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C) && at24->write_max > I2C_SMBUS_BLOCK_MAX) at24->write_max = I2C_SMBUS_BLOCK_MAX; @@ -728,12 +730,12 @@ static struct i2c_driver at24_driver = { static int __init at24_init(void) { - if (!io_limit) { - pr_err("at24: io_limit must not be 0!\n"); + if (!at24_io_limit) { + pr_err("at24: at24_io_limit must not be 0!\n"); return -EINVAL; } - io_limit = rounddown_pow_of_two(io_limit); + at24_io_limit = rounddown_pow_of_two(at24_io_limit); return i2c_add_driver(&at24_driver); } module_init(at24_init);