public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gupta, Akshay" <Akshay.Gupta@amd.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux@roeck-us.net, arnd@arndb.de,
	naveenkrishna.chatradhi@amd.com
Subject: Re: [PATCH 2/6] misc: sbrmi: Add platform device add to create platform device
Date: Thu, 4 Jul 2024 19:43:17 +0530	[thread overview]
Message-ID: <01c95139-dfeb-6983-77d2-4382ffb50896@amd.com> (raw)
In-Reply-To: <2024070447-cosigner-shanty-fbbd@gregkh>


On 7/4/2024 5:20 PM, Greg KH wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Thu, Jul 04, 2024 at 11:16:20AM +0000, Akshay Gupta wrote:
>> - AMD provides socket power information from out of band
>>    which can be read by sensors.
>> - platform driver will probe drivers/hwmon/sbrmi as a platform device
>>    and share the sbrmi device data.
> So you are "splitting" a real device into different ones using a
> platform device?  THat's not ok, and an abuse of the platform api.
> Please use the correct one for that instead.

is it ok to call API, devm_hwmon_device_register_with_info() from misc 
driver

which will require to defining the hwmon ops in here.

>
>> Signed-off-by: Akshay Gupta <akshay.gupta@amd.com>
>> Reviewed-by: Naveen Krishna Chatradhi <naveenkrishna.chatradhi@amd.com>
>> ---
>>   drivers/misc/amd-sb/sbrmi-i2c.c | 25 ++++++++++++++++++++++++-
>>   include/misc/amd-sb.h           |  2 ++
>>   2 files changed, 26 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/misc/amd-sb/sbrmi-i2c.c b/drivers/misc/amd-sb/sbrmi-i2c.c
>> index c4903d9e9f0f..b593bbdd78e0 100644
>> --- a/drivers/misc/amd-sb/sbrmi-i2c.c
>> +++ b/drivers/misc/amd-sb/sbrmi-i2c.c
>> @@ -72,7 +72,29 @@ static int sbrmi_i2c_probe(struct i2c_client *client)
>>                return ret;
>>
>>        /* Cache maximum power limit */
>> -     return sbrmi_get_max_pwr_limit(data);
>> +     ret = sbrmi_get_max_pwr_limit(data);
>> +     if (ret < 0)
>> +             return ret;
>> +
>> +     dev_set_drvdata(dev, (void *)data);
> No need to cast, right?
Yes, will update.
>
>> +     data->pdev = platform_device_register_data(dev, "sbrmi-hwmon",
>> +                                                PLATFORM_DEVID_NONE,
> Yeah, that's not ok.  Please do this correctly, as this is NOT a
> platform device, but rather a made-up one that you just created out of
> no where.  Instead use the correct apis for that.
>
>> +                                                data,
>> +                                                sizeof(struct sbrmi_data));
>> +     if (IS_ERR(data->pdev)) {
>> +             pr_err("unable to register platform device for sbrmi-hwmon\n");
>> +             return PTR_ERR(data->pdev);
> You don't need to unwind anything else here?
Yes, not required.
>
>
>
>> +     }
>> +     return ret;
>> +}
>> +
>> +static void sbrmi_i2c_remove(struct i2c_client *client)
>> +{
>> +     struct sbrmi_data *data = dev_get_drvdata(&client->dev);
>> +
>> +     if (!data)
>> +             return;
> How can that happen?
Its just a safe check, once we remove platform driver this will not be 
required.
> greg k-h

  reply	other threads:[~2024-07-04 14:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-04 11:16 [PATCH 0/6] misc: add amd side-band functionality Akshay Gupta
2024-07-04 11:16 ` [PATCH 1/6] hwmon/misc sbrmi: Move core sbrmi from hwmon to misc Akshay Gupta
2024-07-04 11:47   ` Greg KH
2024-07-04 13:57     ` Gupta, Akshay
2024-07-04 11:16 ` [PATCH 2/6] misc: sbrmi: Add platform device add to create platform device Akshay Gupta
2024-07-04 11:50   ` Greg KH
2024-07-04 14:13     ` Gupta, Akshay [this message]
2024-07-04 11:16 ` [PATCH 3/6] misc: sbrmi: Use regmap subsystem Akshay Gupta
2024-07-04 11:53   ` Greg KH
2024-07-04 14:26     ` Gupta, Akshay
2024-07-04 11:16 ` [PATCH 4/6] misc: sbrmi: Clear sbrmi status register bit SwAlertSts Akshay Gupta
2024-07-04 11:16 ` [PATCH 5/6] misc/hwmon: sbrmi: Add support for APML protocols Akshay Gupta
2024-07-04 11:16 ` [PATCH 6/6] misc: sbrmi: Add support for new revision Akshay Gupta
2024-07-04 11:54   ` Greg KH
2024-07-04 14:28     ` Gupta, Akshay
2024-07-04 11:48 ` [PATCH 0/6] misc: add amd side-band functionality Greg KH
2024-07-04 14:47   ` Gupta, Akshay

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=01c95139-dfeb-6983-77d2-4382ffb50896@amd.com \
    --to=akshay.gupta@amd.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=naveenkrishna.chatradhi@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox