From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lee Jones Subject: Re: [PATCH v2 06/11] mfd: qcom-smd-rpm: Driver for the Qualcomm RPM over SMD Date: Fri, 24 Jul 2015 11:06:57 +0100 Message-ID: <20150724100657.GD3436@x1> References: <1435355419-23602-1-git-send-email-bjorn.andersson@sonymobile.com> <1435355419-23602-7-git-send-email-bjorn.andersson@sonymobile.com> <20150707123716.GA3182@x1> <20150713215825.GB15178@usrtlx11787.corpusers.net> <20150723132251.GA3436@x1> <20150723165556.GE4753@usrtlx11787.corpusers.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mail-wi0-f176.google.com ([209.85.212.176]:33926 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753473AbbGXKHC (ORCPT ); Fri, 24 Jul 2015 06:07:02 -0400 Received: by wibud3 with SMTP id ud3so58839707wib.1 for ; Fri, 24 Jul 2015 03:07:00 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20150723165556.GE4753@usrtlx11787.corpusers.net> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: Bjorn Andersson Cc: "bjorn@kryo.se" , Andy Gross , Samuel Ortiz , Mark Brown , "linux-kernel@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" On Thu, 23 Jul 2015, Bjorn Andersson wrote: > On Thu 23 Jul 06:22 PDT 2015, Lee Jones wrote: >=20 > > On Mon, 13 Jul 2015, Bjorn Andersson wrote: > >=20 > > > On Tue 07 Jul 05:37 PDT 2015, Lee Jones wrote: > > >=20 > > > > On Fri, 26 Jun 2015, bjorn@kryo.se wrote: > > > >=20 > > > > > From: Bjorn Andersson > > > [..] > > >=20 > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > >=20 > > > [..] > > >=20 > > > > > +config MFD_QCOM_SMD_RPM > > > > > + tristate "Qualcomm Resource Power Manager (RPM) over SMD" > > > > > + depends on QCOM_SMD && OF > > > > > + help > > > > > + If you say yes to this option, support will be included f= or the > > > > > + Resource Power Manager system found in the Qualcomm 8974 = based > > > > > + devices. > > > > > + > > > > > + This is required to access many regulators, clocks and bu= s > > > > > + frequencies controlled by the RPM on these devices. > > > > > + > > > > > + Say M here if you want to include support for the Qualcom= m RPM as a > > > > > + module. This will build a module called "qcom-smd-rpm". > > > >=20 > > > > I'm not exactly sure what makes this an MFD device. > > > >=20 > > >=20 > > > It represents a piece of hardware (a micro-controller) that expos= es > > > control of a multitude of regulators and clocks in the Qualcomm > > > platforms. > > >=20 > > > It's basically just a successor of the qcom_rpm driver - same > > > functionality but a new communication method is used. > >=20 > > My point still stands. Please investigate moving this (and the > > qcom_rpm driver if it's the same) into either drivers/soc or > > drivers/platform. The support in these two directories _seem_ to b= e > > pretty similar. > >=20 >=20 > We had this exact discussion last year and I argued that a piece of > hardware that exposes regulators and clocks - like most PMICs - is a > mfd and you agreed and picked the driver. I've become stricter since then. An IC which only does power management should either live in drivers/power, or more recently they have been described as platform specific drivers which have subsequently been moved to drivers/platform. Particularly if they have their own special, platform specific communication method/bus. > I will have a word with Andy about moving this and the qcom_rpm drive= r > out of mfd. Thanks. > > > > > diff --git a/drivers/mfd/qcom-smd-rpm.c b/drivers/mfd/qcom-sm= d-rpm.c > > >=20 > > > [..] > > >=20 > > > > > + > > > > > +#define RPM_ERR_INVALID_RESOURCE "resource does not exist" > > > >=20 > > > > I don't like this at all. > > > >=20 > > >=20 > > > Which part of it? > > >=20 > > > It should probably be a static const char *, inlined in the funct= ion > > > below. Would that be to your liking? > >=20 > > It would be better, but I never really see the point in initialisin= g > > variables with these types of messages. I'd get rid of the > > superfluous chuff and just do: > >=20 > > memcmp(msg->message, "resource does not exist", 23); > >=20 >=20 > The point was simply to not have to write: >=20 > if (msg->length =3D=3D 23 && memcmp(msg->message, ..., 23); >=20 > Simply because I don't like the first part of the expression. I'll > rewrite it... All this cruft just to avoid that? Just define '23', then code looks good and problem vaporises. > > > > > +static int qcom_smd_rpm_callback(struct qcom_smd_device *qsd= ev, > > > > > + const void *data, > > > > > + size_t count) > > > > > +{ > > > > > + const struct qcom_rpm_header *hdr =3D data; > > > > > + const struct qcom_rpm_message *msg; > > > > > + const size_t inv_res_len =3D sizeof(RPM_ERR_INVALID_RESOURC= E) - 1; > > > > > + struct qcom_smd_rpm *rpm =3D dev_get_drvdata(&qsdev->dev); > > > > > + const u8 *buf =3D data + sizeof(struct qcom_rpm_header); > > > > > + const u8 *end =3D buf + hdr->length; > > > > > + int status =3D 0; > > > > > + > > > > > + if (hdr->service_type !=3D RPM_SERVICE_TYPE_REQUEST || > > > > > + hdr->length < sizeof(struct qcom_rpm_message)) { > > > > > + dev_err(&qsdev->dev, "invalid request\n"); > > > > > + return 0; > > > > > + } > > > > > + > > > > > + while (buf < end) { > > > > > + msg =3D (struct qcom_rpm_message *)buf; > > > > > + switch (msg->msg_type) { > > > > > + case RPM_MSG_TYPE_MSG_ID: > > > > > + break; > > > > > + case RPM_MSG_TYPE_ERR: > > > > > + if (msg->length =3D=3D inv_res_len && > > > > > + !memcmp(msg->message, > > > > > + RPM_ERR_INVALID_RESOURCE, > > > > > + inv_res_len)) > > > >=20 > > > > strncpy(msg->message, "resource does not exist", 23); > > > >=20 > > >=20 > > > No, I want to compare the content of msg->message with the string > >=20 > > Yes, I just noticed that. > >=20 > > > "resource does not exist" - as that's the only way to know what t= ype of > > > error we got. > > >=20 > > > This is unfortunately how the protocol looks :/ > >=20 > > What about either my memcmp suggestion above or this then: > >=20 > > strncmp(msg->message, "resource does not exist", 23); > >=20 >=20 > That would require the string to be 0-terminated. No it doesn't. strNcmp, only compares the first N characters. > > > > > +static struct qcom_smd_driver qcom_smd_rpm_driver =3D { > > > > > + .probe =3D qcom_smd_rpm_probe, > > > > > + .remove =3D qcom_smd_rpm_remove, > > > > > + .callback =3D qcom_smd_rpm_callback, > > > > > + .driver =3D { > > > > > + .name =3D "qcom_smd_rpm", > > > > > + .owner =3D THIS_MODULE, > > > >=20 > > > > Remove this line. > >=20 > > Still not 100% sure why you need your own 'special' driver struct. = If > > it's for the .callback, there are other ways to do this without hav= ing > > to invent your own bus. >=20 > Because the life cycle of these components are much like, say, USB - > they can come and go. As such e.g. a platform_driver is not a good fi= t. You mean they are hot-swappable? Don't we have any platform devices which support that already? --=20 Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org =E2=94=82 Open source software for ARM SoCs =46ollow Linaro: Facebook | Twitter | Blog