Skip to content

Commit

Permalink
small fix to make sure no line exceeds 80 chars using 8-char tabs (#57)
Browse files Browse the repository at this point in the history
* small fix to make sure no line exceeds 80 chars using 8-char tabs

* run clang-format on all the files
  • Loading branch information
Wolfvak authored Jun 26, 2021
1 parent 819f70f commit 3810c17
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 304 deletions.
16 changes: 8 additions & 8 deletions drivers/platform/nintendo3ds/ctr_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#define DRIVER_NAME "3ds-gpio"
#define pr_fmt(fmt) DRIVER_NAME ": " fmt
#define pr_fmt(fmt) DRIVER_NAME ": " fmt

#include <linux/io.h>
#include <linux/irq.h>
Expand Down Expand Up @@ -61,8 +61,8 @@ static void ctr_gpio_irqhandler(struct irq_desc *desc)
chained_irq_exit(chip, desc);
}

static void ctr_gpio_irq_toggle(struct ctr_gpio *gpio,
unsigned irq, unsigned enable)
static void ctr_gpio_irq_toggle(struct ctr_gpio *gpio, unsigned irq,
unsigned enable)
{
u8 mask;
unsigned offset;
Expand Down Expand Up @@ -164,8 +164,8 @@ static int ctr_gpiointc_probe(struct platform_device *pdev)
bgpio_flags = 0;
}

err = bgpio_init(&gpio->gpioc, dev, nregs, gpio->dat,
gpio->dat, NULL, gpio->dir, NULL, bgpio_flags);
err = bgpio_init(&gpio->gpioc, dev, nregs, gpio->dat, gpio->dat, NULL,
gpio->dir, NULL, bgpio_flags);
if (err)
return err;

Expand All @@ -186,8 +186,8 @@ static int ctr_gpiointc_probe(struct platform_device *pdev)
girq->chip = &gpio->irqc;
girq->parent_handler = ctr_gpio_irqhandler;
girq->num_parents = irq_count;
girq->parents = devm_kcalloc(dev, irq_count,
sizeof(*girq->parents), GFP_KERNEL);
girq->parents = devm_kcalloc(
dev, irq_count, sizeof(*girq->parents), GFP_KERNEL);
if (!girq->parents)
return -ENOMEM;

Expand All @@ -203,7 +203,7 @@ static int ctr_gpiointc_probe(struct platform_device *pdev)

static const struct of_device_id ctr_gpiointc_of_match[] = {
{ .compatible = "nintendo," DRIVER_NAME },
{ },
{},
};
MODULE_DEVICE_TABLE(of, ctr_gpiointc_of_match);

Expand Down
66 changes: 38 additions & 28 deletions drivers/platform/nintendo3ds/ctr_i2c.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#define DRIVER_NAME "3ds-i2c"
#define pr_fmt(fmt) DRIVER_NAME ": " fmt
#define pr_fmt(fmt) DRIVER_NAME ": " fmt

#include <linux/io.h>
#include <linux/i2c.h>
Expand Down Expand Up @@ -39,35 +39,41 @@ struct ctr_i2c {
struct i2c_adapter adap;
};

