From: Stefan Wahren <stefan.wahren@i2se.com>
To: Charles Mirabile <cmirabil@redhat.com>, linux-kernel@vger.kernel.org
Cc: Lee Jones <lee.jones@linaro.org>,
Serge Schneider <serge@raspberrypi.org>,
Nicolas Saenz Julienne <nsaenzju@redhat.com>,
Mattias Brugger <mbrugger@suse.com>,
linux-rpi-kernel@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
fedora-rpi@googlegroups.com, Mwesigwa Guma <mguma@redhat.com>,
Joel Savitz <jsavitz@redhat.com>
Subject: Re: [PATCH V5 1/6] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver
Date: Sun, 12 Dec 2021 12:43:30 +0100 [thread overview]
Message-ID: <50355fae-0745-c8a9-87f9-2a7491cd2c17@i2se.com> (raw)
In-Reply-To: <20211210221033.912430-2-cmirabil@redhat.com>
Am 10.12.21 um 23:10 schrieb Charles Mirabile:
> This patch adds the core driver file, containing the regmap configuration
> needed to communicate with the board over I2C. We also add the header
> file shared by all three drivers, containing common data and definitions.
> In addition, we add a config option to toggle compilation of the driver.
>
> Signed-off-by: Charles Mirabile <cmirabil@redhat.com>
> Co-developed-by: Mwesigwa Guma <mguma@redhat.com>
> Signed-off-by: Mwesigwa Guma <mguma@redhat.com>
> Co-developed-by: Joel Savitz <jsavitz@redhat.com>
> Signed-off-by: Joel Savitz <jsavitz@redhat.com>
> ---
> drivers/mfd/Kconfig | 8 ++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/sensehat-core.c | 157 +++++++++++++++++++++++++++++++++++
> include/linux/mfd/sensehat.h | 51 ++++++++++++
> 4 files changed, 217 insertions(+)
> create mode 100644 drivers/mfd/sensehat-core.c
> create mode 100644 include/linux/mfd/sensehat.h
>
...
> diff --git a/drivers/mfd/sensehat-core.c b/drivers/mfd/sensehat-core.c
> new file mode 100644
> index 000000000000..c5b6f4648d88
> --- /dev/null
> +++ b/drivers/mfd/sensehat-core.c
> @@ -0,0 +1,157 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Raspberry Pi Sense HAT core driver
> + * http://raspberrypi.org
> + *
> + * Copyright (C) 2015 Raspberry Pi
> + * Copyright (C) 2021 Charles Mirabile, Mwesigwa Guma, Joel Savitz
> + *
> + * Original Author: Serge Schneider
> + * Revised for upstream Linux by: Charles Mirabile, Mwesigwa Guma, Joel Savitz
> + *
> + * This driver is based on wm8350 implementation and was refactored to use the
> + * misc device subsystem rather than the deprecated framebuffer subsystem.
> + */
> +
> +#include <linux/module.h>
> +#include <linux/moduleparam.h>
Is this header really necessary?
> +#include <linux/err.h>
> +#include <linux/init.h>
> +#include <linux/i2c.h>
> +#include <linux/platform_device.h>
> +#include <linux/slab.h>
> +#include <linux/regmap.h>
> +#include <linux/mfd/sensehat.h>
> +
> +#define SENSEHAT_WAI 0xF0
> +#define SENSEHAT_VER 0xF1
> +
> +#define SENSEHAT_ID 's'
> +
> +static struct platform_device *
> +sensehat_client_dev_register(struct sensehat *sensehat, const char *name);
Please avoid this forward declaration
> +
> +static struct regmap_config sensehat_config;
Is there a specific reason, why the driver only supports one sense hat?
> +
> +static int sensehat_probe(struct i2c_client *i2c,
> + const struct i2c_device_id *id)
> +{
> + int ret;
> + unsigned int reg;
> +
> + struct sensehat *sensehat =
> + devm_kzalloc(&i2c->dev, sizeof(*sensehat), GFP_KERNEL);
> +
> + if (!sensehat)
> + return -ENOMEM;
> +
> + i2c_set_clientdata(i2c, sensehat);
> + sensehat->dev = &i2c->dev;
> + sensehat->i2c_client = i2c;
> +
> + sensehat->regmap =
> + devm_regmap_init_i2c(sensehat->i2c_client, &sensehat_config);
> +
> + if (IS_ERR(sensehat->regmap)) {
> + dev_err(sensehat->dev, "Failed to initialize sensehat regmap");
> + return PTR_ERR(sensehat->regmap);
> + }
> +
> + ret = regmap_read(sensehat->regmap, SENSEHAT_WAI, ®);
> + if (ret < 0) {
> + dev_err(sensehat->dev, "failed to read from device");
I think the return code of regmap_read could be helpful in the log entry.
> + return ret;
> + }
> +
> + if (reg != SENSEHAT_ID) {
> + dev_err(sensehat->dev, "expected device ID %i, got %i",
> + SENSEHAT_ID, ret);
> + return -EINVAL;
> + }
> +
> + ret = regmap_read(sensehat->regmap, SENSEHAT_VER, ®);
> + if (ret < 0) {
> + dev_err(sensehat->dev,
> + "Unable to get sensehat firmware version");
> + return ret;
> + }
> +
> + dev_info(sensehat->dev, "Raspberry Pi Sense HAT firmware version %i\n",
> + reg);
> +
> +#ifdef CONFIG_JOYSTICK_SENSEHAT
> + sensehat->joystick.pdev =
> + sensehat_client_dev_register(sensehat, "sensehat-joystick");
> +
> + if (IS_ERR(sensehat->joystick.pdev)) {
> + dev_err(sensehat->dev, "failed to register sensehat-joystick");
> + return PTR_ERR(sensehat->joystick.pdev);
> + }
> +#endif
Please replace the #ifdev blocks with IS_ENABLED() to increase compile
coverage
next prev parent reply other threads:[~2021-12-12 11:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-10 22:10 [PATCH V5 0/6] Raspberry Pi Sense HAT driver Charles Mirabile
2021-12-10 22:10 ` [PATCH V5 1/6] drivers/mfd: sensehat: Raspberry Pi Sense HAT core driver Charles Mirabile
2021-12-11 20:53 ` Thomas Weißschuh
2021-12-12 11:43 ` Stefan Wahren [this message]
2021-12-13 11:49 ` Nicolas Saenz Julienne
2021-12-10 22:10 ` [PATCH V5 2/6] drivers/input/joystick: sensehat: Raspberry Pi Sense HAT joystick driver Charles Mirabile
2021-12-10 23:17 ` Dmitry Torokhov
2021-12-10 22:10 ` [PATCH V5 3/6] drivers/auxdisplay: sensehat: Raspberry Pi Sense HAT display driver Charles Mirabile
2021-12-11 18:38 ` Miguel Ojeda
2021-12-10 22:10 ` [PATCH V5 4/6] dt-bindings: mfd: sensehat: Add Raspberry Pi Sense HAT schema Charles Mirabile
2021-12-11 19:59 ` Rob Herring
2021-12-13 17:09 ` Rob Herring
2021-12-10 22:10 ` [PATCH V5 5/6] MAINTAINERS: Add sensehat driver authors to MAINTAINERS Charles Mirabile
2021-12-10 22:10 ` [PATCH V5 6/6] DO NOT MERGE: full sensehat device tree overlay for raspberry pi 4 Charles Mirabile
2021-12-13 11:29 ` [PATCH V5 0/6] Raspberry Pi Sense HAT driver Nicolas Saenz Julienne
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=50355fae-0745-c8a9-87f9-2a7491cd2c17@i2se.com \
--to=stefan.wahren@i2se.com \
--cc=cmirabil@redhat.com \
--cc=fedora-rpi@googlegroups.com \
--cc=jsavitz@redhat.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rpi-kernel@lists.infradead.org \
--cc=mbrugger@suse.com \
--cc=mguma@redhat.com \
--cc=nsaenzju@redhat.com \
--cc=serge@raspberrypi.org \
/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;
as well as URLs for NNTP newsgroup(s).