Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 143136
b: refs/heads/master
c: 8a49cfa
h: refs/heads/master
v: v3
  • Loading branch information
Ville Syrjala authored and Dmitry Torokhov committed Jan 30, 2009
1 parent 40b5b2d commit e7b6fc9
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d329e33c7c2bdcd955a00c84a9363cb309cad352
refs/heads/master: 8a49cfa9de4ef47eb9238d625b900d4cdddccf30
64 changes: 60 additions & 4 deletions trunk/drivers/input/misc/ati_remote2.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,68 @@ enum {
ATI_REMOTE2_MAX_MODE_MASK = 0x1F,
};

static int ati_remote2_set_mask(const char *val,
struct kernel_param *kp, unsigned int max)
{
unsigned long mask;
int ret;

if (!val)
return -EINVAL;

ret = strict_strtoul(val, 0, &mask);
if (ret)
return ret;

if (mask & ~max)
return -EINVAL;

*(unsigned int *)kp->arg = mask;

return 0;
}

static int ati_remote2_set_channel_mask(const char *val,
struct kernel_param *kp)
{
pr_debug("%s()\n", __func__);

return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK);
}

static int ati_remote2_get_channel_mask(char *buffer, struct kernel_param *kp)
{
pr_debug("%s()\n", __func__);

return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg);
}

static int ati_remote2_set_mode_mask(const char *val, struct kernel_param *kp)
{
pr_debug("%s()\n", __func__);

return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK);
}

static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp)
{
pr_debug("%s()\n", __func__);

return sprintf(buffer, "0x%02x", *(unsigned int *)kp->arg);
}

static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK;
module_param(channel_mask, uint, 0644);
#define param_check_channel_mask(name, p) __param_check(name, p, unsigned int)
#define param_set_channel_mask ati_remote2_set_channel_mask
#define param_get_channel_mask ati_remote2_get_channel_mask
module_param(channel_mask, channel_mask, 0644);
MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>");

static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
module_param(mode_mask, uint, 0644);
#define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
#define param_set_mode_mask ati_remote2_set_mode_mask
#define param_get_mode_mask ati_remote2_get_mode_mask
module_param(mode_mask, mode_mask, 0644);
MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>");

static struct usb_device_id ati_remote2_id_table[] = {
Expand Down Expand Up @@ -722,8 +778,8 @@ static int ati_remote2_probe(struct usb_interface *interface, const struct usb_d
if (r)
goto fail2;

ar2->channel_mask = channel_mask & ATI_REMOTE2_MAX_CHANNEL_MASK;
ar2->mode_mask = mode_mask & ATI_REMOTE2_MAX_MODE_MASK;
ar2->channel_mask = channel_mask;
ar2->mode_mask = mode_mask;

r = ati_remote2_setup(ar2, ar2->channel_mask);
if (r)
Expand Down

0 comments on commit e7b6fc9

Please sign in to comment.