Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754142AbbGWQ4H (ORCPT ); Thu, 23 Jul 2015 12:56:07 -0400 Received: from seldrel01.sonyericsson.com ([37.139.156.2]:4383 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752923AbbGWQ4C (ORCPT ); Thu, 23 Jul 2015 12:56:02 -0400 Date: Thu, 23 Jul 2015 09:55:56 -0700 From: Bjorn Andersson To: Lee Jones CC: "bjorn@kryo.se" , Andy Gross , Samuel Ortiz , Mark Brown , "linux-kernel@vger.kernel.org" , "linux-arm-msm@vger.kernel.org" Subject: Re: [PATCH v2 06/11] mfd: qcom-smd-rpm: Driver for the Qualcomm RPM over SMD Message-ID: <20150723165556.GE4753@usrtlx11787.corpusers.net> 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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150723132251.GA3436@x1> User-Agent: Mutt/1.5.22 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5156 Lines: 156 On Thu 23 Jul 06:22 PDT 2015, Lee Jones wrote: > On Mon, 13 Jul 2015, Bjorn Andersson wrote: > > > On Tue 07 Jul 05:37 PDT 2015, Lee Jones wrote: > > > > > On Fri, 26 Jun 2015, bjorn@kryo.se wrote: > > > > > > > From: Bjorn Andersson > > [..] > > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > > > [..] > > > > > > +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 for the > > > > + Resource Power Manager system found in the Qualcomm 8974 based > > > > + devices. > > > > + > > > > + This is required to access many regulators, clocks and bus > > > > + frequencies controlled by the RPM on these devices. > > > > + > > > > + Say M here if you want to include support for the Qualcomm RPM as a > > > > + module. This will build a module called "qcom-smd-rpm". > > > > > > I'm not exactly sure what makes this an MFD device. > > > > > > > It represents a piece of hardware (a micro-controller) that exposes > > control of a multitude of regulators and clocks in the Qualcomm > > platforms. > > > > It's basically just a successor of the qcom_rpm driver - same > > functionality but a new communication method is used. > > 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 be > pretty similar. > 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 will have a word with Andy about moving this and the qcom_rpm driver out of mfd. > > > > diff --git a/drivers/mfd/qcom-smd-rpm.c b/drivers/mfd/qcom-smd-rpm.c > > > > [..] > > > > > > + > > > > +#define RPM_ERR_INVALID_RESOURCE "resource does not exist" > > > > > > I don't like this at all. > > > > > > > Which part of it? > > > > It should probably be a static const char *, inlined in the function > > below. Would that be to your liking? > > It would be better, but I never really see the point in initialising > variables with these types of messages. I'd get rid of the > superfluous chuff and just do: > > memcmp(msg->message, "resource does not exist", 23); > The point was simply to not have to write: if (msg->length == 23 && memcmp(msg->message, ..., 23); Simply because I don't like the first part of the expression. I'll rewrite it... > > > > +static int qcom_smd_rpm_callback(struct qcom_smd_device *qsdev, > > > > + const void *data, > > > > + size_t count) > > > > +{ > > > > + const struct qcom_rpm_header *hdr = data; > > > > + const struct qcom_rpm_message *msg; > > > > + const size_t inv_res_len = sizeof(RPM_ERR_INVALID_RESOURCE) - 1; > > > > + struct qcom_smd_rpm *rpm = dev_get_drvdata(&qsdev->dev); > > > > + const u8 *buf = data + sizeof(struct qcom_rpm_header); > > > > + const u8 *end = buf + hdr->length; > > > > + int status = 0; > > > > + > > > > + if (hdr->service_type != RPM_SERVICE_TYPE_REQUEST || > > > > + hdr->length < sizeof(struct qcom_rpm_message)) { > > > > + dev_err(&qsdev->dev, "invalid request\n"); > > > > + return 0; > > > > + } > > > > + > > > > + while (buf < end) { > > > > + msg = (struct qcom_rpm_message *)buf; > > > > + switch (msg->msg_type) { > > > > + case RPM_MSG_TYPE_MSG_ID: > > > > + break; > > > > + case RPM_MSG_TYPE_ERR: > > > > + if (msg->length == inv_res_len && > > > > + !memcmp(msg->message, > > > > + RPM_ERR_INVALID_RESOURCE, > > > > + inv_res_len)) > > > > > > strncpy(msg->message, "resource does not exist", 23); > > > > > > > No, I want to compare the content of msg->message with the string > > Yes, I just noticed that. > > > "resource does not exist" - as that's the only way to know what type of > > error we got. > > > > This is unfortunately how the protocol looks :/ > > What about either my memcmp suggestion above or this then: > > strncmp(msg->message, "resource does not exist", 23); > That would require the string to be 0-terminated. [..] > > > > +static struct qcom_smd_driver qcom_smd_rpm_driver = { > > > > + .probe = qcom_smd_rpm_probe, > > > > + .remove = qcom_smd_rpm_remove, > > > > + .callback = qcom_smd_rpm_callback, > > > > + .driver = { > > > > + .name = "qcom_smd_rpm", > > > > + .owner = THIS_MODULE, > > > > > > Remove this line. > > 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 having > to invent your own bus. > 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 fit. Regards, Bjorn -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/