static u8 ctr_i2c_read_data(struct ctr_i2c *i2c) {
static u8 ctr_i2c_read_data(struct ctr_i2c *i2c)
{
return ioread8(i2c->base + 0x00);
}

static u8 ctr_i2c_read_cnt(struct ctr_i2c *i2c) {
static u8 ctr_i2c_read_cnt(struct ctr_i2c *i2c)
{
return ioread8(i2c->base + 0x01);
}

static void ctr_i2c_write_data(struct ctr_i2c *i2c, u8 val) {
static void ctr_i2c_write_data(struct ctr_i2c *i2c, u8 val)
{
iowrite8(val, i2c->base + 0x00);
}

static void ctr_i2c_write_cnt(struct ctr_i2c *i2c, u8 val) {
static void ctr_i2c_write_cnt(struct ctr_i2c *i2c, u8 val)
{
iowrite8(val, i2c->base + 0x01);
}

static void ctr_i2c_write_cntex(struct ctr_i2c *i2c, u16 cntex) {
static void ctr_i2c_write_cntex(struct ctr_i2c *i2c, u16 cntex)
{
iowrite16(cntex, i2c->base + 0x02);
}

static void ctr_i2c_write_scl(struct ctr_i2c *i2c, u16 scl) {
static void ctr_i2c_write_scl(struct ctr_i2c *i2c, u16 scl)
{
iowrite16(scl, i2c->base + 0x04);
}

static int ctr_i2c_wait_busy(struct ctr_i2c *i2c)
{
long res = wait_event_interruptible_timeout(
i2c->wq, !(ctr_i2c_read_cnt(i2c) & I2C_CNT_BUSY), CTR_I2C_TIMEOUT
);
i2c->wq, !(ctr_i2c_read_cnt(i2c) & I2C_CNT_BUSY),
CTR_I2C_TIMEOUT);

if (res > 0)
return 0;
Expand All @@ -79,16 +85,16 @@ static int ctr_i2c_wait_busy(struct ctr_i2c *i2c)
static int ctr_i2c_send(struct ctr_i2c *i2c, u8 byte, unsigned flags)
{
ctr_i2c_write_data(i2c, byte);
ctr_i2c_write_cnt(i2c, I2C_CNT_BUSY | I2C_CNT_IRQEN |
I2C_CNT_WRITE | flags);
ctr_i2c_write_cnt(i2c,
I2C_CNT_BUSY | I2C_CNT_IRQEN | I2C_CNT_WRITE | flags);
return ctr_i2c_wait_busy(i2c);
}

static int ctr_i2c_recv(struct ctr_i2c *i2c, u8 *byte, unsigned flags)
{
int err;
ctr_i2c_write_cnt(i2c, I2C_CNT_BUSY | I2C_CNT_IRQEN |
I2C_CNT_READ | flags);
ctr_i2c_write_cnt(i2c,
I2C_CNT_BUSY | I2C_CNT_IRQEN | I2C_CNT_READ | flags);
err = ctr_i2c_wait_busy(i2c);
*byte = ctr_i2c_read_data(i2c);
return err;
Expand All @@ -103,7 +109,8 @@ static int ctr_i2c_msg_read(struct ctr_i2c *i2c, u8 *buf, int len, bool last)
{
int i;
for (i = 0; i < len; i++) {
unsigned flag = (last && (i==(len-1))) ? I2C_CNT_LAST : I2C_CNT_ERRACK;
unsigned flag = (last && (i == (len - 1))) ? I2C_CNT_LAST :
I2C_CNT_ERRACK;
if (ctr_i2c_recv(i2c, &buf[i], flag))
return i;
}
Expand All @@ -114,21 +121,22 @@ static int ctr_i2c_msg_write(struct ctr_i2c *i2c, u8 *buf, int len, bool last)
{
int i;
for (i = 0; i < len; i++) {
unsigned flag = (last && (i==(len-1))) ? I2C_CNT_LAST : 0;
unsigned flag = (last && (i == (len - 1))) ? I2C_CNT_LAST : 0;
if (ctr_i2c_send(i2c, buf[i], flag))
return i;

if (!(ctr_i2c_read_cnt(i2c) & I2C_CNT_ERRACK)) {
ctr_i2c_write_cnt(i2c, I2C_CNT_BUSY | I2C_CNT_IRQEN |
I2C_CNT_PAUSE | I2C_CNT_WRITE);
I2C_CNT_PAUSE |
I2C_CNT_WRITE);
return i;
}
}
return len;
}

static int ctr_i2c_master_xfer(struct i2c_adapter *adap,
struct i2c_msg *msgs, int num)
static int ctr_i2c_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int num)
{
int i, plen;
struct i2c_msg *msg;
Expand All @@ -144,11 +152,13 @@ static int ctr_i2c_master_xfer(struct i2c_adapter *adap,
ctr_i2c_select_device(i2c, msg);

if (msg->len != 0) {
bool last = i == (num-1);
bool last = i == (num - 1);
if (msg->flags & I2C_M_RD) {
plen = ctr_i2c_msg_read(i2c, msg->buf, msg->len, last);
plen = ctr_i2c_msg_read(i2c, msg->buf, msg->len,
last);
} else {
plen = ctr_i2c_msg_write(i2c, msg->buf, msg->len, last);
plen = ctr_i2c_msg_write(i2c, msg->buf,
msg->len, last);
}

if (plen != msg->len)
Expand Down Expand Up @@ -202,8 +212,8 @@ static int ctr_i2c_probe(struct platform_device *pdev)
if (!i2c->irq)
return -EINVAL;

err = devm_request_irq(dev, i2c->irq,
ctr_i2c_irq, 0, dev_name(dev), i2c);
err = devm_request_irq(dev, i2c->irq, ctr_i2c_irq, 0, dev_name(dev),
i2c);
if (err)
return err;

Expand All @@ -213,11 +223,11 @@ static int ctr_i2c_probe(struct platform_device *pdev)
ctr_i2c_write_scl(i2c, 5 << 8);

/* setup the i2c_adapter */
adap->owner = THIS_MODULE;
adap->owner = THIS_MODULE;
strlcpy(adap->name, dev_name(dev), sizeof(adap->name));
adap->dev.parent = dev;
adap->dev.parent = dev;
adap->dev.of_node = dev->of_node;
adap->algo = &ctr_i2c_algo;
adap->algo = &ctr_i2c_algo;
adap->algo_data = i2c;

dev_set_drvdata(dev, i2c);
Expand All @@ -232,8 +242,8 @@ static int ctr_i2c_remove(struct platform_device *pdev)
}

static const struct of_device_id ctr_i2c_of_match[] = {
{ .compatible = "nintendo," DRIVER_NAME, },
{ },
{ .compatible = "nintendo," DRIVER_NAME },
{},
};
MODULE_DEVICE_TABLE(of, ctr_i2c_of_match);

Expand Down
Loading

0 comments on commit 3810c17

Please sign in to comment.