* [PATCH v2 0/2] eeprom: at24: coding style fixes @ 2017-12-06 13:01 Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 1/2] eeprom: at24: fix coding style issues Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Bartosz Golaszewski 0 siblings, 2 replies; 6+ messages in thread From: Bartosz Golaszewski @ 2017-12-06 13:01 UTC (permalink / raw) To: Uwe Kleine-König, linux-i2c; +Cc: linux-kernel, Bartosz Golaszewski Just two patches fixing minor coding style issues. The first one contains fixes for problems reported by checkpatch. The second adds a common prefix to all symbols in at24.c. v1 -> v2: - don't breal the user space: use module_param_named() for module parameters Bartosz Golaszewski (2): eeprom: at24: fix coding style issues eeprom: at24: use a common prefix for all symbols in at24.c drivers/misc/eeprom/at24.c | 48 ++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) -- 2.15.1 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v2 1/2] eeprom: at24: fix coding style issues 2017-12-06 13:01 [PATCH v2 0/2] eeprom: at24: coding style fixes Bartosz Golaszewski @ 2017-12-06 13:01 ` Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Bartosz Golaszewski 1 sibling, 0 replies; 6+ messages in thread From: Bartosz Golaszewski @ 2017-12-06 13:01 UTC (permalink / raw) To: Uwe Kleine-König, linux-i2c; +Cc: linux-kernel, Bartosz Golaszewski Fix issues reported by checkpatch for at24.c. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- drivers/misc/eeprom/at24.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 625b00166117..2426f2c111c7 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,16 +93,16 @@ struct at24_data { * * This value is forced to be a power of two so that writes align on pages. */ -static unsigned io_limit = 128; -module_param(io_limit, uint, 0); +static unsigned int io_limit = 128; +module_param(io_limit, uint, 0000); 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; -module_param(write_timeout, uint, 0); +static unsigned int write_timeout = 25; +module_param(write_timeout, uint, 0000); MODULE_PARM_DESC(write_timeout, "Time (in ms) to try writes (default 25)"); #define AT24_SIZE_BYTELEN 5 @@ -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; -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c 2017-12-06 13:01 [PATCH v2 0/2] eeprom: at24: coding style fixes Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 1/2] eeprom: at24: fix coding style issues Bartosz Golaszewski @ 2017-12-06 13:01 ` Bartosz Golaszewski 2017-12-06 13:40 ` Peter Rosin 1 sibling, 1 reply; 6+ messages in thread From: Bartosz Golaszewski @ 2017-12-06 13:01 UTC (permalink / raw) To: Uwe Kleine-König, linux-i2c; +Cc: linux-kernel, Bartosz Golaszewski 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 not to break the userspace. Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- 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 2426f2c111c7..dd0903c7df39 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, 0000); -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, 0000); +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, 0000); -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, 0000); +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_tool_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_tool_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_tool_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); -- 2.15.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c 2017-12-06 13:01 ` [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Bartosz Golaszewski @ 2017-12-06 13:40 ` Peter Rosin 2017-12-06 14:29 ` Bartosz Golaszewski 0 siblings, 1 reply; 6+ messages in thread From: Peter Rosin @ 2017-12-06 13:40 UTC (permalink / raw) To: Bartosz Golaszewski, Uwe Kleine-König, linux-i2c; +Cc: linux-kernel Hi! Some nits... On 2017-12-06 14:01, Bartosz Golaszewski wrote: > 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 not to break the > userspace. I'd write that as "...in order to not break userspace" > > Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> > --- > 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 2426f2c111c7..dd0903c7df39 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, 0000); > -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, 0000); > +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, 0000); > -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, 0000); > +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_tool_until_timeout(tout, op_time) \ s/tool/loop/ .oO(hmm, is that a figure skating jump? naaah, guess not...) Cheers, peda > + 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_tool_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_tool_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); > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c 2017-12-06 13:40 ` Peter Rosin @ 2017-12-06 14:29 ` Bartosz Golaszewski 2017-12-06 17:27 ` Peter Rosin 0 siblings, 1 reply; 6+ messages in thread From: Bartosz Golaszewski @ 2017-12-06 14:29 UTC (permalink / raw) To: Peter Rosin; +Cc: Uwe Kleine-König, linux-i2c, Linux Kernel Mailing List 2017-12-06 14:40 GMT+01:00 Peter Rosin <peda@axentia.se>: > Hi! > > Some nits... > > On 2017-12-06 14:01, Bartosz Golaszewski wrote: >> 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 not to break the >> userspace. > > I'd write that as "...in order to not break userspace" > I would love to hear an English native speaker's opinion on that. :) >> >> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> >> --- >> 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 2426f2c111c7..dd0903c7df39 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, 0000); >> -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, 0000); >> +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, 0000); >> -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, 0000); >> +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_tool_until_timeout(tout, op_time) \ > > s/tool/loop/ > Yep, that's a good idea. > .oO(hmm, is that a figure skating jump? naaah, guess not...) > > Cheers, > peda > >> + 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_tool_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_tool_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); >> > ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c 2017-12-06 14:29 ` Bartosz Golaszewski @ 2017-12-06 17:27 ` Peter Rosin 0 siblings, 0 replies; 6+ messages in thread From: Peter Rosin @ 2017-12-06 17:27 UTC (permalink / raw) To: Bartosz Golaszewski Cc: Uwe Kleine-König, linux-i2c, Linux Kernel Mailing List On 2017-12-06 15:29, Bartosz Golaszewski wrote: > 2017-12-06 14:40 GMT+01:00 Peter Rosin <peda@axentia.se>: >> Hi! >> >> Some nits... >> >> On 2017-12-06 14:01, Bartosz Golaszewski wrote: >>> 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 not to break the >>> userspace. >> >> I'd write that as "...in order to not break userspace" >> > > I would love to hear an English native speaker's opinion on that. :) "not to" or "to not" is a matter of style/taste. I mainly wanted to point out that the definite article of "userspace" should be removed, because you are not talking about one particular userspace. Cheers, peda ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-12-06 17:27 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-12-06 13:01 [PATCH v2 0/2] eeprom: at24: coding style fixes Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 1/2] eeprom: at24: fix coding style issues Bartosz Golaszewski 2017-12-06 13:01 ` [PATCH v2 2/2] eeprom: at24: use a common prefix for all symbols in at24.c Bartosz Golaszewski 2017-12-06 13:40 ` Peter Rosin 2017-12-06 14:29 ` Bartosz Golaszewski 2017-12-06 17:27 ` Peter Rosin
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.