All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gene Chen <gene.chen.richtek@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Lee Jones <lee.jones@linaro.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
	Gene Chen <gene_chen@richtek.com>,
	shufan_lee@richtek.com, cy_huang@richtek.com,
	benjamin.chao@mediatek.com
Subject: Re: [PATCH 3/4] mfd: mt6360: Fix flow which is used to check ic exist
Date: Thu, 16 Jul 2020 17:53:36 +0800	[thread overview]
Message-ID: <CAE+NS36LOqnG+toSQcxVAeQHUqyvs9Z39tU7-ijkAntRUH6uqg@mail.gmail.com> (raw)
In-Reply-To: <3205bb9b-c7b4-c99a-2673-f3a56cc0addf@gmail.com>

Matthias Brugger <matthias.bgg@gmail.com> 於 2020年7月10日 週五 下午10:25寫道:
>
>
>
> On 07/07/2020 12:30, Gene Chen wrote:
> > From: Gene Chen <gene_chen@richtek.com>
> >
> > Fix flow which is used to check ic exist
> >
> > Signed-off-by: Gene Chen <gene_chen@richtek.com>
> > ---
> >   drivers/mfd/mt6360-core.c  | 28 +++++++++++++++++++---------
> >   include/linux/mfd/mt6360.h |  8 ++++----
> >   2 files changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c
> > index 2dd5918..4bb2949 100644
> > --- a/drivers/mfd/mt6360-core.c
> > +++ b/drivers/mfd/mt6360-core.c
> > @@ -293,6 +293,23 @@ static const struct mfd_cell mt6360_devs[] = {
> >                   NULL, 0, 0, "mediatek,mt6360-tcpc"),
> >   };
> >
> > +static int mt6360_check_vendor_info(struct mt6360_data *data)
> > +{
> > +     u32 info;
> > +     int ret;
> > +
> > +     ret = regmap_read(data->regmap, MT6360_REG_PMU_DEVINFO, &info);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     if ((info & MT6360_CHIPVEN_MASK) != MT6360_CHIPVEN_VAL)
> > +             return -ENODEV;
> > +
> > +     data->chip_rev = info & MT6360_CHIPREV_MASK;
> > +
> > +     return 0;
> > +}
> > +
> >   static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >       MT6360_PMU_SLAVEID,
> >       MT6360_PMIC_SLAVEID,
> > @@ -303,7 +320,6 @@ static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >   static int mt6360_probe(struct i2c_client *client)
> >   {
> >       struct mt6360_data *data;
> > -     unsigned int reg_data;
> >       int i, ret;
> >
> >       data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> > @@ -319,16 +335,10 @@ static int mt6360_probe(struct i2c_client *client)
> >               return PTR_ERR(data->regmap);
> >       }
> >
> > -     ret = regmap_read(data->regmap, MT6360_PMU_DEV_INFO, &reg_data);
> > +     ret = mt6360_check_vendor_info(data);
> >       if (ret) {
> > -             dev_err(&client->dev, "Device not found\n");
> > -             return ret;
> > -     }
> > -
> > -     data->chip_rev = reg_data & CHIP_REV_MASK;
> > -     if (data->chip_rev != CHIP_VEN_MT6360) {
>
> Why not only applying the MASK here instead of put this all in a new function?
>

I think merge the ic check flow into function is well-organized.
if not, i can restore the same as before.

> >               dev_err(&client->dev, "Device not supported\n");
> > -             return -ENODEV;
> > +             return ret;
> >       }
> >
> >       ret = devm_regmap_add_irq_chip(&client->dev, data->regmap, client->irq,
> > diff --git a/include/linux/mfd/mt6360.h b/include/linux/mfd/mt6360.h
> > index 9fc6718..5ec0f5d 100644
> > --- a/include/linux/mfd/mt6360.h
> > +++ b/include/linux/mfd/mt6360.h
> > @@ -30,7 +30,7 @@ struct mt6360_data {
> >   };
> >
> >   /* PMU register defininition */
> > -#define MT6360_PMU_DEV_INFO                  (0x00)
> > +#define MT6360_REG_PMU_DEVINFO                       (0x00)
> >   #define MT6360_PMU_CORE_CTRL1                       (0x01)
> >   #define MT6360_PMU_RST1                             (0x02)
> >   #define MT6360_PMU_CRCEN                    (0x03)
> > @@ -233,8 +233,8 @@ struct mt6360_data {
> >   #define MT6360_IRQ_REGNUM   16
> >   #define MT6360_IRQ_RETRIG   BIT(2)
> >
> > -#define CHIP_VEN_MASK                                (0xF0)
> > -#define CHIP_VEN_MT6360                              (0x50)
> > -#define CHIP_REV_MASK                                (0x0F)
> > +#define MT6360_CHIPVEN_MASK                  (0xF0)
> > +#define MT6360_CHIPVEN_VAL                   (0x50)
> > +#define MT6360_CHIPREV_MASK                  (0x0F)
>
> Same here as in the other patches. Don't just rename defines if there is no good
> reason.
>

Is easy to read a good reason to rename it?
if not, i can restore the same as before.

> Regards,
> Matthias
>
> >
> >   #endif /* __MT6360_H__ */
> >

WARNING: multiple messages have this Message-ID (diff)
From: Gene Chen <gene.chen.richtek@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Gene Chen <gene_chen@richtek.com>,
	linux-kernel@vger.kernel.org, cy_huang@richtek.com,
	benjamin.chao@mediatek.com, linux-mediatek@lists.infradead.org,
	Lee Jones <lee.jones@linaro.org>,
	linux-arm-kernel@lists.infradead.org, shufan_lee@richtek.com
Subject: Re: [PATCH 3/4] mfd: mt6360: Fix flow which is used to check ic exist
Date: Thu, 16 Jul 2020 17:53:36 +0800	[thread overview]
Message-ID: <CAE+NS36LOqnG+toSQcxVAeQHUqyvs9Z39tU7-ijkAntRUH6uqg@mail.gmail.com> (raw)
In-Reply-To: <3205bb9b-c7b4-c99a-2673-f3a56cc0addf@gmail.com>

Matthias Brugger <matthias.bgg@gmail.com> 於 2020年7月10日 週五 下午10:25寫道:
>
>
>
> On 07/07/2020 12:30, Gene Chen wrote:
> > From: Gene Chen <gene_chen@richtek.com>
> >
> > Fix flow which is used to check ic exist
> >
> > Signed-off-by: Gene Chen <gene_chen@richtek.com>
> > ---
> >   drivers/mfd/mt6360-core.c  | 28 +++++++++++++++++++---------
> >   include/linux/mfd/mt6360.h |  8 ++++----
> >   2 files changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c
> > index 2dd5918..4bb2949 100644
> > --- a/drivers/mfd/mt6360-core.c
> > +++ b/drivers/mfd/mt6360-core.c
> > @@ -293,6 +293,23 @@ static const struct mfd_cell mt6360_devs[] = {
> >                   NULL, 0, 0, "mediatek,mt6360-tcpc"),
> >   };
> >
> > +static int mt6360_check_vendor_info(struct mt6360_data *data)
> > +{
> > +     u32 info;
> > +     int ret;
> > +
> > +     ret = regmap_read(data->regmap, MT6360_REG_PMU_DEVINFO, &info);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     if ((info & MT6360_CHIPVEN_MASK) != MT6360_CHIPVEN_VAL)
> > +             return -ENODEV;
> > +
> > +     data->chip_rev = info & MT6360_CHIPREV_MASK;
> > +
> > +     return 0;
> > +}
> > +
> >   static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >       MT6360_PMU_SLAVEID,
> >       MT6360_PMIC_SLAVEID,
> > @@ -303,7 +320,6 @@ static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >   static int mt6360_probe(struct i2c_client *client)
> >   {
> >       struct mt6360_data *data;
> > -     unsigned int reg_data;
> >       int i, ret;
> >
> >       data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> > @@ -319,16 +335,10 @@ static int mt6360_probe(struct i2c_client *client)
> >               return PTR_ERR(data->regmap);
> >       }
> >
> > -     ret = regmap_read(data->regmap, MT6360_PMU_DEV_INFO, &reg_data);
> > +     ret = mt6360_check_vendor_info(data);
> >       if (ret) {
> > -             dev_err(&client->dev, "Device not found\n");
> > -             return ret;
> > -     }
> > -
> > -     data->chip_rev = reg_data & CHIP_REV_MASK;
> > -     if (data->chip_rev != CHIP_VEN_MT6360) {
>
> Why not only applying the MASK here instead of put this all in a new function?
>

I think merge the ic check flow into function is well-organized.
if not, i can restore the same as before.

> >               dev_err(&client->dev, "Device not supported\n");
> > -             return -ENODEV;
> > +             return ret;
> >       }
> >
> >       ret = devm_regmap_add_irq_chip(&client->dev, data->regmap, client->irq,
> > diff --git a/include/linux/mfd/mt6360.h b/include/linux/mfd/mt6360.h
> > index 9fc6718..5ec0f5d 100644
> > --- a/include/linux/mfd/mt6360.h
> > +++ b/include/linux/mfd/mt6360.h
> > @@ -30,7 +30,7 @@ struct mt6360_data {
> >   };
> >
> >   /* PMU register defininition */
> > -#define MT6360_PMU_DEV_INFO                  (0x00)
> > +#define MT6360_REG_PMU_DEVINFO                       (0x00)
> >   #define MT6360_PMU_CORE_CTRL1                       (0x01)
> >   #define MT6360_PMU_RST1                             (0x02)
> >   #define MT6360_PMU_CRCEN                    (0x03)
> > @@ -233,8 +233,8 @@ struct mt6360_data {
> >   #define MT6360_IRQ_REGNUM   16
> >   #define MT6360_IRQ_RETRIG   BIT(2)
> >
> > -#define CHIP_VEN_MASK                                (0xF0)
> > -#define CHIP_VEN_MT6360                              (0x50)
> > -#define CHIP_REV_MASK                                (0x0F)
> > +#define MT6360_CHIPVEN_MASK                  (0xF0)
> > +#define MT6360_CHIPVEN_VAL                   (0x50)
> > +#define MT6360_CHIPREV_MASK                  (0x0F)
>
> Same here as in the other patches. Don't just rename defines if there is no good
> reason.
>

Is easy to read a good reason to rename it?
if not, i can restore the same as before.

> Regards,
> Matthias
>
> >
> >   #endif /* __MT6360_H__ */
> >

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

WARNING: multiple messages have this Message-ID (diff)
From: Gene Chen <gene.chen.richtek@gmail.com>
To: Matthias Brugger <matthias.bgg@gmail.com>
Cc: Gene Chen <gene_chen@richtek.com>,
	linux-kernel@vger.kernel.org, cy_huang@richtek.com,
	benjamin.chao@mediatek.com, linux-mediatek@lists.infradead.org,
	Lee Jones <lee.jones@linaro.org>,
	linux-arm-kernel@lists.infradead.org, shufan_lee@richtek.com
Subject: Re: [PATCH 3/4] mfd: mt6360: Fix flow which is used to check ic exist
Date: Thu, 16 Jul 2020 17:53:36 +0800	[thread overview]
Message-ID: <CAE+NS36LOqnG+toSQcxVAeQHUqyvs9Z39tU7-ijkAntRUH6uqg@mail.gmail.com> (raw)
In-Reply-To: <3205bb9b-c7b4-c99a-2673-f3a56cc0addf@gmail.com>

Matthias Brugger <matthias.bgg@gmail.com> 於 2020年7月10日 週五 下午10:25寫道:
>
>
>
> On 07/07/2020 12:30, Gene Chen wrote:
> > From: Gene Chen <gene_chen@richtek.com>
> >
> > Fix flow which is used to check ic exist
> >
> > Signed-off-by: Gene Chen <gene_chen@richtek.com>
> > ---
> >   drivers/mfd/mt6360-core.c  | 28 +++++++++++++++++++---------
> >   include/linux/mfd/mt6360.h |  8 ++++----
> >   2 files changed, 23 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c
> > index 2dd5918..4bb2949 100644
> > --- a/drivers/mfd/mt6360-core.c
> > +++ b/drivers/mfd/mt6360-core.c
> > @@ -293,6 +293,23 @@ static const struct mfd_cell mt6360_devs[] = {
> >                   NULL, 0, 0, "mediatek,mt6360-tcpc"),
> >   };
> >
> > +static int mt6360_check_vendor_info(struct mt6360_data *data)
> > +{
> > +     u32 info;
> > +     int ret;
> > +
> > +     ret = regmap_read(data->regmap, MT6360_REG_PMU_DEVINFO, &info);
> > +     if (ret < 0)
> > +             return ret;
> > +
> > +     if ((info & MT6360_CHIPVEN_MASK) != MT6360_CHIPVEN_VAL)
> > +             return -ENODEV;
> > +
> > +     data->chip_rev = info & MT6360_CHIPREV_MASK;
> > +
> > +     return 0;
> > +}
> > +
> >   static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >       MT6360_PMU_SLAVEID,
> >       MT6360_PMIC_SLAVEID,
> > @@ -303,7 +320,6 @@ static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = {
> >   static int mt6360_probe(struct i2c_client *client)
> >   {
> >       struct mt6360_data *data;
> > -     unsigned int reg_data;
> >       int i, ret;
> >
> >       data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
> > @@ -319,16 +335,10 @@ static int mt6360_probe(struct i2c_client *client)
> >               return PTR_ERR(data->regmap);
> >       }
> >
> > -     ret = regmap_read(data->regmap, MT6360_PMU_DEV_INFO, &reg_data);
> > +     ret = mt6360_check_vendor_info(data);
> >       if (ret) {
> > -             dev_err(&client->dev, "Device not found\n");
> > -             return ret;
> > -     }
> > -
> > -     data->chip_rev = reg_data & CHIP_REV_MASK;
> > -     if (data->chip_rev != CHIP_VEN_MT6360) {
>
> Why not only applying the MASK here instead of put this all in a new function?
>

I think merge the ic check flow into function is well-organized.
if not, i can restore the same as before.

> >               dev_err(&client->dev, "Device not supported\n");
> > -             return -ENODEV;
> > +             return ret;
> >       }
> >
> >       ret = devm_regmap_add_irq_chip(&client->dev, data->regmap, client->irq,
> > diff --git a/include/linux/mfd/mt6360.h b/include/linux/mfd/mt6360.h
> > index 9fc6718..5ec0f5d 100644
> > --- a/include/linux/mfd/mt6360.h
> > +++ b/include/linux/mfd/mt6360.h
> > @@ -30,7 +30,7 @@ struct mt6360_data {
> >   };
> >
> >   /* PMU register defininition */
> > -#define MT6360_PMU_DEV_INFO                  (0x00)
> > +#define MT6360_REG_PMU_DEVINFO                       (0x00)
> >   #define MT6360_PMU_CORE_CTRL1                       (0x01)
> >   #define MT6360_PMU_RST1                             (0x02)
> >   #define MT6360_PMU_CRCEN                    (0x03)
> > @@ -233,8 +233,8 @@ struct mt6360_data {
> >   #define MT6360_IRQ_REGNUM   16
> >   #define MT6360_IRQ_RETRIG   BIT(2)
> >
> > -#define CHIP_VEN_MASK                                (0xF0)
> > -#define CHIP_VEN_MT6360                              (0x50)
> > -#define CHIP_REV_MASK                                (0x0F)
> > +#define MT6360_CHIPVEN_MASK                  (0xF0)
> > +#define MT6360_CHIPVEN_VAL                   (0x50)
> > +#define MT6360_CHIPREV_MASK                  (0x0F)
>
> Same here as in the other patches. Don't just rename defines if there is no good
> reason.
>

Is easy to read a good reason to rename it?
if not, i can restore the same as before.

> Regards,
> Matthias
>
> >
> >   #endif /* __MT6360_H__ */
> >

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-07-16  9:53 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-07 10:30 [PATCH 0/4] mfd: mt6360: Merge different sub-devices i2c read/write Gene Chen
2020-07-07 10:30 ` Gene Chen
2020-07-07 10:30 ` Gene Chen
2020-07-07 10:30 ` [PATCH 1/4] mfd: mt6360: Refactor and fix code style Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-10 14:06   ` Matthias Brugger
2020-07-10 14:06     ` Matthias Brugger
2020-07-10 14:06     ` Matthias Brugger
2020-07-13  6:51     ` Lee Jones
2020-07-13  6:51       ` Lee Jones
2020-07-13  6:51       ` Lee Jones
2020-07-13 10:35       ` Gene Chen
2020-07-13 10:35         ` Gene Chen
2020-07-13 10:35         ` Gene Chen
2020-07-13 10:48         ` Lee Jones
2020-07-13 10:48           ` Lee Jones
2020-07-13 10:48           ` Lee Jones
2020-07-16 10:12           ` Gene Chen
2020-07-16 10:12             ` Gene Chen
2020-07-16 10:12             ` Gene Chen
2020-07-16 13:44             ` Lee Jones
2020-07-16 13:44               ` Lee Jones
2020-07-16 13:44               ` Lee Jones
2020-07-07 10:30 ` [PATCH 2/4] mfd: mt6360: Remove handle_post_irq callback function Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-10 14:22   ` Matthias Brugger
2020-07-10 14:22     ` Matthias Brugger
2020-07-10 14:22     ` Matthias Brugger
2020-07-17  9:35     ` Gene Chen
2020-07-17  9:35       ` Gene Chen
2020-07-17  9:35       ` Gene Chen
2020-07-07 10:30 ` [PATCH 3/4] mfd: mt6360: Fix flow which is used to check ic exist Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-10 14:25   ` Matthias Brugger
2020-07-10 14:25     ` Matthias Brugger
2020-07-10 14:25     ` Matthias Brugger
2020-07-16  9:53     ` Gene Chen [this message]
2020-07-16  9:53       ` Gene Chen
2020-07-16  9:53       ` Gene Chen
2020-07-07 10:30 ` [PATCH 4/4] mfd: mt6360: Merge different sub-devices i2c read/write into one regmap Gene Chen
2020-07-07 10:30   ` Gene Chen
2020-07-07 10:30   ` Gene Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAE+NS36LOqnG+toSQcxVAeQHUqyvs9Z39tU7-ijkAntRUH6uqg@mail.gmail.com \
    --to=gene.chen.richtek@gmail.com \
    --cc=benjamin.chao@mediatek.com \
    --cc=cy_huang@richtek.com \
    --cc=gene_chen@richtek.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=shufan_lee@richtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.