Message ID | 20210118003428.568892-4-djrscally@gmail.com (mailing list archive) |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | Introduce intel_skl_int3472 driver | expand |
Hi Daniel, Thank you for the patch. On Mon, Jan 18, 2021 at 12:34:24AM +0000, Daniel Scally wrote: > Some places in the kernel allow users to map resources to a device > using device name (for example, gpiod_lookup_table). Currently > this involves waiting for the i2c_client to have been registered so we > can use dev_name(&client->dev). We want to add a function to allow users > to refer to an i2c device by name before it has been instantiated, so > create a macro for the format that's accessible outside the i2c layer > and use it in i2c_dev_set_name() > > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Daniel Scally <djrscally@gmail.com> I'd change the subject line to say "Add a format macro for I2C device names", as that's the most important part of the patch. Apart from that, Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > - Used format macro in i2c_dev_set_name() instead of sub func > > drivers/i2c/i2c-core-base.c | 4 ++-- > include/linux/i2c.h | 3 +++ > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 63ebf722a424..547b8926cac8 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -811,12 +811,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, > struct acpi_device *adev = ACPI_COMPANION(&client->dev); > > if (info && info->dev_name) { > - dev_set_name(&client->dev, "i2c-%s", info->dev_name); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); > return; > } > > if (adev) { > - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); > return; > } > > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index 56622658b215..4d40a4b46810 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -39,6 +39,9 @@ enum i2c_slave_event; > typedef int (*i2c_slave_cb_t)(struct i2c_client *client, > enum i2c_slave_event event, u8 *val); > > +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ > +#define I2C_DEV_NAME_FORMAT "i2c-%s" > + > /* I2C Frequency Modes */ > #define I2C_MAX_STANDARD_MODE_FREQ 100000 > #define I2C_MAX_FAST_MODE_FREQ 400000
Hi Daniel, On Mon, Jan 18, 2021 at 12:34:24AM +0000, Daniel Scally wrote: > Some places in the kernel allow users to map resources to a device > using device name (for example, gpiod_lookup_table). Currently > this involves waiting for the i2c_client to have been registered so we > can use dev_name(&client->dev). We want to add a function to allow users > to refer to an i2c device by name before it has been instantiated, so > create a macro for the format that's accessible outside the i2c layer > and use it in i2c_dev_set_name() > > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Daniel Scally <djrscally@gmail.com> > --- > - Used format macro in i2c_dev_set_name() instead of sub func > > drivers/i2c/i2c-core-base.c | 4 ++-- > include/linux/i2c.h | 3 +++ > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 63ebf722a424..547b8926cac8 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -811,12 +811,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, > struct acpi_device *adev = ACPI_COMPANION(&client->dev); > > if (info && info->dev_name) { > - dev_set_name(&client->dev, "i2c-%s", info->dev_name); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); > return; > } > > if (adev) { > - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); Over 80, please wrap. With that, Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> > return; > } > > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index 56622658b215..4d40a4b46810 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -39,6 +39,9 @@ enum i2c_slave_event; > typedef int (*i2c_slave_cb_t)(struct i2c_client *client, > enum i2c_slave_event event, u8 *val); > > +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ > +#define I2C_DEV_NAME_FORMAT "i2c-%s" > + > /* I2C Frequency Modes */ > #define I2C_MAX_STANDARD_MODE_FREQ 100000 > #define I2C_MAX_FAST_MODE_FREQ 400000 > -- > 2.25.1 >
On Mon, Jan 18, 2021 at 11:41:58AM +0200, Sakari Ailus wrote: > Hi Daniel, > > On Mon, Jan 18, 2021 at 12:34:24AM +0000, Daniel Scally wrote: > > Some places in the kernel allow users to map resources to a device > > using device name (for example, gpiod_lookup_table). Currently > > this involves waiting for the i2c_client to have been registered so we > > can use dev_name(&client->dev). We want to add a function to allow users > > to refer to an i2c device by name before it has been instantiated, so > > create a macro for the format that's accessible outside the i2c layer > > and use it in i2c_dev_set_name() > > > > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > > Signed-off-by: Daniel Scally <djrscally@gmail.com> > > --- > > - Used format macro in i2c_dev_set_name() instead of sub func > > > > drivers/i2c/i2c-core-base.c | 4 ++-- > > include/linux/i2c.h | 3 +++ > > 2 files changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > > index 63ebf722a424..547b8926cac8 100644 > > --- a/drivers/i2c/i2c-core-base.c > > +++ b/drivers/i2c/i2c-core-base.c > > @@ -811,12 +811,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, > > struct acpi_device *adev = ACPI_COMPANION(&client->dev); > > > > if (info && info->dev_name) { > > - dev_set_name(&client->dev, "i2c-%s", info->dev_name); > > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); > > return; > > } > > > > if (adev) { > > - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); > > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); > > Over 80, please wrap. > > With that, > > Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com> Or rather: Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com> > > > return; > > } > > > > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > > index 56622658b215..4d40a4b46810 100644 > > --- a/include/linux/i2c.h > > +++ b/include/linux/i2c.h > > @@ -39,6 +39,9 @@ enum i2c_slave_event; > > typedef int (*i2c_slave_cb_t)(struct i2c_client *client, > > enum i2c_slave_event event, u8 *val); > > > > +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ > > +#define I2C_DEV_NAME_FORMAT "i2c-%s" > > + > > /* I2C Frequency Modes */ > > #define I2C_MAX_STANDARD_MODE_FREQ 100000 > > #define I2C_MAX_FAST_MODE_FREQ 400000 > > -- > > 2.25.1 > > > > -- > Sakari Ailus
> > if (adev) { > > - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); > > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); > > Over 80, please wrap. I am not that strict with the 80, and I don't think it will improve readability here. It can stay this time IMO.
On Mon, Jan 18, 2021 at 12:34:24AM +0000, Daniel Scally wrote: > Some places in the kernel allow users to map resources to a device > using device name (for example, gpiod_lookup_table). Currently "...in the struct gpiod_lookup_table)." ? > this involves waiting for the i2c_client to have been registered so we I²C client ? > can use dev_name(&client->dev). We want to add a function to allow users > to refer to an i2c device by name before it has been instantiated, so I²C device ? > create a macro for the format that's accessible outside the i2c layer I²C layer ? > and use it in i2c_dev_set_name() Period at the end. For the record, I do not like wrapping below to 80 limit and agree with Wolfram. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > Signed-off-by: Daniel Scally <djrscally@gmail.com> > --- > - Used format macro in i2c_dev_set_name() instead of sub func > > drivers/i2c/i2c-core-base.c | 4 ++-- > include/linux/i2c.h | 3 +++ > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 63ebf722a424..547b8926cac8 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -811,12 +811,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, > struct acpi_device *adev = ACPI_COMPANION(&client->dev); > > if (info && info->dev_name) { > - dev_set_name(&client->dev, "i2c-%s", info->dev_name); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); > return; > } > > if (adev) { > - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); > + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); > return; > } > > diff --git a/include/linux/i2c.h b/include/linux/i2c.h > index 56622658b215..4d40a4b46810 100644 > --- a/include/linux/i2c.h > +++ b/include/linux/i2c.h > @@ -39,6 +39,9 @@ enum i2c_slave_event; > typedef int (*i2c_slave_cb_t)(struct i2c_client *client, > enum i2c_slave_event event, u8 *val); > > +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ > +#define I2C_DEV_NAME_FORMAT "i2c-%s" > + > /* I2C Frequency Modes */ > #define I2C_MAX_STANDARD_MODE_FREQ 100000 > #define I2C_MAX_FAST_MODE_FREQ 400000 > -- > 2.25.1 >
On Mon, Jan 18, 2021 at 09:28:34AM +0200, Laurent Pinchart wrote: > On Mon, Jan 18, 2021 at 12:34:24AM +0000, Daniel Scally wrote: > I'd change the subject line to say "Add a format macro for I2C device > names", as that's the most important part of the patch. Apart from that, Actually prefix can be "i2c: core: ". Hint: look at the git history to find what was lately used mostly. % git log --oneline -- drivers/i2c/i2c-*
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c index 63ebf722a424..547b8926cac8 100644 --- a/drivers/i2c/i2c-core-base.c +++ b/drivers/i2c/i2c-core-base.c @@ -811,12 +811,12 @@ static void i2c_dev_set_name(struct i2c_adapter *adap, struct acpi_device *adev = ACPI_COMPANION(&client->dev); if (info && info->dev_name) { - dev_set_name(&client->dev, "i2c-%s", info->dev_name); + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, info->dev_name); return; } if (adev) { - dev_set_name(&client->dev, "i2c-%s", acpi_dev_name(adev)); + dev_set_name(&client->dev, I2C_DEV_NAME_FORMAT, acpi_dev_name(adev)); return; } diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 56622658b215..4d40a4b46810 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -39,6 +39,9 @@ enum i2c_slave_event; typedef int (*i2c_slave_cb_t)(struct i2c_client *client, enum i2c_slave_event event, u8 *val); +/* I2C Device Name Format - to maintain consistency outside the i2c layer */ +#define I2C_DEV_NAME_FORMAT "i2c-%s" + /* I2C Frequency Modes */ #define I2C_MAX_STANDARD_MODE_FREQ 100000 #define I2C_MAX_FAST_MODE_FREQ 400000
Some places in the kernel allow users to map resources to a device using device name (for example, gpiod_lookup_table). Currently this involves waiting for the i2c_client to have been registered so we can use dev_name(&client->dev). We want to add a function to allow users to refer to an i2c device by name before it has been instantiated, so create a macro for the format that's accessible outside the i2c layer and use it in i2c_dev_set_name() Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Daniel Scally <djrscally@gmail.com> --- - Used format macro in i2c_dev_set_name() instead of sub func drivers/i2c/i2c-core-base.c | 4 ++-- include/linux/i2c.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-)